<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE spec SYSTEM "xml/1998/06/xmlspec-v20.dtd">
<spec>
   <header>
      <title>XPath Requirements</title>
      <version>Version 2.0</version>
      <w3c-designation>WD-xpath20req-20010214</w3c-designation>
      <w3c-doctype>W3C Working Draft</w3c-doctype>
      <pubdate>
         <day>14</day>
         <month>February</month>
         <year>2001</year>
      </pubdate>
      <publoc>
         <loc href="http://www.w3.org/TR/2001/WD-xpath20req-20010214">http://www.w3.org/TR/2001/WD-xpath20req-20010214</loc>
         <loc role="available-format" href="http://www.w3.org/TR/2001/WD-xpath20req-20010214.xml">XML</loc>
         <loc role="available-format" href="http://www.w3.org/TR/2001/WD-xpath20req-20010214.html">HTML</loc>
      </publoc>
      <latestloc>
         <loc href="http://www.w3.org/TR/xpath20req">http://www.w3.org/TR/xpath20req</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>
         <author>
            <name>Mary Fernandez</name>
            <affiliation>AT&#38;T</affiliation>
            <email href="mailto:mff@research.att.com">mff@research.att.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 XPath 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 jointly as part of the <loc href="http://www.w3.org/Style/Activity">W3C Style
	  Activity</loc> and the <loc href="http://www.w3.org/XML/">W3C XML 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> and the <loc href="http://www.w3.org/XML/Group/Query">XML Query 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>, and the goals of the XML Query Working
          Group are discussed in the <loc href="http://www.w3.org/1999/07/query-charter">XML 
          Query Working Group Charter</loc>.  

  This Working Draft represents the current thinking of the XSL
  Working Group and XML Query Working Group. The groups have consensus
  except in a few specific areas as noted below and the details of
  these areas are still under active discussion.  Nonetheless, we are
  publishing this draft to encourage early public feedback to the
  XPath 2.0 requirements process.

</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 XPath 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>XPath 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>
      </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, XPath 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 Express  Data model in Terms of the Infoset</emph>
                     <emph role="br"/>
                     <p>XPath 2.0 data model MUST be expressed in terms of
 the <xspecref href="http://www.w3.org/TR/xml-infoset">XML Infoset</xspecref>, including Post Schema Validation Infoset contributions. Ideally, XSLT, XPath, and XML Query should share a common data model.</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 Provide Common Core Syntax and Semantics for XSLT 2.0 and XML Query 1.0</emph>
                     <emph role="br"/>
                     <p>XSLT 2.0 contains an expression language which is "XPath 2.0 plus
XSLT 2.0 extensions". XML Query 1.0 contains an expression language
which we believe should be "XPath 2.0 plus XML Query 1.0 extensions."
The scope of XPath 2.0 must be the set of common
functionality between the expression language of XSLT 2.0 and the
expression language of XML Query 1.0. This will guarantee for Web
developers and users that any common functionality are implemented
with identical syntax and semantics.</p>
                     <ednote>
                        <edtext>
                           <p>The XSL Working group has consensus on the above requirement but the XML Query Working Group does not. Specifically, the XML Query Working Group is discussing what functionality constitutes a common core. The Working Groups therefore particularly wish to receive feedback on this requirement.</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-p0">Must Support Explicit "For Any" or "For All" Comparison and Equality Semantics</emph>
                     <emph role="br"/>
                     <p>It MUST be possible for boolean expressions involving node-sets to explicitly use "for any" or "for all" semantics, otherwise known as explicit existential quantification and explicit universal quantification, respectively. Any <emph>implicit</emph> quantification should be explained in terms of these explicit semantics.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>The following examples illustrate limitations of XPath 1.0 that can
