<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>18524</bug_id>
          
          <creation_ts>2012-08-10 15:30:10 +0000</creation_ts>
          <short_desc>AVT in mode attribute for apply-templates</short_desc>
          <delta_ts>2014-05-15 14:00:24 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Working drafts</version>
          <rep_platform>Macintosh</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Paul Ryan">tolzidan</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>72041</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Ryan">tolzidan</who>
    <bug_when>2012-08-10 15:30:10 +0000</bug_when>
    <thetext>At the moment mode in apply-templates is a token (http://www.w3.org/TR/2007/REC-xslt20-20070123/#element-apply-templates, http://www.w3.org/TR/2012/WD-xslt-30-20120710/#element-apply-templates). This works for most use cases by leaves out a number of use cases having to to do with secondary processing. It would be very useful if this could be an AVT to allow for a secondary processor to further specify the format of an output.

An example usage might follow the following pipeline.

Run an xsl transform on document:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;document&gt;
  &lt;element&gt;some text&lt;/element&gt;
&lt;/document&gt;

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
    xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;
    xmlns:math=&quot;http://www.w3.org/2005/xpath-functions/math&quot;
    xmlns:parser=&quot;parsernamespace&quot;
    exclude-result-prefixes=&quot;xs&quot;
    version=&quot;3.0&quot;&gt;
    &lt;xsl:param name=&quot;data&quot; as=&quot;document-node()?&quot;/&gt;
    
    &lt;xsl:template match=&quot;/document&quot;&gt;
        &lt;ouputitem path=&quot;/document/element&quot; mode=&quot;myrendermode&quot;/&gt;
    &lt;/xsl:template&gt;
    
    &lt;xsl:template match=&quot;/outputitem&quot;&gt;
        &lt;html&gt;
            &lt;head&gt;
                &lt;title&gt;A Page&lt;/title&gt;
            &lt;/head&gt;
            &lt;body&gt;
                &lt;xsl:apply-templates select=&quot;.&quot; mode=&quot;rendercontents&quot;/&gt;
            &lt;/body&gt;
        &lt;/html&gt;
        
    &lt;/xsl:template&gt;
    
    &lt;xsl:template match=&quot;*&quot; mode=&quot;rendercontents&quot;&gt;
        &lt;xsl:variable name=&quot;datapoint&quot; select=&quot;parser:eval($data, concat(&apos;$p1&apos;, @path))&quot;/&gt;
        &lt;xsl:choose&gt;
            &lt;xsl:when test=&quot;@mode&quot;&gt;
                &lt;xsl:apply-templates select=&quot;$datapoint&quot; mode=&quot;{@mode}&quot;/&gt;
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
                &lt;xsl:value-of select=&quot;$datapoint&quot;/&gt;
            &lt;/xsl:otherwise&gt;
        &lt;/xsl:choose&gt;
    &lt;/xsl:template&gt;
    
    &lt;xsl:template match=&quot;*&quot; mode=&quot;myrendermode&quot;&gt;
        &lt;p&gt;
            &lt;strong&gt;element&lt;/strong&gt;: &lt;xsl:value-of select=&quot;.&quot;/&gt;
        &lt;/p&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;

Then run the same transform on the output from the template as the primary document and the original document as the data xsl:param.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72045</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-08-10 16:00:24 +0000</bug_when>
    <thetext>Personal response: We&apos;ve tended to resist requests for call-template and apply-templates to be more dynamic, because sometimes allowing them to be more dynamic can inhibit optimizations even when the facility is not used. My instinct is that with higher-order functions in XSLT 3.0, there is a pretty clean and well understood way of doing this kind of thing. At its simplest, you could have for each mode a function that does apply-templates to a supplied set of nodes in that mode, and then you could bind a function item to the one of these functions that you wish to be invoked. You could even have a map that indexes these functions by mode name, allowing the dynamic apply templates call to take the form

$mode-map($mode)($nodes)

We&apos;re also getting to the point where we are trying to close the spec for XSLT 3.0 down, that is, to resist new &quot;good ideas&quot; unless the case is very strong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82912</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-02-11 16:12:30 +0000</bug_when>
    <thetext>The Working Group decided to confirm the response in comment #1.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>