<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE spec SYSTEM "xml/1998/06/xmlspec-v20.dtd">
<spec>
   <header>
      <title>XSLT Requirements</title>
      <version>Version 2.0</version>
      <w3c-designation>WD-xslt20req-20010126</w3c-designation>
      <w3c-doctype>W3C Working Draft</w3c-doctype>
      <pubdate>
         <day>26</day>
         <month>January</month>
         <year>2001</year>
      </pubdate>
      <publoc>
         <loc href="http://www.w3.org/TR/2001/WD-xslt20req-20010126">http://www.w3.org/TR/2001/WD-xslt20req-20010126</loc>
         <loc role="available-format" href="http://www.w3.org/TR/2001/WD-xslt20req-20010126.xml">XML</loc>
         <loc role="available-format" href="http://www.w3.org/TR/2001/WD-xslt20req-20010126.html">HTML</loc>
      </publoc>
      <latestloc>
         <loc href="http://www.w3.org/TR/xslt20req/">http://www.w3.org/TR/xslt20req/</loc>
      </latestloc>
      <authlist>
         <author>
            <name>Steve Muench</name>
            <affiliation>Oracle</affiliation>
            <email href="mailto:Steve.Muench@oracle.com">Steve.Muench@oracle.com</email>
         </author>
         <author>
            <name>Mark Scardina</name>
            <affiliation>Oracle</affiliation>
            <email href="mailto:Mark.Scardina@oracle.com">Mark.Scardina@oracle.com</email>
         </author>
      </authlist>
      <status>
         <p>This section describes the status of this document at the
	  time of its publication. Other documents may supersede this
	  document. The latest status of this document series is
	  maintained at the W3C. This document is the first public XSLT 2.0 Requirements working draft. </p>
         <p>This is a W3C Working Draft for review by W3C Members and
	  other interested parties. It is a draft document and may be
	  updated, replaced or made obsolete by other documents at any
	  time. It is inappropriate to use W3C Working Drafts as
	  reference material or to cite them as other than "work in
	  progress". This is work in progress and does not imply
	  endorsement by the <loc href="http://www.w3.org/Consortium/Member/List">W3C
	  membership</loc>.</p>
         <p>This document has been produced as part of the <loc href="http://www.w3.org/Style/Activity">W3C Style
	  activity</loc>, following the procedures set out for the W3C
	  Process. The document has been written by the <loc href="http://www.w3.org/Style/XSL/Group">XSL Working
	  Group</loc> ( <loc href="http://cgi.w3.org/MemberAccess/AccessRequest">W3C
	  members only</loc>). The goals of the XSL Working Group are
	  discussed in the <loc href="http://www.w3.org/Style/2000/xsl-charter.html">XSL
	  Working Group charter</loc>.  The XSL Working Group feels that
	  the contents of this Working Draft are relatively stable, and
	  therefore encourages feedback on this version.</p>
         <p>Comments on this document should be sent to the W3C mailing
	  list <loc href="mailto:xsl-editors@w3.org">xsl-editors@w3.org</loc>
	  (archived at <loc href="http://lists.w3.org/Archives/Public/xsl-editors/">
	  http://lists.w3.org/Archives/Public/xsl-editors/</loc>).  A
	  list of current W3C Recommendations and other technical
	  documents can be found at <loc href="http://www.w3.org/TR/">http://www.w3.org/TR/</loc>.
	  </p>
      </status>
      <abstract>
         <p>This document describes the requirements for the XSLT 2.0 specification.</p>
      </abstract>
      <langusage>
         <language id="EN">English</language>
      </langusage>
      <revisiondesc>
         <slist>
            <sitem>See RCS log for revision history.</sitem>
         </slist>
      </revisiondesc>
   </header>
   <body>
      <div1>
         <head>Goals</head>
         <p>XSLT 2.0 has the following goals: </p>
         <ulist>
            <item>Simplify  manipulation of XML Schema-typed content</item>
            <item>Simplify manipulation of string content</item>
            <item>Support related XML standards</item>
            <item>Improve ease of use</item>
            <item>Improve interoperability</item>
            <item>Improve i18n support</item>
            <item>Maintain backward compatibility</item>
            <item>Enable improved processor efficiency</item>
         </ulist>
         <p>In addition, the following are explicitly <emph>not</emph> goals:<ulist>
               <item>Simplifying the ability to parse unstructured information to produce structured results.</item>
               <item>Turning XSLT  into a general-purpose programming language</item>
            </ulist>
         </p>
      </div1>
      <div1>
         <head>Requirements</head>
         <table width="100%" border="0" cellspacing="0">
            <tbody>
               <tr role="class-r1">
                  <td valign="top" align="right">
                     <emph role="bold">1 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Support the XML "Family" of Standards</emph>
                     <emph role="br"/>
                     <p>As part of the evolving  family of XML standards, XSLT 2.0 MUST support the W3C XML architecture by integrating well with other standards in the family.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.1 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Maintain Backwards Compatibility with XSLT 1.1</emph>
                     <emph role="br"/>
                     <p>Any stylesheet whose behavior is fully defined in XSLT
1.1 and which generates no errors will produce the same result tree under
XSLT 2.0</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Match Elements with Null Values</emph>
                     <emph role="br"/>
                     <p>A stylesheet SHOULD be able to match elements and attributes whose value is explicitly <code>null</code>. </p>
                     <ednote>
                        <edtext>
                           <p>
                              <emph>Just</emph> matching <code>@xsi:null="true"</code> would find elements with this attribute even if the element actually had content like:</p>
                           <eg>&#60;foo xsi:null="true">SomeValue&#60;/foo></eg>
                           <p>or used the xsi:null when the element did not allow its content to be nullable, both of which are invalid.</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.3 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Allow Included Documents to "Encapsulate"  Local Stylesheets</emph>
                     <emph role="br"/>
                     <p>XSLT 2.0 SHOULD define a mechanism to allow the templates in  a stylesheet associated with a <emph>secondary</emph> source document, to be imported and used to format the included fragment, taking precedence over any applicable templates in the current stylesheet.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>When a  MATHML document is included in the current  source document, that MATHML fragment could already contain its own &#60;?xml-stylesheet?> indicating appropriate templates to properly style the Math.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support Accessing Infoset Items for XML Declaration</emph>
                     <emph role="br"/>
                     <p>A stylesheet COULD be able to access information like the version and encoding from the XML declaration of a document.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>A stylesheet should be able to set the output encoding to use the same encoding as the input document.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.5 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Provide QName Aware String Functions</emph>
                     <emph role="br"/>
                     <p>Users manipulating documents (e.g. stylesheets, schemas) that have QName-valued element or attribute content need functions that take a
string containing a QName as their argument, convert it to an expanded name
using either the namespace declarations in scope at that point in the
stylesheet, or the namespace declarations in scope for a specific source
node, and return properties of the expanded name such as its namespace URI
and local name.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.6 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Enable Constructing a Namespace with Computed Name</emph>
                     <emph role="br"/>
                     <p>Provide an <code>&#60;xsl:namespace></code> analog to <code>&#60;xsl:element></code> for constructing a namespace node with a computed prefix and URI.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.7 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Simplify Resolving Prefix Conflicts in QName-Valued Attributes</emph>
                     <emph role="br"/>
                     <p>XSLT 2.0 COULD simplify the renaming of conflicting namespace prefixes in result tree fragments, particularly for attributes declared in a schema as being QNames. Once the processor knows an attribute value
is a QName, an XSLT processor should be able to rename prefixes and
generate namespace declarations to preserve the semantics of that
attribute value, just as it does for attribute names.  </p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">1.8 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support XHTML Output Method</emph>
                     <emph role="br"/>
                     <p>Complementing the existing output methods for <code>html</code>, <code>xml</code>, and <code>text</code>, an xhtml output method could be provided to simplify transformations which target XHTML output.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top" align="right">
                     <emph role="bold">2 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Improve Ease of Use</emph>
                     <emph role="br"/>
                     <p>XSLT 2.0 MUST address frequently requested enhancements to make using XPath even more straightfoward for handling common use cases.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.1 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Allow Matching on Default Namespace Without Explicit Prefix</emph>
                     <emph role="br"/>
                     <p>Many users stumble trying to match an element with a default namespace. They expect to be able to do something like:</p>
                     <eg>&#60;xsl:stylesheet version="1.0" 
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns="urn:myuri">
  &#60;!-- Expect this matches &#60;foo> in default namespace -->
  &#60;xsl:template match="foo"></eg>
                     <p> thinking that leaving off the prefix from the <code>foo</code> element name, that it will match <code>&#60;foo></code> elements in the default namespace with the URI of <code>urn:myuri</code>. Instead, they are required to assign a non-null prefix name to their namespace URI and then match on "<code>someprefix:foo</code>" instead, which has proven to be far from obvious. XSLT 2.0 SHOULD provide an explicit way to handle this scenario to avoid further user confusion.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Add Date Formatting Functions</emph>
                     <emph role="br"/>
                     <p>
               One of the more frequent requests from XSLT 1.0 users is the ability to format date information with similar control  to XSLT's <code>format-number()</code>. XML Schema introduces several kinds of date and time datatypes which will further increase the demand for date formatting during transformations. Functionality similar to that provided by <xspecref href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.SimpleDateFormat.html">java.text.SimpleDateFormat</xspecref>. A date analog of XSLT's named  <code>xsl:decimal-format</code> may be required to handle locale-specific date formatting issues. </p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Given an XML element like: <code>&#60;Period start="2000-05-07" end="2000-05-13"/></code>
                                       </p>
                                       <p>Format it as:  <code>Invoice: 7 May 2000 - 13 May 2000</code>
                                       </p>
                                    </item>
                                    <item>
                                       <p>Given the same element above, format it according to the current locale as:</p>
                                       <eg>Fattura: 7 Maggio 2000 - 13 Maggio 2000</eg>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.3 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Simplify Accessing Id's and Key's in Other Documents</emph>
                     <emph role="br"/>
                     <p>Currently it is cumbersome to lookup nodes by <code>id()</code> or <code>key()</code> in documents other than the source document. Users must first use an <code>xsl:for-each</code> instruction, selecting the desired <code>document()</code> to make it the current node, then relative XPath expressions within the scope of the <code>xsl:for-each</code> can refer to <code>id()</code> or <code>key()</code>  as desired.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Provide Function to Absolutize Relative URIs</emph>
                     <emph role="br"/>
                     <p>There SHOULD be a way in XSLT 2.0 to create an absolute URI. The functionality should allow passing a node-set and return a string value representing the absolute URI resolved with respect to the base URI of the current node. </p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.5 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Include Unparsed Text from an External Resource</emph>
                     <emph role="br"/>
                     <p>Frequently stylesheets must import text from external resources. Today users have to resort to extension functions to accomplish this because XSLT 1.0 only provides the <code>document()</code> function which, while useful, can only read external resources that are well-formed XML documents.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Given an XML document like:</p>
                                 <eg>&#60;section>
  &#60;para>The code for the example looks like this:&#60;/para>
  &#60;example>
    &#60;external-file href="ParseXML.java"/>
  &#60;/example>
&#60;/section></eg>
                                 <p>Format the section and include the source of the sample code from the external file in the output.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.6 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Allow Authoring Extension Functions in XSLT</emph>
                     <emph role="br"/>
                     <p>As part of the XSLT 1.1 work done on extension functions, a proposal to author XSLT extension functions in XSLT itself was deferred for reconsideration in XSLT 2.0. This would allow the functions in an extension namespace to be implemented in "pure" XSLT, without resulting to external programming languages.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.7 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Output  Character Entity References Instead of Numeric Character Entities</emph>
                     <emph role="br"/>
                     <p>Users have frequently requested the ability to have the output of their transformation use (named) character references  instead of the numeric character entity. The ability to control this preference as the level of the whole document is sufficient. For example, rather than seeing <code>&#38;#160;</code> in the output, the user could request to see the equivalent <code>&#38;nbsp;</code> instead.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.8 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Construct Entity Reference by Name</emph>
                     <emph role="br"/>
                     <p>Analogous to the ability to create elements and attributes, users have expressed a desire to construct named entity references.  </p>
                     <ednote>
                        <edtext>
                           <p>Does this require a change to the data model?</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.9 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Support for Unicode String Normalization</emph>
                     <emph role="br"/>
                     <p>For reliable string comparison of Unicode strings, users need the ability to apply Unicode normalization before comparing the strings.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.10 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Standardize Extension Element Language Bindings</emph>
                     <emph role="br"/>
                     <p>XSLT 1.1 undertook the standarization of language bindings for XSLT extension functions. For XSLT 2.0, analogous bindings SHOULD be provided for extension elements.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.11 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Improve Efficiency of Transformations on Large Documents</emph>
                     <emph role="br"/>
                     <p>Many useful transformations take place on large documents consisting of thousands of repeating "sub-documents". Today transformations over these documents are impractical due to the need to have the entire source tree in memory.  Enabling "progressive" transformations, where the processor is able to produce
progressively more output as more input is received,  is tantamount to avoiding the need for XSLT processors to have random access to the entire
source document. This might be accomplished by: </p>
                     <ulist>
                        <item>
                           <p>Identifying a core subset of XPath that does not require random access to the source tree, or</p>
                        </item>
                        <item>
                           <p>Consider a "transform all subtrees" mode where the stylesheet
says, "Apply the transformation implied by this stylesheet to each node that
matches <code>XXX</code>, considered as the root of a separate tree, and copy all the
results of these mini-transformations as separate subtrees on to the final
result tree."</p>
                        </item>
                     </ulist>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Transforming an XML document representing the daily closing prices of NASDAQ stocks for 1999 like the example below (over 1.3 millon <code>&#60;ClosingQuote></code> sub-elements) to produce a comma-separated list of Ticker, Date, and Closing Price.</p>
                                 <eg>&#60;YearOfNasdaqCloses Year="1999" TotalSecurities="5207">
  &#60;ClosingQuote Ticker="AAABB">
    &#60;Date>01/01/1999&#60;/Date>
    &#60;Price>6.25&#60;/Price>
    &#60;Percent>0.5&#60;/Percent>
  &#60;/ClosingQuote>
  &#60;!-- 1,353,818 Additional Entries Removed -->
  &#60;ClosingQuote Ticker="ZVXI">
    &#60;Date>12/31/1999&#60;/Date>
    &#60;Price>16.10&#60;/Price>
    &#60;Percent>-1.05&#60;/Percent>
  &#60;/ClosingQuote>
&#60;/YearOfNasdaqCloses></eg>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.12 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support for Reverse IDREF attributes</emph>
                     <emph role="br"/>
                     <p>Given a particular value of an <code>ID</code>, produce a list of all elements that have an <code>IDREF</code> or <code>IDREFS</code> attribute which refers to this ID.</p>
                     <ednote>
                        <edtext>
                           <p>This functionality can be accomplished using the current <code>&#60;xsl:key></code> and <code>key()</code> mechanism.</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.13 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support for Case-Insensitive Comparisons</emph>
                     <emph role="br"/>
                     <p> XSLT 2.0 could expand its comparison functionality  to include support for case-insensitive string comparison.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.14 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support Lexigraphic String Comparisons</emph>
                     <emph role="br"/>
                     <p>We don't let users compare strings like <code>$x > 'a'</code>. </p>
                     <ednote>
                        <edtext>
                           <p>i18n issues.</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.15 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Allow Comparing  Nodes Based on Document Order</emph>
                     <emph role="br"/>
                     <p>Support the ability to test whether one node comes before another in document order.</p>
                     <ednote>
                        <edtext>
                           <p>Need a Use Case for this.</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.16 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Improve Support for Unparsed Entities</emph>
                     <emph role="br"/>
                     <p>In XSLT 1.0 there is an asymmetry in support for unparsed entities. They can be handled on input but not on output. In particular, there is no way to do an identity transformation that preserves them. At a minimum we need the ability to retrieve the Public ID of an unparsed entity.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.17 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Allow Processing a Node with the "Next Best Matching" Template</emph>
                     <emph role="br"/>
                     <p>In the construction of large stylesheets for complex documents, it is often necessary to construct templates that implement special behavior for a particular instance of an element, and then apply the normal styling for that element. Currently this is not possible because <code>&#60;xsl:apply-templates/></code> specifies that for any given node only a single template will be selected and instantiated.</p>
                     <p>Currently the processor determines a list of matching templates and then discards all but the one with the highest priority. In order to support this requirement, the processor would retain the list of matching templates sorted in priority order. A new instruction, for example <code>&#60;xsl:next-match/></code>, in a template would simply trigger the next template in the list of matching templates.

This "next best match"  recursion naturally bottoms out at the builtin template which can be seen as the lowest priority matching template for every match pattern.
</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Consider a large, complex stylesheet for a particular document type. In order to support a new application, the schema designer for that document type adds a new global attribute, that is an attribute allowed on every element in the schema. For example, consider the addition of a global attribute named <code>diff</code> for  marking changes made between one version of a document and another. You must now augment your stylesheet to support this new behavior.</p>
                                 <p>One would like to add a single new template, or a small number of templates, that would implement the new functionality for the entire doctype. Something like this:</p>
                                 <eg>&#60;xsl:template match="*[@diff='new']">
  &#60;div class="new">
    &#60;!-- do whatever you would have done for this element -->
  &#60;/div>
&#60;/xsl:template>

&#60;xsl:template match="para">
  &#60;p>
    &#60;xsl:apply-templates/>
  &#60;/p>
&#60;/xsl:template>
</eg>
                                 <p>When passed a document that contains <code>&#60;p diff='new'>...&#60;/p></code>, it would produce:</p>
                                 <eg>&#60;div class="new">
&#60;p>...&#60;/p>
&#60;/div>
</eg>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.18 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Make Coercions Symmetric By Allowing Scalar to Nodeset Conversion</emph>
                     <emph role="br"/>
                     <p>Presently, no datatype can be coerced or cast to a node-set. By allowing a string value to convert to a node-set, some user "gotchas" could be avoided due. </p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top" align="right">
                     <emph role="bold">3 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Support XML Schema</emph>
                     <emph role="br"/>
                     <p>
                        <xspecref href="http://www.w3.org/TR/xmlschema-1/">XML Schema: Structures</xspecref> and <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> enable users to define and use both simple and structured types and associate them to elements and attributes in a schema. XSLT 2.0 MUST provide  support for the common operations needed for matching and construction of transformed documents based on a source document containing these typed elements and attributes.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">3.1 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Simplify Constructing and Copying Typed Content</emph>
                     <emph role="br"/>
                     <p>It MUST be possible to construct XML Schema-typed elements and attributes. In addition, when copying an element or an attribute to the result, it should be possible to preserve the type during the process.</p>
                     <ednote>
                        <edtext>
                           <p>Use Case needs work.</p>
                        </edtext>
                     </ednote>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <eg>&#60;href xsi:type="urireference">foo.xml&#60;/href></eg>
                                    </item>
                                    <item>
                                       <eg>&#60;href xsl:type="urireference">&#60;xsl:value-of select="$foo"/>&#60;/href></eg>
                                    </item>
                                    <item>
                                       <eg>&#60;href>&#60;xsl:typed-value-of select="$foo"/>&#60;/href></eg>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">3.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Support Sorting Nodes Based on XML Schema Type</emph>
                     <emph role="br"/>
                     <p>XSLT 1.0 supports  sorting based on <code>string</code>-valued and <code>number</code>-valued expressions. <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> introduces new scalar types (for example, <code>date</code>) with well-known sort orders. It MUST be possible to sort based on these extended set of scalar data types. Since <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> does not define an ordering for complex types, this sorting support should only be considered for simple types.</p>
                     <ednote>
                        <edtext>
                           <p>Should be consistent with whatever we define for the matrix of conversion and comparisons.</p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">3.3 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Support Scientific Notation in Number Formatting</emph>
                     <emph role="br"/>
                     <p>Several users have requested the ability to have the existing <code>format-number()</code> function extended to format numbers using Scientific Notation.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">3.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p2">Could Provide Ability to Detect Whether "Rich" Schema Information is Available</emph>
                     <emph role="br"/>
                     <p>A stylesheet that requires XML Schema type-related functionality COULD be able to test whether a "rich" Post-Schema-Validated Infoset is available from the XML Schema processor, so that the stylesheet can provide fallback behavior or choose to exit with <code>&#60;xsl:message abort="yes"/></code>.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top" align="right">
                     <emph role="bold">4 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Simplify Grouping</emph>
                     <emph role="br"/>
                     <p>Grouping is complicated in XSLT 1.0. It MUST be possible for users to group nodes in a document based on </p>
                     <ulist>
                        <item>
                           <p>common string-values</p>
                        </item>
                        <item>
                           <p>common names</p>
                        </item>
                        <item>
                           <p>common values for any other expression</p>
                        </item>
                     </ulist>
                     <p>In addition XSLT must  allow grouping based on sequential position, e.g.
selecting groups of adjacent <code>&#60;P></code> elements. Ideally it should also make it
easier to do fixed-size grouping as well, e.g. groups of three adjacent nodes, for
laying out data in multiple columns.
For each group of nodes identified, it must be possible to instantiate a template for the group. Grouping must be "nestable" to multiple levels so that groups of distinct nodes can be identified, then from among the distinct groups selected, further sub-grouping of distinct node in the current group can be done. </p>
                     <p> Often users express this requirement in different words, asking for a way to easily select the distinct values of an XPath expression relative to a nodeset. For example, many users using keys have requested a function like <code>distinct-keys('</code>
                        <emph>keyname</emph>
                        <code>')</code> to return a node-set containing, for
each value of the named key that is present in the current document, the
first node in document order that has that key value. Others have suggested adding a <code>select-distinct="</code>
                        <emph>XpathExpression</emph>
                        <code>"</code> to places where XSLT currently allows a <code>select</code> attribute. </p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>
                                          <emph role="bold">Group by common values, groups unsorted, with group totals</emph>
                                       </p>
                                       <p>Given XML document:</p>
                                       <eg>&#60;cities>
  &#60;city name="milan"  country="italy"   pop="5"/>
  &#60;city name="paris"  country="france"  pop="7"/>
  &#60;city name="munich" country="germany" pop="4"/>
  &#60;city name="lyon"   country="france"  pop="2"/>
  &#60;city name="venice" country="italy"   pop="1"/>
&#60;/cities></eg>
                                       <p>Produce a 3-column table  listing each distinct country  in the first column, an alphabetical list of the city names for each country in the 2nd column, and the sum of the population for the cities in each country in the third column:</p>
                                       <eg>&#60;table>
  &#60;tr>
    &#60;th>Country&#60;/th>
    &#60;th>City List&#60;/th>
    &#60;th>Population&#60;/th>
  &#60;/tr>
  &#60;tr>
    &#60;td>italy&#60;/td>
    &#60;td>milan, venice&#60;/td>
    &#60;td>6&#60;/td>
  &#60;/tr>
  &#60;tr>
    &#60;td>france&#60;/td>
    &#60;td>lyon, paris&#60;/td>
    &#60;td>9&#60;/td>
  &#60;/tr>  
  &#60;tr>
    &#60;td>germany&#60;/td>
    &#60;td>munich&#60;/td>
    &#60;td>4&#60;/td>
  &#60;/tr>  
&#60;/table></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Group by common values, sorting the groups, with group totals</emph>
                                       </p>
                                       <p>Given same XML document as in use case 1 above, produce a 3-column table  listing each distinct country  in the first column (sorted in alphabetical order), an alphabetical list of the city names for each country in the 2nd column, and the sum of the population for the cities in each country in the third column:</p>
                                       <eg>&#60;table>
  &#60;tr>
    &#60;th>Country&#60;/th>
    &#60;th>City List&#60;/th>
    &#60;th>Population&#60;/th>
  &#60;/tr>
  &#60;tr>
    &#60;td>france&#60;/td>
    &#60;td>lyon, paris&#60;/td>
    &#60;td>9&#60;/td>
  &#60;/tr>  
  &#60;tr>
    &#60;td>germany&#60;/td>
    &#60;td>munich&#60;/td>
    &#60;td>4&#60;/td>
  &#60;/tr>  
  &#60;tr>
    &#60;td>italy&#60;/td>
    &#60;td>milan, venice&#60;/td>
    &#60;td>6&#60;/td>
  &#60;/tr>
&#60;/table></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Group by common values, sorting the groups by a group total</emph>
                                       </p>
                                       <p>Given same XML document as in use case 1 above, produce a 3-column table  listing each distinct country  in the first column (sorted in order of decreasing total population), a list of the city names for each country in the 2nd column (sorted in order of decreasing population), and the sum of the population for the cities in each country in the third column:</p>
                                       <eg>&#60;table>
  &#60;tr>
    &#60;th>Country&#60;/th>
    &#60;th>City List&#60;/th>
    &#60;th>Population&#60;/th>
  &#60;/tr>
  &#60;tr>
    &#60;td>france&#60;/td>
    &#60;td>paris, lyon&#60;/td>
    &#60;td>9&#60;/td>
  &#60;/tr>  
  &#60;tr>
    &#60;td>italy&#60;/td>
    &#60;td>milan, venice&#60;/td>
    &#60;td>6&#60;/td>
  &#60;/tr>
  &#60;tr>
    &#60;td>germany&#60;/td>
    &#60;td>munich&#60;/td>
    &#60;td>4&#60;/td>&#60;/tr>  
&#60;/table></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Group by result of an expression (e.g. initial letter, with a count for
each group)</emph>
                                       </p>
                                       <p>Given the input XML document above, produce the table below which groups by the initial letter of the city name, sorts these first-letters alphabetically,  then produces a list of cities whose names begin with that letter. The heading contains a count of entries:</p>
                                       <eg>&#60;h2>L (1)&#60;/h2>&#60;p>lyon&#60;/p>
&#60;h2>M (2)&#60;/h2>&#60;p>milan&#60;/p>&#60;p>munich&#60;/p>
&#60;h2>P (1)&#60;/h2>&#60;p>paris&#60;/p>
&#60;h2>V (1)&#60;/h2>&#60;p>venice&#60;/p></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Group by patterns of elements in a sequence</emph>
                                       </p>
                                       <p>Given the input:</p>
                                       <eg>&#60;body>
  &#60;h2>heading1&#60;/h2>
  &#60;p>para1&#60;/p>
  &#60;p>para2&#60;/p>
  &#60;h2>heading2&#60;/h2>
  &#60;p>para3&#60;/p>
  &#60;p>para4&#60;/p>
  &#60;p>para5&#60;/p>
&#60;/body></eg>
                                       <p>Produce the following output:</p>
                                       <eg>&#60;chapter>
  &#60;section title="heading1">
    &#60;para>para1&#60;/para>
    &#60;para>para2&#60;/para>
  &#60;/section> 
  &#60;section title="heading2">
    &#60;para>para3&#60;/para>
    &#60;para>para4&#60;/para>
    &#60;para>para5&#60;/para>
  &#60;/section>
&#60;/chapter> </eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Produce Hierarchical Nested Output from Flat Structure</emph>
                                       </p>
                                       <p>Given a source document like:</p>
                                       <eg>&#60;doc>
  &#60;group1>
    &#60;tag>value&#60;/tag>
  &#60;/group1>
  &#60;group2>
    &#60;tag>value&#60;/tag>
  &#60;/group2>
  &#60;group2>
    &#60;tag>value&#60;/tag>
  &#60;/group2>
  &#60;group3>
    &#60;tag>value&#60;/tag>
  &#60;/group3>
&#60;/doc></eg>
                                       <p>produce the output:</p>
                                       <eg>&#60;doc>
  &#60;group1>
    &#60;tag>value&#60;/tag>
    &#60;group2>
      &#60;tag>value&#60;/tag>
    &#60;/group2></eg>
                                       <eg>    &#60;group2>
      &#60;tag>value&#60;/tag>
      &#60;group3>
        &#60;tag>value&#60;/tag>
      &#60;/group3>
    &#60;/group2>
  &#60;/group1>
&#60;/doc></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Formatting HTML Term Definition Lists (Case 1)</emph>
                                       </p>
                                       <p>Given a source document like:</p>
                                       <eg>&#60;DL>
  &#60;!-- Handle the case with no DD or DT -->
  &#60;DT>One&#60;/DT>  
  &#60;DD>One Def&#60;/DD>
  &#60;DT>Two&#60;/DT>  
  &#60;DD>Two Def&#60;/DD>
  &#60;DT>Three&#60;/DT>  
&#60;/DL></eg>
                                       <p>produce the output:</p>
                                       <eg>&#60;OL>
  &#60;LI>&#60;B>One&#60;B> - &#60;I>One Def&#60;/I>&#60;/LI>
  &#60;LI>&#60;B>Two&#60;B> - &#60;I>Two Def&#60;/I>&#60;/LI>
  &#60;LI>&#60;B>Three&#60;B> - &#60;I>(No definition provided)&#60;/I>&#60;/LI>
&#60;/OL></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Formatting HTML Term Definition Lists (Case 2)</emph>
                                       </p>
                                       <p>A slightly more compliated version of the HTML term definition list involved multiple terms with a single definition or multiple definitions for a single term. Given the source</p>
                                       <eg>&#60;DL>
  &#60;DT>One&#60;/DT>
  &#60;DT>Two&#60;/DT>
  &#60;DD>One and Two Def&#60;/DD>
&#60;/DL></eg>
                                       <p>produce the output</p>
                                       <eg>&#60;OL>
  &#60;LI>&#60;B>One, Two&#60;/B> - &#60;I>One and Two Def&#60;/I>&#60;/LI>
&#60;/OL></eg>
                                       <p>For the other varation, given the source:</p>
                                       <eg>&#60;DL>
  &#60;DT>One&#60;/DT>
  &#60;DD>One Def&#60;/DD>
  &#60;DD>Another One Def&#60;/DD>
&#60;/DL></eg>
                                       <p>produce the output:</p>
                                       <eg>&#60;UL>
  &#60;LI>
    &#60;B>One&#60;/B>
    &#60;OL>
      &#60;LI>One Def&#60;/LI>
      &#60;LI>Another One Def&#60;/LI>
    &#60;/OL>
  &#60;/LI>
&#60;/UL></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Transform Inline &#60;para> Elements to Block &#60;para> Elements</emph>
                                       </p>
                                       <p>Transform from a DTD that allows para elements to have nested
block-level elements to a DTD that requires para elements to have only
inline elements, e.g. transform:</p>
                                       <eg>&#60;p>Do &#60;em>not&#60;/em>:
&#60;ul>
&#60;li>talk,&#60;/li>
&#60;li>eat, or&#60;/li>
&#60;li>use your mobile telephone&#60;/li>
&#60;/ul>
while you are in the cinema.&#60;/p></eg>
                                       <p>into:</p>
                                       <eg>&#60;p>Do &#60;em>not&#60;/em>:&#60;/p>
&#60;ul>
&#60;li>talk,&#60;/li>
&#60;li>eat, or&#60;/li>
&#60;li>use your mobile telephone&#60;/li>
&#60;/ul>
&#60;p>while you are in the cinema.&#60;/p></eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Arrange into Fixed-Sized Groups (Across/Down)</emph>
                                       </p>
                                       <p>Given the input from use case number 1 above, produce a two-column list of all city names, sorted alphabetically, in "Across/Down" format. The result should correctly format the "left over" cells when the number of items is not a multiple of the number of items in the group.</p>
                                       <eg>&#60;table>
  &#60;!-- Alphabetized Across each row -->
  &#60;tr>&#60;td>lyon&#60;/td>&#60;td>milan&#60;/td>&#60;/tr>
  &#60;tr>&#60;td>munich&#60;/td>&#60;td>paris&#60;/td>&#60;/tr>
  &#60;tr>&#60;td>venice&#60;/td>&#60;td>&#38;nbsp;&#60;/td>&#60;/tr>
&#60;/table>
</eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Arrange into Fixed-Sized Groups (Down/Across)</emph>
                                       </p>
                                       <p>Given the input from use case number 1 above, produce a two-column list of all city names, sorted alphabetically, in "Down/Across" format. The result should correctly format the "left over" cells when the number of items is not a multiple of the number of items in the group.</p>
                                       <eg>&#60;table>
  &#60;!-- Alphabetized Down each column -->
  &#60;tr>&#60;td>lyon&#60;/td>&#60;td>paris&#60;/td>&#60;/tr>
  &#60;tr>&#60;td>milan&#60;/td>&#60;td>venice&#60;/td>&#60;/tr>
  &#60;tr>&#60;td>munich&#60;/td>&#60;td>&#38;nbsp;&#60;/td>&#60;/tr>
&#60;/table>
</eg>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">Multi-level Grouping</emph>
                                       </p>
                                       <p>Given the XML list of software bugs assigned to developers on different teams...</p>
                                       <eg>&#60;bugs>
  &#60;bug dev="ace" team="ui">
    &#60;desc>Border shows white when it should be grey&#60;/desc>
  &#60;/bug>
  &#60;bug dev="tom" team="core">
    &#60;desc>Incorrectly handling nulls on entry&#60;/desc>
  &#60;/bug>
  &#60;bug dev="gary" team="ui">
    &#60;desc>Preferences dialog has two Cancel buttons&#60;/desc>
  &#60;/bug>
  &#60;bug dev="ace" team="ui">
    &#60;desc>Drag and drop cursor never changes back&#60;/desc>
  &#60;/bug>
  &#60;bug dev="tim" team="core">
    &#60;desc>Infinite loop in validation code&#60;/desc>
  &#60;/bug>
  &#60;bug dev="gary" team="ui">
    &#60;desc>Resizing dialog doesn't resize text box&#60;/desc>
  &#60;/bug>
  &#60;bug dev="ace" team="ui">
    &#60;desc>German text is truncated&#60;/desc>
  &#60;/bug>
  &#60;bug dev="tim" team="core">
    &#60;desc>Data inserted twice&#60;/desc>
  &#60;/bug>
&#60;/bugs>
</eg>
                                       <p>produce an HTML page that includes:</p>
                                       <ulist>
                                          <item>
                                             <p>The total number of open bugs in the title</p>
                                          </item>
                                          <item>
                                             <p>A column for each team of developers, with a per-team bug count. The teams should be ordered left to right by descreasing number of open bugs assigned to the team.</p>
                                          </item>
                                          <item>
                                             <p>A vertical list (separated by &#60;br/> tags) of developers on each team, with their bug count. Developers should be listed top down in order of descreasing individual bug count.</p>
                                          </item>
                                       </ulist>
                                       <p> The result is a nested, grouped output giving development managers a bird's-eye view of which teams and which developers are in the most "bug trouble":</p>
                                       <eg>&#60;html>
  &#60;body>
    &#60;h2>Bug Summary (8)&#60;/h2>
    &#60;table>
      &#60;tr>
	       &#60;th>ui (5)&#60;/th>
     	  &#60;th>core (3)&#60;/th>
      &#60;/tr>
      &#60;tr>
     	  &#60;td>
     	    ace (3)&#60;br/>
     	    gary (2)
     	  &#60;/td>
     	  &#60;td>
     	    tim (2)&#60;br/>
     	    tom (1)
     	  &#60;/td>
      &#60;/tr>
    &#60;/table>
  &#60;/body>
&#60;/html></eg>
                                    </item>
                                    <item>
                                       <p>List all the different element names in a
 document, and for each one list all the attributes used, and for each attribute list the distinct values used in the document.  For example, given the document:</p>
                                       <eg>&#60;foo baz="Q">
  &#60;bar baz="3" bop="T"/>
  &#60;foo baz="1">
    &#60;bar bop="S" bip="4" baz="5"/>
  &#60;/foo>
&#60;/foo></eg>
                                       <p>Produce the result:</p>
                                       <eg>&#60;inventory>
  &#60;element name="bar">
    &#60;attribute name="baz">
      &#60;value>3&#60;/value>
      &#60;value>5&#60;/value>
    &#60;/attribute>
    &#60;attribute name="bip">
      &#60;value>4&#60;/value>
    &#60;/attribute>
    &#60;attribute name="bop">
      &#60;value>S&#60;/value>
      &#60;value>T&#60;/value>
    &#60;/attribute>
  &#60;/element>
  &#60;element name="foo">
    &#60;attribute name="baz">
      &#60;value>1&#60;/value>
      &#60;value>Q&#60;/value>
    &#60;/attribute>
  &#60;/element>
&#60;/inventory></eg>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
            </tbody>
         </table>
      </div1>
      <div1>
         <head>References</head>
         <blist>
            <bibl>XML Schema: Structures, <loc href="http://www.w3.org/TR/xmlschema-1/">http://www.w3.org/TR/xmlschema-1/</loc>
            </bibl>
            <bibl>XML Schema: Datatypes, <loc href="http://www.w3.org/TR/xmlschema-2/">http://www.w3.org/TR/xmlschema-2/</loc>
            </bibl>
         </blist>
      </div1>
   </body>
</spec>