be addressed by the addition of existential and universal quantifiers
to XPath 2.0:</p>
                                 <olist>
                                    <item>
                                       <p>In XPath 1.0, the expression <code>5 > $ns</code> evaluates to true if <code>5</code> is greater than the  <code>number()</code> value of at least one node in the <code>$ns</code> node set. There is no way to test whether <code>5</code> is greater than the <code>number()</code> values of all nodes in <code>$ns</code>.</p>
                                    </item>
                                    <item>
                                       <p>In XPath 1.0, the expression <code>$ns1 > $ns2</code> evaluates to true if the <code>number()</code> value of at least one node in <code>$ns1</code> is greater than the  <code>number()</code> value of at least one node in the <code>$ns2</code> node set. There is no way to test whether the <code>number()</code> values of all of the nodes in <code>$ns1</code> are greater than all the <code>number()</code> values of all nodes in <code>$ns2</code>.</p>
                                    </item>
                                    <item>
                                       <p>In XPath 1.0, the expression <code>5 = $ns</code> evaluates to true if <code>5</code> equals the  <code>number()</code> value of at least one node in the <code>$ns</code> node set. There is no way to test whether <code>5</code> equals the <code>number()</code> value of all nodes in <code>$ns</code>.</p>
                                    </item>
                                    <item>
                                       <p>In XPath 1.0, the expression <code>$ns1 = $ns2</code> evaluates to true if the <code>number()</code> value of at least one node in <code>$ns1</code> equals the  <code>number()</code> value of at least one node in the <code>$ns2</code> node set. There is no way to test whether the <code>number()</code> values of all of the nodes in <code>$ns1</code> are greater than all the <code>number()</code> values of all nodes in <code>$ns2</code>.</p>
                                    </item>
                                    <item>
                                       <p>In XPath 1.0, the expression    <code>0 + LineItem/@UnitPrice > 40</code> is equivalent to <code>0 + number(OrderDetail/@UnitPrice) > 40</code>

which will be true if the <emph>first</emph>
                                          <code>LineItem</code> element's <code>UnitPrice</code> attribute is greater than 40. However, the expression <code>LineItem/@UnitPrice > 40</code> is true if <emph>any</emph> of the <code>LineItem</code> elements' <code>UnitPrice</code> attributes is greater than 40.  This difference in behavior could be resolved through explicit quantification.</p>
                                    </item>
                                 </olist>
                              </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-p0">Must Extend Set of Aggregation Functions</emph>
                     <emph role="br"/>
                     <p>XPath 1.0 currently supports <code>sum()</code> and <code>count()</code>.  XSLT users have frequently requested the addition of <code>min()</code> and <code>max()</code>. XPath 2.0 MUST address this by extending its basic set of aggegration functions by adopting some or all of the ones defined for XML
Query. </p>
                  </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-p1">Should Maintain Backwards Compatibility with XPath 1.0</emph>
                     <emph role="br"/>
                     <p>Any valid XPath 1.0 expression SHOULD also be a valid XPath 2.0 expression, and have the same semantics when operating in the absence of XML Schema type information. If not possible to achieve due to other requirements, XPath 2.0 should minimize the number of changes to the XPath 2.0 syntax to maximize backward compatibility with XPath 1.0.</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-p1">Should Provide Intersection and Difference Functions</emph>
                     <emph role="br"/>
                     <p>XPath 1.0 supports the union of two node sets. Set functionality in XPath 2.0 SHOULD be expanded to include intersection and difference functions, and should be compatible with equivalent functions   supported by XML Query.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Given an XML document like:</p>
                                       <eg>&#60;hr>
  &#60;teams>
    &#60;team id="t1">
      &#60;members ref="e101 e103"/>
    &#60;/team>
    &#60;team id="t2">
      &#60;members ref="e102"/>
    &#60;/team>  
  &#60;/teams>
  &#60;departments>
    &#60;department>
      &#60;employee id="e101" name="Steve"    teams="t1"/>
      &#60;employee id="e102" name="Jonathan" teams="t2"/>
      &#60;employee id="e103" name="James"    teams="t1"/>
    &#60;/department>
  &#60;/departments>
&#60;/hr></eg>
                                       <p>Format the list of employees that work in the same department as the <code>employee</code> with <code>id</code> = <code>e101</code> and that are on the same teams as that employee.  To accomplish this:</p>
                                       <ulist>
                                          <item>
                                             <p>Select the list of all employees in the  employee's department:</p>
                                             <eg>id('e101')/parent::department/employee</eg>
                                          </item>
                                          <item>
                                             <p>Intersect that set with the list of all employees who are members of the current employee's teams:</p>
                                             <eg>id('e101')/id(id(@teams)/members/@ref)</eg>
                                          </item>
                                          <item>
                                             <p>Difference that set with the list containing the current employee so they don't appear in their own list of team members:</p>
                                             <eg>id('e101')</eg>
                                          </item>
                                       </ulist>
                                       <p>The result should be the employee "James".</p>
                                    </item>
                                    <item>
                                       <p>Given an XML document full of book information, a book with multiple authors appears like this: </p>
                                       <eg>&#60;books>
  &#60;book>
    &#60;title>Exciting New Book&#60;/title>
    &#60;author>Kay&#60;/author>
    &#60;author>Muench&#60;/author>
  &#60;/book>
  &#60;book>
    &#60;title>Building Oracle XML Applications&#60;/title>
    &#60;author>Muench&#60;/author>
  &#60;/book>
  &#60;book>
    &#60;title>XSLT Programmer's Reference&#60;/title>
    &#60;author>Kay&#60;/author>
  &#60;/book>
&#60;/books></eg>
                                       <p>Assuming an XSLT key is defined as follows:</p>
                                       <eg>&#60;xsl:key name="auth" match="book" use="author"/></eg>
                                       <p>then, to find the list of books that have both Muench and Kay among their authors, you need to select the intersection of <code>key('auth','Muench')</code> and <code>key('auth','Kay')</code>.</p>
                                       <p>To find books authored by Muench but <emph>not</emph> by Kay, you need to select the difference of <code>key('auth','Muench')</code> and <code>key('auth','Kay')</code>.</p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </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-p1">Should Support Unary Plus Operator</emph>
                     <emph role="br"/>
                     <p>XML Schema allows decimals to have a leading plus. To align better with this, XPath 2.0 SHOULD  allow this by providing a unary plus operator.</p>
                     <ednote>
                        <edtext>
                           <p>There's a potential though rather remote  problem if
there are nodes in the source document containing a number with a leading
plus sign. Currently the defined behavior is to convert these values to <code>NaN</code>,
and this will change. A stylesheet that is looking for phone-numbers
beginning with "+" might rely on this. </p>
                        </edtext>
                     </ednote>
                  </td>
               </tr>
               <tr role="class-r1">
                  <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>Users of XPath 1.0 have requested enhancements to simplify
   expression of common XPath use cases.  XPath 2.0 MUST address
these frequently
   requested enhancements.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <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 Loosen Restrictions on Location Steps</emph>
                     <emph role="br"/>
                     <p>To better align with <xspecref href="http://www.w3.org/TR/xptr">XPointer</xspecref> and to simplify the use of XPath expressions in which multiple alternatives are allowed for a given location step, XPath 2.0 MUST relax current restrictions for what can appear after a '<code>/</code>' in an XPath expression. Neither unions nor node-set functions are  allowed to appear after a '<code>/</code>' in XPath 1.0.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>An XPointer's expression can use node-set functions on the right of the '<code>/</code>' in a path:</p>
                                       <eg>id("chap1")/range-to(id("chap2"))</eg>
                                    </item>
                                    <item>
                                       <p> Allowing unions in a location step would allow expressions like:</p>
                                       <eg>/foo/(xxx|yyy)/li/(p|eg)</eg>
                                       <p>instead of the more cumbersome:</p>
                                       <eg>/foo/xxx/li/p  | 
/foo/xxx/li/eg | 
/foo/yyy/li/p  |
/foo/yyy/li/eg</eg>
                                    </item>
                                    <item>
                                       <p>Allowing node-set functions to appear in a location step would allow expressions like:</p>
                                       <eg>document("otherdoc.xml")/id("foo")/a/b</eg>
                                       <p>and</p>
                                       <eg>document("otherdoc.xml")/key("x","foo")/a/b</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.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Provide a Conditional Expression</emph>
                     <emph role="br"/>
                     <p>Many users have requested the ability to return a conditional value based on a boolean expression. XPath 2.0 MUST provide a conditional expression which takes three expressions:</p>
                     <olist>
                        <item>
                           <p>
                              <emph>expression1 (boolean)</emph>
                           </p>
                        </item>
                        <item>
                           <p>
                              <emph> expression2</emph>
                           </p>
                        </item>
                        <item>
                           <p>
                              <emph>expression3</emph>
                           </p>
                        </item>
                     </olist>
                     <p>and evaluates to <emph>expression2</emph> if <emph>expression1</emph> is <code>true</code> and to <emph>expression3</emph> if <code>expression1</code> is <code>false</code>. Only <emph>expression1</emph> and the expression to be returned must be evaluated. </p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>
                                    <emph role="bold">XSLT Use Cases</emph>
                                 </p>
                                 <olist>
                                    <item>
                                       <p>In a  template, construct a <code>&#60;table></code> element with a <code>border</code> attribute whose value is provided by an <emph>attribute value template</emph> and is conditional depending on the value of the <code>frame</code> attribute of the current node. If <code>@frame = 'none'</code>, then the value of <code>border</code> should be <code>0</code>, otherwise the value of <code>border</code> should be <code>1</code>.</p>
                                    </item>
                                    <item>
                                       <p>Assign an XSLT variable a conditional value based on whether the current node has any <code>&#60;test></code> element children. If it does, assign the value "<code>is</code>" to the variable, otherwise assign the value "<code>is not</code>".</p>
                                    </item>
                                    <item>
                                       <p>Given a source XML document like this:</p>
                                       <eg>&#60;Emps>
  &#60;Emp>
     &#60;LastName>Smith&#60;/LastName>
  &#60;/Emp>
  &#60;Emp>
    &#60;CommonName>Scott&#60;/CommonName>
  &#60;/Emp>
&#60;/Emps></eg>
                                       <p>provide an <code>&#60;xsl:sort></code> select expression to sort the list of employees on the value of their <code>&#60;LastName></code> if it's present, otherwise on the value of their  <code>&#60;CommonName></code> element.</p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <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 Define Consistent Implicit Semantics for Collection-Valued Subexpressions</emph>
                     <emph role="br"/>
                     <p>In XPath 1.0, the use of a collection-valued subexpression can
introduce an implicit existential quantification or
choose-first-member operation into the containing expression's
semantics.  XPath 2.0 MUST define a consistent implicit semantics for
expressions that have collection-valued subexpressions.  This may
require that XPath 2.0 expressions use explicit quantification or
indexing expressions to achieve the same implicit semantics provided
in XPath 1.0.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>In XPath 1.0, the expression <code>a[b=5]</code> returns <code>&#60;a></code> elements that have
      ANY <code>&#60;b></code> element child with value 5, where as the expression <code>a[b+1=6]</code>
returns <code>&#60;a></code> elements whose FIRST <code>&#60;b></code> element child has value 5.  
 These results should be consistent for XPath 2.0.</p>
                                    </item>
                                    <item>
                                       <p>Assume for this use case that the typed-value of an element or attribute is referenced using the syntax <code>typed-value(elt)</code> and <code>typed-value(@attr)</code>, respectively. In XPath 2.0, when working with the typed value of an element or attribute with <code>boolean</code> type, the expression <code>a[typed-value(b) = false()]</code> should return <code>&#60;a></code> elements having at least one <code>&#60;b></code> element child with <code>boolean</code> value <code>false</code>. Similarly, the expression <code>a[typed-value(@b) = false()]</code>  should return &#60;a> elements having a boolean attribute <code>b</code> with value <code>false</code>.</p>
                                    </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.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Support Additional String Functions</emph>
                     <emph role="br"/>
                     <p>Users of XSLT 1.0 have requested additional string manipulation
functions. 
      Common requests include string padding (with spaces, dashes, or
other characters),
      string replacement, and converting strings to upper and lower
case. XPath 2.0 SHOULD provide additional string functions. As with any string functions, internationalization issues need to be addressed to insure that the functionality is as broadly useful as possible.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.4.1 </emph>
                  </td>
                  <td colspan="1">
                     <emph role="underline.class-p1">Should Simplify String Replacement</emph>
                     <emph role="br"/>
                     <p>XPath 1.0 provides the <code>translate()</code> function that allows each
single 
          character in a source string to be translated to another
          single character in the result string, or to be removed. Users
of XPath 1.0
          frequently want to replace <emph>sequences</emph> of consecutive characters
with
          other sequences of characters, which <code>translate()</code> does not
support. 
          XPath 2.0 SHOULD support a more flexible string replacement
function.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Replace each occurrence of "<code>foo</code>" in a string with "<code>foobar</code>".</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.4.2 </emph>
                  </td>
                  <td colspan="1">
                     <emph role="underline.class-p1">Should Simplify String Padding</emph>
                     <emph role="br"/>
                     <p>Often string values need to be padded on the left or right to 
          make the value occupy a fixed length. XPath 2.0 SHOULD support
a string
          padding function that permits any character as a padding
character.
</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Pad the value of a string on the right to ensure a length of 10 characters using spaces</p>
                                    </item>
                                    <item>
                                       <p>Pad the value of a string on the left to 10 characters using  asterisks</p>
                                    </item>
                                    <item>
                                       <p>Output a string containing as many dashes as the length of a section title</p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">2.4.3 </emph>
                  </td>
                  <td colspan="1">
                     <emph role="underline.class-p1">Should Simplify String Case Conversions</emph>
                     <emph role="br"/>
                     <p>XPath 2.0 SHOULD provide the ability to convert the case of text to upper or lower case for presentation and/or comparison. </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 Support Aggregation Functions Over Collection-Valued Expressions</emph>
                     <emph role="br"/>
                     <p>Users of XPath 1.0 frequently  request the ability to apply an
aggregate function,
      like <code>sum()</code>, to the values of expressions applied to a node set.  
      XPath 2.0 SHOULD support aggregation functions over expressions
applied to node sets.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Given a document like</p>
                                       <eg>&#60;sect title="Plan">
   &#60;sect title="Overview">
      &#60;sect title="Competitors">
        &#60;sect title="SuperSoft"/>
        &#60;sect title="BarnWare"/>
      &#60;/sect>
   &#60;/sect>
   &#60;sect title="Details">
      &#60;sect title="Summary"/>
   &#60;/sect>
&#60;/sect></eg>
                                       <p>Calculate the maximum depth of the nesting of <code>&#60;sect></code> elements. The nodeset is identified by the expression <code>//sect</code> and the expression to maximize would be <code>count(ancestor-or-self::sect)</code>.</p>
                                    </item>
                                    <item>
                                       <p>Given the same document above, calculate the average string length of section titles. The nodeset is identified by <code>//section/@title</code> and the expression to sum would be <code>string-length(.)</code>, divided by the <code>count(//section/@title)</code>
                                       </p>
                                    </item>
                                    <item>
                                       <p>Given an XML document containing a purchase order and its line <code>&#60;item></code> elements, calculate the total amount of the purchase order by summing the price times the quantity of each item. The nodeset is identified by <code>item</code>, and the expression to sum would be <code>price * quantity</code>.</p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top" align="right">
                     <emph role="bold">3 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Support String Matching Using Regular Expressions </emph>
                     <emph role="br"/>
                     <p>Regular expressions provide a powerful way to specify string pattern matching and now play an important role in XML Schema as the mechanism by which pattern facets are specified. XPath 2.0 MUST support regular expressions for matching against strings using the regular expression notation established in <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref>.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Given XML like:</p>
                                       <eg>&#60;Data>
  &#60;EmpRow>
     :
  &#60;/EmpRow>
  &#60;DeptRow>
     &#60;Deptno>10&#60;/Deptno>
     &#60;Employees>
        &#60;EmpRow>
          &#60;Empno>1000&#60;/Empno>
          &#60;Ename>1000&#60;/Ename>
        &#60;/Emprow>
     &#60;/Employees>
  &#60;/DeptRow>
&#60;/Data></eg>
                                       <p>match elements that "end with <code>Row</code> or <code>row</code>"</p>
                                       <eg>*[local-name() =~ ".*[rR]ow"]</eg>
                                    </item>
                                    <item>
                                       <p>Match phone numbers like 123-456-7890</p>
                                       <eg>field[ . =~ "\d\d\d-\d\d\d\-\d\d\d\d ]</eg>
                                    </item>
                                    <item>
                                       <p>Match any element name with the string "Addr" contained within the name (case-insensitively)</p>
                                       <eg>*[local-name() =~ ".*[Aa][Dd][Dd][Rr].*"]</eg>
                                    </item>
                                    <item>
                                       <p>Match a string from a dynamic regular expression</p>
                                       <eg>Department[Code =~ concat("[0-9][0-9]",$v,".*")]</eg>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top" align="right">
                     <emph role="bold">4 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p0">Must Add Support for XML Schema Primitive Datatypes</emph>
                     <emph role="br"/>
                     <p>
                        <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> defines a set of primitive
   datatypes.
               In addition to the types supported by the XPath 1.0 data
   model, <code>string</code>, <code>number</code>, <code>boolean</code>, and
   <code>node-set</code>, the XPath 2.0 data model MUST support XML Schema primitive
   types. XPath 2.0 will extend the XPath data model to accommodate working with elements and attribute values having an XML Schema primitive type. </p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.1 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Define the Operator Matrix and Conversions</emph>
                     <emph role="br"/>
                     <p>XPath 2.0 MUST support the operators and type-coercion rules
defined by the joint XSLT/Schema/Query task force on operators.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <ulist>
                                    <item>
                                       <p>
                                          <emph role="bold">General</emph>
                                       </p>
                                       <olist>
                                          <item>
                                             <p>Use and create the type information of any datatype</p>
                                          </item>
                                          <item>
                                             <p>Do not require the user to respecify the datatype (i.e. number and boolean)</p>
                                          </item>
                                          <item>
                                             <p>Maintain the facet constraints of primitive datatypes while manipulating the value. For example, take a 14.4 number plus a 14.4 number and return a 14.4 number.</p>
                                          </item>
                                       </olist>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">For DateTime</emph>
                                       </p>
                                       <olist>
                                          <item>
                                             <p>Compare dates of documents and return a boolean</p>
                                          </item>
                                          <item>
                                             <p>Add a time or date interval and return the same type</p>
                                          </item>
                                          <item>
                                             <p>Add a scalar value to a time or date and return the same type</p>
                                          </item>
                                          <item>
                                             <p>Calculate an end time from a start time+duration. For example, given:</p>
                                             <eg>&#60;appointment time="20001224-16:00:00" duration="1:00"/></eg>
                                             <p>Produce the end-time:</p>
                                             <eg>End time: &#60;xsl:value-of select="@time + @duration"/></eg>
                                          </item>
                                          <item>
                                             <p>Detect intersections between datetime durations</p>
                                             <eg>&#60;appointment time="20001224-16:00:00" 
             duration="2:00" reminder="0:15"/>
&#60;appointment time="20001224-17:00:00" 
             duration="1:00" reminder="0:15"/></eg>
                                          </item>
                                       </olist>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">For Boolean</emph>
                                       </p>
                                       <p>Perform pattern matching on "yes" and "no"</p>
                                    </item>
                                    <item>
                                       <p>
                                          <emph role="bold">For QName</emph>
                                       </p>
                                       <olist>
                                          <item>
                                             <p>Build a Namespace element from a QName</p>
                                          </item>
                                          <item>
                                             <p>Compare a Namespace URI from a QName with a string</p>
                                          </item>
                                       </olist>
                                    </item>
                                 </ulist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Allow Scientific Notation for Numbers</emph>
                     <emph role="br"/>
                     <p>XML Schema specifies a lexical representation for doubles and
   floats that includes scientific notation as well as <code>INF</code>, <code>-INF</code> or
   <code>NaN</code>.  XPath 2.0 MUST support the lexical representations of floats
   and doubles supported by XML Schema.</p>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.3 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Define Appropriate Cast and Constructor Functions</emph>
                     <emph role="br"/>
                     <p>XPath 2.0 MUST define an appropriate set of functions to allow users to cast and construct instances of XML Schema primitive types.  At a minimum, this  set MUST include cast and constructor functions for URI and date/time types.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Be able to compare an element or attribute with an XML Schema date or time type with a constant date or time value.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Add List Data Type to the Type System of the Expression Langauge</emph>
                     <emph role="br"/>
                     <p>XML Schema allows the definition of simple types derived by list, 
   including lists of unions of non-list simple types. XPath 2.0 SHOULD
   support an ordered list of simple-typed
values.
</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Create an XSLT transformation that converts an element structure like this:</p>
                                 <p/>
                                 <eg>&#60;xdr:attribute name="a1" 
                     dt:type="enumeration"
                     dt:values="a1 a2 a3"/></eg>
                                 <p>into an alternative structure like this:</p>
                                 <eg>&#60;xsd:attribute name="a1">          
  &#60;xsd:simpleType>           
    &#60;xsd:restriction base="NMTOKEN">           
      &#60;xsd:enumeration value="a1"/>           
      &#60;xsd:enumeration value="a2"/>           
      &#60;xsd:enumeration value="a3"/>              
    &#60;/xsd:restriction>               
  &#60;/xsd:simpleType>           
&#60;/xsd:attribute></eg>
                                 <p>This requires the ability in XPath to select the list of NMTOKENS values of the <code>dt:values</code> attribute for processing.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.5 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Support Accessing  Simple-Typed Value of Elements and Attributes</emph>
                     <emph role="br"/>
                     <p>The XPath 1.0 type system supports the <code>number</code>, <code>string</code>, <code>boolean</code>, and <code>node-set</code> types. 
      <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> introduces many new types. XPath 1.0
supports conversion 
      of the simple-typed values of elements and attributes to strings.  
      In addition to this functionality, XPath 2.0 MUST support access
to the native,
      simple-typed value of an element or attribute.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">4.6 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p0">Must Define Behavior of Operators for Null Arguments</emph>
                     <emph role="br"/>
                     <p>Since the typed value of an element can be <code>null</code>, XPath 2.0 MUST
define 
    how the behavior of operations applies to null values.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>Assuming the typed value of an element is addressed using a syntax like <code>typed-value(elementname)</code>,  XPath needs to specify what <code>1.20 * typed-value(salary)</code> evaluates to when the typed value of the <code>&#60;salary></code>  is <code>null</code>. </p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top" align="right">
                     <emph role="bold">5 </emph>
                  </td>
                  <td colspan="3">
                     <emph role="underline.class-p1">Should Add Support for XML Schema: Structures</emph>
                     <emph role="br"/>
                     <p>
                        <xspecref href="http://www.w3.org/TR/xmlschema-1/">XML Schema: Structures</xspecref> enables users to define structured types and associate them to elements in a schema. XPath 2.0 SHOULD provide  support for the common operations needed for navigation and selection of typed elements.</p>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">5.1 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Select Elements/Attributes Based on an Explicit XML Schema Type</emph>
                     <emph role="br"/>
                     <p>XML Schema : Structures provides the ability to define the type of an element or attribute. XPath 2.0 SHOULD be able to test whether an
element or attribute is an instance of a given type.
</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <olist>
                                    <item>
                                       <p>Select all elements that are instances of the complex type <code>Address</code>. </p>
                                    </item>
                                    <item>
                                       <p>Select all attributes that are instances of the simple-type <code>xsd:integer</code>. </p>
                                    </item>
                                    <item>
                                       <p>Select elements of type <code>Address</code> indicated in the instance with <code>xsi:type="Address"</code>
                                       </p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">5.2 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Select Elements/Attributes Based on  XML Schema Type Hierarchy</emph>
                     <emph role="br"/>
                     <p>XML Schema : Structures provides the ability to define a hierarchy of types by derivation.  XPath 2.0 SHOULD be able to selects elements or attributes that are instances of a type, also matching any types derived from it by restriction
or extension.</p>
                     <ednote>
                        <edtext>
                           <p>This introduces some interesting precedence decisions about how matches for an explicit type would need to take precedence over matches for compatible types. In other words, given a template matching elements with types compatible to <code>Address</code> and another template explicitly matching type <code>USAddress</code>, one would expect the explicit type match to take precedence. Also consider the case where two templates exist, one that matches the <code>Address</code> type and one that matches the <code>USAddress</code> type. If an element of type RuralRouteAddress (further derived from USAddress) is considered for matching, one would expect the template for the "closest inherited ancestor", that is <code>USAddress</code>, to take precendence over a template matching the type of a "more distant inherited ancestor" like <code>Address</code>.</p>
                        </edtext>
                     </ednote>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>
                                    <emph role="bold">Derivation by Restriction</emph>
                                 </p>
                                 <p>The <xspecref href="http://www.w3.org/TR/xmlschema-0/">XML Schema Primer</xspecref> defines the <code>Items</code> type and the <code>ConfirmedItems</code> type which is derived by restriction from <code>Items</code>. Select purchase orders whose <code>&#60;items></code> member element is an instance of the <code>ConfirmedItems</code> type,  which restricts the minimum number of <code>&#60;item></code> elements that can appear to be at least one.</p>
                                 <p>
                                    <emph role="bold">Derivation by Extension</emph>
                                 </p>
                                 <p>The <xspecref href="http://www.w3.org/TR/xmlschema-0/">XML Schema Primer</xspecref> defines the <code>Address</code> type and the  <code>UKAddress</code> and <code>USAddress</code> types which is derived by extension from <code>Address</code>, adding additional element content in the subtypes. </p>
                                 <olist>
                                    <item>
                                       <p>Select all elements that are instances of complex type <code>Address</code>, matching elements of type <code>USAddress</code> and elements of type <code>UKAddress</code> as well.</p>
                                    </item>
                                    <item>
                                       <p>Select all elements that are instances of complex type <code>Address</code>, without selecting elements of types derived from <code>Address</code>.</p>
                                    </item>
                                    <item>
                                       <p>Select all attributes that are instances of the simple-type <code>xsd:integer</code>, matching attribute of type <code>SKU-Number</code> which derives from <code>xsd:integer</code>.</p>
                                    </item>
                                 </olist>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r1">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">5.3 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Select Elements Based on  XML Schema Substitution Groups</emph>
                     <emph role="br"/>
                     <p>
                        <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> provides the ability to include two or more element
names 
      in a substitution group. XPath 2.0 SHOULD be able to test whether
an 
      element is a member of an XML Schema substitution group.</p>
                     <table border="0">
                        <tbody>
                           <tr>
                              <td>
                                 <emph role="underline.bold">Use Case</emph>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <p>The <xspecref href="http://www.w3.org/TR/xmlschema-0/">XML Schema Primer</xspecref> defines the global <code>&#60;ipo:comment></code> element as the head of a substitution group, whose substitutible member elements include <code>&#60;ipo:customerComment></code> and <code>&#60;ipo:shipComment></code>. Select the list of all elements that are <code>&#60;ipo:comment></code> elements, including any elements that are substitutible for <code>&#60;ipo:comment></code> through this substitution group.</p>
                              </td>
                           </tr>
                        </tbody>
                     </table>
                  </td>
               </tr>
               <tr role="class-r0">
                  <td valign="top">        </td>
                  <td valign="top" align="right">
                     <emph role="bold">5.4 </emph>
                  </td>
                  <td colspan="2">
                     <emph role="underline.class-p1">Should Support Lookups Based on Schema Unique Constraints and Keys</emph>
                     <emph role="br"/>
                     <p>
                        <xspecref href="http://www.w3.org/TR/xmlschema-2/">XML Schema: Datatypes</xspecref> supports named, multi-part keys. XPath 2.0 SHOULD
support 
      a mechanism for looking up the element to which a Schema key
refers. Similar
      mechanisms already exist, such as the <code>id()</code> function in XPath 1.0
and the <code>key()</code> function        in XSLT.
 </p>
                  </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 Infoset, <loc href="http://www.w3.org/TR/xml-infoset">http://www.w3.org/TR/xml-infoset</loc>
            </bibl>
            <bibl>XML Schema: Datatypes, <loc href="http://www.w3.org/TR/xmlschema-2/">http://www.w3.org/TR/xmlschema-2/</loc>
            </bibl>
            <bibl>XPointer, <loc href="http://www.w3.org/TR/xptr">http://www.w3.org/TR/xptr</loc>
            </bibl>
         </blist>
      </div1>
   </body>
</spec>