You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by am...@apache.org on 2001/06/20 20:57:40 UTC

cvs commit: xml-xalan/test/tests/contrib-gold/xsltc/mk mk003.out mk004.out mk005.out mk006.out mk007.out mk008.out mk011.out mk012.out mk013.out mk014.out mk015.out mk016.out mk017.out mk018.out mk019.out mk020.out mk021.out mk022.out mk023.out mk024.out mk025.out mk026.out mk027.out mk028.out mk029.out mk030.out mk031.out mk032.out mk033.out mk034.out mk035.out mk036.out mk037.out mk038.out mk039.out mk040.out mk041.out mk042.out mk043.out mk044.out mk045.out mk046.out mk047.out mk048.out mk049.out mk050.out mk051.out mk052.out mk053.out mk054.out mk055.out mk056.out mk057.out mk062.out

amiro       01/06/20 11:57:39

  Added:       test/tests/contrib-gold/xsltc/mk mk003.out mk004.out
                        mk005.out mk006.out mk007.out mk008.out mk011.out
                        mk012.out mk013.out mk014.out mk015.out mk016.out
                        mk017.out mk018.out mk019.out mk020.out mk021.out
                        mk022.out mk023.out mk024.out mk025.out mk026.out
                        mk027.out mk028.out mk029.out mk030.out mk031.out
                        mk032.out mk033.out mk034.out mk035.out mk036.out
                        mk037.out mk038.out mk039.out mk040.out mk041.out
                        mk042.out mk043.out mk044.out mk045.out mk046.out
                        mk047.out mk048.out mk049.out mk050.out mk051.out
                        mk052.out mk053.out mk054.out mk055.out mk056.out
                        mk057.out mk062.out
  Log:
  gold for mk tests
  
  Revision  Changes    Path
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk003.out
  
  Index: mk003.out
  ===================================================================
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Song</title>
     </head>
     <body>
        <div align="center">
           <h1>Song</h1>
        </div>
        <div align="center">
           <h2>By Rupert Brooke</h2>
        </div>
        <p>And suddenly the wind comes soft,<br>&nbsp;&nbsp;And Spring is here again;<br>And the hawthorn quickens with buds of green<br>&nbsp;&nbsp;And my heart with buds of pain.<br></p>
        <p>My heart all Winter lay so numb,<br>&nbsp;&nbsp;The earth so dead and frore,<br>That I never thought the Spring would come again<br>&nbsp;&nbsp;Or my heart wake any more.<br></p>
        <p>But Winter's broken and earth has woken,<br>&nbsp;&nbsp;And the small birds cry again;<br>And the hawthorn hedge puts forth its buds,<br>&nbsp;&nbsp;And my heart puts forth its pain.<br></p>
        <p><i>1912</i></p>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk004.out
  
  Index: mk004.out
  ===================================================================
  <html><body><h1>A list of books</h1>
  <table width="640">
  	<tr><td>1</td>
  
  		<td>Nigel Rees</td>
  
  		<td>Sayings of the Century</td>
  
  		<td>8.95</td>
  
  	</tr>
  
  	<tr><td>2</td>
  
  		<td>Evelyn Waugh</td>
  
  		<td>Sword of Honour</td>
  
  		<td>12.99</td>
  
  	</tr>
  
  	<tr><td>3</td>
  
  		<td>Herman Melville</td>
  
  		<td>Moby Dick</td>
  
  		<td>8.99</td>
  
  	</tr>
  
  	<tr><td>4</td>
  
  		<td>J. R. R. Tolkien</td>
  
  		<td>The Lord of the Rings</td>
  
  		<td>22.99</td>
  
  	</tr>
  
  </table>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk005.out
  
  Index: mk005.out
  ===================================================================
  <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>A list of books</title>
    </head>
    <body>
      <h1>A list of books</h1>
      <table border="2">
        <tr>
          <td>Evelyn Waugh</td>
          <td>Sword of Honour</td>
          <td>fiction</td>
          <td>12.99</td>
        </tr>
        <tr>
          <td>Herman Melville</td>
          <td>Moby Dick</td>
          <td>fiction</td>
          <td>8.99</td>
        </tr>
        <tr>
          <td>J. R. R. Tolkien</td>
          <td>The Lord of the Rings</td>
          <td>fiction</td>
          <td>22.99</td>
        </tr>
        <tr>
          <td>Nigel Rees</td>
          <td>Sayings of the Century</td>
          <td>reference</td>
          <td>8.95</td>
        </tr>
      </table>
    </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk006.out
  
  Index: mk006.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <div id="div1">Sayings of the Century</div>
  <div id="div2">Sword of Honour</div>
  <div id="div3">Moby Dick</div>
  <div id="div4">The Lord of the Rings</div>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk007.out
  
  Index: mk007.out
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  <document>
    <author>Michael Kay</author>
    <title>XSLT Programmer's Reference</title>
    <copyright>Copyright � Wrox Press 2000</copyright>
    <date>2001</date>
    <abstract>A comprehensive guide to the XSLT and XPath recommendations
      published by the World Wide Web Consortium on 16 November 1999</abstract>
  </document>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk008.out
  
  Index: mk008.out
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  <document>
     <author>Michael Kay</author>
     <title>XSLT Programmer's Reference</title>
     <copyright>Copyright � Wrox Press Ltd 2000</copyright>
     <date>Mon Aug 07 13:35:40 EDT 2000</date>
     <abstract>A comprehensive guide to the XSLT and XPath recommendations
      published by the World Wide Web Consortium on 16 November 1999</abstract>
  </document>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk011.out
  
  Index: mk011.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <LINE>That thou, Iago, who hast had my purse</LINE>
  ;
      <LINE>It is as sure as you are Roderigo,</LINE>
  ;
      <LINE>Were I the Moor, I would not be Iago:</LINE>
  ;
      <LINE>What, ho, Brabantio! Signior Brabantio, ho!</LINE>
  ;
      <LINE>Awake! what, ho, Brabantio! thieves! thieves! thieves!</LINE>
  ;
      <LINE>My name is Roderigo.</LINE>
  ;
      <LINE>Most grave Brabantio,</LINE>
  ;
      <LINE>This thou shalt answer; I know thee, Roderigo.</LINE>
  ;
      <LINE>Is nought but bitterness. Now, Roderigo,</LINE>
  ;
      <LINE>May be abused? Have you not read, Roderigo,</LINE>
  ;
      <LINE>On, good Roderigo: I'll deserve your pains.</LINE>
  ;
      
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk012.out
  
  Index: mk012.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  Longest speech is 26 lines.  
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk013.out
  
  Index: mk013.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <poem>
     <author>Rupert Brooke</author>
     <date>1912</date>
     <title>Song</title>
     <stanza>
        <line number="1" of="4">And suddenly the wind comes soft,</line>
        <line number="2" of="4">And Spring is here again;</line>
        <line number="3" of="4">And the hawthorn quickens with buds of green</line>
        <line number="4" of="4">And my heart with buds of pain.</line>
     </stanza>
     <stanza>
        <line number="1" of="4">My heart all Winter lay so numb,</line>
        <line number="2" of="4">The earth so dead and frore,</line>
        <line number="3" of="4">That I never thought the Spring would come again</line>
        <line number="4" of="4">Or my heart wake any more.</line>
     </stanza>
     <stanza>
        <line number="1" of="4">But Winter's broken and earth has woken,</line>
        <line number="2" of="4">And the small birds cry again;</line>
        <line number="3" of="4">And the hawthorn hedge puts forth its buds,</line>
        <line number="4" of="4">And my heart puts forth its pain.</line>
     </stanza>
  </poem>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk014.out
  
  Index: mk014.out
  ===================================================================
  <html>
    <body>
      <h1>Please select a country:</h1>
      <select id="country">
        <option value="France">France</option>
        <option value="Germany">Germany</option>
        <option value="Israel">Israel</option>
        <option value="Japan">Japan</option>
        <option value="Poland">Poland</option>
        <option value="United States" selected="selected">United States</option>
        <option value="Venezuela">Venezuela</option>
      </select>
      <hr>
    </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk015.out
  
  Index: mk015.out
  ===================================================================
  
  <html>
     <body>
        <h1>Matches in Group A</h1>
        <h2>Brazil versus Scotland</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>10-Jun-98&nbsp;</td>
              <td>Brazil&nbsp;</td>
              <td>Scotland&nbsp;</td>
              <td>2-1&nbsp;</td>
           </tr>
        </table>
        <h2>Morocco versus Norway</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>10-Jun-98&nbsp;</td>
              <td>Morocco&nbsp;</td>
              <td>Norway&nbsp;</td>
              <td>2-2&nbsp;</td>
           </tr>
        </table>
        <h2>Scotland versus Norway</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>16-Jun-98&nbsp;</td>
              <td>Scotland&nbsp;</td>
              <td>Norway&nbsp;</td>
              <td>1-1&nbsp;</td>
           </tr>
        </table>
        <h2>Brazil versus Morocco</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>16-Jun-98&nbsp;</td>
              <td>Brazil&nbsp;</td>
              <td>Morocco&nbsp;</td>
              <td>3-0&nbsp;</td>
           </tr>
        </table>
        <h2>Brazil versus Norway</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>23-Jun-98&nbsp;</td>
              <td>Brazil&nbsp;</td>
              <td>Norway&nbsp;</td>
              <td>1-2&nbsp;</td>
           </tr>
        </table>
        <h2>Scotland versus Morocco</h2>
        <table bgcolor="#cccccc" border="1" cellpadding="5">
           <tr>
              <td><b>Date</b></td>
              <td><b>Home Team</b></td>
              <td><b>Away Team</b></td>
              <td><b>Result</b></td>
           </tr>
           <tr>
              <td>23-Jun-98&nbsp;</td>
              <td>Scotland&nbsp;</td>
              <td>Morocco&nbsp;</td>
              <td>0-3&nbsp;</td>
           </tr>
        </table>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk016.out
  
  Index: mk016.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <book>
    <title>Object-oriented Languages</title>
    <author>Michel Beaudouin-Lafon</author>
    <translator>Jack Howlett</translator>
    <publisher>Chapman &amp; Hall</publisher>
    <isbn>0 412 55800 9</isbn>
    <date>1994</date>
  </book>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk017.out
  
  Index: mk017.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?><!--poem-->
  <!--author within poem-->Rupert Brooke
  <!--date within poem-->1912
  <!--title within poem-->Song
  <!--stanza within poem-->
  <!--line within stanza within poem-->And suddenly the wind comes soft,
  <!--line within stanza within poem-->And Spring is here again;
  <!--line within stanza within poem-->And the hawthorn quickens with buds of green
  <!--line within stanza within poem-->And my heart with buds of pain.
  
  <!--stanza within poem-->
  <!--line within stanza within poem-->My heart all Winter lay so numb,
  <!--line within stanza within poem-->The earth so dead and frore,
  <!--line within stanza within poem-->That I never thought the Spring would come again
  <!--line within stanza within poem-->Or my heart wake any more.
  
  <!--stanza within poem-->
  <!--line within stanza within poem-->But Winter's broken and earth has woken,
  <!--line within stanza within poem-->And the small birds cry again;
  <!--line within stanza within poem-->And the hawthorn hedge puts forth its buds,
  <!--line within stanza within poem-->And my heart puts forth its pain.
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk018.out
  
  Index: mk018.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  Design Patterns
     by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk019.out
  
  Index: mk019.out
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  <c>Copyright � Acme Widgets Limited</c>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk020.out
  
  Index: mk020.out
  ===================================================================
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Song</title>
     </head>
     <body>
        
        <div align="right"><i>by </i>Rupert Brooke
        </div>
        
        
        <h1>Song</h1>
        
        <p>
           And suddenly the wind comes soft,<br>
           And Spring is here again;<br>
           And the hawthorn quickens with buds of green<br>
           And my heart with buds of pain.<br>
           
        </p>
        
        <p>
           My heart all Winter lay so numb,<br>
           The earth so dead and frore,<br>
           That I never thought the Spring would come again<br>
           Or my heart wake any more.<br>
           
        </p>
        
        <p>
           But Winter's broken and earth has woken,<br>
           And the small birds cry again;<br>
           And the hawthorn hedge puts forth its buds,<br>
           And my heart puts forth its pain.<br>
           
        </p>
        
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk021.out
  
  Index: mk021.out
  ===================================================================
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Song</title>
     </head>
     <body>
        
        <div align="right"><i>by </i>Rupert Brooke
        </div>
        
        
        <h1>Song</h1>
        
        <p>
           001&nbsp;&nbsp;
           And suddenly the wind comes soft,<br>
           002&nbsp;&nbsp;
           And Spring is here again;<br>
           003&nbsp;&nbsp;
           And the hawthorn quickens with buds of green<br>
           004&nbsp;&nbsp;
           And my heart with buds of pain.<br>
           
        </p>
        
        <p>
           005&nbsp;&nbsp;
           My heart all Winter lay so numb,<br>
           006&nbsp;&nbsp;
           The earth so dead and frore,<br>
           007&nbsp;&nbsp;
           That I never thought the Spring would come again<br>
           008&nbsp;&nbsp;
           Or my heart wake any more.<br>
           
        </p>
        
        <p>
           009&nbsp;&nbsp;
           But Winter's broken and earth has woken,<br>
           010&nbsp;&nbsp;
           And the small birds cry again;<br>
           011&nbsp;&nbsp;
           And the hawthorn hedge puts forth its buds,<br>
           012&nbsp;&nbsp;
           And my heart puts forth its pain.<br>
           
        </p>
        
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk022.out
  
  Index: mk022.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <picture color="red" transparency="100"/>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk023.out
  
  Index: mk023.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <book>
      <title>Design Patterns</title>
      <author>Erich Gamma</author>
      <author>Richard Helm</author>
      <author>Ralph Johnson</author>
      <author>John Vlissides</author>
  </book><book>
      <title>Pattern Hatching</title>
      <author>John Vlissides</author>
  </book>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk024.out
  
  Index: mk024.out
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <out:stylesheet xmlns:out="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <out:variable name="v"/>
  </out:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk025.out
  
  Index: mk025.out
  ===================================================================
  <html><body><p><p><table>
  <tr><td width="350">And suddenly the wind comes soft,</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">And Spring is here again;</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">And the hawthorn quickens with buds of green</td>
  <td width="50">3</td>
  </tr>
  
  <tr><td width="350">And my heart with buds of pain.</td>
  <td width="50"></td>
  </tr>
  
  </table>
  </p>
  <p><table>
  <tr><td width="350">My heart all Winter lay so numb,</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">The earth so dead and frore,</td>
  <td width="50">6</td>
  </tr>
  
  <tr><td width="350">That I never thought the Spring would come again</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">Or my heart wake any more.</td>
  <td width="50"></td>
  </tr>
  
  </table>
  </p>
  <p><table>
  <tr><td width="350">But Winter's broken and earth has woken,</td>
  <td width="50">9</td>
  </tr>
  
  <tr><td width="350">And the small birds cry again;</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">And the hawthorn hedge puts forth its buds,</td>
  <td width="50"></td>
  </tr>
  
  <tr><td width="350">And my heart puts forth its pain.</td>
  <td width="50">12</td>
  </tr>
  
  </table>
  </p>
  </p>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk026.out
  
  Index: mk026.out
  ===================================================================
  poem -- 1;
  author -- 2;
  date -- 2;
  title -- 2;
  stanza -- 2;
  line -- 3;
  line -- 3;
  line -- 3;
  line -- 3;
  stanza -- 2;
  line -- 3;
  line -- 3;
  line -- 3;
  line -- 3;
  stanza -- 2;
  line -- 3;
  line -- 3;
  line -- 3;
  line -- 3;
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk027.out
  
  Index: mk027.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <product sales="$359.70" name="plum jam"/><product sales="$215.66" name="raspberry jam"/><product sales="$70.00" name="strawberry jam"/>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk028.out
  
  Index: mk028.out
  ===================================================================
  <html><body>
  <p>
  
  <font face="arial">Early Music Review</font>
   said of his debut Wigmore concert with
  Ensemble Sonnerie in 1998: "One of the finest concerts I have
  ever heard ... a singer to watch out for". 
  Other highlights include a
  televised production of Bach's <i>St. Matthew Passion</i>
  
  conducted by Jonathan Miller, in which he played
  <u>Judas</u>
  , an acclaimed performance of
  <i>Winterreise</i>
   with Julius Drake in Leamington Hastings,
   
  <i>Die Sch�ne M�llerin</i>
   last summer at St. John's Smith Square,
  and in the same venue the Good Friday St John Passion, conducted
  by Stephen Layton, broadcast on Radio Three. 
  </p>
  
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk029.out
  
  	<<Binary file>>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk030.out
  
  Index: mk030.out
  ===================================================================
  
  <html>
     <body>
        <center>
           <h1>Programme</h1>
           <h2>Wolfgang Amadeus Mozart (1756-1791)</h2>
           <p>The Magic Flute</p>
           <p>Don Giovanni</p>
           <h2>Guiseppe Verdi (1813-1901)</h2>
           <p>Ernani</p>
           <p>Rigoletto</p>
           <h2>Giacomo Puccini (1858-1924)</h2>
           <p>Tosca</p>
        </center>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk031.out
  
  Index: mk031.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
      This week's composers are:
      Wolfgang Amadeus Mozart; Guiseppe Verdi; and Giacomo Puccini
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk032.out
  
  Index: mk032.out
  ===================================================================
  <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Itinerary</title>
  </head>
  <body><center><h3>Day 1</h3>
  <p>Arrive in Cairo</p>
  <h3>Day 2</h3>
  <p>Visit the Pyramids at Gaza</p>
  <h3>Day 3</h3>
  <p>Archaelogical Museum at Cairo</p>
  <h3>Day 4</h3>
  <p>Flight to Luxor; coach to Aswan</p>
  <h3>Day 5</h3>
  <p>Visit Temple at Philae and Aswan High Dam</p>
  <h3>Day 6</h3>
  <p>Cruise to Edfu</p>
  <h3>Day 7</h3>
  <p>Cruise to Luxor; visit Temple at Karnak</p>
  <h3>Day 8</h3>
  <p>Valley of the Kings</p>
  <h3>Day 9</h3>
  <p>Return flight from Luxor</p>
  </center>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk033.out
  
  Index: mk033.out
  ===================================================================
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Itinerary</title>
     </head>
     <body>
        <center>
           <h3>Day 1</h3>
           <p>Arrive in Cairo</p>
           <h3>Day 2</h3>
           <p>Visit the Pyramids at Gaza</p>
           <h3>Day 3</h3>
           <p>Archaelogical Museum at Cairo</p>
           <h3>Day 4</h3>
           <p>Flight to Luxor; coach to Aswan</p>
           <h3>Day 5</h3>
           <p><font color="red">Visit Temple at Philae and Aswan High Dam</font></p>
           <h3>Day 6</h3>
           <p>Cruise to Edfu</p>
           <h3>Day 7</h3>
           <p>Cruise to Luxor; visit Temple at Karnak</p>
           <h3>Day 8</h3>
           <p>Valley of the Kings</p>
           <h3>Day 9</h3>
           <p>Return flight from Luxor</p>
        </center>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk034.out
  
  Index: mk034.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <out>
    <city>Paris, France</city>
    <city>Roma, Italia</city>
    <city>Nice, France</city>
    <city>Madrid, Espana</city>
    <city>Milano, Italia</city>
    <city>Firenze, Italia</city>
    <city>Napoli, Italia</city>
    <city>Lyon, France</city>
    <city>Barcelona, Espana</city>
  </out>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk035.out
  
  Index: mk035.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?><count>3</count>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk036.out
  
  Index: mk036.out
  ===================================================================
  
  <html>
     <body>
        <h1>Number, the Language of Science</h1>
        <p><i>by </i>Danzig
        </p>
        <h1>The Young Visiters</h1>
        <p><i>by </i>Daisy Ashford
        </p>
        <p>Other books in this category:</p>
        <ul>
           <li>When We Were Very Young</li>
        </ul>
        <h1>When We Were Very Young</h1>
        <p><i>by </i>A. A. Milne
        </p>
        <p>Other books in this category:</p>
        <ul>
           <li>The Young Visiters</li>
        </ul>
        <h1>Design Patterns</h1>
        <p><i>by </i>Erich Gamma and others
        </p>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk037.out
  
  Index: mk037.out
  ===================================================================
  
  <html>
     <body>
        <h1>Stylesheet Module Structure</h1>
        <ul>
           <li>includes dummya.xsl
              <ul>
                 <li>imports dummyb.xsl
                    <ul></ul>
                 </li>
                 <li>imports dummyc.xsl
                    <ul></ul>
                 </li>
              </ul>
           </li>
        </ul>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk038.out
  
  Index: mk038.out
  ===================================================================
  
  <html>
     <body>
        <h1>Number, the Language of Science</h1>
        <p>Category: Science</p>
        <h1>The Young Visiters</h1>
        <p>Category: Children's Fiction</p>
        <h1>When We Were Very Young</h1>
        <p>Category: Children's Fiction</p>
        <h1>Design Patterns</h1>
        <p>Category: Computing</p>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk039.out
  
  Index: mk039.out
  ===================================================================
  <html><body><h1>Hotels</h1>
  <h2>Grand Hotel</h2>
  <p>Address:  . . . </p>
  <p>Stars: 5</p>
  <p>Resort: <a href="#N4">Amsterdam</a>
  </p>
  <h2>Central Hotel</h2>
  <p>Address:  . . . </p>
  <p>Stars: 5</p>
  <p>Resort: <a href="#N37">Bruges</a>
  </p>
  <h2>Less Grand Hotel</h2>
  <p>Address:  . . . </p>
  <p>Stars: 2</p>
  <p>Resort: <a href="#N4">Amsterdam</a>
  </p>
  <h2>Peripheral Hotel</h2>
  <p>Address:  . . . </p>
  <p>Stars: 2</p>
  <p>Resort: <a href="#N37">Bruges</a>
  </p>
  <h1>Resorts</h1>
  <h2><a name="N4">Amsterdam</a>
  </h2>
  <p>A wordy description of Amsterdam</p>
  <h2><a name="N37">Bruges</a>
  </h2>
  <p>An eloquent description of Bruges</p>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk040.out
  
  Index: mk040.out
  ===================================================================
  
  <html>
     <body>
        <h1>Number, the Language of Science</h1>
        <h2>Author</h2>
        <h3>Danzig</h3>
        <p> - </p>
        <p></p>
        <h1>The Young Visiters</h1>
        <h2>Author</h2>
        <h3>Daisy Ashford</h3>
        <p>1881 - 1972</p>
        <p>Daisy Ashford (Mrs George Norman) wrote The Young Visiters, a small
           comic masterpiece, while still a young child in Lewes. It was found in a drawer
           in 1919 and sent to Chatto and Windus, who published it in the same year with an
           introduction by J. M. Barrie, who had first insisted on meeting the author in order
           to check that she was genuine.
        </p>
        <h1>When We Were Very Young</h1>
        <h2>Author</h2>
        <h3>A. A. Milne</h3>
        <p>1852 - 1956</p>
        <p>Alan Alexander Milne, educated at Westminster School and Trinity College
           Cambridge, became a prolific author of plays, novels, poetry, short stories, and essays,
           all of which have been overshadowed by his children's books.
           
        </p>
        <h1>Design Patterns</h1>
        <h2>Authors</h2>
        <h3>Erich Gamma</h3>
        <p> - </p>
        <p></p>
        <h3>Richard Helm</h3>
        <p> - </p>
        <p></p>
        <h3>Ralph Johnson</h3>
        <p> - </p>
        <p></p>
        <h3>John Vlissides</h3>
        <p> - </p>
        <p></p>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk041.out
  
  Index: mk041.out
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  <date>16 November 1999</date>
  <date>08 October 1999</date>
  <date>13 August 1999</date>
  <date>09 July 1999</date>
  <date>21 April 1999</date>
  <date>16 December 1998</date>
  <date>18 August 1998</date>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk042.out
  
  Index: mk042.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  <auth>Danzig</auth>
  <auth>Daisy Ashford</auth>
  <auth>A. A. Milne</auth>
  <auth>Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides</auth>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk043.out
  
  Index: mk043.out
  ===================================================================
  
  <html>
     <body>
        <h1>Table of elements</h1>
        <table border="1" cellpadding="5">
           <tr>
              <td>Element</td>
              <td>Prefix</td>
              <td>Local name</td>
              <td>Namespace URI</td>
           </tr>
           <tr>
              <td>body</td>
              <td></td>
              <td>body</td>
              <td></td>
           </tr>
           <tr>
              <td>h1</td>
              <td></td>
              <td>h1</td>
              <td></td>
           </tr>
           <tr>
              <td>html</td>
              <td></td>
              <td>html</td>
              <td></td>
           </tr>
           <tr>
              <td>table</td>
              <td></td>
              <td>table</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>td</td>
              <td></td>
              <td>td</td>
              <td></td>
           </tr>
           <tr>
              <td>tr</td>
              <td></td>
              <td>tr</td>
              <td></td>
           </tr>
           <tr>
              <td>tr</td>
              <td></td>
              <td>tr</td>
              <td></td>
           </tr>
           <tr>
              <td>xsl:apply-templates</td>
              <td>xsl</td>
              <td>apply-templates</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:choose</td>
              <td>xsl</td>
              <td>choose</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:otherwise</td>
              <td>xsl</td>
              <td>otherwise</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:sort</td>
              <td>xsl</td>
              <td>sort</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:sort</td>
              <td>xsl</td>
              <td>sort</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:template</td>
              <td>xsl</td>
              <td>template</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:template</td>
              <td>xsl</td>
              <td>template</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:transform</td>
              <td>xsl</td>
              <td>transform</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:value-of</td>
              <td>xsl</td>
              <td>value-of</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:value-of</td>
              <td>xsl</td>
              <td>value-of</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:value-of</td>
              <td>xsl</td>
              <td>value-of</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:value-of</td>
              <td>xsl</td>
              <td>value-of</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:value-of</td>
              <td>xsl</td>
              <td>value-of</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:variable</td>
              <td>xsl</td>
              <td>variable</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
           <tr>
              <td>xsl:when</td>
              <td>xsl</td>
              <td>when</td>
              <td>http://www.w3.org/1999/XSL/Transform</td>
           </tr>
        </table>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk044.out
  
  Index: mk044.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?><element name="authors" words="101"/>;
      <element name="author" words="35"/>;
      <element name="born" words="1"/>;
      <element name="died" words="1"/>;
      <element name="biog" words="33"/>;
      <element name="author" words="66"/>;
      <element name="born" words="1"/>;
      <element name="died" words="1"/>;
      <element name="biog" words="64"/>;
      <element name="i" words="3"/>;
      
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk045.out
  
  Index: mk045.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>1079.159
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk046.out
  
  Index: mk046.out
  ===================================================================
  <html><body><h1>Product sales by period</h1>
  <table border="1" width="100%" cellpadding="5"><tr><th width="50%">Product</th>
  <th width="17%">Q1</th>
  <th width="17%">Q2</th>
  <th width="17%">Q3</th>
  </tr>
  <tr><td>Windows 98
        </td>
  <td>82</td>
  <td>64</td>
  <td>58</td>
  </tr>
  <tr><td>Windows NT
        </td>
  <td>17</td>
  <td>44</td>
  <td>82</td>
  </tr>
  </table>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk047.out
  
  Index: mk047.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?><authors>
  
  <author name="A. A. Milne">
  <born>1852</born>
  <died>1956</died>
  <biog>Alan Alexander Milne, educated at Westminster School and Trinity College
  Cambridge, became a prolific **** of plays, novels, poetry, short stories, and essays,
  all of which have been overshadowed by his children's books.
  </biog>
  </author>
  
  <author name="Daisy Ashford">
  <born>1881</born>
  <died>1972</died>
  <biog>Daisy Ashford (Mrs George Norman) wrote <i>The Young Visiters</i>, a small
  comic masterpiece, while still a young child in Lewes. It was found in a drawer
  in 1919 and sent to Chatto and Windus, who published it in the same year with an
  introduction by J. M. Barrie, who had first insisted on meeting the **** in order
  to check that she was genuine.</biog>
  </author>
  
  </authors>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk048.out
  
  Index: mk048.out
  ===================================================================
  
  <html>
     <body>
        <h1>Results of Group A</h1>
        <table cellpadding="5">
           <tr>
              <td>Team</td>
              <td>Played</td>
              <td>Won</td>
              <td>Drawn</td>
              <td>Lost</td>
              <td>For</td>
              <td>Against</td>
           </tr>
           <tr>
              <td>Brazil</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>3</td>
           </tr>
           <tr>
              <td>Scotland</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>2</td>
              <td>6</td>
           </tr>
           <tr>
              <td>Morocco</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>5</td>
              <td>5</td>
           </tr>
           <tr>
              <td>Norway</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>6</td>
              <td>5</td>
              <td>4</td>
           </tr>
        </table>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk049.out
  
  Index: mk049.out
  ===================================================================
  <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Management Structure</title>
  </head>
  <body><h1>Management Structure</h1>
  <p>The following responsibilies were announced on 
        28 March 2000:</p>
  <table border="2" cellpadding="5"><tr><th>Name</th>
  <th>Role</th>
  <th>Reporting to</th>
  </tr>
  <tr><td>Keith Todd</td>
  <td>Chief Executive Officer</td>
  <td></td>
  </tr>
  <tr><td>Andrew Boswell</td>
  <td>Technical Director</td>
  <td>Keith Todd</td>
  </tr>
  <tr><td>Dave McVitie</td>
  <td>Chief Engineer</td>
  <td>Andrew Boswell</td>
  </tr>
  <tr><td>John Elmore</td>
  <td>Director of Research</td>
  <td>Andrew Boswell</td>
  </tr>
  <tr><td>Alan Gibson</td>
  <td>Operations and Finance</td>
  <td>Keith Todd</td>
  </tr>
  <tr><td>Fiona Colquhoun</td>
  <td>Human Resources</td>
  <td>Keith Todd</td>
  </tr>
  <tr><td>John Davison</td>
  <td>Marketing</td>
  <td>Keith Todd</td>
  </tr>
  <tr><td>Marie-Anne van Ingen</td>
  <td>International</td>
  <td>Keith Todd</td>
  </tr>
  </table>
  <hr>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk050.out
  
  Index: mk050.out
  ===================================================================
  <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Sales volume by publisher</title>
  </head>
  <body><h1>Sales volume by publisher</h1>
  <table><tr><th>Publisher</th>
  <th>Total Sales Value</th>
  </tr>
  <tr><td>HarperCollins</td>
  <td>235</td>
  </tr>
  <tr><td>Penguin Books</td>
  <td>12</td>
  </tr>
  </table>
  </body>
  </html>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk051.out
  
  Index: mk051.out
  ===================================================================
  <HTML><HEAD><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <TITLE>SCENE II.  Another street.</TITLE>
  </HEAD>
  <BODY BGCOLOR="#FFFFCC">
     <H1><CENTER>SCENE II.  Another street.</CENTER>
  </H1>
  <HR>
  
     <CENTER><H3>Enter OTHELLO, IAGO, and Attendants with torches</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">Though in the trade of war I have slain men,<BR>
  Yet do I hold it very stuff o' the conscience<BR>
  To do no contrived murder: I lack iniquity<BR>
  Sometimes to do me service: nine or ten times<BR>
  I had thought to have yerk'd him here under the ribs.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">'Tis better as it is.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">Nay, but he prated,<BR>
  And spoke such scurvy and provoking terms<BR>
  Against your honour<BR>
  That, with the little godliness I have,<BR>
  I did full hard forbear him. But, I pray you, sir,<BR>
  Are you fast married? Be assured of this,<BR>
  That the magnifico is much beloved,<BR>
  And hath in his effect a voice potential<BR>
  As double as the duke's: he will divorce you;<BR>
  Or put upon you what restraint and grievance<BR>
  The law, with all his might to enforce it on,<BR>
  Will give him cable.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Let him do his spite:<BR>
  My services which I have done the signiory<BR>
  Shall out-tongue his complaints. 'Tis yet to know,--<BR>
  Which, when I know that boasting is an honour,<BR>
  I shall promulgate--I fetch my life and being<BR>
  From men of royal siege, and my demerits<BR>
  May speak unbonneted to as proud a fortune<BR>
  As this that I have reach'd: for know, Iago,<BR>
  But that I love the gentle Desdemona,<BR>
  I would not my unhoused free condition<BR>
  Put into circumscription and confine<BR>
  For the sea's worth. But, look! what lights come yond?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">Those are the raised father and his friends:<BR>
  You were best go in.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Not I I must be found:<BR>
  My parts, my title and my perfect soul<BR>
  Shall manifest me rightly. Is it they?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">By Janus, I think no.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>Enter CASSIO, and certain Officers with torches</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">The servants of the duke, and my lieutenant.<BR>
  The goodness of the night upon you, friends!<BR>
  What is the news?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">The duke does greet you, general,<BR>
  And he requires your haste-post-haste appearance,<BR>
  Even on the instant.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">What is the matter, think you?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">Something from Cyprus as I may divine:<BR>
  It is a business of some heat: the galleys<BR>
  Have sent a dozen sequent messengers<BR>
  This very night at one another's heels,<BR>
  And many of the consuls, raised and met,<BR>
  Are at the duke's already: you have been<BR>
  hotly call'd for;<BR>
  When, being not at your lodging to be found,<BR>
  The senate hath sent about three several guests<BR>
  To search you out.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">'Tis well I am found by you.<BR>
  I will but spend a word here in the house,<BR>
  And go with you.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>Exit</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">Ancient, what makes he here?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">'Faith, he to-night hath boarded a land carack:<BR>
  If it prove lawful prize, he's made for ever.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">I do not understand.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">He's married.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">To who?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>Re-enter OTHELLO</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">Marry, to--Come, captain, will you go?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Have with you.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>CASSIO</B>
  </TD>
  <TD VALIGN="TOP">Here comes another troop to seek for you.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">It is Brabantio. General, be advised;<BR>
  He comes to bad intent.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>Enter BRABANTIO, RODERIGO, and Officers with
  torches and weapons</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Holla! stand there!<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>RODERIGO</B>
  </TD>
  <TD VALIGN="TOP">Signior, it is the Moor.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>BRABANTIO</B>
  </TD>
  <TD VALIGN="TOP">Down with him, thief!<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>They draw on both sides</H3>
  </CENTER>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>IAGO</B>
  </TD>
  <TD VALIGN="TOP">You, Roderigo! come, sir, I am for you.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Keep up your bright swords, for the dew will rust them.<BR>
  Good signior, you shall more command with years<BR>
  Than with your weapons.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>BRABANTIO</B>
  </TD>
  <TD VALIGN="TOP">O thou foul thief, where hast thou stow'd my daughter?<BR>
  Damn'd as thou art, thou hast enchanted her;<BR>
  For I'll refer me to all things of sense,<BR>
  If she in chains of magic were not bound,<BR>
  Whether a maid so tender, fair and happy,<BR>
  So opposite to marriage that she shunned<BR>
  The wealthy curled darlings of our nation,<BR>
  Would ever have, to incur a general mock,<BR>
  Run from her guardage to the sooty bosom<BR>
  Of such a thing as thou, to fear, not to delight.<BR>
  Judge me the world, if 'tis not gross in sense<BR>
  That thou hast practised on her with foul charms,<BR>
  Abused her delicate youth with drugs or minerals<BR>
  That weaken motion: I'll have't disputed on;<BR>
  'Tis probable and palpable to thinking.<BR>
  I therefore apprehend and do attach thee<BR>
  For an abuser of the world, a practiser<BR>
  Of arts inhibited and out of warrant.<BR>
  Lay hold upon him: if he do resist,<BR>
  Subdue him at his peril.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">Hold your hands,<BR>
  Both you of my inclining, and the rest:<BR>
  Were it my cue to fight, I should have known it<BR>
  Without a prompter. Where will you that I go<BR>
  To answer this your charge?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>BRABANTIO</B>
  </TD>
  <TD VALIGN="TOP">To prison, till fit time<BR>
  Of law and course of direct session<BR>
  Call thee to answer.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>OTHELLO</B>
  </TD>
  <TD VALIGN="TOP">What if I do obey?<BR>
  How may the duke be therewith satisfied,<BR>
  Whose messengers are here about my side,<BR>
  Upon some present business of the state<BR>
  To bring me to him?<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>First Officer</B>
  </TD>
  <TD VALIGN="TOP">'Tis true, most worthy signior;<BR>
  The duke's in council and your noble self,<BR>
  I am sure, is sent for.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <TABLE><TR><TD VALIGN="TOP" WIDTH="160"><B>BRABANTIO</B>
  </TD>
  <TD VALIGN="TOP">How! the duke in council!<BR>
  In this time of the night! Bring him away:<BR>
  Mine's not an idle cause: the duke himself,<BR>
  Or any of my brothers of the state,<BR>
  Cannot but feel this wrong as 'twere their own;<BR>
  For if such actions may have passage free,<BR>
  Bond-slaves and pagans shall our statesmen be.<BR>
  </TD>
  </TR>
  </TABLE>
  
     <CENTER><H3>Exeunt</H3>
  </CENTER>
  
  </BODY>
  </HTML>
  
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk052.out
  
  Index: mk052.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>29.7
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk053.out
  
  Index: mk053.out
  ===================================================================
  <?xml version="1.0" encoding="utf-8" ?>
  Total sales value is: $1798.53
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk054.out
  
  Index: mk054.out
  ===================================================================
  
  <!DOCTYPE html
    PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Extensible Markup Language (XML) 1.0</title>
        <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC"><style type="text/css">code { font-family: monospace }</style></head>
     <body>
        
        <div class="head"><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/WWW/w3c_home" alt="W3C" height="48" width="72"></a><h1>Extensible Markup Language (XML) 1.0<br></h1>
           <h2>W3C Recommendation 10 February 1998</h2>
           <dl>
              <dt>This version:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/1998/REC-xml-19980210">
                    http://www.w3.org/TR/1998/REC-xml-19980210
                 </a><br>
                 <a href="http://www.w3.org/TR/1998/REC-xml-19980210.xml">
                    http://www.w3.org/TR/1998/REC-xml-19980210.xml
                 </a><br>
                 <a href="http://www.w3.org/TR/1998/REC-xml-19980210.html">
                    http://www.w3.org/TR/1998/REC-xml-19980210.html
                 </a><br>
                 <a href="http://www.w3.org/TR/1998/REC-xml-19980210.pdf">
                    http://www.w3.org/TR/1998/REC-xml-19980210.pdf
                 </a><br>
                 <a href="http://www.w3.org/TR/1998/REC-xml-19980210.ps">
                    http://www.w3.org/TR/1998/REC-xml-19980210.ps
                 </a><br>
                 
              </dd>
              <dt>Latest version:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/REC-xml">
                    http://www.w3.org/TR/REC-xml
                 </a><br>
                 
              </dd>
              <dt>Previous version:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/PR-xml-971208">
                    http://www.w3.org/TR/PR-xml-971208
                 </a><br>
                 
                 
              </dd>
              <dt>Editors:</dt>
              <dd>
                 Tim Bray
                  (Textuality and Netscape) 
                 <a href="mailto:tbray@textuality.com">&lt;tbray@textuality.com></a><br>
                 Jean Paoli
                  (Microsoft) 
                 <a href="mailto:jeanpa@microsoft.com">&lt;jeanpa@microsoft.com></a><br>
                 C. M. Sperberg-McQueen
                  (University of Illinois at Chicago) 
                 <a href="mailto:cmsmcq@uic.edu">&lt;cmsmcq@uic.edu></a><br>
                 
              </dd>
           </dl>
           <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright">
                 		Copyright
              </a> &nbsp;&copy;&nbsp; 1999 <a href="http://www.w3.org">W3C</a>
              		(<a href="http://www.lcs.mit.edu">MIT</a>,
              		<a href="http://www.inria.fr/">INRIA</a>,
              		<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal_Disclaimer">liability</a>,
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C_Trademarks">trademark</a>,
              		<a href="http://www.w3.org/Consortium/Legal/copyright-documents.html">document use</a> and
              		<a href="http://www.w3.org/Consortium/Legal/copyright-software.html">software licensing</a> rules apply.
              	
           </p>
           <hr title="Separator for header">
        </div>
        <h2><a name="abstract">Abstract</a></h2>
        
        <p>The Extensible Markup Language (XML) is a subset of
           SGML that is completely described in this document. Its goal is to
           enable generic SGML to be served, received, and processed on the Web
           in the way that is now possible with HTML. XML has been designed for
           ease of implementation and for interoperability with both SGML and
           HTML.
        </p>
        
        <h2><a name="status">Status of this document</a></h2>
        
        <p>This document has been reviewed by W3C Members and
           other interested parties and has been endorsed by the
           Director as a W3C Recommendation. It is a stable
           document and may be used as reference material or cited
           as a normative reference from another document. W3C's
           role in making the Recommendation is to draw attention
           to the specification and to promote its widespread
           deployment. This enhances the functionality and
           interoperability of the Web.
        </p>
        
        <p>
           This document specifies a syntax created by subsetting an existing,
           widely used international text processing standard (Standard
           Generalized Markup Language, ISO 8879:1986(E) as amended and
           corrected) for use on the World Wide Web.  It is a product of the W3C
           XML Activity, details of which can be found at <a href="http://www.w3.org/XML">http://www.w3.org/XML</a>.  A list of
           current W3C Recommendations and other technical documents can be found
           at <a href="http://www.w3.org/TR">http://www.w3.org/TR</a>.
           
        </p>
        
        <p>This specification uses the term URI, which is defined by <a href="#Berners-Lee">[Berners-Lee et al.]</a>, a work in progress expected to update <a href="#RFC1738">[IETF RFC1738]</a> and <a href="#RFC1808">[IETF RFC1808]</a>. 
           
        </p>
        
        <p>The list of known errors in this specification is 
           available at 
           <a href="http://www.w3.org/XML/xml-19980210-errata">http://www.w3.org/XML/xml-19980210-errata</a>.
        </p>
        
        <p>Please report errors in this document to 
           <a href="mailto:xml-editor@w3.org">xml-editor@w3.org</a>.
           
        </p>
        
        
        <h2><a name="contents">Table of contents</a></h2>1 <a href="#sec-intro">Introduction</a><br>&nbsp;&nbsp;&nbsp;&nbsp;1.1 <a href="#sec-origin-goals">Origin and Goals</a><br>&nbsp;&nbsp;&nbsp;&nbsp;1.2 <a href="#sec-terminology">Terminology</a><br>2 <a href="#sec-documents">Documents</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.1 <a href="#sec-well-formed">Well-Formed XML Documents</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.2 <a href="#charsets">Characters</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.3 <a href="#sec-common-syn">Common Syntactic Constructs</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.4 <a href="#syntax">Character Data and Markup</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.5 <a href="#sec-comments">Comments</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.6 <a href="#sec-pi">Processing Instructions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.7 <a href="#sec-cdata-sect">CDATA Sections</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.8 <a href="#sec-prolog-dtd">Prolog and Document Type Declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.9 <a href="#sec-rmd">Standalone Document Declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.10 <a href="#sec-white-space">White Space Handling</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.11 <a href="#sec-line-ends">End-of-Line Handling</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.12 <a href="#sec-lang-tag">Language Identification</a><br>3 <a href="#sec-logical-struct">Logical Structures</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.1 <a href="#sec-starttags">Start-Tags, End-Tags, and Empty-Element Tags</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.2 <a href="#elemdecls">Element Type Declarations</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.2.1 <a href="#sec-element-content">Element Content</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.2.2 <a href="#sec-mixed-content">Mixed Content</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.3 <a href="#attdecls">Attribute-List Declarations</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.1 <a href="#sec-attribute-types">Attribute Types</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.2 <a href="#sec-attr-defaults">Attribute Defaults</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.3 <a href="#AVNormalize">Attribute-Value Normalization</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.4 <a href="#sec-condition-sect">Conditional Sections</a><br>4 <a href="#sec-physical-struct">Physical Structures</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.1 <a href="#sec-references">Character and Entity References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.2 <a href="#sec-entity-decl">Entity Declarations</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2.1 <a href="#sec-internal-ent">Internal Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2.2 <a href="#sec-external-ent">External Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.3 <a href="#TextEntities">Parsed Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.1 <a href="#sec-TextDecl">The Text Declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.2 <a href="#wf-entities">Well-Formed Parsed Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.3 <a href="#charencoding">Character Encoding in Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.4 <a href="#entproc">XML Processor Treatment of Entities and References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.1 <a href="#not-recognized">Not Recognized</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.2 <a href="#included">Included</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.3 <a href="#include-if-valid">Included If Validating</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.4 <a href="#forbidden">Forbidden</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.5 <a href="#inliteral">Included in Literal</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.6 <a href="#notify">Notify</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.7 <a href="#bypass">Bypassed</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.8 <a href="#as-PE">Included as PE</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.5 <a href="#intern-replacement">Construction of Internal Entity Replacement Text</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.6 <a href="#sec-predefined-ent">Predefined Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.7 <a href="#Notations">Notation Declarations</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.8 <a href="#sec-doc-entity">Document Entity</a><br>5 <a href="#sec-conformance">Conformance</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.1 <a href="#proc-types">Validating and Non-Validating Processors</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.2 <a href="#safe-behavior">Using XML Processors</a><br>6 <a href="#sec-notation">Notation</a><br><h3>Appendices</h3>A <a href="#sec-bibliography">References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.1 <a href="#sec-existing-stds">Normative References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.2 <a href="#section-Other-References">Other References</a><br>B <a href="#CharClasses">Character Classes</a><br>C <a href="#sec-xml-and-sgml">XML and SGML</a> (Non-Normative)<br>D <a href="#sec-entexpand">Expansion of Entity and Character References</a> (Non-Normative)<br>E <a href="#determinism">Deterministic Content Models</a> (Non-Normative)<br>F <a href="#sec-guessing">Autodetection of Character Encodings</a> (Non-Normative)<br>G <a href="#sec-xml-wg">W3C XML Working Group</a> (Non-Normative)<br><hr> 
        
        
        <h2><a name="sec-intro"></a>1 Introduction
        </h2>
        
        <p>Extensible Markup Language, abbreviated XML, describes a class of
           data objects called <a href="#dt-xml-doc">XML documents</a> and
           partially describes the behavior of 
           computer programs which process them. XML is an application profile or
           restricted form of SGML, the Standard Generalized Markup 
           Language <a href="#ISO8879">[ISO 8879]</a>.
           By construction, XML documents 
           are conforming SGML documents.
           
        </p>
        
        <p>XML documents are made up of storage units called <a href="#dt-entity">entities</a>, which contain either parsed
           or unparsed data.
           Parsed data is made up of <a href="#dt-character">characters</a>,
           some 
           of which form <a href="#dt-chardata">character data</a>, 
           and some of which form <a href="#dt-markup">markup</a>.
           Markup encodes a description of the document's storage layout and
           logical structure. XML provides a mechanism to impose constraints on
           the storage layout and logical structure.
        </p>
        
        <p><a name="dt-xml-proc"></a>A software module
           called an <b>XML processor</b> is used to read XML documents
           and provide access to their content and structure. <a name="dt-app"></a>It is assumed that an XML processor is
           doing its work on behalf of another module, called the
           <b>application</b>. This specification describes the
           required behavior of an XML processor in terms of how it must read XML
           data and the information it must provide to the application.
        </p>
        
        
        
        <h3><a name="sec-origin-goals"></a>1.1 Origin and Goals
        </h3>
        
        <p>XML was developed by an XML Working Group (originally known as the
           SGML Editorial Review Board) formed under the auspices of the World
           Wide Web Consortium (W3C) in 1996.
           It was chaired by Jon Bosak of Sun
           Microsystems with the active participation of an XML Special
           Interest Group (previously known as the SGML Working Group) also
           organized by the W3C. The membership of the XML Working Group is given
           in an appendix. Dan Connolly served as the WG's contact with the W3C.
           
        </p>
        
        <p>The design goals for XML are:
           <ol>
              
              <li>
                 <p>XML shall be straightforwardly usable over the
                    Internet.
                 </p>
              </li>
              
              <li>
                 <p>XML shall support a wide variety of applications.</p>
              </li>
              
              <li>
                 <p>XML shall be compatible with SGML.</p>
              </li>
              
              <li>
                 <p>It shall be easy to write programs which process XML
                    documents.
                 </p>
              </li>
              
              <li>
                 <p>The number of optional features in XML is to be kept to the
                    absolute minimum, ideally zero.
                 </p>
              </li>
              
              <li>
                 <p>XML documents should be human-legible and reasonably
                    clear.
                 </p>
              </li>
              
              <li>
                 <p>The XML design should be prepared quickly.</p>
              </li>
              
              <li>
                 <p>The design of XML shall be formal and concise.</p>
              </li>
              
              <li>
                 <p>XML documents shall be easy to create.</p>
              </li>
              
              <li>
                 <p>Terseness in XML markup is of minimal importance.</p>
              </li>
           </ol>
           
        </p>
        
        <p>This specification, 
           together with associated standards
           (Unicode and ISO/IEC 10646 for characters,
           Internet RFC 1766 for language identification tags, 
           ISO 639 for language name codes, and 
           ISO 3166 for country name codes),
           provides all the information necessary to understand 
           XML Version 1.0
           and construct computer programs to process it.
        </p>
        
        <p>This version of the XML specification
           
           may be distributed freely, as long as
           all text and legal notices remain intact.
        </p>
        
        
        
        
        
        
        
        
        <h3><a name="sec-terminology"></a>1.2 Terminology
        </h3>
        
        
        <p>The terminology used to describe XML documents is defined in the body of
           this specification.
           The terms defined in the following list are used in building those
           definitions and in describing the actions of an XML processor:
           
           <dl>
              
              
              <dt><b>may</b></dt>
              
              <dd>
                 <p><a name="dt-may"></a>Conforming documents and XML
                    processors are permitted to but need not behave as
                    described.
                 </p>
              </dd>
              
              
              
              <dt><b>must</b></dt>
              
              <dd>
                 <p>Conforming documents and XML processors 
                    are required to behave as described; otherwise they are in error.
                    
                    
                 </p>
              </dd>
              
              
              
              <dt><b>error</b></dt>
              
              <dd>
                 <p><a name="dt-error"></a>A violation of the rules of this
                    specification; results are
                    undefined.  Conforming software may detect and report an error and may
                    recover from it.
                 </p>
              </dd>
              
              
              
              <dt><b>fatal error</b></dt>
              
              <dd>
                 <p><a name="dt-fatal"></a>An error
                    which a conforming <a href="#dt-xml-proc">XML processor</a>
                    must detect and report to the application.
                    After encountering a fatal error, the
                    processor may continue
                    processing the data to search for further errors and may report such
                    errors to the application.  In order to support correction of errors,
                    the processor may make unprocessed data from the document (with
                    intermingled character data and markup) available to the application.
                    Once a fatal error is detected, however, the processor must not
                    continue normal processing (i.e., it must not
                    continue to pass character data and information about the document's
                    logical structure to the application in the normal way).
                    
                 </p>
              </dd>
              
              
              
              <dt><b>at user option</b></dt>
              
              <dd>
                 <p>Conforming software may or must (depending on the modal verb in the
                    sentence) behave as described; if it does, it must
                    provide users a means to enable or disable the behavior
                    described.
                 </p>
              </dd>
              
              
              
              <dt><b>validity constraint</b></dt>
              
              <dd>
                 <p>A rule which applies to all 
                    <a href="#dt-valid">valid</a> XML documents.
                    Violations of validity constraints are errors; they must, at user option, 
                    be reported by 
                    <a href="#dt-validating">validating XML processors</a>.
                 </p>
              </dd>
              
              
              
              <dt><b>well-formedness constraint</b></dt>
              
              <dd>
                 <p>A rule which applies to all <a href="#dt-wellformed">well-formed</a> XML documents.
                    Violations of well-formedness constraints are 
                    <a href="#dt-fatal">fatal errors</a>.
                 </p>
              </dd>
              
              
              
              
              <dt><b>match</b></dt>
              
              <dd>
                 <p><a name="dt-match"></a>(Of strings or names:) 
                    Two strings or names being compared must be identical.
                    Characters with multiple possible representations in ISO/IEC 10646 (e.g.
                    characters with 
                    both precomposed and base+diacritic forms) match only if they have the
                    same representation in both strings.
                    At user option, processors may normalize such characters to
                    some canonical form.
                    No case folding is performed. 
                    (Of strings and rules in the grammar:)  
                    A string matches a grammatical production if it belongs to the
                    language generated by that production.
                    (Of content and content models:)
                    An element matches its declaration when it conforms
                    in the fashion described in the constraint
                    <a href="#elementvalid">[<b>3 Element Valid</b>]
                    </a>.
                    
                    
                 </p>
              </dd>
              
              
              
              <dt><b>for compatibility</b></dt>
              
              <dd>
                 <p><a name="dt-compat"></a>A feature of
                    XML included solely to ensure that XML remains compatible with SGML.
                    
                 </p>
              </dd>
              
              
              
              <dt><b>for interoperability</b></dt>
              
              <dd>
                 <p><a name="dt-interop"></a>A
                    non-binding recommendation included to increase the chances that XML
                    documents can be processed by the existing installed base of SGML
                    processors which predate the
                    WebSGML Adaptations Annex to ISO 8879.
                 </p>
              </dd>
              
              
           </dl>
           
        </p>
        
        
        
        
        
        
        
        
        <h2><a name="sec-documents"></a>2 Documents
        </h2>
        
        
        <p><a name="dt-xml-doc"></a>
           A data object is an
           <b>XML document</b> if it is
           <a href="#dt-wellformed">well-formed</a>, as
           defined in this specification.
           A well-formed XML document may in addition be
           <a href="#dt-valid">valid</a> if it meets certain further 
           constraints.
        </p>
        
        
        <p>Each XML document has both a logical and a physical structure.
           Physically, the document is composed of units called <a href="#dt-entity">entities</a>.  An entity may <a href="#dt-entref">refer</a> to other entities to cause their
           inclusion in the document. A document begins in a "root"  or <a href="#dt-docent">document entity</a>.
           Logically, the document is composed of declarations, elements, 
           comments,
           character references, and
           processing
           instructions, all of which are indicated in the document by explicit
           markup.
           The logical and physical structures must nest properly, as described  
           in <a href="#wf-entities">[<b>4.3.2 Well-Formed Parsed Entities</b>]
           </a>.
           
        </p>
        
        
        
        <h3><a name="sec-well-formed"></a>2.1 Well-Formed XML Documents
        </h3>
        
        
        <p><a name="dt-wellformed"></a>
           A textual object is 
           a well-formed XML document if:
           
           <ol>
              
              <li>
                 <p>Taken as a whole, it
                    matches the production labeled <a href="#NT-document">document</a>.
                 </p>
              </li>
              
              <li>
                 <p>It
                    meets all the well-formedness constraints given in this specification.
                 </p>
                 
              </li>
              
              <li>
                 <p>Each of the <a href="#dt-parsedent">parsed entities</a> 
                    which is referenced directly or indirectly within the document is
                    <a href="#wf-entities">well-formed</a>.
                 </p>
              </li>
              
           </ol>
        </p>
        
        <p>
           
           <h5>Document</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-document"></a>[1]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>document</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-prolog">prolog</a> 
                       <a href="#NT-element">element</a> 
                       <a href="#NT-Misc">Misc</a>*
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        <p>Matching the <a href="#NT-document">document</a> production 
           implies that:
           
           <ol>
              
              <li>
                 <p>It contains one or more
                    <a href="#dt-element">elements</a>.
                 </p>
                 
              </li>
              
              
              <li>
                 <p><a name="dt-root"></a>There is  exactly
                    one element, called the <b>root</b>, or document element,  no
                    part of which appears in the <a href="#dt-content">content</a> of any other element.
                    For all other elements, if the start-tag is in the content of another
                    element, the end-tag is in the content of the same element.  More
                    simply stated, the elements, delimited by start- and end-tags, nest
                    properly within each other.
                    
                 </p>
              </li>
              
           </ol>
           
        </p>
        
        <p><a name="dt-parentchild"></a>As a consequence 
           of this,
           for each non-root element
           <code>C</code> in the document, there is one other element <code>P</code>
           in the document such that 
           <code>C</code> is in the content of <code>P</code>, but is not in
           the content of any other element that is in the content of
           <code>P</code>.  
           <code>P</code> is referred to as the
           <b>parent</b> of <code>C</code>, and <code>C</code> as a
           <b>child</b> of <code>P</code>.
        </p>
        
        
        
        <h3><a name="charsets"></a>2.2 Characters
        </h3>
        
        
        <p><a name="dt-text"></a>A parsed entity contains
           <b>text</b>, a sequence of 
           <a href="#dt-character">characters</a>, 
           which may represent markup or character data. 
           <a name="dt-character"></a>A <b>character</b> 
           is an atomic unit of text as specified by
           ISO/IEC 10646 <a href="#ISO10646">[ISO/IEC 10646]</a>.
           Legal characters are tab, carriage return, line feed, and the legal
           graphic characters of Unicode and ISO/IEC 10646.
           The use of "compatibility characters", as defined in section 6.8
           of <a href="#Unicode">[Unicode]</a>, is discouraged.
            
           
           <h5>Character Range</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Char"></a>[2]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Char</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] 
                       | [#x10000-#x10FFFF]
                    </td>
                    <td>/*any Unicode character, excluding the
                       surrogate blocks, FFFE, and FFFF.*/
                    </td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        
        
        <p>The mechanism for encoding character code points into bit patterns may
           vary from entity to entity. All XML processors must accept the UTF-8
           and UTF-16 encodings of 10646; the mechanisms for signaling which of
           the two is in use, or for bringing other encodings into play, are
           discussed later, in <a href="#charencoding">[<b>4.3.3 Character Encoding in Entities</b>]
           </a>.
           
        </p>
        
        
        
        
        
        <h3><a name="sec-common-syn"></a>2.3 Common Syntactic Constructs
        </h3>
        
        
        <p>This section defines some symbols used widely in the grammar.</p>
        
        <p><a href="#NT-S">S</a> (white space) consists of one or more space (#x20)
           characters, carriage returns, line feeds, or tabs.
           
           
           <h5>White Space</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-S"></a>[3]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>S</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(#x20 | #x9 | #xD | #xA)+</td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
        </p>
        
        <p>Characters are classified for convenience as letters, digits, or other
           characters.  Letters consist of an alphabetic or syllabic 
           base character possibly
           followed by one or more combining characters, or of an ideographic
           character.  
           Full definitions of the specific characters in each class
           are given in <a href="#CharClasses">[<b>B Character Classes</b>]
           </a>.
        </p>
        
        <p><a name="dt-name"></a>A <b>Name</b> is a token
           beginning with a letter or one of a few punctuation characters, and continuing
           with letters, digits, hyphens, underscores, colons, or full stops, together
           known as name characters.
           Names beginning with the string "<code>xml</code>", or any string
           which would match <code>(('X'|'x') ('M'|'m') ('L'|'l'))</code>, are
           reserved for standardization in this or future versions of this
           specification.
           
        </p>
        
        <blockquote><b>NOTE: </b>
           The colon character within XML names is reserved for experimentation with
           name spaces.  
           Its meaning is expected to be
           standardized at some future point, at which point those documents 
           using the colon for experimental purposes may need to be updated.
           (There is no guarantee that any name-space mechanism
           adopted for XML will in fact use the colon as a name-space delimiter.)
           In practice, this means that authors should not use the colon in XML
           names except as part of name-space experiments, but that XML processors
           should accept the colon as a name character.
           
        </blockquote>
        
        <p>An
           <a href="#NT-Nmtoken">Nmtoken</a> (name token) is any mixture of
           name characters.
           
           <h5>Names and Tokens</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-NameChar"></a>[4]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>NameChar</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Letter">Letter</a> 
                       | <a href="#NT-Digit">Digit</a> 
                       | '.' | '-' | '_' | ':'
                       | <a href="#NT-CombiningChar">CombiningChar</a> 
                       | <a href="#NT-Extender">Extender</a></td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Name"></a>[5]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Name</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-Letter">Letter</a> | '_' | ':')
                       (<a href="#NT-NameChar">NameChar</a>)*
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Names"></a>[6]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Names</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Name">Name</a> 
                       (<a href="#NT-S">S</a> <a href="#NT-Name">Name</a>)*
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Nmtoken"></a>[7]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Nmtoken</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-NameChar">NameChar</a>)+
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Nmtokens"></a>[8]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Nmtokens</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Nmtoken">Nmtoken</a> (<a href="#NT-S">S</a> <a href="#NT-Nmtoken">Nmtoken</a>)*
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        <p>Literal data is any quoted string not containing
           the quotation mark used as a delimiter for that string.
           Literals are used
           for specifying the content of internal entities
           (<a href="#NT-EntityValue">EntityValue</a>),
           the values of attributes (<a href="#NT-AttValue">AttValue</a>), 
           and external identifiers 
           (<a href="#NT-SystemLiteral">SystemLiteral</a>).  
           Note that a <a href="#NT-SystemLiteral">SystemLiteral</a>
           can be parsed without scanning for markup.
           
           <h5>Literals</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-EntityValue"></a>[9]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EntityValue</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'"' 
                       ([^%&amp;"] 
                       | <a href="#NT-PEReference">PEReference</a> 
                       | <a href="#NT-Reference">Reference</a>)*
                       '"' 
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>|&nbsp; 
                       "'" 
                       ([^%&amp;'] 
                       | <a href="#NT-PEReference">PEReference</a> 
                       | <a href="#NT-Reference">Reference</a>)* 
                       "'"
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-AttValue"></a>[10]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>AttValue</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'"' 
                       ([^&lt;&amp;"] 
                       | <a href="#NT-Reference">Reference</a>)* 
                       '"' 
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>|&nbsp; 
                       "'" 
                       ([^&lt;&amp;'] 
                       | <a href="#NT-Reference">Reference</a>)* 
                       "'"
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-SystemLiteral"></a>[11]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>SystemLiteral</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>('"' [^"]* '"') |&nbsp;("'" [^']* "'")
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-PubidLiteral"></a>[12]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PubidLiteral</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'"' <a href="#NT-PubidChar">PubidChar</a>* 
                       '"' 
                       | "'" (<a href="#NT-PubidChar">PubidChar</a> - "'")* "'"
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-PubidChar"></a>[13]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PubidChar</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>#x20 | #xD | #xA 
                       |&nbsp;[a-zA-Z0-9]
                       |&nbsp;[-'()+,./:=?;!*#@$_%]
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        
        
        
        
        <h3><a name="syntax"></a>2.4 Character Data and Markup
        </h3>
        
        
        <p><a href="#dt-text">Text</a> consists of intermingled 
           <a href="#dt-chardata">character
              data
           </a> and markup.
           <a name="dt-markup"></a><b>Markup</b> takes the form of
           <a href="#dt-stag">start-tags</a>,
           <a href="#dt-etag">end-tags</a>,
           <a href="#dt-empty">empty-element tags</a>,
           <a href="#dt-entref">entity references</a>,
           <a href="#dt-charref">character references</a>,
           <a href="#dt-comment">comments</a>,
           <a href="#dt-cdsection">CDATA section</a> delimiters,
           <a href="#dt-doctype">document type declarations</a>, and
           <a href="#dt-pi">processing instructions</a>.
           
           
        </p>
        
        <p><a name="dt-chardata"></a>All text that is not markup
           constitutes the <b>character data</b> of
           the document.
        </p>
        
        <p>The ampersand character (&amp;) and the left angle bracket (&lt;)
           may appear in their literal form <i>only</i> when used as markup
           delimiters, or within a <a href="#dt-comment">comment</a>, a
           <a href="#dt-pi">processing instruction</a>, 
           or a <a href="#dt-cdsection">CDATA section</a>.  
           
           They are also legal within the <a href="#dt-litentval">literal entity
              value
           </a> of an internal entity declaration; see
           <a href="#wf-entities">[<b>4.3.2 Well-Formed Parsed Entities</b>]
           </a>.
           
           If they are needed elsewhere,
           they must be <a href="#dt-escape">escaped</a>
           using either <a href="#dt-charref">numeric character references</a>
           or the strings
           "<code>&amp;amp;</code>" and "<code>&amp;lt;</code>" respectively. 
           The right angle
           bracket (>) may be represented using the string
           "<code>&amp;gt;</code>", and must, <a href="#dt-compat">for
              compatibility
           </a>, 
           be escaped using
           "<code>&amp;gt;</code>" or a character reference 
           when it appears in the string
           "<code>]]></code>"
           in content, 
           when that string is not marking the end of 
           a <a href="#dt-cdsection">CDATA section</a>. 
           
        </p>
        
        <p>
           In the content of elements, character data 
           is any string of characters which does
           not contain the start-delimiter of any markup.  
           In a CDATA section, character data
           is any string of characters not including the CDATA-section-close
           delimiter, "<code>]]></code>".
        </p>
        
        <p>
           To allow attribute values to contain both single and double quotes, the
           apostrophe or single-quote character (') may be represented as
           "<code>&amp;apos;</code>", and the double-quote character (") as
           "<code>&amp;quot;</code>".
           
           <h5>Character Data</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-CharData"></a>[14]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CharData</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[^&lt;&amp;]* - ([^&lt;&amp;]* ']]>' [^&lt;&amp;]*)</td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        
        
        
        <h3><a name="sec-comments"></a>2.5 Comments
        </h3>
        
        
        <p><a name="dt-comment"></a><b>Comments</b> may 
           appear anywhere in a document outside other 
           <a href="#dt-markup">markup</a>; in addition,
           they may appear within the document type declaration
           at places allowed by the grammar.
           They are not part of the document's <a href="#dt-chardata">character
              data
           </a>; an XML
           processor may, but need not, make it possible for an application to
           retrieve the text of comments.
           <a href="#dt-compat">For compatibility</a>, the string
           "<code>--</code>" (double-hyphen) must not occur within
           comments.
           
           <h5>Comments</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-Comment"></a>[15]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Comment</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!--'
                       ((<a href="#NT-Char">Char</a> - '-') 
                       | ('-' (<a href="#NT-Char">Char</a> - '-')))* 
                       '-->'
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        <p>An example of a comment:
           <pre>&lt;!-- declarations for &lt;head> &amp; &lt;body> --></pre>
           </p>
        
        
        
        
        <h3><a name="sec-pi"></a>2.6 Processing Instructions
        </h3>
        
        
        <p><a name="dt-pi"></a><b>Processing
              instructions
           </b> (PIs) allow documents to contain instructions
           for applications.
           
           
           <h5>Processing Instructions</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-PI"></a>[16]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PI</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;?' <a href="#NT-PITarget">PITarget</a> 
                       (<a href="#NT-S">S</a> 
                       (<a href="#NT-Char">Char</a>* - 
                       (<a href="#NT-Char">Char</a>* '?>' <a href="#NT-Char">Char</a>*)))?
                       '?>'
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-PITarget"></a>[17]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PITarget</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Name">Name</a> - 
                       (('X' | 'x') ('M' | 'm') ('L' | 'l'))
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           PIs are not part of the document's <a href="#dt-chardata">character
              data
           </a>, but must be passed through to the application. The
           PI begins with a target (<a href="#NT-PITarget">PITarget</a>) used
           to identify the application to which the instruction is directed.  
           The target names "<code>XML</code>", "<code>xml</code>", and so on are
           reserved for standardization in this or future versions of this
           specification.
           The 
           XML <a href="#dt-notation">Notation</a> mechanism
           may be used for
           formal declaration of PI targets.
           
        </p>
        
        
        
        
        <h3><a name="sec-cdata-sect"></a>2.7 CDATA Sections
        </h3>
        
        
        <p><a name="dt-cdsection"></a><b>CDATA sections</b>
           may occur 
           anywhere character data may occur; they are
           used to escape blocks of text containing characters which would
           otherwise be recognized as markup.  CDATA sections begin with the
           string "<code>&lt;![CDATA[</code>" and end with the string
           "<code>]]></code>":
           
           <h5>CDATA Sections</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-CDSect"></a>[18]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CDSect</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-CDStart">CDStart</a> 
                       <a href="#NT-CData">CData</a> 
                       <a href="#NT-CDEnd">CDEnd</a></td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-CDStart"></a>[19]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CDStart</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;![CDATA['</td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-CData"></a>[20]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CData</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-Char">Char</a>* - 
                       (<a href="#NT-Char">Char</a>* ']]>' <a href="#NT-Char">Char</a>*))
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-CDEnd"></a>[21]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CDEnd</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>']]>'</td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
           Within a CDATA section, only the <a href="#NT-CDEnd">CDEnd</a> string is
           recognized as markup, so that left angle brackets and ampersands may occur in
           their literal form; they need not (and cannot) be escaped using
           "<code>&amp;lt;</code>" and "<code>&amp;amp;</code>".  CDATA sections
           cannot nest.
           
        </p>
        
        
        <p>An example of a CDATA section, in which "<code>&lt;greeting></code>" and 
           "<code>&lt;/greeting></code>"
           are recognized as <a href="#dt-chardata">character data</a>, not
           <a href="#dt-markup">markup</a>:
           <pre>&lt;![CDATA[&lt;greeting>Hello, world!&lt;/greeting>]]></pre>
           </p>
        
        
        
        
        <h3><a name="sec-prolog-dtd"></a>2.8 Prolog and Document Type Declaration
        </h3>
        
        
        <p><a name="dt-xmldecl"></a>XML documents 
           may, and should, 
           begin with an <b>XML declaration</b> which specifies
           the version of
           XML being used.
           For example, the following is a complete XML document, <a href="#dt-wellformed">well-formed</a> but not
           <a href="#dt-valid">valid</a>:
           <pre>&lt;?xml version="1.0"?>
  &lt;greeting>Hello, world!&lt;/greeting>
  </pre>
           and so is this:
           <pre>&lt;greeting>Hello, world!&lt;/greeting>
  </pre>
           </p>
        
        
        <p>The version number "<code>1.0</code>" should be used to indicate
           conformance to this version of this specification; it is an error
           for a document to use the value "<code>1.0</code>" 
           if it does not conform to this version of this specification.
           It is the intent
           of the XML working group to give later versions of this specification
           numbers other than "<code>1.0</code>", but this intent does not
           indicate a
           commitment to produce any future versions of XML, nor if any are produced, to
           use any particular numbering scheme.
           Since future versions are not ruled out, this construct is provided 
           as a means to allow the possibility of automatic version recognition, should
           it become necessary.
           Processors may signal an error if they receive documents labeled with 
           versions they do not support. 
           
        </p>
        
        <p>The function of the markup in an XML document is to describe its
           storage and logical structure and to associate attribute-value pairs
           with its logical structures.  XML provides a mechanism, the <a href="#dt-doctype">document type declaration</a>, to define
           constraints on the logical structure and to support the use of
           predefined storage units.
           
           <a name="dt-valid"></a>An XML document is 
           <b>valid</b> if it has an associated document type
           declaration and if the document
           complies with the constraints expressed in it.
        </p>
        
        <p>The document type declaration must appear before
           the first <a href="#dt-element">element</a> in the document.
           
           <h5>Prolog</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-prolog"></a>[22]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>prolog</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-XMLDecl">XMLDecl</a>? 
                       <a href="#NT-Misc">Misc</a>* 
                       (<a href="#NT-doctypedecl">doctypedecl</a> 
                       <a href="#NT-Misc">Misc</a>*)?
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-XMLDecl"></a>[23]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>XMLDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;?xml' 
                       <a href="#NT-VersionInfo">VersionInfo</a> 
                       <a href="#NT-EncodingDecl">EncodingDecl</a>? 
                       <a href="#NT-SDDecl">SDDecl</a>? 
                       <a href="#NT-S">S</a>? 
                       '?>'
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-VersionInfo"></a>[24]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>VersionInfo</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-S">S</a> 'version' <a href="#NT-Eq">Eq</a> 
                       (' <a href="#NT-VersionNum">VersionNum</a> ' 
                       | " <a href="#NT-VersionNum">VersionNum</a> ")
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Eq"></a>[25]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Eq</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-S">S</a>? '=' <a href="#NT-S">S</a>?
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-VersionNum"></a>[26]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>VersionNum</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>([a-zA-Z0-9_.:] | '-')+</td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Misc"></a>[27]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Misc</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Comment">Comment</a> | <a href="#NT-PI">PI</a> | 
                       <a href="#NT-S">S</a></td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
        </p>
        
        
        <p><a name="dt-doctype"></a>The XML
           <b>document type declaration</b> 
           contains or points to 
           <a href="#dt-markupdecl">markup declarations</a> 
           that provide a grammar for a
           class of documents.  
           This grammar is known as a document type definition,
           or <b>DTD</b>.  
           The document type declaration can point to an external subset (a
           special kind of 
           <a href="#dt-extent">external entity</a>) containing markup
           declarations, or can 
           contain the markup declarations directly in an internal subset, or can do
           both.   
           The DTD for a document consists of both subsets taken
           together.
           
        </p>
        
        <p><a name="dt-markupdecl"></a>
           A <b>markup declaration</b> is 
           an <a href="#dt-eldecl">element type declaration</a>, 
           an <a href="#dt-attdecl">attribute-list declaration</a>, 
           an <a href="#dt-entdecl">entity declaration</a>, or
           a <a href="#dt-notdecl">notation declaration</a>.
           
           These declarations may be contained in whole or in part
           within <a href="#dt-PE">parameter entities</a>,
           as described in the well-formedness and validity constraints below.
           For fuller information, see
           <a href="#sec-physical-struct">[<b>4 Physical Structures</b>]
           </a>.
        </p>
        
        <h5>Document Type Definition</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-doctypedecl"></a>[28]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>doctypedecl</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'&lt;!DOCTYPE' <a href="#NT-S">S</a> 
                    <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a> 
                    <a href="#NT-ExternalID">ExternalID</a>)? 
                    <a href="#NT-S">S</a>? ('[' 
                    (<a href="#NT-markupdecl">markupdecl</a> 
                    | <a href="#NT-PEReference">PEReference</a> 
                    | <a href="#NT-S">S</a>)*
                    ']' 
                    <a href="#NT-S">S</a>?)? '>'
                 </td>
                 <td>[&nbsp;VC:&nbsp;<a href="#vc-roottype">Root Element Type</a>&nbsp;]
                 </td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-markupdecl"></a>[29]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>markupdecl</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-elementdecl">elementdecl</a> 
                    | <a href="#NT-AttlistDecl">AttlistDecl</a> 
                    | <a href="#NT-EntityDecl">EntityDecl</a> 
                    | <a href="#NT-NotationDecl">NotationDecl</a> 
                    | <a href="#NT-PI">PI</a> 
                    | <a href="#NT-Comment">Comment</a>
                    
                 </td>
                 <td>[&nbsp;VC:&nbsp;<a href="#vc-PEinMarkupDecl">Proper Declaration/PE Nesting</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#wfc-PEinInternalSubset">PEs in Internal Subset</a>&nbsp;]
                 </td>
              </tr>
              
              
           </tbody>
        </table>
        
        
        <p>The markup declarations may be made up in whole or in part of
           the <a href="#dt-repltext">replacement text</a> of 
           <a href="#dt-PE">parameter entities</a>.
           The productions later in this specification for
           individual nonterminals (<a href="#NT-elementdecl">elementdecl</a>,
           <a href="#NT-AttlistDecl">AttlistDecl</a>, and so on) describe 
           the declarations <i>after</i> all the parameter entities have been 
           <a href="#dt-include">included</a>.
        </p>
        
        <a name="vc-roottype"></a><p><b>Validity Constraint: Root Element Type</b></p>
        Root Element Type
        
        <p>
           The <a href="#NT-Name">Name</a> in the document type declaration must
           match the element type of the <a href="#dt-root">root element</a>.
           
        </p>
        
        
        <a name="vc-PEinMarkupDecl"></a><p><b>Validity Constraint: Proper Declaration/PE Nesting</b></p>
        Proper Declaration/PE Nesting
        
        <p>Parameter-entity 
           <a href="#dt-repltext">replacement text</a> must be properly nested
           with markup declarations. 
           That is to say, if either the first character
           or the last character of a markup
           declaration (<a href="#NT-markupdecl">markupdecl</a> above)
           is contained in the replacement text for a 
           <a href="#dt-PERef">parameter-entity reference</a>,
           both must be contained in the same replacement text.
        </p>
        
        <a name="wfc-PEinInternalSubset"></a><p><b>Well Formedness Constraint: PEs in Internal Subset</b></p>
        PEs in Internal Subset
        
        <p>In the internal DTD subset, 
           <a href="#dt-PERef">parameter-entity references</a>
           can occur only where markup declarations can occur, not
           within markup declarations.  (This does not apply to
           references that occur in
           external parameter entities or to the external subset.)
           
        </p>
        
        
        <p>
           Like the internal subset, the external subset and 
           any external parameter entities referred to in the DTD 
           must consist of a series of complete markup declarations of the types 
           allowed by the non-terminal symbol
           <a href="#NT-markupdecl">markupdecl</a>, interspersed with white space
           or <a href="#dt-PERef">parameter-entity references</a>.
           However, portions of the contents
           of the 
           external subset or of external parameter entities may conditionally be ignored
           by using 
           the <a href="#dt-cond-section">conditional section</a>
           construct; this is not allowed in the internal subset.
           
           
           <h5>External Subset</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-extSubset"></a>[30]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>extSubset</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-TextDecl">TextDecl</a>?
                       <a href="#NT-extSubsetDecl">extSubsetDecl</a></td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-extSubsetDecl"></a>[31]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>extSubsetDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(
                       <a href="#NT-markupdecl">markupdecl</a> 
                       | <a href="#NT-conditionalSect">conditionalSect</a> 
                       | <a href="#NT-PEReference">PEReference</a> 
                       | <a href="#NT-S">S</a>
                       )*
                    </td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
        </p>
        
        <p>The external subset and external parameter entities also differ 
           from the internal subset in that in them,
           <a href="#dt-PERef">parameter-entity references</a>
           are permitted <i>within</i> markup declarations,
           not only <i>between</i> markup declarations.
        </p>
        
        <p>An example of an XML document with a document type declaration:
           <pre>&lt;?xml version="1.0"?>
  &lt;!DOCTYPE greeting SYSTEM "hello.dtd">
  &lt;greeting>Hello, world!&lt;/greeting>
  </pre>
           The <a href="#dt-sysid">system identifier</a> 
           "<code>hello.dtd</code>" gives the URI of a DTD for the document.
        </p>
        
        <p>The declarations can also be given locally, as in this 
           example:
           <pre>&lt;?xml version="1.0" encoding="UTF-8" ?>
  &lt;!DOCTYPE greeting [
    &lt;!ELEMENT greeting (#PCDATA)>
  ]>
  &lt;greeting>Hello, world!&lt;/greeting>
  </pre>
           If both the external and internal subsets are used, the 
           internal subset is considered to occur before the external subset.
           
           This has the effect that entity and attribute-list declarations in the
           internal subset take precedence over those in the external subset.
           </p>
        
        
        
        
        <h3><a name="sec-rmd"></a>2.9 Standalone Document Declaration
        </h3>
        
        <p>Markup declarations can affect the content of the document,
           as passed from an <a href="#dt-xml-proc">XML processor</a> 
           to an application; examples are attribute defaults and entity
           declarations.
           The standalone document declaration,
           which may appear as a component of the XML declaration, signals
           whether or not there are such declarations which appear external to 
           the <a href="#dt-docent">document entity</a>.
           
           <h5>Standalone Document Declaration</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-SDDecl"></a>[32]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>SDDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>
                       <a href="#NT-S">S</a> 
                       'standalone' <a href="#NT-Eq">Eq</a> 
                       (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
                       
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#vc-check-rmd">Standalone Document Declaration</a>&nbsp;]
                    </td>
                 </tr>
                 
              </tbody>
           </table>
        </p>
        
        <p>
           In a standalone document declaration, the value "<code>yes</code>" indicates
           that there 
           are no markup declarations external to the <a href="#dt-docent">document
              entity
           </a> (either in the DTD external subset, or in an
           external parameter entity referenced from the internal subset)
           which affect the information passed from the XML processor to
           the application.  
           The value "<code>no</code>" indicates that there are or may be such
           external markup declarations.
           Note that the standalone document declaration only 
           denotes the presence of external <i>declarations</i>; the presence, in a
           document, of 
           references to external <i>entities</i>, when those entities are
           internally declared, 
           does not change its standalone status.
        </p>
        
        <p>If there are no external markup declarations, the standalone document
           declaration has no meaning. 
           If there are external markup declarations but there is no standalone
           document declaration, the value "<code>no</code>" is assumed.
        </p>
        
        <p>Any XML document for which <code>standalone="no"</code> holds can 
           be converted algorithmically to a standalone document, 
           which may be desirable for some network delivery applications.
        </p>
        <a name="vc-check-rmd"></a><p><b>Validity Constraint: Standalone Document Declaration</b></p>
        Standalone Document Declaration
        
        <p>The standalone document declaration must have
           the value "<code>no</code>" if any external markup declarations
           contain declarations of:
        </p>
        <ul>
           
           <li>
              <p>attributes with <a href="#dt-default">default</a> values, if
                 elements to which
                 these attributes apply appear in the document without
                 specifications of values for these attributes, or
              </p>
           </li>
           
           <li>
              <p>entities (other than <code>amp</code>,
                 <code>lt</code>,
                 <code>gt</code>,
                 <code>apos</code>,
                 <code>quot</code>), 
                 if <a href="#dt-entref">references</a> to those
                 entities appear in the document, or
              </p>
              
           </li>
           
           <li>
              <p>attributes with values subject to
                 <a href="#AVNormalize">normalization</a>, where the
                 attribute appears in the document with a value which will
                 change as a result of normalization, or
              </p>
              
           </li>
           
           <li>
              
              <p>element types with <a href="#dt-elemcontent">element content</a>, 
                 if white space occurs
                 directly within any instance of those types.
                 
              </p>
           </li>
           
        </ul>
        
        
        
        <p>An example XML declaration with a standalone document declaration:<pre>&lt;?xml version="1.0" standalone='yes'?></pre></p>
        
        
        
        <h3><a name="sec-white-space"></a>2.10 White Space Handling
        </h3>
        
        
        <p>In editing XML documents, it is often convenient to use "white space"
           (spaces, tabs, and blank lines, denoted by the nonterminal 
           <a href="#NT-S">S</a> in this specification) to
           set apart the markup for greater readability.  Such white space is typically
           not intended for inclusion in the delivered version of the document.
           On the other hand, "significant" white space that should be preserved in the
           delivered version is common, for example in poetry and
           source code.
        </p>
        
        <p>An <a href="#dt-xml-proc">XML processor</a> 
           must always pass all characters in a document that are not
           markup through to the application.   A <a href="#dt-validating">
              validating XML processor
           </a> must also inform the application
           which  of these characters constitute white space appearing
           in <a href="#dt-elemcontent">element content</a>.
           
        </p>
        
        <p>A special <a href="#dt-attr">attribute</a> 
           named xml:space may be attached to an element
           to signal an intention that in that element,
           white space should be preserved by applications.
           In valid documents, this attribute, like any other, must be 
           <a href="#dt-attdecl">declared</a> if it is used.
           When declared, it must be given as an 
           <a href="#dt-enumerated">enumerated type</a> whose only
           possible values are "<code>default</code>" and "<code>preserve</code>".
           For example:<pre>    &lt;!ATTLIST poem   xml:space (default|preserve) 'preserve'></pre></p>
        
        <p>The value "<code>default</code>" signals that applications'
           default white-space processing modes are acceptable for this element; the
           value "<code>preserve</code>" indicates the intent that applications preserve
           all the white space.
           This declared intent is considered to apply to all elements within the content
           of the element where it is specified, unless overriden with another instance
           of the xml:space attribute.
           
        </p>
        
        <p>The <a href="#dt-root">root element</a> of any document
           is considered to have signaled no intentions as regards application space
           handling, unless it provides a value for 
           this attribute or the attribute is declared with a default value.
           
        </p>
        
        
        
        
        <h3><a name="sec-line-ends"></a>2.11 End-of-Line Handling
        </h3>
        
        <p>XML <a href="#dt-parsedent">parsed entities</a> are often stored in
           computer files which, for editing convenience, are organized into lines.
           These lines are typically separated by some combination of the characters
           carriage-return (#xD) and line-feed (#xA).
        </p>
        
        <p>To simplify the tasks of <a href="#dt-app">applications</a>,
           wherever an external parsed entity or the literal entity value
           of an internal parsed entity contains either the literal 
           two-character sequence "#xD#xA" or a standalone literal
           #xD, an <a href="#dt-xml-proc">XML processor</a> must 
           pass to the application the single character #xA.
           (This behavior can 
           conveniently be produced by normalizing all 
           line breaks to #xA on input, before parsing.)
           
        </p>
        
        
        
        <h3><a name="sec-lang-tag"></a>2.12 Language Identification
        </h3>
        
        <p>In document processing, it is often useful to
           identify the natural or formal language 
           in which the content is 
           written.
           A special <a href="#dt-attr">attribute</a> named
           xml:lang may be inserted in
           documents to specify the 
           language used in the contents and attribute values 
           of any element in an XML document.
           In valid documents, this attribute, like any other, must be 
           <a href="#dt-attdecl">declared</a> if it is used.
           The values of the attribute are language identifiers as defined
           by <a href="#RFC1766">[IETF RFC 1766]</a>, "Tags for the Identification of Languages":
           
           <h5>Language Identification</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-LanguageID"></a>[33]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>LanguageID</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Langcode">Langcode</a> 
                       ('-' <a href="#NT-Subcode">Subcode</a>)*
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Langcode"></a>[34]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Langcode</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-ISO639Code">ISO639Code</a> | 
                       <a href="#NT-IanaCode">IanaCode</a> | 
                       <a href="#NT-UserCode">UserCode</a></td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-ISO639Code"></a>[35]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>ISO639Code</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>([a-z] | [A-Z]) ([a-z] | [A-Z])</td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-IanaCode"></a>[36]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>IanaCode</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>('i' | 'I') '-' ([a-z] | [A-Z])+</td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-UserCode"></a>[37]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>UserCode</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>('x' | 'X') '-' ([a-z] | [A-Z])+</td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Subcode"></a>[38]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Subcode</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>([a-z] | [A-Z])+</td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           The <a href="#NT-Langcode">Langcode</a> may be any of the following:
           
           <ul>
              
              <li>
                 <p>a two-letter language code as defined by 
                    <a href="#ISO639">[ISO 639]</a>, "Codes
                    for the representation of names of languages"
                 </p>
              </li>
              
              <li>
                 <p>a language identifier registered with the Internet
                    Assigned Numbers Authority <a href="#IANA">[IANA]</a>; these begin with the 
                    prefix "<code>i-</code>" (or "<code>I-</code>")
                 </p>
              </li>
              
              <li>
                 <p>a language identifier assigned by the user, or agreed on
                    between parties in private use; these must begin with the
                    prefix "<code>x-</code>" or "<code>X-</code>" in order to ensure that they do not conflict 
                    with names later standardized or registered with IANA
                 </p>
              </li>
              
           </ul>
        </p>
        
        <p>There may be any number of <a href="#NT-Subcode">Subcode</a> segments; if
           the first 
           subcode segment exists and the Subcode consists of two 
           letters, then it must be a country code from 
           <a href="#ISO3166">[ISO 3166]</a>, "Codes 
           for the representation of names of countries."
           If the first 
           subcode consists of more than two letters, it must be
           a subcode for the language in question registered with IANA,
           unless the <a href="#NT-Langcode">Langcode</a> begins with the prefix 
           "<code>x-</code>" or
           "<code>X-</code>". 
        </p>
        
        <p>It is customary to give the language code in lower case, and
           the country code (if any) in upper case.
           Note that these values, unlike other names in XML documents,
           are case insensitive.
        </p>
        
        <p>For example:
           <pre>&lt;p xml:lang="en">The quick brown fox jumps over the lazy dog.&lt;/p>
  &lt;p xml:lang="en-GB">What colour is it?&lt;/p>
  &lt;p xml:lang="en-US">What color is it?&lt;/p>
  &lt;sp who="Faust" desc='leise' xml:lang="de">
    &lt;l>Habe nun, ach! Philosophie,&lt;/l>
    &lt;l>Juristerei, und Medizin&lt;/l>
    &lt;l>und leider auch Theologie&lt;/l>
    &lt;l>durchaus studiert mit hei&szlig;em Bem&uuml;h'n.&lt;/l>
    &lt;/sp></pre></p>
        
        
        <p>The intent declared with xml:lang is considered to apply to
           all attributes and content of the element where it is specified,
           unless overridden with an instance of xml:lang
           on another element within that content.
        </p>
        
        
        <p>A simple declaration for xml:lang might take
           the form
           <pre>xml:lang  NMTOKEN  #IMPLIED</pre>
           but specific default values may also be given, if appropriate.  In a
           collection of French poems for English students, with glosses and
           notes in English, the xml:lang attribute might be declared this way:
           <pre>    &lt;!ATTLIST poem   xml:lang NMTOKEN 'fr'>
      &lt;!ATTLIST gloss  xml:lang NMTOKEN 'en'>
      &lt;!ATTLIST note   xml:lang NMTOKEN 'en'></pre>
           </p>
        
        
        
        
        
        
        
        <h2><a name="sec-logical-struct"></a>3 Logical Structures
        </h2>
        
        
        <p><a name="dt-element"></a>Each <a href="#dt-xml-doc">XML document</a> contains one or more
           <b>elements</b>, the boundaries of which are 
           either delimited by <a href="#dt-stag">start-tags</a> 
           and <a href="#dt-etag">end-tags</a>, or, for <a href="#dt-empty">empty</a> elements, by an <a href="#dt-eetag">empty-element tag</a>. Each element has a type,
           identified by name, sometimes called its "generic
           identifier" (GI), and may have a set of
           attribute specifications.  Each attribute specification 
           has a <a href="#dt-attrname">name</a> and a <a href="#dt-attrval">value</a>.
           
        </p>
        
        <h5>Element</h5>
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-element"></a>[39]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>element</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-EmptyElemTag">EmptyElemTag</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-STag">STag</a> <a href="#NT-content">content</a> 
                    <a href="#NT-ETag">ETag</a></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#GIMatch">Element Type Match</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;VC:&nbsp;<a href="#elementvalid">Element Valid</a>&nbsp;]
                 </td>
              </tr>
           </tbody>
        </table>
        
        <p>This specification does not constrain the semantics, use, or (beyond
           syntax) names of the element types and attributes, except that names
           beginning with a match to <code>(('X'|'x')('M'|'m')('L'|'l'))</code>
           are reserved for standardization in this or future versions of this
           specification.
           
        </p>
        <a name="GIMatch"></a><p><b>Well Formedness Constraint: Element Type Match</b></p>
        Element Type Match
        
        <p>
           The <a href="#NT-Name">Name</a> in an element's end-tag must match 
           the element type in
           the start-tag.
           
        </p>
        
        <a name="elementvalid"></a><p><b>Validity Constraint: Element Valid</b></p>
        Element Valid
        
        <p>An element is
           valid if
           there is a declaration matching 
           <a href="#NT-elementdecl">elementdecl</a> where the
           <a href="#NT-Name">Name</a> matches the element type, and
           one of the following holds:
        </p>
        
        <ol>
           
           <li>
              <p>The declaration matches EMPTY and the element has no 
                 <a href="#dt-content">content</a>.
              </p>
           </li>
           
           <li>
              <p>The declaration matches <a href="#NT-children">children</a> and
                 the sequence of 
                 <a href="#dt-parentchild">child elements</a>
                 belongs to the language generated by the regular expression in
                 the content model, with optional white space (characters 
                 matching the nonterminal <a href="#NT-S">S</a>) between each pair
                 of child elements.
              </p>
           </li>
           
           <li>
              <p>The declaration matches <a href="#NT-Mixed">Mixed</a> and 
                 the content consists of <a href="#dt-chardata">character 
                    data
                 </a> and <a href="#dt-parentchild">child elements</a>
                 whose types match names in the content model.
              </p>
           </li>
           
           <li>
              <p>The declaration matches ANY, and the types
                 of any <a href="#dt-parentchild">child elements</a> have
                 been declared.
              </p>
           </li>
           
        </ol>
        
        
        
        
        <h3><a name="sec-starttags"></a>3.1 Start-Tags, End-Tags, and Empty-Element Tags
        </h3>
        
        
        <p><a name="dt-stag"></a>The beginning of every
           non-empty XML element is marked by a <b>start-tag</b>.
           
           <h5>Start-tag</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-STag"></a>[40]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>STag</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;' <a href="#NT-Name">Name</a> 
                       (<a href="#NT-S">S</a> <a href="#NT-Attribute">Attribute</a>)* 
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#uniqattspec">Unique Att Spec</a>&nbsp;]
                    </td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Attribute"></a>[41]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Attribute</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Name">Name</a> <a href="#NT-Eq">Eq</a> 
                       <a href="#NT-AttValue">AttValue</a></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#ValueType">Attribute Value Type</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#NoExternalRefs">No External Entity References</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#CleanAttrVals">No &lt; in Attribute Values</a>&nbsp;]
                    </td>
                 </tr>
                 
              </tbody>
           </table>
           The <a href="#NT-Name">Name</a> in
           the start- and end-tags gives the 
           element's <b>type</b>.
           <a name="dt-attr"></a>
           The <a href="#NT-Name">Name</a>-<a href="#NT-AttValue">AttValue</a> pairs are
           referred to as 
           the <b>attribute specifications</b> of the element,
           <a name="dt-attrname"></a>with the 
           <a href="#NT-Name">Name</a> in each pair
           referred to as the <b>attribute name</b> and
           <a name="dt-attrval"></a>the content of the
           <a href="#NT-AttValue">AttValue</a> (the text between the
           <code>'</code> or <code>"</code> delimiters)
           as the <b>attribute value</b>.
           
        </p>
        <a name="uniqattspec"></a><p><b>Well Formedness Constraint: Unique Att Spec</b></p>
        Unique Att Spec
        
        <p>
           No attribute name may appear more than once in the same start-tag
           or empty-element tag.
           
        </p>
        
        <a name="ValueType"></a><p><b>Validity Constraint: Attribute Value Type</b></p>
        Attribute Value Type
        
        <p>
           The attribute must have been declared; the value must be of the type 
           declared for it.
           (For attribute types, see <a href="#attdecls">[<b>3.3 Attribute-List Declarations</b>]
           </a>.)
           
        </p>
        
        <a name="NoExternalRefs"></a><p><b>Well Formedness Constraint: No External Entity References</b></p>
        No External Entity References
        
        <p>
           Attribute values cannot contain direct or indirect entity references 
           to external entities.
           
        </p>
        
        <a name="CleanAttrVals"></a><p><b>Well Formedness Constraint: No &lt; in Attribute Values</b></p>
        No <code>&lt;</code> in Attribute Values
        
        <p>The <a href="#dt-repltext">replacement text</a> of any entity
           referred to directly or indirectly in an attribute
           value (other than "<code>&amp;lt;</code>") must not contain
           a <code>&lt;</code>.
           
        </p>
        
        <p>An example of a start-tag:
           <pre>&lt;termdef id="dt-dog" term="dog"></pre></p>
        
        <p><a name="dt-etag"></a>The end of every element 
           that begins with a start-tag must
           be marked by an <b>end-tag</b>
           containing a name that echoes the element's type as given in the
           start-tag:
           
           <h5>End-tag</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-ETag"></a>[42]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>ETag</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;/' <a href="#NT-Name">Name</a> 
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        
        <p>An example of an end-tag:<pre>&lt;/termdef></pre></p>
        
        <p><a name="dt-content"></a>The 
           <a href="#dt-text">text</a> between the start-tag and
           end-tag is called the element's
           <b>content</b>:
           
           <h5>Content of Elements</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-content"></a>[43]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>content</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-element">element</a> | <a href="#NT-CharData">CharData</a> 
                       | <a href="#NT-Reference">Reference</a> | <a href="#NT-CDSect">CDSect</a> 
                       | <a href="#NT-PI">PI</a> | <a href="#NT-Comment">Comment</a>)*
                    </td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        
        <p><a name="dt-empty"></a>If an element is <b>empty</b>,
           it must be represented either by a start-tag immediately followed
           by an end-tag or by an empty-element tag.
           <a name="dt-eetag"></a>An 
           <b>empty-element tag</b> takes a special form:
           
           <h5>Tags for Empty Elements</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-EmptyElemTag"></a>[44]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EmptyElemTag</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;' <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a> 
                       <a href="#NT-Attribute">Attribute</a>)* <a href="#NT-S">S</a>? 
                       '/>'
                    </td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#uniqattspec">Unique Att Spec</a>&nbsp;]
                    </td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        
        <p>Empty-element tags may be used for any element which has no
           content, whether or not it is declared using the keyword
           EMPTY.
           <a href="#dt-interop">For interoperability</a>, the empty-element
           tag must be used, and can only be used, for elements which are
           <a href="#dt-eldecl">declared</a> EMPTY.
        </p>
        
        <p>Examples of empty elements:
           <pre>&lt;IMG align="left"
   src="http://www.w3.org/Icons/WWW/w3c_home" />
  &lt;br>&lt;/br>
  &lt;br/></pre></p>
        
        
        
        
        <h3><a name="elemdecls"></a>3.2 Element Type Declarations
        </h3>
        
        
        <p>The <a href="#dt-element">element</a> structure of an
           <a href="#dt-xml-doc">XML document</a> may, for 
           <a href="#dt-valid">validation</a> purposes, 
           be constrained
           using element type and attribute-list declarations.
           An element type declaration constrains the element's
           <a href="#dt-content">content</a>.
           
        </p>
        
        
        <p>Element type declarations often constrain which element types can
           appear as <a href="#dt-parentchild">children</a> of the element.
           At user option, an XML processor may issue a warning
           when a declaration mentions an element type for which no declaration
           is provided, but this is not an error.
        </p>
        
        <p><a name="dt-eldecl"></a>An <b>element
              type declaration
           </b> takes the form:
           
           <h5>Element Type Declaration</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-elementdecl"></a>[45]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>elementdecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!ELEMENT' <a href="#NT-S">S</a> 
                       <a href="#NT-Name">Name</a> 
                       <a href="#NT-S">S</a> 
                       <a href="#NT-contentspec">contentspec</a>
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#EDUnique">Unique Element Type Declaration</a>&nbsp;]
                    </td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-contentspec"></a>[46]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>contentspec</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'EMPTY' 
                       | 'ANY' 
                       | <a href="#NT-Mixed">Mixed</a> 
                       | <a href="#NT-children">children</a>
                       
                    </td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
           where the <a href="#NT-Name">Name</a> gives the element type 
           being declared.
           
        </p>
        
        <a name="EDUnique"></a><p><b>Validity Constraint: Unique Element Type Declaration</b></p>
        Unique Element Type Declaration
        
        <p>
           No element type may be declared more than once.
           
        </p>
        
        
        
        <p>Examples of element type declarations:
           <pre>&lt;!ELEMENT br EMPTY>
  &lt;!ELEMENT p (#PCDATA|emph)* >
  &lt;!ELEMENT %name.para; %content.para; >
  &lt;!ELEMENT container ANY></pre></p>
        
        
        
        <h4><a name="sec-element-content"></a>3.2.1 Element Content
        </h4>
        
        
        <p><a name="dt-elemcontent"></a>An element <a href="#dt-stag">type</a> has
           <b>element content</b> when elements of that
           type must contain only <a href="#dt-parentchild">child</a> 
           elements (no character data), optionally separated by 
           white space (characters matching the nonterminal 
           <a href="#NT-S">S</a>).
           
           In this case, the
           constraint includes a content model, a simple grammar governing
           the allowed types of the child
           elements and the order in which they are allowed to appear.  
           The grammar is built on
           content particles (<a href="#NT-cp">cp</a>s), which consist of names, 
           choice lists of content particles, or
           sequence lists of content particles:
           
           <h5>Element-content Models</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-children"></a>[47]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>children</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-choice">choice</a> 
                       | <a href="#NT-seq">seq</a>) 
                       ('?' | '*' | '+')?
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-cp"></a>[48]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>cp</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>(<a href="#NT-Name">Name</a> 
                       | <a href="#NT-choice">choice</a> 
                       | <a href="#NT-seq">seq</a>) 
                       ('?' | '*' | '+')?
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-choice"></a>[49]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>choice</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'(' <a href="#NT-S">S</a>? cp 
                       ( <a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> )*
                       <a href="#NT-S">S</a>? ')'
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#vc-PEinGroup">Proper Group/PE Nesting</a>&nbsp;]
                    </td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-seq"></a>[50]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>seq</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'(' <a href="#NT-S">S</a>? cp 
                       ( <a href="#NT-S">S</a>? ',' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> )*
                       <a href="#NT-S">S</a>? ')'
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#vc-PEinGroup">Proper Group/PE Nesting</a>&nbsp;]
                    </td>
                 </tr>
                 
                 
              </tbody>
           </table>
           where each <a href="#NT-Name">Name</a> is the type of an element which may
           appear as a <a href="#dt-parentchild">child</a>.  
           Any content
           particle in a choice list may appear in the <a href="#dt-elemcontent">element content</a> at the location where
           the choice list appears in the grammar;
           content particles occurring in a sequence list must each
           appear in the <a href="#dt-elemcontent">element content</a> in the
           order given in the list.  
           The optional character following a name or list governs
           whether the element or the content particles in the list may occur one
           or more (<code>+</code>), zero or more (<code>*</code>), or zero or 
           one times (<code>?</code>).  
           The absence of such an operator means that the element or content particle
           must appear exactly once.
           This syntax
           and meaning are identical to those used in the productions in this
           specification.
        </p>
        
        <p>
           The content of an element matches a content model if and only if it is
           possible to trace out a path through the content model, obeying the
           sequence, choice, and repetition operators and matching each element in
           the content against an element type in the content model.  <a href="#dt-compat">For compatibility</a>, it is an error
           if an element in the document can
           match more than one occurrence of an element type in the content model.
           For more information, see <a href="#determinism">[<b>E Deterministic Content Models</b>]
           </a>.
           
           
           
        </p>
        <a name="vc-PEinGroup"></a><p><b>Validity Constraint: Proper Group/PE Nesting</b></p>
        Proper Group/PE Nesting
        
        <p>Parameter-entity 
           <a href="#dt-repltext">replacement text</a> must be properly nested
           with parenthetized groups.
           That is to say, if either of the opening or closing parentheses
           in a <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or
           <a href="#NT-Mixed">Mixed</a> construct 
           is contained in the replacement text for a 
           <a href="#dt-PERef">parameter entity</a>,
           both must be contained in the same replacement text.
        </p>
        
        <p><a href="#dt-interop">For interoperability</a>, 
           if a parameter-entity reference appears in a 
           <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or
           <a href="#NT-Mixed">Mixed</a> construct, its replacement text
           should not be empty, and 
           neither the first nor last non-blank
           character of the replacement text should be a connector 
           (<code>|</code> or <code>,</code>).
           
        </p>
        
        
        <p>Examples of element-content models:
           <pre>&lt;!ELEMENT spec (front, body, back?)>
  &lt;!ELEMENT div1 (head, (p | list | note)*, div2*)>
  &lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*></pre></p>
        
        
        
        
        <h4><a name="sec-mixed-content"></a>3.2.2 Mixed Content
        </h4>
        
        
        <p><a name="dt-mixed"></a>An element 
           <a href="#dt-stag">type</a> has 
           <b>mixed content</b> when elements of that type may contain
           character data, optionally interspersed with
           <a href="#dt-parentchild">child</a> elements.
           In this case, the types of the child elements
           may be constrained, but not their order or their number of occurrences:
           
           <h5>Mixed-content Declaration</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Mixed"></a>[51]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Mixed</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'(' <a href="#NT-S">S</a>? 
                       '#PCDATA'
                       (<a href="#NT-S">S</a>? 
                       '|' 
                       <a href="#NT-S">S</a>? 
                       <a href="#NT-Name">Name</a>)* 
                       <a href="#NT-S">S</a>? 
                       ')*' 
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| '(' <a href="#NT-S">S</a>? '#PCDATA' <a href="#NT-S">S</a>? ')'
                       
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#vc-PEinGroup">Proper Group/PE Nesting</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#vc-MixedChildrenUnique">No Duplicate Types</a>&nbsp;]
                    </td>
                 </tr>
                 
                 
              </tbody>
           </table>
           where the <a href="#NT-Name">Name</a>s give the types of elements
           that may appear as children.
           
        </p>
        <a name="vc-MixedChildrenUnique"></a><p><b>Validity Constraint: No Duplicate Types</b></p>
        No Duplicate Types
        
        <p>The same name must not appear more than once in a single mixed-content
           declaration.
           
        </p>
        
        <p>Examples of mixed content declarations:
           <pre>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*>
  &lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >
  &lt;!ELEMENT b (#PCDATA)></pre></p>
        
        
        
        
        
        <h3><a name="attdecls"></a>3.3 Attribute-List Declarations
        </h3>
        
        
        <p><a href="#dt-attr">Attributes</a> are used to associate
           name-value pairs with <a href="#dt-element">elements</a>.
           Attribute specifications may appear only within <a href="#dt-stag">start-tags</a>
           and <a href="#dt-eetag">empty-element tags</a>; 
           thus, the productions used to
           recognize them appear in <a href="#sec-starttags">[<b>3.1 Start-Tags, End-Tags, and Empty-Element Tags</b>]
           </a>.  
           Attribute-list
           declarations may be used:
           
           <ul>
              
              <li>
                 <p>To define the set of attributes pertaining to a given
                    element type.
                 </p>
              </li>
              
              <li>
                 <p>To establish type constraints for these
                    attributes.
                 </p>
              </li>
              
              <li>
                 <p>To provide <a href="#dt-default">default values</a>
                    for attributes.
                 </p>
              </li>
              
           </ul>
           
        </p>
        
        <p><a name="dt-attdecl"></a>
           <b>Attribute-list declarations</b> specify the name, data type, and default
           value (if any) of each attribute associated with a given element type:
           
           <h5>Attribute-list Declaration</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-AttlistDecl"></a>[52]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>AttlistDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!ATTLIST' <a href="#NT-S">S</a> 
                       <a href="#NT-Name">Name</a> 
                       <a href="#NT-AttDef">AttDef</a>*
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-AttDef"></a>[53]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>AttDef</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-S">S</a> <a href="#NT-Name">Name</a> 
                       <a href="#NT-S">S</a> <a href="#NT-AttType">AttType</a> 
                       <a href="#NT-S">S</a> <a href="#NT-DefaultDecl">DefaultDecl</a></td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           The <a href="#NT-Name">Name</a> in the
           <a href="#NT-AttlistDecl">AttlistDecl</a> rule is the type of an element.  At
           user option, an XML processor may issue a warning if attributes are
           declared for an element type not itself declared, but this is not an
           error.  The <a href="#NT-Name">Name</a> in the 
           <a href="#NT-AttDef">AttDef</a> rule is
           the name of the attribute.
        </p>
        
        <p>
           When more than one <a href="#NT-AttlistDecl">AttlistDecl</a> is provided for a
           given element type, the contents of all those provided are merged.  When
           more than one definition is provided for the same attribute of a
           given element type, the first declaration is binding and later
           declarations are ignored.  
           <a href="#dt-interop">For interoperability,</a> writers of DTDs
           may choose to provide at most one attribute-list declaration
           for a given element type, at most one attribute definition
           for a given attribute name, and at least one attribute definition
           in each attribute-list declaration.
           For interoperability, an XML processor may at user option
           issue a warning when more than one attribute-list declaration is
           provided for a given element type, or more than one attribute definition
           is provided 
           for a given attribute, but this is not an error.
           
        </p>
        
        
        
        <h4><a name="sec-attribute-types"></a>3.3.1 Attribute Types
        </h4>
        
        
        <p>XML attribute types are of three kinds:  a string type, a
           set of tokenized types, and enumerated types.  The string type may take
           any literal string as a value; the tokenized types have varying lexical
           and semantic constraints, as noted:
           
           <h5>Attribute Types</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-AttType"></a>[54]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>AttType</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-StringType">StringType</a> 
                       | <a href="#NT-TokenizedType">TokenizedType</a> 
                       | <a href="#NT-EnumeratedType">EnumeratedType</a>
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-StringType"></a>[55]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>StringType</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'CDATA'</td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-TokenizedType"></a>[56]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>TokenizedType</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'ID'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#id">ID</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#one-id-per-el">One ID per Element Type</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#id-default">ID Attribute Default</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'IDREF'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#idref">IDREF</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'IDREFS'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#idref">IDREF</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'ENTITY'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#entname">Entity Name</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'ENTITIES'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#entname">Entity Name</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'NMTOKEN'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#nmtok">Name Token</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'NMTOKENS'</td>
                    <td>[&nbsp;VC:&nbsp;<a href="#nmtok">Name Token</a>&nbsp;]
                    </td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        <a name="id"></a><p><b>Validity Constraint: ID</b></p>
        ID
        
        <p>
           Values of type ID must match the 
           <a href="#NT-Name">Name</a> production.  
           A name must not appear more than once in
           an XML document as a value of this type; i.e., ID values must uniquely
           identify the elements which bear them.   
           
        </p>
        
        <a name="one-id-per-el"></a><p><b>Validity Constraint: One ID per Element Type</b></p>
        One ID per Element Type
        
        <p>No element type may have more than one ID attribute specified.</p>
        
        <a name="id-default"></a><p><b>Validity Constraint: ID Attribute Default</b></p>
        ID Attribute Default
        
        <p>An ID attribute must have a declared default of #IMPLIED or
           #REQUIRED.
        </p>
        
        <a name="idref"></a><p><b>Validity Constraint: IDREF</b></p>
        IDREF
        
        <p>
           Values of type IDREF must match
           the <a href="#NT-Name">Name</a> production, and
           values of type IDREFS must match
           <a href="#NT-Names">Names</a>; 
           each <a href="#NT-Name">Name</a> must match the value of an ID attribute on 
           some element in the XML document; i.e. IDREF values must 
           match the value of some ID attribute. 
           
        </p>
        
        <a name="entname"></a><p><b>Validity Constraint: Entity Name</b></p>
        Entity Name
        
        <p>
           Values of type ENTITY 
           must match the <a href="#NT-Name">Name</a> production,
           values of type ENTITIES must match
           <a href="#NT-Names">Names</a>;
           each <a href="#NT-Name">Name</a> must 
           match the
           name of an <a href="#dt-unparsed">unparsed entity</a> declared in the
           <a href="#dt-doctype">DTD</a>.
           
        </p>
        
        <a name="nmtok"></a><p><b>Validity Constraint: Name Token</b></p>
        Name Token
        
        <p>
           Values of type NMTOKEN must match the
           <a href="#NT-Nmtoken">Nmtoken</a> production;
           values of type NMTOKENS must 
           match <a href="#NT-Nmtokens">Nmtokens</a>.
           
        </p>
        
        
        
        <p><a name="dt-enumerated"></a><b>Enumerated attributes</b> can take one 
           of a list of values provided in the declaration. There are two
           kinds of enumerated types:
           
           <h5>Enumerated Attribute Types</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-EnumeratedType"></a>[57]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EnumeratedType</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-NotationType">NotationType</a> 
                       | <a href="#NT-Enumeration">Enumeration</a>
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-NotationType"></a>[58]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>NotationType</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'NOTATION' 
                       <a href="#NT-S">S</a> 
                       '(' 
                       <a href="#NT-S">S</a>?  
                       <a href="#NT-Name">Name</a> 
                       (<a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>?  
                       <a href="#NT-Name">Name</a>)*
                       <a href="#NT-S">S</a>? ')'
                       
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#notatn">Notation Attributes</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-Enumeration"></a>[59]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Enumeration</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'(' <a href="#NT-S">S</a>?
                       <a href="#NT-Nmtoken">Nmtoken</a> 
                       (<a href="#NT-S">S</a>? '|' 
                       <a href="#NT-S">S</a>?  
                       <a href="#NT-Nmtoken">Nmtoken</a>)* 
                       <a href="#NT-S">S</a>? 
                       ')'
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#enum">Enumeration</a>&nbsp;]
                    </td>
                 </tr>
              </tbody>
           </table>
           A NOTATION attribute identifies a 
           <a href="#dt-notation">notation</a>, declared in the 
           DTD with associated system and/or public identifiers, to
           be used in interpreting the element to which the attribute
           is attached.
           
        </p>
        
        <a name="notatn"></a><p><b>Validity Constraint: Notation Attributes</b></p>
        Notation Attributes
        
        <p>
           Values of this type must match
           one of the <a href="#Notations">notation</a> names included in
           the declaration; all notation names in the declaration must
           be declared.
           
        </p>
        
        <a name="enum"></a><p><b>Validity Constraint: Enumeration</b></p>
        Enumeration
        
        <p>
           Values of this type
           must match one of the <a href="#NT-Nmtoken">Nmtoken</a> tokens in the
           declaration. 
           
        </p>
        
        
        <p><a href="#dt-interop">For interoperability,</a> the same
           <a href="#NT-Nmtoken">Nmtoken</a> should not occur more than once in the
           enumerated attribute types of a single element type.
           
        </p>
        
        
        
        
        <h4><a name="sec-attr-defaults"></a>3.3.2 Attribute Defaults
        </h4>
        
        
        <p>An <a href="#dt-attdecl">attribute declaration</a> provides
           information on whether
           the attribute's presence is required, and if not, how an XML processor should
           react if a declared attribute is absent in a document.
           
           <h5>Attribute Defaults</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-DefaultDecl"></a>[60]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>DefaultDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'#REQUIRED' 
                       |&nbsp;'#IMPLIED' 
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| (('#FIXED' S)? <a href="#NT-AttValue">AttValue</a>)
                    </td>
                    <td>[&nbsp;VC:&nbsp;<a href="#RequiredAttr">Required Attribute</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#defattrvalid">Attribute Default Legal</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#CleanAttrVals">No &lt; in Attribute Values</a>&nbsp;]
                    </td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#FixedAttr">Fixed Attribute Default</a>&nbsp;]
                    </td>
                 </tr>
                 
              </tbody>
           </table>
           
           
        </p>
        
        <p>In an attribute declaration, #REQUIRED means that the
           attribute must always be provided, #IMPLIED that no default 
           value is provided.
           
           <a name="dt-default"></a>If the 
           declaration
           is neither #REQUIRED nor #IMPLIED, then the
           <a href="#NT-AttValue">AttValue</a> value contains the declared
           <b>default</b> value; the #FIXED keyword states that
           the attribute must always have the default value.
           If a default value
           is declared, when an XML processor encounters an omitted attribute, it
           is to behave as though the attribute were present with 
           the declared default value.
        </p>
        <a name="RequiredAttr"></a><p><b>Validity Constraint: Required Attribute</b></p>
        Required Attribute
        
        <p>If the default declaration is the keyword #REQUIRED, then
           the attribute must be specified for
           all elements of the type in the attribute-list declaration.
           
        </p>
        <a name="defattrvalid"></a><p><b>Validity Constraint: Attribute Default Legal</b></p>
        Attribute Default Legal
        
        <p>
           The declared
           default value must meet the lexical constraints of the declared attribute type.
           
        </p>
        
        <a name="FixedAttr"></a><p><b>Validity Constraint: Fixed Attribute Default</b></p>
        Fixed Attribute Default
        
        <p>If an attribute has a default value declared with the 
           #FIXED keyword, instances of that attribute must
           match the default value.
           
        </p>
        
        
        <p>Examples of attribute-list declarations:
           <pre>&lt;!ATTLIST termdef
            id      ID      #REQUIRED
            name    CDATA   #IMPLIED>
  &lt;!ATTLIST list
            type    (bullets|ordered|glossary)  "ordered">
  &lt;!ATTLIST form
            method  CDATA   #FIXED "POST"></pre></p>
        
        
        
        <h4><a name="AVNormalize"></a>3.3.3 Attribute-Value Normalization
        </h4>
        
        <p>Before the value of an attribute is passed to the application
           or checked for validity, the
           XML processor must normalize it as follows:
           
           <ul>
              
              <li>
                 <p>a character reference is processed by appending the referenced    
                    character to the attribute value
                 </p>
              </li>
              
              <li>
                 <p>an entity reference is processed by recursively processing the
                    replacement text of the entity
                 </p>
              </li>
              
              <li>
                 <p>a whitespace character (#x20, #xD, #xA, #x9) is processed by
                    appending #x20 to the normalized value, except that only a single #x20
                    is appended for a "#xD#xA" sequence that is part of an external
                    parsed entity or the literal entity value of an internal parsed
                    entity
                 </p>
              </li>
              
              <li>
                 <p>other characters are processed by appending them to the normalized
                    value
                 </p>
                 
              </li>
           </ul>
           
        </p>
        
        <p>If the declared value is not CDATA, then the XML processor must
           further process the normalized attribute value by discarding any
           leading and trailing space (#x20) characters, and by replacing
           sequences of space (#x20) characters by a single space (#x20)
           character.
        </p>
        
        <p>
           All attributes for which no declaration has been read should be treated
           by a non-validating parser as if declared
           CDATA.
           
        </p>
        
        
        
        
        <h3><a name="sec-condition-sect"></a>3.4 Conditional Sections
        </h3>
        
        <p><a name="dt-cond-section"></a>
           <b>Conditional sections</b> are portions of the
           <a href="#dt-doctype">document type declaration external subset</a>
           which are 
           included in, or excluded from, the logical structure of the DTD based on
           the keyword which governs them.
           
           <h5>Conditional Section</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-conditionalSect"></a>[61]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>conditionalSect</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-includeSect">includeSect</a>
                       | <a href="#NT-ignoreSect">ignoreSect</a>
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-includeSect"></a>[62]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>includeSect</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;![' S? 'INCLUDE' S? '[' 
                       
                       <a href="#NT-extSubsetDecl">extSubsetDecl</a>
                       ']]>'
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-ignoreSect"></a>[63]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>ignoreSect</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;![' S? 'IGNORE' S? '[' 
                       <a href="#NT-ignoreSectContents">ignoreSectContents</a>*
                       ']]>'
                    </td>
                    <td></td>
                 </tr>
                 
                 
                 <tr valign="baseline">
                    <td><a name="NT-ignoreSectContents"></a>[64]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>ignoreSectContents</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Ignore">Ignore</a>
                       ('&lt;![' <a href="#NT-ignoreSectContents">ignoreSectContents</a> ']]>' 
                       <a href="#NT-Ignore">Ignore</a>)*
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Ignore"></a>[65]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Ignore</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-Char">Char</a>* - 
                       (<a href="#NT-Char">Char</a>* ('&lt;![' | ']]>') 
                       <a href="#NT-Char">Char</a>*)
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 
              </tbody>
           </table>
           
        </p>
        
        <p>Like the internal and external DTD subsets, a conditional section
           may contain one or more complete declarations,
           comments, processing instructions, 
           or nested conditional sections, intermingled with white space.
           
        </p>
        
        <p>If the keyword of the
           conditional section is INCLUDE, then the contents of the conditional
           section are part of the DTD.
           If the keyword of the conditional
           section is IGNORE, then the contents of the conditional section are
           not logically part of the DTD.
           Note that for reliable parsing, the contents of even ignored
           conditional sections must be read in order to
           detect nested conditional sections and ensure that the end of the
           outermost (ignored) conditional section is properly detected.
           If a conditional section with a
           keyword of INCLUDE occurs within a larger conditional
           section with a keyword of IGNORE, both the outer and the
           inner conditional sections are ignored.
        </p>
        
        <p>If the keyword of the conditional section is a 
           parameter-entity reference, the parameter entity must be replaced by its
           content before the processor decides whether to
           include or ignore the conditional section.
        </p>
        
        <p>An example:
           <pre>&lt;!ENTITY % draft 'INCLUDE' >
  &lt;!ENTITY % final 'IGNORE' >
   
  &lt;![%draft;[
  &lt;!ELEMENT book (comments*, title, body, supplements?)>
  ]]>
  &lt;![%final;[
  &lt;!ELEMENT book (title, body, supplements?)>
  ]]>
  </pre>
           </p>
        
        
        
         
        
        
        
        
        
        
        <h2><a name="sec-physical-struct"></a>4 Physical Structures
        </h2>
        
        
        <p><a name="dt-entity"></a>An XML document may consist
           of one or many storage units.   These are called
           <b>entities</b>; they all have <b>content</b> and are all
           (except for the document entity, see below, and 
           the <a href="#dt-doctype">external DTD subset</a>) 
           identified by <b>name</b>.
           
           Each XML document has one entity
           called the <a href="#dt-docent">document entity</a>, which serves
           as the starting point for the <a href="#dt-xml-proc">XML
              processor
           </a> and may contain the whole document.
        </p>
        
        <p>Entities may be either parsed or unparsed.
           <a name="dt-parsedent"></a>A <b>parsed entity's</b>
           contents are referred to as its 
           <a href="#dt-repltext">replacement text</a>;
           this <a href="#dt-text">text</a> is considered an
           integral part of the document.
        </p>
        
        
        <p><a name="dt-unparsed"></a>An 
           <b>unparsed entity</b> 
           is a resource whose contents may or may not be
           <a href="#dt-text">text</a>, and if text, may not be XML.
           Each unparsed entity
           has an associated <a href="#dt-notation">notation</a>, identified by name.
           Beyond a requirement
           that an XML processor make the identifiers for the entity and 
           notation available to the application,
           XML places no constraints on the contents of unparsed entities. 
           
        </p>
        
        <p>
           Parsed entities are invoked by name using entity references;
           unparsed entities by name, given in the value of ENTITY
           or ENTITIES
           attributes.
        </p>
        
        <p><a name="gen-entity"></a><b>General entities</b>
           are entities for use within the document content.
           In this specification, general entities are sometimes referred 
           to with the unqualified term <i>entity</i> when this leads
           to no ambiguity. 
           <a name="dt-PE"></a>Parameter entities 
           are parsed entities for use within the DTD.
           These two types of entities use different forms of reference and
           are recognized in different contexts.
           Furthermore, they occupy different namespaces; a parameter entity and
           a general entity with the same name are two distinct entities.
           
        </p>
        
        
        
        <h3><a name="sec-references"></a>4.1 Character and Entity References
        </h3>
        
        <p><a name="dt-charref"></a>
           A <b>character reference</b> refers to a specific character in the
           ISO/IEC 10646 character set, for example one not directly accessible from
           available input devices.
           
           <h5>Character Reference</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-CharRef"></a>[66]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CharRef</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&amp;#' [0-9]+ ';' </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| '&amp;#x' [0-9a-fA-F]+ ';'</td>
                    <td>[&nbsp;WFC:&nbsp;<a href="#wf-Legalchar">Legal Character</a>&nbsp;]
                    </td>
                 </tr>
              </tbody>
           </table>
           <a name="wf-Legalchar"></a><p><b>Well Formedness Constraint: Legal Character</b></p>
           Legal Character
           
           <p>Characters referred to using character references must
              match the production for
              <a href="#NT-Char">Char</a>.
           </p>
           
           If the character reference begins with "<code>&amp;#x</code>", the digits and
           letters up to the terminating <code>;</code> provide a hexadecimal
           representation of the character's code point in ISO/IEC 10646.
           If it begins just with "<code>&amp;#</code>", the digits up to the terminating
           <code>;</code> provide a decimal representation of the character's 
           code point.
           
           
        </p>
        
        <p><a name="dt-entref"></a>An <b>entity
              reference
           </b> refers to the content of a named entity.
           <a name="dt-GERef"></a>References to 
           parsed general entities
           use ampersand (<code>&amp;</code>) and semicolon (<code>;</code>) as
           delimiters.
           <a name="dt-PERef"></a>
           <b>Parameter-entity references</b> use percent-sign (<code>%</code>) and
           semicolon 
           (<code>;</code>) as delimiters.
           
        </p>
        
        <h5>Entity Reference</h5>
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-Reference"></a>[67]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Reference</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-EntityRef">EntityRef</a> 
                    | <a href="#NT-CharRef">CharRef</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-EntityRef"></a>[68]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>EntityRef</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'&amp;' <a href="#NT-Name">Name</a> ';'
                 </td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#wf-entdeclared">Entity Declared</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;VC:&nbsp;<a href="#vc-entdeclared">Entity Declared</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#textent">Parsed Entity</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#norecursion">No Recursion</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-PEReference"></a>[69]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>PEReference</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'%' <a href="#NT-Name">Name</a> ';'
                 </td>
                 <td>[&nbsp;VC:&nbsp;<a href="#vc-entdeclared">Entity Declared</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#norecursion">No Recursion</a>&nbsp;]
                 </td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>[&nbsp;WFC:&nbsp;<a href="#indtd">In DTD</a>&nbsp;]
                 </td>
              </tr>
           </tbody>
        </table>
        
        <a name="wf-entdeclared"></a><p><b>Well Formedness Constraint: Entity Declared</b></p>
        Entity Declared
        
        <p>In a document without any DTD, a document with only an internal
           DTD subset which contains no parameter entity references, or a document with
           "<code>standalone='yes'</code>", 
           the <a href="#NT-Name">Name</a> given in the entity reference must 
           <a href="#dt-match">match</a> that in an 
           <a href="#sec-entity-decl">entity declaration</a>, except that
           well-formed documents need not declare 
           any of the following entities: <code>amp</code>,
           <code>lt</code>,
           <code>gt</code>,
           <code>apos</code>,
           <code>quot</code>.  
           The declaration of a parameter entity must precede any reference to it.
           Similarly, the declaration of a general entity must precede any
           reference to it which appears in a default value in an attribute-list
           declaration.
        </p>
        
        <p>Note that if entities are declared in the external subset or in 
           external parameter entities, a non-validating processor is 
           <a href="#include-if-valid">not obligated to</a> read
           and process their declarations; for such documents, the rule that
           an entity must be declared is a well-formedness constraint only
           if <a href="#sec-rmd">standalone='yes'</a>.
        </p>
        
        <a name="vc-entdeclared"></a><p><b>Validity Constraint: Entity Declared</b></p>
        Entity Declared
        
        <p>In a document with an external subset or external parameter
           entities with "<code>standalone='no'</code>",
           the <a href="#NT-Name">Name</a> given in the entity reference must <a href="#dt-match">match</a> that in an 
           <a href="#sec-entity-decl">entity declaration</a>.
           For interoperability, valid documents should declare the entities 
           <code>amp</code>,
           <code>lt</code>,
           <code>gt</code>,
           <code>apos</code>,
           <code>quot</code>, in the form
           specified in <a href="#sec-predefined-ent">[<b>4.6 Predefined Entities</b>]
           </a>.
           The declaration of a parameter entity must precede any reference to it.
           Similarly, the declaration of a general entity must precede any
           reference to it which appears in a default value in an attribute-list
           declaration.
        </p>
        
        
        <a name="textent"></a><p><b>Well Formedness Constraint: Parsed Entity</b></p>
        Parsed Entity
        
        <p>
           An entity reference must not contain the name of an <a href="#dt-unparsed">unparsed entity</a>. Unparsed entities may be referred
           to only in <a href="#dt-attrval">attribute values</a> declared to
           be of type ENTITY or ENTITIES.
           
        </p>
        
        <a name="norecursion"></a><p><b>Well Formedness Constraint: No Recursion</b></p>
        No Recursion
        
        <p>
           A parsed entity must not contain a recursive reference to itself,
           either directly or indirectly.
           
        </p>
        
        <a name="indtd"></a><p><b>Well Formedness Constraint: In DTD</b></p>
        In DTD
        
        <p>
           Parameter-entity references may only appear in the 
           <a href="#dt-doctype">DTD</a>.
           
        </p>
        
        
        <p>Examples of character and entity references:
           <pre>Type &lt;key>less-than&lt;/key> (&amp;#x3C;) to save options.
  This document was prepared on &amp;docdate; and
  is classified &amp;security-level;.</pre></p>
        
        <p>Example of a parameter-entity reference:
           <pre>&lt;!-- declare the parameter entity "ISOLat2"... -->
  &lt;!ENTITY % ISOLat2
           SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
  &lt;!-- ... now reference it. -->
  %ISOLat2;</pre></p>
        
        
        
        
        <h3><a name="sec-entity-decl"></a>4.2 Entity Declarations
        </h3>
        
        
        <p><a name="dt-entdecl"></a>
           Entities are declared thus:
           
           <h5>Entity Declaration</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-EntityDecl"></a>[70]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EntityDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-GEDecl">GEDecl</a> | <a href="#NT-PEDecl">PEDecl</a></td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-GEDecl"></a>[71]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>GEDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!ENTITY' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> 
                       <a href="#NT-S">S</a> <a href="#NT-EntityDef">EntityDef</a> 
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-PEDecl"></a>[72]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PEDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!ENTITY' <a href="#NT-S">S</a> '%' <a href="#NT-S">S</a> 
                       <a href="#NT-Name">Name</a> <a href="#NT-S">S</a> 
                       <a href="#NT-PEDef">PEDef</a> <a href="#NT-S">S</a>? '>'
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-EntityDef"></a>[73]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EntityDef</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-EntityValue">EntityValue</a>
                       | (<a href="#NT-ExternalID">ExternalID</a> 
                       <a href="#NT-NDataDecl">NDataDecl</a>?)
                    </td>
                    <td></td>
                 </tr>
                 
                 
                 <tr valign="baseline">
                    <td><a name="NT-PEDef"></a>[74]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PEDef</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-EntityValue">EntityValue</a> 
                       | <a href="#NT-ExternalID">ExternalID</a></td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
           The <a href="#NT-Name">Name</a> identifies the entity in an
           <a href="#dt-entref">entity reference</a> or, in the case of an
           unparsed entity, in the value of an ENTITY or ENTITIES
           attribute.
           If the same entity is declared more than once, the first declaration
           encountered is binding; at user option, an XML processor may issue a
           warning if entities are declared multiple times.
           
        </p>
        
        
        
        <h4><a name="sec-internal-ent"></a>4.2.1 Internal Entities
        </h4>
        
        
        <p><a name="dt-internent"></a>If 
           the entity definition is an 
           <a href="#NT-EntityValue">EntityValue</a>,  
           the defined entity is called an <b>internal entity</b>.  
           There is no separate physical
           storage object, and the content of the entity is given in the
           declaration. 
           Note that some processing of entity and character references in the
           <a href="#dt-litentval">literal entity value</a> may be required to
           produce the correct <a href="#dt-repltext">replacement 
              text
           </a>: see <a href="#intern-replacement">[<b>4.5 Construction of Internal Entity Replacement Text</b>]
           </a>.
           
        </p>
        
        <p>An internal entity is a <a href="#dt-parsedent">parsed
              entity
           </a>.
        </p>
        
        <p>Example of an internal entity declaration:
           <pre>&lt;!ENTITY Pub-Status "This is a pre-release of the
   specification."></pre></p>
        
        
        
        
        <h4><a name="sec-external-ent"></a>4.2.2 External Entities
        </h4>
        
        
        <p><a name="dt-extent"></a>If the entity is not
           internal, it is an <b>external
              entity
           </b>, declared as follows:
           
           <h5>External Entity Declaration</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-ExternalID"></a>[75]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>ExternalID</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'SYSTEM' <a href="#NT-S">S</a> 
                       <a href="#NT-SystemLiteral">SystemLiteral</a></td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td>| 'PUBLIC' <a href="#NT-S">S</a> 
                       <a href="#NT-PubidLiteral">PubidLiteral</a> 
                       <a href="#NT-S">S</a> 
                       <a href="#NT-SystemLiteral">SystemLiteral</a>
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-NDataDecl"></a>[76]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>NDataDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-S">S</a> 'NDATA' <a href="#NT-S">S</a> 
                       <a href="#NT-Name">Name</a></td>
                    <td>[&nbsp;VC:&nbsp;<a href="#not-declared">Notation Declared</a>&nbsp;]
                    </td>
                 </tr>
              </tbody>
           </table>
           If the <a href="#NT-NDataDecl">NDataDecl</a> is present, this is a
           general <a href="#dt-unparsed">unparsed
              entity
           </a>; otherwise it is a parsed entity.
        </p>
        <a name="not-declared"></a><p><b>Validity Constraint: Notation Declared</b></p>
        Notation Declared
        
        <p>
           The <a href="#NT-Name">Name</a> must match the declared name of a
           <a href="#dt-notation">notation</a>.
           
        </p>
        
        
        <p><a name="dt-sysid"></a>The
           <a href="#NT-SystemLiteral">SystemLiteral</a> 
           is called the entity's <b>system identifier</b>. It is a URI,
           which may be used to retrieve the entity.
           Note that the hash mark (<code>#</code>) and fragment identifier 
           frequently used with URIs are not, formally, part of the URI itself; 
           an XML processor may signal an error if a fragment identifier is 
           given as part of a system identifier.
           Unless otherwise provided by information outside the scope of this
           specification (e.g. a special XML element type defined by a particular
           DTD, or a processing instruction defined by a particular application
           specification), relative URIs are relative to the location of the
           resource within which the entity declaration occurs.
           A URI might thus be relative to the 
           <a href="#dt-docent">document entity</a>, to the entity
           containing the <a href="#dt-doctype">external DTD subset</a>, 
           or to some other <a href="#dt-extent">external parameter entity</a>.
           
        </p>
        
        <p>An XML processor should handle a non-ASCII character in a URI by
           representing the character in UTF-8 as one or more bytes, and then 
           escaping these bytes with the URI escaping mechanism (i.e., by
           converting each byte to %HH, where HH is the hexadecimal notation of the
           byte value).
        </p>
        
        <p><a name="dt-pubid"></a>
           In addition to a system identifier, an external identifier may
           include a <b>public identifier</b>.  
           An XML processor attempting to retrieve the entity's content may use the public
           identifier to try to generate an alternative URI.  If the processor
           is unable to do so, it must use the URI specified in the system
           literal.  Before a match is attempted, all strings
           of white space in the public identifier must be normalized to single space characters (#x20),
           and leading and trailing white space must be removed.
        </p>
        
        <p>Examples of external entity declarations:
           <pre>&lt;!ENTITY open-hatch
           SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
  &lt;!ENTITY open-hatch
           PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
           "http://www.textuality.com/boilerplate/OpenHatch.xml">
  &lt;!ENTITY hatch-pic
           SYSTEM "../grafix/OpenHatch.gif"
           NDATA gif ></pre></p>
        
        
        
        
        
        
        <h3><a name="TextEntities"></a>4.3 Parsed Entities
        </h3>
        
        
        <h4><a name="sec-TextDecl"></a>4.3.1 The Text Declaration
        </h4>
        
        <p>External parsed entities may each begin with a <b>text
              declaration
           </b>. 
           
           <h5>Text Declaration</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-TextDecl"></a>[77]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>TextDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;?xml' 
                       <a href="#NT-VersionInfo">VersionInfo</a>?
                       <a href="#NT-EncodingDecl">EncodingDecl</a>
                       <a href="#NT-S">S</a>? '?>'
                    </td>
                    <td></td>
                 </tr>
                 
              </tbody>
           </table>
           
        </p>
        
        <p>The text declaration must be provided literally, not
           by reference to a parsed entity.
           No text declaration may appear at any position other than the beginning of
           an external parsed entity.
        </p>
        
        
        
        <h4><a name="wf-entities"></a>4.3.2 Well-Formed Parsed Entities
        </h4>
        
        <p>The document entity is well-formed if it matches the production labeled
           <a href="#NT-document">document</a>.
           An external general 
           parsed entity is well-formed if it matches the production labeled
           <a href="#NT-extParsedEnt">extParsedEnt</a>.
           An external parameter
           entity is well-formed if it matches the production labeled
           <a href="#NT-extPE">extPE</a>.
           
           <h5>Well-Formed External Parsed Entity</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-extParsedEnt"></a>[78]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>extParsedEnt</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-TextDecl">TextDecl</a>? 
                       <a href="#NT-content">content</a></td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-extPE"></a>[79]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>extPE</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-TextDecl">TextDecl</a>? 
                       <a href="#NT-extSubsetDecl">extSubsetDecl</a></td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           An internal general parsed entity is well-formed if its replacement text 
           matches the production labeled
           <a href="#NT-content">content</a>.
           All internal parameter entities are well-formed by definition.
           
        </p>
        
        <p>A consequence of well-formedness in entities is that the logical 
           and physical structures in an XML document are properly nested; no 
           <a href="#dt-stag">start-tag</a>,
           <a href="#dt-etag">end-tag</a>,
           <a href="#dt-empty">empty-element tag</a>,
           <a href="#dt-element">element</a>, 
           <a href="#dt-comment">comment</a>, 
           <a href="#dt-pi">processing instruction</a>, 
           <a href="#dt-charref">character
              reference
           </a>, or
           <a href="#dt-entref">entity reference</a> 
           can begin in one entity and end in another.
        </p>
        
        
        
        <h4><a name="charencoding"></a>4.3.3 Character Encoding in Entities
        </h4>
        
        
        <p>Each external parsed entity in an XML document may use a different
           encoding for its characters. All XML processors must be able to read
           entities in either UTF-8 or UTF-16. 
           
           
        </p>
        
        <p>Entities encoded in UTF-16 must
           begin with the Byte Order Mark described by ISO/IEC 10646 Annex E and
           Unicode Appendix B (the ZERO WIDTH NO-BREAK SPACE character, #xFEFF).
           This is an encoding signature, not part of either the markup or the
           character data of the XML document.
           XML processors must be able to use this character to
           differentiate between UTF-8 and UTF-16 encoded documents.
        </p>
        
        <p>Although an XML processor is required to read only entities in
           the UTF-8 and UTF-16 encodings, it is recognized that other encodings are
           used around the world, and it may be desired for XML processors
           to read entities that use them.
           Parsed entities which are stored in an encoding other than
           UTF-8 or UTF-16 must begin with a <a href="#TextDecl">text
              declaration
           </a> containing an encoding declaration:
           
           <h5>Encoding Declaration</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-EncodingDecl"></a>[80]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EncodingDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-S">S</a>
                       'encoding' <a href="#NT-Eq">Eq</a> 
                       ('"' <a href="#NT-EncName">EncName</a> '"' | 
                       "'" <a href="#NT-EncName">EncName</a> "'" )
                       
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-EncName"></a>[81]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>EncName</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[A-Za-z] ([A-Za-z0-9._] | '-')*</td>
                    <td>/*Encoding name contains only Latin characters*/</td>
                 </tr>
              </tbody>
           </table>
           In the <a href="#dt-docent">document entity</a>, the encoding
           declaration is part of the <a href="#dt-xmldecl">XML declaration</a>.
           The <a href="#NT-EncName">EncName</a> is the name of the encoding used.
           
        </p>
        
        
        <p>In an encoding declaration, the values
           "<code>UTF-8</code>",
           "<code>UTF-16</code>",
           "<code>ISO-10646-UCS-2</code>", and
           "<code>ISO-10646-UCS-4</code>" should be 
           used for the various encodings and transformations of Unicode /
           ISO/IEC 10646, the values
           "<code>ISO-8859-1</code>",
           "<code>ISO-8859-2</code>", ...
           "<code>ISO-8859-9</code>" should be used for the parts of ISO 8859, and
           the values
           "<code>ISO-2022-JP</code>",
           "<code>Shift_JIS</code>", and
           "<code>EUC-JP</code>"
           should be used for the various encoded forms of JIS X-0208-1997.  XML
           processors may recognize other encodings; it is recommended that
           character encodings registered (as <i>charset</i>s) 
           with the Internet Assigned Numbers
           Authority <a href="#IANA">[IANA]</a>, other than those just listed, should be
           referred to
           using their registered names.
           Note that these registered names are defined to be 
           case-insensitive, so processors wishing to match against them 
           should do so in a case-insensitive
           way.
        </p>
        
        <p>In the absence of information provided by an external
           transport protocol (e.g. HTTP or MIME), 
           it is an <a href="#dt-error">error</a> for an entity including
           an encoding declaration to be presented to the XML processor 
           in an encoding other than that named in the declaration, 
           for an encoding declaration to occur other than at the beginning 
           of an external entity, or for
           an entity which begins with neither a Byte Order Mark nor an encoding
           declaration to use an encoding other than UTF-8.
           Note that since ASCII
           is a subset of UTF-8, ordinary ASCII entities do not strictly need
           an encoding declaration.
        </p>
        
        
        <p>It is a <a href="#dt-fatal">fatal error</a> when an XML processor
           encounters an entity with an encoding that it is unable to process.
        </p>
        
        <p>Examples of encoding declarations:
           <pre>&lt;?xml encoding='UTF-8'?>
  &lt;?xml encoding='EUC-JP'?></pre></p>
        
        
        
        
        <h3><a name="entproc"></a>4.4 XML Processor Treatment of Entities and References
        </h3>
        
        <p>The table below summarizes the contexts in which character references,
           entity references, and invocations of unparsed entities might appear and the
           required behavior of an <a href="#dt-xml-proc">XML processor</a> in
           each case.  
           The labels in the leftmost column describe the recognition context:
           
           <dl>
              
              <dt><b>Reference in Content</b></dt>
              
              <dd>
                 <p>as a reference
                    anywhere after the <a href="#dt-stag">start-tag</a> and
                    before the <a href="#dt-etag">end-tag</a> of an element; corresponds
                    to the nonterminal <a href="#NT-content">content</a>.
                 </p>
              </dd>
              
              
              
              <dt><b>Reference in Attribute Value</b></dt>
              
              <dd>
                 <p>as a reference within either the value of an attribute in a 
                    <a href="#dt-stag">start-tag</a>, or a default
                    value in an <a href="#dt-attdecl">attribute declaration</a>;
                    corresponds to the nonterminal
                    <a href="#NT-AttValue">AttValue</a>.
                 </p>
              </dd>
              
              
              <dt><b>Occurs as Attribute Value</b></dt>
              
              <dd>
                 <p>as a <a href="#NT-Name">Name</a>, not a reference, appearing either as
                    the value of an 
                    attribute which has been declared as type ENTITY, or as one of
                    the space-separated tokens in the value of an attribute which has been
                    declared as type ENTITIES.
                 </p>
                 
              </dd>
              
              <dt><b>Reference in Entity Value</b></dt>
              
              <dd>
                 <p>as a reference
                    within a parameter or internal entity's 
                    <a href="#dt-litentval">literal entity value</a> in
                    the entity's declaration; corresponds to the nonterminal 
                    <a href="#NT-EntityValue">EntityValue</a>.
                 </p>
              </dd>
              
              <dt><b>Reference in DTD</b></dt>
              
              <dd>
                 <p>as a reference within either the internal or external subsets of the 
                    <a href="#dt-doctype">DTD</a>, but outside
                    of an <a href="#NT-EntityValue">EntityValue</a> or
                    <a href="#NT-AttValue">AttValue</a>.
                 </p>
              </dd>
              
              
           </dl>
        </p>
        
        <table border="1" cellpadding="7" align="center">
           
           <tbody>
              
              <tr align="" valign="">
                 <td bgcolor="#c0d9c0" rowspan="2" colspan="1" align="" valign=""></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="4" align="center" valign="bottom">Entity Type</td>
                 
                 <td bgcolor="#c0d9c0" rowspan="2" colspan="1" align="center" valign="">Character</td>
                 
              </tr>
              
              <tr align="center" valign="bottom">
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign="">Parameter</td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign="">Internal
                    General
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign="">External Parsed
                    General
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign="">Unparsed</td>
                 
              </tr>
              
              <tr align="center" valign="middle">
                 
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="right" valign="">Reference
                    in Content
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not-recognized">Not recognized</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#included">Included</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#include-if-valid">Included if validating</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#included">Included</a></td>
                 
              </tr>
              
              <tr align="center" valign="middle">
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="right" valign="">Reference
                    in Attribute Value
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not-recognized">Not recognized</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#inliteral">Included in literal</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#included">Included</a></td>
                 
              </tr>
              
              <tr align="center" valign="middle">
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="right" valign="">Occurs as
                    Attribute Value
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not-recognized">Not recognized</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not-recognized">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not-recognized">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#notify">Notify</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#not%20recognized">Not recognized</a></td>
                 
              </tr>
              
              <tr align="center" valign="middle">
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="right" valign="">Reference
                    in EntityValue
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#inliteral">Included in literal</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#bypass">Bypassed</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#bypass">Bypassed</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#included">Included</a></td>
                 
              </tr>
              
              <tr align="center" valign="middle">
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="right" valign="">Reference
                    in DTD
                 </td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#as-PE">Included as PE</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
                 <td bgcolor="#c0d9c0" rowspan="1" colspan="1" align="" valign=""><a href="#forbidden">Forbidden</a></td>
                 
              </tr>
              
           </tbody>
           
        </table>
        
        
        <h4><a name="not-recognized"></a>4.4.1 Not Recognized
        </h4>
        
        <p>Outside the DTD, the <code>%</code> character has no
           special significance; thus, what would be parameter entity references in the
           DTD are not recognized as markup in <a href="#NT-content">content</a>.
           Similarly, the names of unparsed entities are not recognized except
           when they appear in the value of an appropriately declared attribute.
           
        </p>
        
        
        
        <h4><a name="included"></a>4.4.2 Included
        </h4>
        
        <p><a name="dt-include"></a>An entity is 
           <b>included</b> when its 
           <a href="#dt-repltext">replacement text</a> is retrieved 
           and processed, in place of the reference itself,
           as though it were part of the document at the location the
           reference was recognized.
           The replacement text may contain both 
           <a href="#dt-chardata">character data</a>
           and (except for parameter entities) <a href="#dt-markup">markup</a>,
           which must be recognized in
           the usual way, except that the replacement text of entities used to escape
           markup delimiters (the entities <code>amp</code>,
           <code>lt</code>,
           <code>gt</code>,
           <code>apos</code>,
           <code>quot</code>) is always treated as
           data.  (The string "<code>AT&amp;amp;T;</code>" expands to
           "<code>AT&amp;T;</code>" and the remaining ampersand is not recognized
           as an entity-reference delimiter.) 
           A character reference is <b>included</b> when the indicated
           character is processed in place of the reference itself.
           
        </p>
        
        
        
        <h4><a name="include-if-valid"></a>4.4.3 Included If Validating
        </h4>
        
        <p>When an XML processor recognizes a reference to a parsed entity, in order
           to <a href="#dt-valid">validate</a>
           the document, the processor must 
           <a href="#dt-include">include</a> its
           replacement text.
           If the entity is external, and the processor is not
           attempting to validate the XML document, the
           processor <a href="#dt-may">may</a>, but need not, 
           include the entity's replacement text.
           If a non-validating parser does not include the replacement text,
           it must inform the application that it recognized, but did not
           read, the entity.
        </p>
        
        <p>This rule is based on the recognition that the automatic inclusion
           provided by the SGML and XML entity mechanism, primarily designed
           to support modularity in authoring, is not necessarily 
           appropriate for other applications, in particular document browsing.
           Browsers, for example, when encountering an external parsed entity reference,
           might choose to provide a visual indication of the entity's
           presence and retrieve it for display only on demand.
           
        </p>
        
        
        
        <h4><a name="forbidden"></a>4.4.4 Forbidden
        </h4>
        
        <p>The following are forbidden, and constitute
           <a href="#dt-fatal">fatal</a> errors:
           
           <ul>
              
              <li>
                 <p>the appearance of a reference to an
                    <a href="#dt-unparsed">unparsed entity</a>.
                    
                 </p>
              </li>
              
              <li>
                 <p>the appearance of any character or general-entity reference in the
                    DTD except within an <a href="#NT-EntityValue">EntityValue</a> or 
                    <a href="#NT-AttValue">AttValue</a>.
                 </p>
              </li>
              
              <li>
                 <p>a reference to an external entity in an attribute value.</p>
                 
              </li>
              
           </ul>
           
        </p>
        
        
        
        <h4><a name="inliteral"></a>4.4.5 Included in Literal
        </h4>
        
        <p>When an <a href="#dt-entref">entity reference</a> appears in an
           attribute value, or a parameter entity reference appears in a literal entity
           value, its <a href="#dt-repltext">replacement text</a> is
           processed in place of the reference itself as though it
           were part of the document at the location the reference was recognized,
           except that a single or double quote character in the replacement text
           is always treated as a normal data character and will not terminate the
           literal. 
           For example, this is well-formed:
           <pre>&lt;!ENTITY % YN '"Yes"' >
  &lt;!ENTITY WhatHeSaid "He said &amp;YN;" ></pre>
           while this is not:
           <pre>&lt;!ENTITY EndAttr "27'" >
  &lt;element attribute='a-&amp;EndAttr;></pre>
           </p>
        
        
        <h4><a name="notify"></a>4.4.6 Notify
        </h4>
        
        <p>When the name of an <a href="#dt-unparsed">unparsed
              entity
           </a> appears as a token in the
           value of an attribute of declared type ENTITY or ENTITIES,
           a validating processor must inform the
           application of the <a href="#dt-sysid">system</a> 
           and <a href="#dt-pubid">public</a> (if any)
           identifiers for both the entity and its associated
           <a href="#dt-notation">notation</a>.
        </p>
        
        
        
        <h4><a name="bypass"></a>4.4.7 Bypassed
        </h4>
        
        <p>When a general entity reference appears in the
           <a href="#NT-EntityValue">EntityValue</a> in an entity declaration,
           it is bypassed and left as is.
        </p>
        
        
        
        <h4><a name="as-PE"></a>4.4.8 Included as PE
        </h4>
        
        <p>Just as with external parsed entities, parameter entities
           need only be <a href="#include-if-valid">included if
              validating
           </a>. 
           When a parameter-entity reference is recognized in the DTD
           and included, its 
           <a href="#dt-repltext">replacement
              text
           </a> is enlarged by the attachment of one leading and one following
           space (#x20) character; the intent is to constrain the replacement
           text of parameter 
           entities to contain an integral number of grammatical tokens in the DTD.
           
        </p>
        
        
        
        
        
        <h3><a name="intern-replacement"></a>4.5 Construction of Internal Entity Replacement Text
        </h3>
        
        <p>In discussing the treatment
           of internal entities, it is  
           useful to distinguish two forms of the entity's value.
           <a name="dt-litentval"></a>The <b>literal
              entity value
           </b> is the quoted string actually
           present in the entity declaration, corresponding to the
           non-terminal <a href="#NT-EntityValue">EntityValue</a>.
           <a name="dt-repltext"></a>The <b>replacement
              text
           </b> is the content of the entity, after
           replacement of character references and parameter-entity
           references.
           
        </p>
        
        
        <p>The literal entity value 
           as given in an internal entity declaration
           (<a href="#NT-EntityValue">EntityValue</a>) may contain character,
           parameter-entity, and general-entity references.
           Such references must be contained entirely within the
           literal entity value.
           The actual replacement text that is 
           <a href="#dt-include">included</a> as described above
           must contain the <i>replacement text</i> of any 
           parameter entities referred to, and must contain the character
           referred to, in place of any character references in the
           literal entity value; however,
           general-entity references must be left as-is, unexpanded.
           For example, given the following declarations:
           
           <pre>&lt;!ENTITY % pub    "&amp;#xc9;ditions Gallimard" >
  &lt;!ENTITY   rights "All rights reserved" >
  &lt;!ENTITY   book   "La Peste: Albert Camus, 
  &amp;#xA9; 1947 %pub;. &amp;rights;" ></pre>
           then the replacement text for the entity "<code>book</code>" is:
           <pre>La Peste: Albert Camus, 
  &copy; 1947 &Eacute;ditions Gallimard. &amp;rights;</pre>
           The general-entity reference "<code>&amp;rights;</code>" would be expanded
           should the reference "<code>&amp;book;</code>" appear in the document's
           content or an attribute value.
        </p>
        
        <p>These simple rules may have complex interactions; for a detailed
           discussion of a difficult example, see
           <a href="#sec-entexpand">[<b>D Expansion of Entity and Character References</b>]
           </a>.
           
        </p>
        
        
        
        
        <h3><a name="sec-predefined-ent"></a>4.6 Predefined Entities
        </h3>
        
        <p><a name="dt-escape"></a>Entity and character
           references can both be used to <b>escape</b> the left angle bracket,
           ampersand, and other delimiters.   A set of general entities
           (<code>amp</code>,
           <code>lt</code>,
           <code>gt</code>,
           <code>apos</code>,
           <code>quot</code>) is specified for this purpose.
           Numeric character references may also be used; they are
           expanded immediately when recognized and must be treated as
           character data, so the numeric character references
           "<code>&amp;#60;</code>" and "<code>&amp;#38;</code>" may be used to 
           escape <code>&lt;</code> and <code>&amp;</code> when they occur
           in character data.
        </p>
        
        <p>All XML processors must recognize these entities whether they
           are declared or not.  
           <a href="#dt-interop">For interoperability</a>,
           valid XML documents should declare these
           entities, like any others, before using them.
           If the entities in question are declared, they must be declared
           as internal entities whose replacement text is the single
           character being escaped or a character reference to
           that character, as shown below.
           <pre>&lt;!ENTITY lt     "&amp;#38;#60;"> 
  &lt;!ENTITY gt     "&amp;#62;"> 
  &lt;!ENTITY amp    "&amp;#38;#38;"> 
  &lt;!ENTITY apos   "&amp;#39;"> 
  &lt;!ENTITY quot   "&amp;#34;"> 
  </pre>
           Note that the <code>&lt;</code> and <code>&amp;</code> characters
           in the declarations of "<code>lt</code>" and "<code>amp</code>"
           are doubly escaped to meet the requirement that entity replacement
           be well-formed.
           
        </p>
        
        
        
        
        <h3><a name="Notations"></a>4.7 Notation Declarations
        </h3>
        
        
        <p><a name="dt-notation"></a><b>Notations</b> identify by
           name the format of <a href="#dt-extent">unparsed
              entities
           </a>, the
           format of elements which bear a notation attribute, 
           or the application to which  
           a <a href="#dt-pi">processing instruction</a> is
           addressed.
        </p>
        
        <p><a name="dt-notdecl"></a>
           <b>Notation declarations</b>
           provide a name for the notation, for use in
           entity and attribute-list declarations and in attribute specifications,
           and an external identifier for the notation which may allow an XML
           processor or its client application to locate a helper application
           capable of processing data in the given notation.
           
           <h5>Notation Declarations</h5>
           <table class="scrap">
              <tbody>
                 <tr valign="baseline">
                    <td><a name="NT-NotationDecl"></a>[82]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>NotationDecl</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'&lt;!NOTATION' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> 
                       <a href="#NT-S">S</a> 
                       (<a href="#NT-ExternalID">ExternalID</a> | 
                       <a href="#NT-PublicID">PublicID</a>)
                       <a href="#NT-S">S</a>? '>'
                    </td>
                    <td></td>
                 </tr>
                 <tr valign="baseline">
                    <td><a name="NT-PublicID"></a>[83]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>PublicID</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>'PUBLIC' <a href="#NT-S">S</a> 
                       <a href="#NT-PubidLiteral">PubidLiteral</a> 
                       
                    </td>
                    <td></td>
                 </tr>
              </tbody>
           </table>
           
        </p>
        
        <p>XML processors must provide applications with the name and external
           identifier(s) of any notation declared and referred to in an attribute
           value, attribute definition, or entity declaration.  They may
           additionally resolve the external identifier into the
           <a href="#dt-sysid">system identifier</a>,
           file name, or other information needed to allow the
           application to call a processor for data in the notation described.  (It
           is not an error, however, for XML documents to declare and refer to
           notations for which notation-specific applications are not available on
           the system where the XML processor or application is running.)
        </p>
        
        
        
        
        
        <h3><a name="sec-doc-entity"></a>4.8 Document Entity
        </h3>
        
        
        <p><a name="dt-docent"></a>The <b>document
              entity
           </b> serves as the root of the entity
           tree and a starting-point for an <a href="#dt-xml-proc">XML
              processor
           </a>.
           This specification does
           not specify how the document entity is to be located by an XML
           processor; unlike other entities, the document entity has no name and might
           well appear on a processor input stream 
           without any identification at all.
        </p>
        
        
        
        
        
        
        
        
        <h2><a name="sec-conformance"></a>5 Conformance
        </h2>
        
        
        
        <h3><a name="proc-types"></a>5.1 Validating and Non-Validating Processors
        </h3>
        
        <p>Conforming <a href="#dt-xml-proc">XML processors</a> fall into two
           classes: validating and non-validating.
        </p>
        
        <p>Validating and non-validating processors alike must report
           violations of this specification's well-formedness constraints
           in the content of the
           <a href="#dt-docent">document entity</a> and any 
           other <a href="#dt-parsedent">parsed entities</a> that 
           they read.
        </p>
        
        <p><a name="dt-validating"></a>
           <b>Validating processors</b> must report
           violations of the constraints expressed by the declarations in the
           <a href="#dt-doctype">DTD</a>, and
           failures to fulfill the validity constraints given
           in this specification.
           
           To accomplish this, validating XML processors must read and process the entire
           DTD and all external parsed entities referenced in the document.
           
        </p>
        
        <p>Non-validating processors are required to check only the 
           <a href="#dt-docent">document entity</a>, including
           the entire internal DTD subset, for well-formedness.
           <a name="dt-use-mdecl"></a>
           While they are not required to check the document for validity,
           they are required to 
           <b>process</b> all the declarations they read in the
           internal DTD subset and in any parameter entity that they
           read, up to the first reference
           to a parameter entity that they do <i>not</i> read; that is to 
           say, they must
           use the information in those declarations to
           <a href="#AVNormalize">normalize</a> attribute values,
           <a href="#included">include</a> the replacement text of 
           internal entities, and supply 
           <a href="#sec-attr-defaults">default attribute values</a>.
           
           They must not <a href="#dt-use-mdecl">process</a>
           <a href="#dt-entdecl">entity declarations</a> or 
           <a href="#dt-attdecl">attribute-list declarations</a> 
           encountered after a reference to a parameter entity that is not
           read, since the entity may have contained overriding declarations.
           
        </p>
        
        
        
        <h3><a name="safe-behavior"></a>5.2 Using XML Processors
        </h3>
        
        <p>The behavior of a validating XML processor is highly predictable; it
           must read every piece of a document and report all well-formedness and
           validity violations.
           Less is required of a non-validating processor; it need not read any
           part of the document other than the document entity.
           This has two effects that may be important to users of XML processors:
           
           <ul>
              
              <li>
                 <p>Certain well-formedness errors, specifically those that require
                    reading external entities, may not be detected by a non-validating processor.
                    Examples include the constraints entitled 
                    <a href="#wf-entdeclared">Entity Declared</a>, 
                    <a href="#wf-textent">Parsed Entity</a>, and
                    <a href="#wf-norecursion">No Recursion</a>, as well
                    as some of the cases described as
                    <a href="#forbidden">forbidden</a> in 
                    <a href="#entproc">[<b>4.4 XML Processor Treatment of Entities and References</b>]
                    </a>.
                 </p>
              </li>
              
              <li>
                 <p>The information passed from the processor to the application may
                    vary, depending on whether the processor reads
                    parameter and external entities.
                    For example, a non-validating processor may not 
                    <a href="#AVNormalize">normalize</a> attribute values,
                    <a href="#included">include</a> the replacement text of 
                    internal entities, or supply 
                    <a href="#sec-attr-defaults">default attribute values</a>,
                    where doing so depends on having read declarations in 
                    external or parameter entities.
                 </p>
              </li>
              
           </ul>
           
        </p>
        
        <p>For maximum reliability in interoperating between different XML
           processors, applications which use non-validating processors should not 
           rely on any behaviors not required of such processors.
           Applications which require facilities such as the use of default
           attributes or internal entities which are declared in external
           entities should use validating XML processors.
        </p>
        
        
        
        
        
        <h2><a name="sec-notation"></a>6 Notation
        </h2>
        
        
        <p>The formal grammar of XML is given in this specification using a simple
           Extended Backus-Naur Form (EBNF) notation.  Each rule in the grammar defines
           one symbol, in the form
           <pre>symbol ::= expression</pre></p>
        
        <p>Symbols are written with an initial capital letter if they are
           defined by a regular expression, or with an initial lower case letter 
           otherwise.
           Literal strings are quoted.
           
           
        </p>
        
        
        <p>Within the expression on the right-hand side of a rule, the following
           expressions are used to match strings of one or more characters:
           
           <dl>
              
              
              <dt><b><code>#xN</code></b></dt>
              
              <dd>
                 <p>where <code>N</code> is a hexadecimal integer, the
                    expression matches the character in ISO/IEC 10646 whose canonical
                    (UCS-4) 
                    code value, when interpreted as an unsigned binary number, has
                    the value indicated.  The number of leading zeros in the
                    <code>#xN</code> form is insignificant; the number of leading
                    zeros in the corresponding code value 
                    is governed by the character
                    encoding in use and is not significant for XML.
                 </p>
              </dd>
              
              
              
              <dt><b><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></b></dt>
              
              <dd>
                 <p>matches any <a href="#dt-character">character</a> 
                    with a value in the range(s) indicated (inclusive).
                 </p>
              </dd>
              
              
              
              <dt><b><code>[^a-z]</code>, <code>[^#xN-#xN]</code></b></dt>
              
              <dd>
                 <p>matches any <a href="#dt-character">character</a> 
                    with a value <i>outside</i> the
                    range indicated.
                 </p>
              </dd>
              
              
              
              <dt><b><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></b></dt>
              
              <dd>
                 <p>matches any <a href="#dt-character">character</a>
                    with a value not among the characters given.
                 </p>
              </dd>
              
              
              
              <dt><b><code>"string"</code></b></dt>
              
              <dd>
                 <p>matches a literal string <a href="#dt-match">matching</a>
                    that given inside the double quotes.
                 </p>
              </dd>
              
              
              
              <dt><b><code>'string'</code></b></dt>
              
              <dd>
                 <p>matches a literal string <a href="#dt-match">matching</a>
                    that given inside the single quotes.
                 </p>
              </dd>
              
              
           </dl>
           These symbols may be combined to match more complex patterns as follows,
           where <code>A</code> and <code>B</code> represent simple expressions:
           
           <dl>
              
              
              <dt><b>(<code>expression</code>)
                 </b>
              </dt>
              
              <dd>
                 <p><code>expression</code> is treated as a unit 
                    and may be combined as described in this list.
                 </p>
              </dd>
              
              
              
              <dt><b><code>A?</code></b></dt>
              
              <dd>
                 <p>matches <code>A</code> or nothing; optional <code>A</code>.
                 </p>
              </dd>
              
              
              
              <dt><b><code>A B</code></b></dt>
              
              <dd>
                 <p>matches <code>A</code> followed by <code>B</code>.
                 </p>
              </dd>
              
              
              
              <dt><b><code>A | B</code></b></dt>
              
              <dd>
                 <p>matches <code>A</code> or <code>B</code> but not both.
                 </p>
              </dd>
              
              
              
              <dt><b><code>A - B</code></b></dt>
              
              <dd>
                 <p>matches any string that matches <code>A</code> but does not match
                    <code>B</code>.
                    
                 </p>
              </dd>
              
              
              
              <dt><b><code>A+</code></b></dt>
              
              <dd>
                 <p>matches one or more occurrences of <code>A</code>.
                 </p>
              </dd>
              
              
              
              <dt><b><code>A*</code></b></dt>
              
              <dd>
                 <p>matches zero or more occurrences of <code>A</code>.
                 </p>
              </dd>
              
              
              
           </dl>
           Other notations used in the productions are:
           
           <dl>
              
              
              <dt><b><code>/* ... */</code></b></dt>
              
              <dd>
                 <p>comment.</p>
              </dd>
              
              
              
              <dt><b><code>[ wfc: ... ]</code></b></dt>
              
              <dd>
                 <p>well-formedness constraint; this identifies by name a 
                    constraint on 
                    <a href="#dt-wellformed">well-formed</a> documents
                    associated with a production.
                 </p>
              </dd>
              
              
              
              <dt><b><code>[ vc: ... ]</code></b></dt>
              
              <dd>
                 <p>validity constraint; this identifies by name a constraint on
                    <a href="#dt-valid">valid</a> documents associated with
                    a production.
                 </p>
              </dd>
              
              
           </dl>
           
        </p>
        
        
        
        <hr title="Separator from footer">
        
        
        
        
        
        
        
        <h2><a name="sec-bibliography"></a>A References
        </h2>
        
        
        <h3><a name="sec-existing-stds"></a>A.1 Normative References
        </h3>
        
        
        <dl>
           
           <dt><a name="IANA">IANA</a></dt>
           <dd>
              (Internet Assigned Numbers Authority) <i>Official Names for 
                 Character Sets
              </i>,
              ed. Keld Simonsen et al.
              See <a href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</a>.
              
           </dd>
           
           
           <dt><a name="RFC1766">IETF RFC 1766</a></dt>
           <dd>
              IETF (Internet Engineering Task Force).
              <i>RFC 1766:  Tags for the Identification of Languages</i>,
              ed. H. Alvestrand.
              1995.
              
           </dd>
           
           
           <dt><a name="ISO639">ISO 639</a></dt>
           <dd>
              (International Organization for Standardization).
              <i>ISO 639:1988 (E).
                 Code for the representation of names of languages.
              </i>
              [Geneva]:  International Organization for
              Standardization, 1988.
           </dd>
           
           
           <dt><a name="ISO3166">ISO 3166</a></dt>
           <dd>
              (International Organization for Standardization).
              <i>ISO 3166-1:1997 (E).
                 Codes for the representation of names of countries and their subdivisions 
                 -- Part 1: Country codes
              </i>
              [Geneva]:  International Organization for
              Standardization, 1997.
           </dd>
           
           
           <dt><a name="ISO10646">ISO/IEC 10646</a></dt>
           <dd>ISO
              (International Organization for Standardization).
              <i>ISO/IEC 10646-1993 (E).  Information technology -- Universal
                 Multiple-Octet Coded Character Set (UCS) -- Part 1:
                 Architecture and Basic Multilingual Plane.
              </i>
              [Geneva]:  International Organization for
              Standardization, 1993 (plus amendments AM 1 through AM 7).
              
           </dd>
           
           
           <dt><a name="Unicode">Unicode</a></dt>
           <dd>The Unicode Consortium.
              <i>The Unicode Standard, Version 2.0.</i>
              Reading, Mass.:  Addison-Wesley Developers Press, 1996.
           </dd>
           
           
        </dl>
        
        
        
        
        <h3><a name="section-Other-References"></a>A.2 Other References
        </h3> 
        
        
        <dl>
           
           
           <dt><a name="Aho">Aho/Ullman</a></dt>
           <dd>Aho, Alfred V., 
              Ravi Sethi, and Jeffrey D. Ullman.
              <i>Compilers:  Principles, Techniques, and Tools</i>.
              Reading:  Addison-Wesley, 1986, rpt. corr. 1988.
           </dd>
           
           
           <dt><a name="Berners-Lee">Berners-Lee et al.</a></dt>
           <dd>
              Berners-Lee, T., R. Fielding, and L. Masinter.
              <i>Uniform Resource Identifiers (URI):  Generic Syntax and
                 Semantics
              </i>.
              1997.
              (Work in progress; see updates to RFC1738.)
           </dd>
           
           
           <dt><a name="ABK">Br&uuml;ggemann-Klein</a></dt>
           <dd>Br&uuml;ggemann-Klein, Anne.
              <i>Regular Expressions into Finite Automata</i>.
              Extended abstract in I. Simon, Hrsg., LATIN 1992, 
              S. 97-98. Springer-Verlag, Berlin 1992. 
              Full Version in Theoretical Computer Science 120: 197-213, 1993.
              
              
           </dd>
           
           
           <dt><a name="ABKDW">Br&uuml;ggemann-Klein and Wood</a></dt>
           <dd>Br&uuml;ggemann-Klein, Anne,
              and Derick Wood.
              <i>Deterministic Regular Languages</i>.
              Universit&auml;t Freiburg, Institut f&uuml;r Informatik,
              Bericht 38, Oktober 1991.
              
           </dd>
           
           
           <dt><a name="Clark">Clark</a></dt>
           <dd>James Clark.
              Comparison of SGML and XML. See
              <a href="http://www.w3.org/TR/NOTE-sgml-xml-971215">http://www.w3.org/TR/NOTE-sgml-xml-971215</a>.
              
           </dd>
           
           <dt><a name="RFC1738">IETF RFC1738</a></dt>
           <dd>
              IETF (Internet Engineering Task Force).
              <i>RFC 1738:  Uniform Resource Locators (URL)</i>, 
              ed. T. Berners-Lee, L. Masinter, M. McCahill.
              1994.
              
           </dd>
           
           
           <dt><a name="RFC1808">IETF RFC1808</a></dt>
           <dd>
              IETF (Internet Engineering Task Force).
              <i>RFC 1808:  Relative Uniform Resource Locators</i>, 
              ed. R. Fielding.
              1995.
              
           </dd>
           
           
           <dt><a name="RFC2141">IETF RFC2141</a></dt>
           <dd>
              IETF (Internet Engineering Task Force).
              <i>RFC 2141:  URN Syntax</i>, 
              ed. R. Moats.
              1997.
              
           </dd>
           
           
           <dt><a name="ISO8879">ISO 8879</a></dt>
           <dd>ISO
              (International Organization for Standardization).
              <i>ISO 8879:1986(E).  Information processing -- Text and Office
                 Systems -- Standard Generalized Markup Language (SGML).
              </i>  First
              edition -- 1986-10-15.  [Geneva]:  International Organization for
              Standardization, 1986.
              
           </dd>
           
           
           
           <dt><a name="ISO10744">ISO/IEC 10744</a></dt>
           <dd>ISO
              (International Organization for Standardization).
              <i>ISO/IEC 10744-1992 (E).  Information technology --
                 Hypermedia/Time-based Structuring Language (HyTime).
                 
              </i>
              [Geneva]:  International Organization for
              Standardization, 1992.
              <i>Extended Facilities Annexe.</i>
              [Geneva]:  International Organization for
              Standardization, 1996. 
              
           </dd>
           
           
           
           
        </dl>
        
        
        
        
        <h2><a name="CharClasses"></a>B Character Classes
        </h2>
        
        <p>Following the characteristics defined in the Unicode standard,
           characters are classed as base characters (among others, these
           contain the alphabetic characters of the Latin alphabet, without
           diacritics), ideographic characters, and combining characters (among
           others, this class contains most diacritics); these classes combine
           to form the class of letters.  Digits and extenders are
           also distinguished.
           
           <h5>Characters</h5>
           <table class="scrap">
              <tbody>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Letter"></a>[84]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Letter</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td><a href="#NT-BaseChar">BaseChar</a> 
                       | <a href="#NT-Ideographic">Ideographic</a></td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-BaseChar"></a>[85]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>BaseChar</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[#x0041-#x005A]
                       |&nbsp;[#x0061-#x007A]
                       |&nbsp;[#x00C0-#x00D6]
                       |&nbsp;[#x00D8-#x00F6]
                       |&nbsp;[#x00F8-#x00FF]
                       |&nbsp;[#x0100-#x0131]
                       |&nbsp;[#x0134-#x013E]
                       |&nbsp;[#x0141-#x0148]
                       |&nbsp;[#x014A-#x017E]
                       |&nbsp;[#x0180-#x01C3]
                       |&nbsp;[#x01CD-#x01F0]
                       |&nbsp;[#x01F4-#x01F5]
                       |&nbsp;[#x01FA-#x0217]
                       |&nbsp;[#x0250-#x02A8]
                       |&nbsp;[#x02BB-#x02C1]
                       |&nbsp;#x0386
                       |&nbsp;[#x0388-#x038A]
                       |&nbsp;#x038C
                       |&nbsp;[#x038E-#x03A1]
                       |&nbsp;[#x03A3-#x03CE]
                       |&nbsp;[#x03D0-#x03D6]
                       |&nbsp;#x03DA
                       |&nbsp;#x03DC
                       |&nbsp;#x03DE
                       |&nbsp;#x03E0
                       |&nbsp;[#x03E2-#x03F3]
                       |&nbsp;[#x0401-#x040C]
                       |&nbsp;[#x040E-#x044F]
                       |&nbsp;[#x0451-#x045C]
                       |&nbsp;[#x045E-#x0481]
                       |&nbsp;[#x0490-#x04C4]
                       |&nbsp;[#x04C7-#x04C8]
                       |&nbsp;[#x04CB-#x04CC]
                       |&nbsp;[#x04D0-#x04EB]
                       |&nbsp;[#x04EE-#x04F5]
                       |&nbsp;[#x04F8-#x04F9]
                       |&nbsp;[#x0531-#x0556]
                       |&nbsp;#x0559
                       |&nbsp;[#x0561-#x0586]
                       |&nbsp;[#x05D0-#x05EA]
                       |&nbsp;[#x05F0-#x05F2]
                       |&nbsp;[#x0621-#x063A]
                       |&nbsp;[#x0641-#x064A]
                       |&nbsp;[#x0671-#x06B7]
                       |&nbsp;[#x06BA-#x06BE]
                       |&nbsp;[#x06C0-#x06CE]
                       |&nbsp;[#x06D0-#x06D3]
                       |&nbsp;#x06D5
                       |&nbsp;[#x06E5-#x06E6]
                       |&nbsp;[#x0905-#x0939]
                       |&nbsp;#x093D
                       |&nbsp;[#x0958-#x0961]
                       |&nbsp;[#x0985-#x098C]
                       |&nbsp;[#x098F-#x0990]
                       |&nbsp;[#x0993-#x09A8]
                       |&nbsp;[#x09AA-#x09B0]
                       |&nbsp;#x09B2
                       |&nbsp;[#x09B6-#x09B9]
                       |&nbsp;[#x09DC-#x09DD]
                       |&nbsp;[#x09DF-#x09E1]
                       |&nbsp;[#x09F0-#x09F1]
                       |&nbsp;[#x0A05-#x0A0A]
                       |&nbsp;[#x0A0F-#x0A10]
                       |&nbsp;[#x0A13-#x0A28]
                       |&nbsp;[#x0A2A-#x0A30]
                       |&nbsp;[#x0A32-#x0A33]
                       |&nbsp;[#x0A35-#x0A36]
                       |&nbsp;[#x0A38-#x0A39]
                       |&nbsp;[#x0A59-#x0A5C]
                       |&nbsp;#x0A5E
                       |&nbsp;[#x0A72-#x0A74]
                       |&nbsp;[#x0A85-#x0A8B]
                       |&nbsp;#x0A8D
                       |&nbsp;[#x0A8F-#x0A91]
                       |&nbsp;[#x0A93-#x0AA8]
                       |&nbsp;[#x0AAA-#x0AB0]
                       |&nbsp;[#x0AB2-#x0AB3]
                       |&nbsp;[#x0AB5-#x0AB9]
                       |&nbsp;#x0ABD
                       |&nbsp;#x0AE0
                       |&nbsp;[#x0B05-#x0B0C]
                       |&nbsp;[#x0B0F-#x0B10]
                       |&nbsp;[#x0B13-#x0B28]
                       |&nbsp;[#x0B2A-#x0B30]
                       |&nbsp;[#x0B32-#x0B33]
                       |&nbsp;[#x0B36-#x0B39]
                       |&nbsp;#x0B3D
                       |&nbsp;[#x0B5C-#x0B5D]
                       |&nbsp;[#x0B5F-#x0B61]
                       |&nbsp;[#x0B85-#x0B8A]
                       |&nbsp;[#x0B8E-#x0B90]
                       |&nbsp;[#x0B92-#x0B95]
                       |&nbsp;[#x0B99-#x0B9A]
                       |&nbsp;#x0B9C
                       |&nbsp;[#x0B9E-#x0B9F]
                       |&nbsp;[#x0BA3-#x0BA4]
                       |&nbsp;[#x0BA8-#x0BAA]
                       |&nbsp;[#x0BAE-#x0BB5]
                       |&nbsp;[#x0BB7-#x0BB9]
                       |&nbsp;[#x0C05-#x0C0C]
                       |&nbsp;[#x0C0E-#x0C10]
                       |&nbsp;[#x0C12-#x0C28]
                       |&nbsp;[#x0C2A-#x0C33]
                       |&nbsp;[#x0C35-#x0C39]
                       |&nbsp;[#x0C60-#x0C61]
                       |&nbsp;[#x0C85-#x0C8C]
                       |&nbsp;[#x0C8E-#x0C90]
                       |&nbsp;[#x0C92-#x0CA8]
                       |&nbsp;[#x0CAA-#x0CB3]
                       |&nbsp;[#x0CB5-#x0CB9]
                       |&nbsp;#x0CDE
                       |&nbsp;[#x0CE0-#x0CE1]
                       |&nbsp;[#x0D05-#x0D0C]
                       |&nbsp;[#x0D0E-#x0D10]
                       |&nbsp;[#x0D12-#x0D28]
                       |&nbsp;[#x0D2A-#x0D39]
                       |&nbsp;[#x0D60-#x0D61]
                       |&nbsp;[#x0E01-#x0E2E]
                       |&nbsp;#x0E30
                       |&nbsp;[#x0E32-#x0E33]
                       |&nbsp;[#x0E40-#x0E45]
                       |&nbsp;[#x0E81-#x0E82]
                       |&nbsp;#x0E84
                       |&nbsp;[#x0E87-#x0E88]
                       |&nbsp;#x0E8A
                       |&nbsp;#x0E8D
                       |&nbsp;[#x0E94-#x0E97]
                       |&nbsp;[#x0E99-#x0E9F]
                       |&nbsp;[#x0EA1-#x0EA3]
                       |&nbsp;#x0EA5
                       |&nbsp;#x0EA7
                       |&nbsp;[#x0EAA-#x0EAB]
                       |&nbsp;[#x0EAD-#x0EAE]
                       |&nbsp;#x0EB0
                       |&nbsp;[#x0EB2-#x0EB3]
                       |&nbsp;#x0EBD
                       |&nbsp;[#x0EC0-#x0EC4]
                       |&nbsp;[#x0F40-#x0F47]
                       |&nbsp;[#x0F49-#x0F69]
                       |&nbsp;[#x10A0-#x10C5]
                       |&nbsp;[#x10D0-#x10F6]
                       |&nbsp;#x1100
                       |&nbsp;[#x1102-#x1103]
                       |&nbsp;[#x1105-#x1107]
                       |&nbsp;#x1109
                       |&nbsp;[#x110B-#x110C]
                       |&nbsp;[#x110E-#x1112]
                       |&nbsp;#x113C
                       |&nbsp;#x113E
                       |&nbsp;#x1140
                       |&nbsp;#x114C
                       |&nbsp;#x114E
                       |&nbsp;#x1150
                       |&nbsp;[#x1154-#x1155]
                       |&nbsp;#x1159
                       |&nbsp;[#x115F-#x1161]
                       |&nbsp;#x1163
                       |&nbsp;#x1165
                       |&nbsp;#x1167
                       |&nbsp;#x1169
                       |&nbsp;[#x116D-#x116E]
                       |&nbsp;[#x1172-#x1173]
                       |&nbsp;#x1175
                       |&nbsp;#x119E
                       |&nbsp;#x11A8
                       |&nbsp;#x11AB
                       |&nbsp;[#x11AE-#x11AF]
                       |&nbsp;[#x11B7-#x11B8]
                       |&nbsp;#x11BA
                       |&nbsp;[#x11BC-#x11C2]
                       |&nbsp;#x11EB
                       |&nbsp;#x11F0
                       |&nbsp;#x11F9
                       |&nbsp;[#x1E00-#x1E9B]
                       |&nbsp;[#x1EA0-#x1EF9]
                       |&nbsp;[#x1F00-#x1F15]
                       |&nbsp;[#x1F18-#x1F1D]
                       |&nbsp;[#x1F20-#x1F45]
                       |&nbsp;[#x1F48-#x1F4D]
                       |&nbsp;[#x1F50-#x1F57]
                       |&nbsp;#x1F59
                       |&nbsp;#x1F5B
                       |&nbsp;#x1F5D
                       |&nbsp;[#x1F5F-#x1F7D]
                       |&nbsp;[#x1F80-#x1FB4]
                       |&nbsp;[#x1FB6-#x1FBC]
                       |&nbsp;#x1FBE
                       |&nbsp;[#x1FC2-#x1FC4]
                       |&nbsp;[#x1FC6-#x1FCC]
                       |&nbsp;[#x1FD0-#x1FD3]
                       |&nbsp;[#x1FD6-#x1FDB]
                       |&nbsp;[#x1FE0-#x1FEC]
                       |&nbsp;[#x1FF2-#x1FF4]
                       |&nbsp;[#x1FF6-#x1FFC]
                       |&nbsp;#x2126
                       |&nbsp;[#x212A-#x212B]
                       |&nbsp;#x212E
                       |&nbsp;[#x2180-#x2182]
                       |&nbsp;[#x3041-#x3094]
                       |&nbsp;[#x30A1-#x30FA]
                       |&nbsp;[#x3105-#x312C]
                       |&nbsp;[#xAC00-#xD7A3]
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Ideographic"></a>[86]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Ideographic</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[#x4E00-#x9FA5]
                       |&nbsp;#x3007
                       |&nbsp;[#x3021-#x3029]
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-CombiningChar"></a>[87]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>CombiningChar</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[#x0300-#x0345]
                       |&nbsp;[#x0360-#x0361]
                       |&nbsp;[#x0483-#x0486]
                       |&nbsp;[#x0591-#x05A1]
                       |&nbsp;[#x05A3-#x05B9]
                       |&nbsp;[#x05BB-#x05BD]
                       |&nbsp;#x05BF
                       |&nbsp;[#x05C1-#x05C2]
                       |&nbsp;#x05C4
                       |&nbsp;[#x064B-#x0652]
                       |&nbsp;#x0670
                       |&nbsp;[#x06D6-#x06DC]
                       |&nbsp;[#x06DD-#x06DF]
                       |&nbsp;[#x06E0-#x06E4]
                       |&nbsp;[#x06E7-#x06E8]
                       |&nbsp;[#x06EA-#x06ED]
                       |&nbsp;[#x0901-#x0903]
                       |&nbsp;#x093C
                       |&nbsp;[#x093E-#x094C]
                       |&nbsp;#x094D
                       |&nbsp;[#x0951-#x0954]
                       |&nbsp;[#x0962-#x0963]
                       |&nbsp;[#x0981-#x0983]
                       |&nbsp;#x09BC
                       |&nbsp;#x09BE
                       |&nbsp;#x09BF
                       |&nbsp;[#x09C0-#x09C4]
                       |&nbsp;[#x09C7-#x09C8]
                       |&nbsp;[#x09CB-#x09CD]
                       |&nbsp;#x09D7
                       |&nbsp;[#x09E2-#x09E3]
                       |&nbsp;#x0A02
                       |&nbsp;#x0A3C
                       |&nbsp;#x0A3E
                       |&nbsp;#x0A3F
                       |&nbsp;[#x0A40-#x0A42]
                       |&nbsp;[#x0A47-#x0A48]
                       |&nbsp;[#x0A4B-#x0A4D]
                       |&nbsp;[#x0A70-#x0A71]
                       |&nbsp;[#x0A81-#x0A83]
                       |&nbsp;#x0ABC
                       |&nbsp;[#x0ABE-#x0AC5]
                       |&nbsp;[#x0AC7-#x0AC9]
                       |&nbsp;[#x0ACB-#x0ACD]
                       |&nbsp;[#x0B01-#x0B03]
                       |&nbsp;#x0B3C
                       |&nbsp;[#x0B3E-#x0B43]
                       |&nbsp;[#x0B47-#x0B48]
                       |&nbsp;[#x0B4B-#x0B4D]
                       |&nbsp;[#x0B56-#x0B57]
                       |&nbsp;[#x0B82-#x0B83]
                       |&nbsp;[#x0BBE-#x0BC2]
                       |&nbsp;[#x0BC6-#x0BC8]
                       |&nbsp;[#x0BCA-#x0BCD]
                       |&nbsp;#x0BD7
                       |&nbsp;[#x0C01-#x0C03]
                       |&nbsp;[#x0C3E-#x0C44]
                       |&nbsp;[#x0C46-#x0C48]
                       |&nbsp;[#x0C4A-#x0C4D]
                       |&nbsp;[#x0C55-#x0C56]
                       |&nbsp;[#x0C82-#x0C83]
                       |&nbsp;[#x0CBE-#x0CC4]
                       |&nbsp;[#x0CC6-#x0CC8]
                       |&nbsp;[#x0CCA-#x0CCD]
                       |&nbsp;[#x0CD5-#x0CD6]
                       |&nbsp;[#x0D02-#x0D03]
                       |&nbsp;[#x0D3E-#x0D43]
                       |&nbsp;[#x0D46-#x0D48]
                       |&nbsp;[#x0D4A-#x0D4D]
                       |&nbsp;#x0D57
                       |&nbsp;#x0E31
                       |&nbsp;[#x0E34-#x0E3A]
                       |&nbsp;[#x0E47-#x0E4E]
                       |&nbsp;#x0EB1
                       |&nbsp;[#x0EB4-#x0EB9]
                       |&nbsp;[#x0EBB-#x0EBC]
                       |&nbsp;[#x0EC8-#x0ECD]
                       |&nbsp;[#x0F18-#x0F19]
                       |&nbsp;#x0F35
                       |&nbsp;#x0F37
                       |&nbsp;#x0F39
                       |&nbsp;#x0F3E
                       |&nbsp;#x0F3F
                       |&nbsp;[#x0F71-#x0F84]
                       |&nbsp;[#x0F86-#x0F8B]
                       |&nbsp;[#x0F90-#x0F95]
                       |&nbsp;#x0F97
                       |&nbsp;[#x0F99-#x0FAD]
                       |&nbsp;[#x0FB1-#x0FB7]
                       |&nbsp;#x0FB9
                       |&nbsp;[#x20D0-#x20DC]
                       |&nbsp;#x20E1
                       |&nbsp;[#x302A-#x302F]
                       |&nbsp;#x3099
                       |&nbsp;#x309A
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Digit"></a>[88]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Digit</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>[#x0030-#x0039]
                       |&nbsp;[#x0660-#x0669]
                       |&nbsp;[#x06F0-#x06F9]
                       |&nbsp;[#x0966-#x096F]
                       |&nbsp;[#x09E6-#x09EF]
                       |&nbsp;[#x0A66-#x0A6F]
                       |&nbsp;[#x0AE6-#x0AEF]
                       |&nbsp;[#x0B66-#x0B6F]
                       |&nbsp;[#x0BE7-#x0BEF]
                       |&nbsp;[#x0C66-#x0C6F]
                       |&nbsp;[#x0CE6-#x0CEF]
                       |&nbsp;[#x0D66-#x0D6F]
                       |&nbsp;[#x0E50-#x0E59]
                       |&nbsp;[#x0ED0-#x0ED9]
                       |&nbsp;[#x0F20-#x0F29]
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 <tr valign="baseline">
                    <td><a name="NT-Extender"></a>[89]&nbsp;&nbsp;&nbsp;
                    </td>
                    <td>Extender</td>
                    <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                    <td>#x00B7
                       |&nbsp;#x02D0
                       |&nbsp;#x02D1
                       |&nbsp;#x0387
                       |&nbsp;#x0640
                       |&nbsp;#x0E46
                       |&nbsp;#x0EC6
                       |&nbsp;#x3005
                       |&nbsp;[#x3031-#x3035]
                       |&nbsp;[#x309D-#x309E]
                       |&nbsp;[#x30FC-#x30FE]
                       
                    </td>
                    <td></td>
                 </tr>
                 
                 
              </tbody>
           </table>
           
        </p>
        
        <p>The character classes defined here can be derived from the
           Unicode character database as follows:
           
           <ul>
              
              <li>
                 
                 <p>Name start characters must have one of the categories Ll, Lu,
                    Lo, Lt, Nl.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Name characters other than Name-start characters 
                    must have one of the categories Mc, Me, Mn, Lm, or Nd.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Characters in the compatibility area (i.e. with character code
                    greater than #xF900 and less than #xFFFE) are not allowed in XML
                    names.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Characters which have a font or compatibility decomposition (i.e. those
                    with a "compatibility formatting tag" in field 5 of the database --
                    marked by field 5 beginning with a "&lt;") are not allowed.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>The following characters are treated as name-start characters
                    rather than name characters, because the property file classifies
                    them as Alphabetic:  [#x02BB-#x02C1], #x0559, #x06E5, #x06E6.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Characters #x20DD-#x20E0 are excluded (in accordance with 
                    Unicode, section 5.14).
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Character #x00B7 is classified as an extender, because the
                    property list so identifies it.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Character #x0387 is added as a name character, because #x00B7
                    is its canonical equivalent.
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>Characters ':' and '_' are allowed as name-start characters.</p>
                 
              </li>
              
              <li>
                 
                 <p>Characters '-' and '.' are allowed as name characters.</p>
                 
              </li>
              
           </ul>
           
        </p>
        
        
        
        <h2><a name="sec-xml-and-sgml"></a>C XML and SGML (Non-Normative)
        </h2>
        
        
        <p>XML is designed to be a subset of SGML, in that every
           <a href="#dt-valid">valid</a> XML document should also be a
           conformant SGML document.
           For a detailed comparison of the additional restrictions that XML places on
           documents beyond those of SGML, see <a href="#Clark">[Clark]</a>.
           
        </p>
        
        
        
        <h2><a name="sec-entexpand"></a>D Expansion of Entity and Character References (Non-Normative)
        </h2>
        
        <p>This appendix contains some examples illustrating the
           sequence of entity- and character-reference recognition and
           expansion, as specified in <a href="#entproc">[<b>4.4 XML Processor Treatment of Entities and References</b>]
           </a>.
        </p>
        
        <p>
           If the DTD contains the declaration 
           <pre>&lt;!ENTITY example "&lt;p>An ampersand (&amp;#38;#38;) may be escaped
  numerically (&amp;#38;#38;#38;) or with a general entity
  (&amp;amp;amp;).&lt;/p>" >
  </pre>
           then the XML processor will recognize the character references 
           when it parses the entity declaration, and resolve them before 
           storing the following string as the
           value of the entity "<code>example</code>":
           <pre>&lt;p>An ampersand (&amp;#38;) may be escaped
  numerically (&amp;#38;#38;) or with a general entity
  (&amp;amp;amp;).&lt;/p>
  </pre>
           A reference in the document to "<code>&amp;example;</code>" 
           will cause the text to be reparsed, at which time the 
           start- and end-tags of the "<code>p</code>" element will be recognized 
           and the three references will be recognized and expanded, 
           resulting in a "<code>p</code>" element with the following content
           (all data, no delimiters or markup):
           <pre>An ampersand (&amp;) may be escaped
  numerically (&amp;#38;) or with a general entity
  (&amp;amp;).
  </pre>
           </p>
        
        <p>A more complex example will illustrate the rules and their
           effects fully.  In the following example, the line numbers are
           solely for reference.
           <pre>1 &lt;?xml version='1.0'?>
  2 &lt;!DOCTYPE test [
  3 &lt;!ELEMENT test (#PCDATA) >
  4 &lt;!ENTITY % xx '&amp;#37;zz;'>
  5 &lt;!ENTITY % zz '&amp;#60;!ENTITY tricky "error-prone" >' >
  6 %xx;
  7 ]>
  8 &lt;test>This sample shows a &amp;tricky; method.&lt;/test>
  </pre>
           This produces the following:
           <ul>
              
              <li>
                 <p>in line 4, the reference to character 37 is expanded immediately,
                    and the parameter entity "<code>xx</code>" is stored in the symbol
                    table with the value "<code>%zz;</code>".  Since the replacement text
                    is not rescanned, the reference to parameter entity "<code>zz</code>"
                    is not recognized.  (And it would be an error if it were, since
                    "<code>zz</code>" is not yet declared.)
                 </p>
              </li>
              
              <li>
                 <p>in line 5, the character reference "<code>&amp;#60;</code>" is
                    expanded immediately and the parameter entity "<code>zz</code>" is
                    stored with the replacement text 
                    "<code>&lt;!ENTITY tricky "error-prone" ></code>",
                    which is a well-formed entity declaration.
                 </p>
              </li>
              
              <li>
                 <p>in line 6, the reference to "<code>xx</code>" is recognized,
                    and the replacement text of "<code>xx</code>" (namely 
                    "<code>%zz;</code>") is parsed.  The reference to "<code>zz</code>"
                    is recognized in its turn, and its replacement text 
                    ("<code>&lt;!ENTITY tricky "error-prone" ></code>") is parsed.
                    The general entity "<code>tricky</code>" has now been
                    declared, with the replacement text "<code>error-prone</code>".
                 </p>
              </li>
              
              <li>
                 <p>
                    in line 8, the reference to the general entity "<code>tricky</code>" is
                    recognized, and it is expanded, so the full content of the
                    "<code>test</code>" element is the self-describing (and ungrammatical) string
                    <i>This sample shows a error-prone method.</i>
                    
                 </p>
              </li>
              
           </ul>
           
        </p>
         
        
        
        <h2><a name="determinism"></a>E Deterministic Content Models (Non-Normative)
        </h2>
        
        <p><a href="#dt-compat">For compatibility</a>, it is
           required
           that content models in element type declarations be deterministic.  
           
        </p>
        
        
        <p>SGML
           requires deterministic content models (it calls them
           "unambiguous"); XML processors built using SGML systems may
           flag non-deterministic content models as errors.
        </p>
        
        <p>For example, the content model <code>((b, c) | (b, d))</code> is
           non-deterministic, because given an initial <code>b</code> the parser
           cannot know which <code>b</code> in the model is being matched without
           looking ahead to see which element follows the <code>b</code>.
           In this case, the two references to
           <code>b</code> can be collapsed 
           into a single reference, making the model read
           <code>(b, (c | d))</code>.  An initial <code>b</code> now clearly
           matches only a single name in the content model.  The parser doesn't
           need to look ahead to see what follows; either <code>c</code> or
           <code>d</code> would be accepted.
        </p>
        
        <p>More formally:  a finite state automaton may be constructed from the
           content model using the standard algorithms, e.g. algorithm 3.5 
           in section 3.9
           of Aho, Sethi, and Ullman <a href="#Aho">[Aho/Ullman]</a>.
           In many such algorithms, a follow set is constructed for each 
           position in the regular expression (i.e., each leaf 
           node in the 
           syntax tree for the regular expression);
           if any position has a follow set in which 
           more than one following position is 
           labeled with the same element type name, 
           then the content model is in error
           and may be reported as an error.
           
        </p>
        
        <p>Algorithms exist which allow many but not all non-deterministic
           content models to be reduced automatically to equivalent deterministic
           models; see Br&uuml;ggemann-Klein 1991 <a href="#ABK">[Br&uuml;ggemann-Klein]</a>.
        </p>
        
        
        
        <h2><a name="sec-guessing"></a>F Autodetection of Character Encodings (Non-Normative)
        </h2>
        
        <p>The XML encoding declaration functions as an internal label on each
           entity, indicating which character encoding is in use.  Before an XML
           processor can read the internal label, however, it apparently has to
           know what character encoding is in use--which is what the internal label
           is trying to indicate.  In the general case, this is a hopeless
           situation. It is not entirely hopeless in XML, however, because XML
           limits the general case in two ways:  each implementation is assumed
           to support only a  finite set of character encodings, and the XML
           encoding declaration is restricted in position and content in order to
           make it feasible to autodetect the character encoding in use in each
           entity in normal cases.  Also, in many cases other sources of information
           are available in addition to the XML data stream itself.  
           Two cases may be distinguished, 
           depending on whether the XML entity is presented to the
           processor without, or with, any accompanying
           (external) information.  We consider the first case first.
           
        </p>
        
        <p>
           Because each XML entity not in UTF-8 or UTF-16 format <i>must</i>
           begin with an XML encoding declaration, in which the first  characters
           must be '<code>&lt;?xml</code>', any conforming processor can detect,
           after two to four octets of input, which of the following cases apply. 
           In reading this list, it may help to know that in UCS-4, '&lt;' is
           "<code>#x0000003C</code>" and '?' is "<code>#x0000003F</code>", and the Byte
           Order Mark required of UTF-16 data streams is "<code>#xFEFF</code>".
        </p>
        
        <p>
           
           <ul>
              
              <li>
                 
                 <p><code>00 00 00 3C</code>: UCS-4, big-endian machine (1234 order)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>3C 00 00 00</code>: UCS-4, little-endian machine (4321 order)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>00 00 3C 00</code>: UCS-4, unusual octet order (2143)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>00 3C 00 00</code>: UCS-4, unusual octet order (3412)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>FE FF</code>: UTF-16, big-endian
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>FF FE</code>: UTF-16, little-endian
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>00 3C 00 3F</code>: UTF-16, big-endian, no Byte Order Mark
                    (and thus, strictly speaking, in error)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>3C 00 3F 00</code>: UTF-16, little-endian, no Byte Order Mark
                    (and thus, strictly speaking, in error)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>3C 3F 78 6D</code>: UTF-8, ISO 646, ASCII, some part of ISO 8859, 
                    Shift-JIS, EUC, or any other 7-bit, 8-bit, or mixed-width encoding
                    which ensures that the characters of ASCII have their normal positions,
                    width,
                    and values; the actual encoding declaration must be read to 
                    detect which of these applies, but since all of these encodings
                    use the same bit patterns for the ASCII characters, the encoding 
                    declaration itself may be read reliably
                    
                 </p>
                 
              </li>
              
              <li>
                 
                 <p><code>4C 6F A7 94</code>: EBCDIC (in some flavor; the full
                    encoding declaration must be read to tell which code page is in 
                    use)
                 </p>
                 
              </li>
              
              <li>
                 
                 <p>other: UTF-8 without an encoding declaration, or else 
                    the data stream is corrupt, fragmentary, or enclosed in
                    a wrapper of some kind
                 </p>
                 
              </li>
              
           </ul>
           
        </p>
        
        <p>
           This level of autodetection is enough to read the XML encoding
           declaration and parse the character-encoding identifier, which is
           still necessary to distinguish the individual members of each family
           of encodings (e.g. to tell  UTF-8 from 8859, and the parts of 8859
           from each other, or to distinguish the specific EBCDIC code page in
           use, and so on).
           
        </p>
        
        <p>
           Because the contents of the encoding declaration are restricted to
           ASCII characters, a processor can reliably read the entire encoding
           declaration as soon as it has detected which family of encodings is in
           use.  Since in practice, all widely used character encodings fall into
           one of the categories above, the XML encoding declaration allows
           reasonably reliable in-band labeling of character encodings, even when
           external sources of information at the operating-system or
           transport-protocol level are unreliable.
           
        </p>
        
        <p>
           Once the processor has detected the character encoding in use, it can
           act appropriately, whether by invoking a separate input routine for
           each case, or by calling the proper conversion function on each
           character of input. 
           
        </p>
        
        <p>
           Like any self-labeling system, the XML encoding declaration will not
           work if any software changes the entity's character set or encoding
           without updating the encoding declaration.  Implementors of
           character-encoding routines should be careful to ensure the accuracy
           of the internal and external information used to label the entity.
           
        </p>
        
        <p>The second possible case occurs when the XML entity is accompanied
           by encoding information, as in some file systems and some network
           protocols.
           When multiple sources of information are available,
           
           their relative
           priority and the preferred method of handling conflict should be
           specified as part of the higher-level protocol used to deliver XML.
           Rules for the relative priority of the internal label and the
           MIME-type label in an external header, for example, should be part of the
           RFC document defining the text/xml and application/xml MIME types. In
           the interests of interoperability, however, the following rules
           are recommended.
           
           <ul>
              
              <li>
                 <p>If an XML entity is in a file, the Byte-Order Mark
                    and encoding-declaration PI are used (if present) to determine the
                    character encoding.  All other heuristics and sources of information
                    are solely for error recovery.
                    
                 </p>
              </li>
              
              <li>
                 <p>If an XML entity is delivered with a
                    MIME type of text/xml, then the <code>charset</code> parameter
                    on the MIME type determines the
                    character encoding method; all other heuristics and sources of
                    information are solely for error recovery.
                    
                 </p>
              </li>
              
              <li>
                 <p>If an XML entity is delivered 
                    with a
                    MIME type of application/xml, then the Byte-Order Mark and
                    encoding-declaration PI are used (if present) to determine the
                    character encoding.  All other heuristics and sources of
                    information are solely for error recovery.
                    
                 </p>
              </li>
              
           </ul>
           These rules apply only in the absence of protocol-level documentation;
           in particular, when the MIME types text/xml and application/xml are
           defined, the recommendations of the relevant RFC will supersede
           these rules.
           
        </p>
        
        
        
        
        
        <h2><a name="sec-xml-wg"></a>G W3C XML Working Group (Non-Normative)
        </h2>
        
        
        <p>This specification was prepared and approved for publication by the
           W3C XML Working Group (WG).  WG approval of this specification does
           not necessarily imply that all WG members voted for its approval.  
           The current and former members of the XML WG are:
        </p>
        
        Jon Bosak, Sun (Chair); James Clark (Technical Lead); Tim Bray, Textuality and Netscape (XML Co-editor); Jean Paoli, Microsoft (XML Co-editor); C. M. Sperberg-McQueen, U. of Ill. (XML
        Co-editor); Dan Connolly, W3C (W3C Liaison); Paula Angerstein, Texcel; Steve DeRose, INSO; Dave Hollander, HP; Eliot Kimber, ISOGEN; Eve Maler, ArborText; Tom Magliery, NCSA; Murray Maloney, Muzmo and Grif; Makoto Murata, Fuji Xerox Information Systems; Joel Nava, Adobe; Conleth O'Connell, Vignette; Peter Sharpe, SoftQuad; John Tigue, DataChannel
        
        
        
        
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk055.out
  
  Index: mk055.out
  ===================================================================
  
  <!DOCTYPE html
    PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>XML Path Language (XPath)</title>
        <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC"><style type="text/css">code { font-family: monospace }</style></head>
     <body>
        
        <div class="head"><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/WWW/w3c_home" alt="W3C" height="48" width="72"></a><h1>XML Path Language (XPath)<br>Version 1.0
           </h1>
           <h2>W3C Recommendation 16 November 1999</h2>
           <dl>
              <dt>This version:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/1999/REC-xpath-19991116">http://www.w3.org/TR/1999/REC-xpath-19991116</a><br>
                 (available in <a href="http://www.w3.org/TR/1999/REC-xpath-19991116.xml">XML</a> or 
                 <a href="http://www.w3.org/TR/1999/REC-xpath-19991116.html">HTML</a>)
                 
                 
              </dd>
              <dt>Latest version:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath</a><br>
                 
              </dd>
              <dt>Previous versions:</dt>
              <dd>
                 <a href="http://www.w3.org/TR/1999/PR-xpath-19991008">http://www.w3.org/TR/1999/PR-xpath-19991008</a><br>
                 <a href="http://www.w3.org/1999/08/WD-xpath-19990813">http://www.w3.org/1999/08/WD-xpath-19990813</a><br>
                 <a href="http://www.w3.org/1999/07/WD-xpath-19990709">http://www.w3.org/1999/07/WD-xpath-19990709</a><br>
                 <a href="http://www.w3.org/TR/1999/WD-xslt-19990421">http://www.w3.org/TR/1999/WD-xslt-19990421</a><br>
                 
              </dd>
              <dt>Editors:</dt>
              <dd>
                 
                 James Clark
                 <a href="mailto:jjc@jclark.com">&lt;jjc@jclark.com></a>
                 <br>
                 
                 Steve DeRose
                  (Inso Corp. and Brown University) 
                 <a href="mailto:Steven_DeRose@Brown.edu">&lt;Steven_DeRose@Brown.edu></a>
                 <br>
                 
              </dd>
           </dl>
           <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright">
                 		Copyright
              </a> &nbsp;&copy;&nbsp; 1999 <a href="http://www.w3.org">W3C</a>
              		(<a href="http://www.lcs.mit.edu">MIT</a>,
              		<a href="http://www.inria.fr/">INRIA</a>,
              		<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal_Disclaimer">liability</a>,
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C_Trademarks">trademark</a>,
              		<a href="http://www.w3.org/Consortium/Legal/copyright-documents.html">document use</a> and
              		<a href="http://www.w3.org/Consortium/Legal/copyright-software.html">software licensing</a> rules apply.
              	
           </p>
           <hr title="Separator for header">
        </div>
        <h2><a name="abstract">Abstract</a></h2>
        <p>XPath is a language for addressing parts of an XML
           document, designed to be used by both XSLT and
           XPointer.
        </p>
        <h2><a name="status">Status of this document</a></h2>
        
        
        <p>This document has been reviewed by W3C Members and other interested
           parties and has been endorsed by the Director as a W3C <a href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</a>. It
           is a stable document and may be used as reference material or cited as
           a normative reference from other documents. W3C's role in making the
           Recommendation is to draw attention to the specification and to
           promote its widespread deployment. This enhances the functionality and
           interoperability of the Web.
        </p>
        
        
        <p>The list of known errors in this specification is available at
           <a href="http://www.w3.org/1999/11/REC-xpath-19991116-errata">http://www.w3.org/1999/11/REC-xpath-19991116-errata</a>.
        </p>
        
        
        <p>Comments on this specification may be sent to <a href="mailto:www-xpath-comments@w3.org">www-xpath-comments@w3.org</a>; <a href="http://lists.w3.org/Archives/Public/www-xpath-comments">archives</a>
           of the comments are available.
        </p>
        
        
        <p>The English version of this specification is the only normative
           version. However, for translations of this document, see <a href="http://www.w3.org/Style/XSL/translations.html">http://www.w3.org/Style/XSL/translations.html</a>.
        </p>
        
        
        <p>A list of current W3C Recommendations and other technical documents
           can be found at <a href="http://www.w3.org/TR">http://www.w3.org/TR</a>.
        </p>
        
        
        <p>This specification is joint work of the XSL Working Group and the
           XML Linking Working Group and so is part of the <a href="http://www.w3.org/Style/Activity">W3C Style activity</a> and
           of the <a href="http://www.w3.org/XML/Activity">W3C XML
              activity
           </a>.
        </p>
        
        
        
        <h2><a name="contents">Table of contents</a></h2>1 <a href="#section-Introduction">Introduction</a><br>2 <a href="#location-paths">Location Paths</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.1 <a href="#section-Location-Steps">Location Steps</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.2 <a href="#axes">Axes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.3 <a href="#node-tests">Node Tests</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.4 <a href="#predicates">Predicates</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.5 <a href="#path-abbrev">Abbreviated Syntax</a><br>3 <a href="#section-Expressions">Expressions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.1 <a href="#section-Basics">Basics</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.2 <a href="#section-Function-Calls">Function Calls</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.3 <a href="#node-sets">Node-sets</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.4 <a href="#booleans">Booleans</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.5 <a href="#numbers">Numbers</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.6 <a href="#strings">Strings</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.7 <a href="#exprlex">Lexical Structure</a><br>4 <a href="#corelib">Core Function Library</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.1 <a href="#section-Node-Set-Functions">Node Set Functions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.2 <a href="#section-String-Functions">String Functions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.3 <a href="#section-Boolean-Functions">Boolean Functions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;4.4 <a href="#section-Number-Functions">Number Functions</a><br>5 <a href="#data-model">Data Model</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.1 <a href="#root-node">Root Node</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.2 <a href="#element-nodes">Element Nodes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.2.1 <a href="#unique-id">Unique IDs</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.3 <a href="#attribute-nodes">Attribute Nodes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.4 <a href="#namespace-nodes">Namespace Nodes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.5 <a href="#section-Processing-Instruction-Nodes">Processing Instruction Nodes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.6 <a href="#section-Comment-Nodes">Comment Nodes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.7 <a href="#section-Text-Nodes">Text Nodes</a><br>6 <a href="#section-Conformance">Conformance</a><br><h3>Appendices</h3>A <a href="#section-References">References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.1 <a href="#section-Normative-References">Normative References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.2 <a href="#section-Other-References">Other References</a><br>B <a href="#infoset">XML Information Set Mapping</a> (Non-Normative)<br><hr>
        
        
        
        <h2><a name="section-Introduction"></a>1 Introduction
        </h2>
        
        
        <p>XPath is the result of an effort to provide a common syntax and
           semantics for functionality shared between XSL Transformations <a href="#XSLT">[XSLT]</a> and XPointer <a href="#XPTR">[XPointer]</a>.  The primary purpose
           of XPath is to address parts of an XML <a href="#XML">[XML]</a> document.
           In support of this primary purpose, it also provides basic facilities
           for manipulation of strings, numbers and booleans.  XPath uses a
           compact, non-XML syntax to facilitate use of XPath within URIs and XML
           attribute values.  XPath operates on the abstract, logical structure
           of an XML document, rather than its surface syntax.  XPath gets its
           name from its use of a path notation as in URLs for navigating through
           the hierarchical structure of an XML document.
        </p>
        
        
        <p>In addition to its use for addressing, XPath is also designed so
           that it has a natural subset that can be used for matching (testing
           whether or not a node matches a pattern); this use of XPath is
           described in <a href="http://www.w3.org/TR/WD-xslt#patterns">XSLT</a>.
        </p>
        
        
        <p>XPath models an XML document as a tree of nodes.  There are
           different types of nodes, including element nodes, attribute nodes and
           text nodes.  XPath defines a way to compute a <a href="#dt-string-value">string-value</a> for each type of node.
           Some types of nodes also have names.  XPath fully supports XML
           Namespaces <a href="#XMLNAMES">[XML Names]</a>.  Thus, the name of a node is
           modeled as a pair consisting of a local part and a possibly null
           namespace URI; this is called an <a href="#dt-expanded-name">expanded-name</a>.  The data model is
           described in detail in <a href="#data-model">[<b>5 Data Model</b>]
           </a>.
        </p>
        
        
        <p>The primary syntactic construct in XPath is the expression.  An
           expression matches the production <a href="#NT-Expr">Expr</a>.  An
           expression is evaluated to yield an object, which has one of the
           following four basic types:
        </p>
        
        
        <ul>
           
           
           <li>node-set (an unordered collection of nodes without duplicates)</li>
           
           
           <li>boolean (true or false)</li>
           
           
           <li>number (a floating-point number)</li>
           
           
           <li>string (a sequence of UCS characters)</li>
           
           
        </ul>
        
        
        <p>Expression evaluation occurs with respect to a context.  XSLT and
           XPointer specify how the context is determined for XPath expressions
           used in XSLT and XPointer respectively.  The context consists of:
        </p>
        
        
        <ul>
           
           
           <li>a node (<a name="dt-context-node"></a>the
              <b>context node</b>)
           </li>
           
           
           <li>a pair of non-zero positive integers (<a name="dt-context-position"></a>the <b>context
                 position
              </b> and <a name="dt-context-size"></a>the <b>context size</b>)
           </li>
           
           
           <li>a set of variable bindings</li>
           
           
           <li>a function library</li>
           
           
           <li>the set of namespace declarations in scope for the
              expression
           </li>
           
           
        </ul>
        
        
        <p>The context position is always less than or equal to the
           context size.
        </p>
        
        
        <p>The variable bindings consist of a mapping from variable names to
           variable values.  The value of a variable is an object, which can be of
           any of the types that are possible for the value of an expression,
           and may also be of additional types not specified here.
        </p>
        
        
        <p>The function library consists of a mapping from function names to
           functions.  Each function takes zero or more arguments and returns a
           single result.  This document defines a core function library that all
           XPath implementations must support (see <a href="#corelib">[<b>4 Core Function Library</b>]
           </a>).
           For a function in the core function library, arguments and result are
           of the four basic types.  Both XSLT and XPointer extend XPath by
           defining additional functions; some of these functions operate on the
           four basic types; others operate on additional data types defined by
           XSLT and XPointer.
        </p>
        
        
        <p>The namespace declarations consist of a mapping from prefixes to
           namespace URIs.
        </p>
        
        
        <p>The variable bindings, function library and namespace declarations
           used to evaluate a subexpression are always the same as those used to
           evaluate the containing expression.  The context node, context
           position, and context size used to evaluate a subexpression are
           sometimes different from those used to evaluate the containing
           expression. Several kinds of expressions change the context node; only
           predicates change the context position and context size (see <a href="#predicates">[<b>2.4 Predicates</b>]
           </a>).  When the evaluation of a kind of expression is
           described, it will always be explicitly stated if the context node,
           context position, and context size change for the evaluation of
           subexpressions; if nothing is said about the context node, context
           position, and context size, they remain unchanged for the
           evaluation of subexpressions of that kind of expression.
        </p>
        
        
        <p>XPath expressions often occur in XML attributes.  The grammar
           specified in this section applies to the attribute value after XML 1.0
           normalization.  So, for example, if the grammar uses the character
           <code>&lt;</code>, this must not appear in the XML source as
           <code>&lt;</code> but must be quoted according to XML 1.0 rules by,
           for example, entering it as <code>&amp;lt;</code>. Within expressions,
           literal strings are delimited by single or double quotation marks,
           which are also used to delimit XML attributes. To avoid a quotation
           mark in an expression being interpreted by the XML processor as
           terminating the attribute value the quotation mark can be entered as a
           character reference (<code>&amp;quot;</code> or
           <code>&amp;apos;</code>).  Alternatively, the expression can use single
           quotation marks if the XML attribute is delimited with double
           quotation marks or vice-versa.
        </p>
        
        
        <p>One important kind of expression is a location path.  A location
           path selects a set of nodes relative to the context node.  The result
           of evaluating an expression that is a location path is the node-set
           containing the nodes selected by the location path.  Location paths
           can recursively contain expressions that are used to filter sets of
           nodes.  A location path matches the production <a href="#NT-LocationPath">LocationPath</a>.
        </p>
        
        
        <p>In the following grammar, the non-terminals <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> and <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> are defined in <a href="#XMLNAMES">[XML Names]</a>, and <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a> is defined in
           <a href="#XML">[XML]</a>.  The grammar uses the same EBNF notation as
           <a href="#XML">[XML]</a> (except that grammar symbols always have initial
           capital letters).
        </p>
        
        
        <p>Expressions are parsed by first dividing the character string to be
           parsed into tokens and then parsing the resulting sequence of tokens.
           Whitespace can be freely used between tokens.  The tokenization
           process is described in <a href="#exprlex">[<b>3.7 Lexical Structure</b>]
           </a>.
        </p>
        
        
        
        
        
        <h2><a name="location-paths"></a>2 Location Paths
        </h2>
        
        
        <p>Although location paths are not the most general grammatical
           construct in the language (a <a href="#NT-LocationPath">LocationPath</a> is a special case of an <a href="#NT-Expr">Expr</a>), they are the most important construct and
           will therefore be described first.
        </p>
        
        
        <p>Every location path can be expressed using a straightforward but
           rather verbose syntax.  There are also a number of syntactic
           abbreviations that allow common cases to be expressed concisely.  This
           section will explain the semantics of location paths using the
           unabbreviated syntax.  The abbreviated syntax will then be explained
           by showing how it expands into the unabbreviated syntax (see <a href="#path-abbrev">[<b>2.5 Abbreviated Syntax</b>]
           </a>).
        </p>
        
        
        <p>Here are some examples of location paths using the unabbreviated
           syntax:
        </p>
        
        
        <ul>
           
           
           <li>
              <p><code>child::para</code> selects the
                 <code>para</code> element children of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::*</code> selects all element
                 children of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::text()</code> selects all text
                 node children of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::node()</code> selects all the
                 children of the context node, whatever their node type
              </p>
           </li>
           
           
           <li>
              <p><code>attribute::name</code> selects the
                 <code>name</code> attribute of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>attribute::*</code> selects all the
                 attributes of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>descendant::para</code> selects the
                 <code>para</code> element descendants of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>ancestor::div</code> selects all <code>div</code>
                 ancestors of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>ancestor-or-self::div</code> selects the
                 <code>div</code> ancestors of the context node and, if the context node is a
                 <code>div</code> element, the context node as well
              </p>
           </li>
           
           
           <li>
              <p><code>descendant-or-self::para</code> selects the
                 <code>para</code> element descendants of the context node and, if the context node is
                 a <code>para</code> element, the context node as well
              </p>
           </li>
           
           
           <li>
              <p><code>self::para</code> selects the context node if it is a
                 <code>para</code> element, and otherwise selects nothing
              </p>
           </li>
           
           
           <li>
              <p><code>child::chapter/descendant::para</code>
                 selects the <code>para</code> element descendants of the
                 <code>chapter</code> element children of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::*/child::para</code> selects
                 all <code>para</code> grandchildren of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>/</code> selects the document root (which is
                 always the parent of the document element)
              </p>
           </li>
           
           
           <li>
              <p><code>/descendant::para</code> selects all the
                 <code>para</code> elements in the same document as the context node
              </p>
           </li>
           
           
           <li>
              <p><code>/descendant::olist/child::item</code> selects all the
                 <code>item</code> elements that have an <code>olist</code> parent and
                 that are in the same document as the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::para[position()=1]</code> selects the first
                 <code>para</code> child of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::para[position()=last()]</code> selects the last
                 <code>para</code> child of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::para[position()=last()-1]</code> selects
                 the last but one <code>para</code> child of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::para[position()>1]</code> selects all
                 the <code>para</code> children of the context node other than the
                 first <code>para</code> child of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>following-sibling::chapter[position()=1]</code>
                 selects the next <code>chapter</code> sibling of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>preceding-sibling::chapter[position()=1]</code>
                 selects the previous <code>chapter</code> sibling of the context
                 node
              </p>
           </li>
           
           
           <li>
              <p><code>/descendant::figure[position()=42]</code> selects
                 the forty-second <code>figure</code> element in the
                 document
              </p>
           </li>
           
           
           <li>
              <p><code>/child::doc/child::chapter[position()=5]/child::section[position()=2]</code>
                 selects the second <code>section</code> of the fifth
                 <code>chapter</code> of the <code>doc</code> document
                 element
              </p>
           </li>
           
           
           <li>
              <p><code>child::para[attribute::type="warning"]</code>
                 selects all <code>para</code> children of the context node that have a
                 <code>type</code> attribute with value <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>child::para[attribute::type='warning'][position()=5]</code>
                 selects the fifth <code>para</code> child of the context node that has
                 a <code>type</code> attribute with value
                 <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>child::para[position()=5][attribute::type="warning"]</code>
                 selects the fifth <code>para</code> child of the context node if that
                 child has a <code>type</code> attribute with value
                 <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>child::chapter[child::title='Introduction']</code>
                 selects the <code>chapter</code> children of the context node that
                 have one or more <code>title</code> children with <a href="#dt-string-value">string-value</a> equal to
                 <code>Introduction</code></p>
           </li>
           
           
           <li>
              <p><code>child::chapter[child::title]</code> selects the
                 <code>chapter</code> children of the context node that have one or
                 more <code>title</code> children
              </p>
           </li>
           
           
           <li>
              <p><code>child::*[self::chapter or self::appendix]</code>
                 selects the <code>chapter</code> and <code>appendix</code> children of
                 the context node
              </p>
           </li>
           
           
           <li>
              <p><code>child::*[self::chapter or
                    self::appendix][position()=last()]
                 </code> selects the last
                 <code>chapter</code> or <code>appendix</code> child of the context
                 node
              </p>
           </li>
           
           
        </ul>
        
        
        <p>There are two kinds of location path: relative location paths
           and absolute location paths.
        </p>
        
        
        <p>A relative location path consists of a sequence of one or more
           location steps separated by <code>/</code>.  The steps in a relative
           location path are composed together from left to right.  Each step in
           turn selects a set of nodes relative to a context node. An initial
           sequence of steps is composed together with a following step as
           follows.  The initial sequence of steps selects a set of nodes
           relative to a context node.  Each node in that set is used as a
           context node for the following step.  The sets of nodes identified by
           that step are unioned together.  The set of nodes identified by
           the composition of the steps is this union. For example,
           <code>child::div/child::para</code> selects the
           <code>para</code> element children of the <code>div</code> element
           children of the context node, or, in other words, the
           <code>para</code> element grandchildren that have <code>div</code>
           parents.
        </p>
        
        
        <p>An absolute location path consists of <code>/</code> optionally
           followed by a relative location path.  A <code>/</code> by itself
           selects the root node of the document containing the context node.  If
           it is followed by a relative location path, then the location path
           selects the set of nodes that would be selected by the relative
           location path relative to the root node of the document containing the
           context node.
        </p>
        
        
        <h5>Location Paths</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-LocationPath"></a>[1]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>LocationPath</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-RelativeLocationPath">RelativeLocationPath</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AbsoluteLocationPath">AbsoluteLocationPath</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-AbsoluteLocationPath"></a>[2]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AbsoluteLocationPath</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'/' <a href="#NT-RelativeLocationPath">RelativeLocationPath</a>?
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AbbreviatedAbsoluteLocationPath">AbbreviatedAbsoluteLocationPath</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-RelativeLocationPath"></a>[3]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>RelativeLocationPath</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-Step">Step</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelativeLocationPath">RelativeLocationPath</a> '/' <a href="#NT-Step">Step</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AbbreviatedRelativeLocationPath">AbbreviatedRelativeLocationPath</a></td>
                 <td></td>
              </tr>
              
           </tbody>
        </table>
        
        
        
        <h3><a name="section-Location-Steps"></a>2.1 Location Steps
        </h3>
        
        
        <p>A location step has three parts:</p>
        
        
        <ul>
           
           
           <li>
              <p>an axis, which specifies the tree relationship between the
                 nodes selected by the location step and the context node,
              </p>
           </li>
           
           
           <li>
              <p>a node test, which specifies the node type and <a href="#dt-expanded-name">expanded-name</a> of the nodes selected
                 by the location step, and
              </p>
           </li>
           
           
           <li>
              <p>zero or more predicates, which use arbitrary expressions to
                 further refine the set of nodes selected by the location
                 step.
              </p>
           </li>
           
           
        </ul>
        
        
        <p>The syntax for a location step is the axis name and node test
           separated by a double colon, followed by zero or more expressions each
           in square brackets. For example, in
           <code>child::para[position()=1]</code>, <code>child</code> is the name
           of the axis, <code>para</code> is the node test and
           <code>[position()=1]</code> is a predicate.
        </p>
        
        
        <p>The node-set selected by the location step is the node-set that
           results from generating an initial node-set from the axis and
           node-test, and then filtering that node-set by each of the predicates
           in turn.
        </p>
        
        
        <p>The initial node-set consists of the nodes having the relationship
           to the context node specified by the axis, and having the node type
           and <a href="#dt-expanded-name">expanded-name</a> specified
           by the node test.  For example, a location step
           <code>descendant::para</code> selects the <code>para</code> element
           descendants of the context node: <code>descendant</code> specifies
           that each node in the initial node-set must be a descendant of the
           context; <code>para</code> specifies that each node in the initial
           node-set must be an element named <code>para</code>.  The available
           axes are described in <a href="#axes">[<b>2.2 Axes</b>]
           </a>.  The available node tests
           are described in <a href="#node-tests">[<b>2.3 Node Tests</b>]
           </a>.  The meaning of some
           node tests is dependent on the axis.
        </p>
        
        
        <p>The initial node-set is filtered by the first predicate to generate
           a new node-set; this new node-set is then filtered using the second
           predicate, and so on. The final node-set is the node-set selected by
           the location step. The axis affects how the expression in each
           predicate is evaluated and so the semantics of a predicate is defined
           with respect to an axis.  See <a href="#predicates">[<b>2.4 Predicates</b>]
           </a>.
        </p>
        
        
        <h5>Location Steps</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-Step"></a>[4]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Step</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-AxisSpecifier">AxisSpecifier</a>
                    <a href="#NT-NodeTest">NodeTest</a>
                    <a href="#NT-Predicate">Predicate</a>*
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AbbreviatedStep">AbbreviatedStep</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-AxisSpecifier"></a>[5]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AxisSpecifier</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-AxisName">AxisName</a> '::'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AbbreviatedAxisSpecifier">AbbreviatedAxisSpecifier</a>
                    
                 </td>
                 <td></td>
              </tr>
              
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="axes"></a>2.2 Axes
        </h3>
        
        
        <p>The following axes are available:</p>
        
        
        <ul>
           
           
           <li>
              <p>the <code>child</code> axis contains the children of the
                 context node
              </p>
           </li>
           
           
           <li>
              <p>the <code>descendant</code> axis contains the descendants of
                 the context node; a descendant is a child or a child of a child and so
                 on; thus the descendant axis never contains attribute or namespace
                 nodes
              </p>
           </li>
           
           
           <li>
              <p>the <code>parent</code> axis contains the <a href="#dt-parent">parent</a> of the context node, if there is
                 one
              </p>
           </li>
           
           
           <li>
              <p>the <code>ancestor</code> axis contains the ancestors of the
                 context node; the ancestors of the context node consist of the
                 <a href="#dt-parent">parent</a> of context node and the
                 parent's parent and so on; thus, the ancestor axis will always include
                 the root node, unless the context node is the root node
              </p>
           </li>
           
           
           <li>
              <p>the <code>following-sibling</code> axis contains all the
                 following siblings of the context node; if the
                 context node is an attribute node or namespace node, the
                 <code>following-sibling</code> axis is empty
              </p>
           </li>
           
           
           <li>
              <p>the <code>preceding-sibling</code> axis contains all the
                 preceding siblings of the context node; if the context node is an
                 attribute node or namespace node, the <code>preceding-sibling</code>
                 axis is empty
              </p>
           </li>
           
           
           <li>
              <p>the <code>following</code> axis contains all nodes in the
                 same document as the context node that are after the context node in
                 document order, excluding any descendants and excluding attribute
                 nodes and namespace nodes
              </p>
           </li>
           
           
           <li>
              <p>the <code>preceding</code> axis contains all nodes in the
                 same document as the context node that are before the context node in
                 document order, excluding any ancestors and excluding attribute nodes
                 and namespace nodes
              </p>
           </li>
           
           
           <li>
              <p>the <code>attribute</code> axis contains the attributes of
                 the context node; the axis will be empty unless the context node is an
                 element
              </p>
           </li>
           
           
           <li>
              <p>the <code>namespace</code> axis contains the namespace nodes
                 of the context node; the axis will be empty unless the context node
                 is an element
              </p>
           </li>
           
           
           <li>
              <p>the <code>self</code> axis contains just the context node
                 itself
              </p>
           </li>
           
           
           <li>
              <p>the <code>descendant-or-self</code> axis contains the context
                 node and the descendants of the context node
              </p>
           </li>
           
           
           <li>
              <p>the <code>ancestor-or-self</code> axis contains the context
                 node and the ancestors of the context node; thus, the ancestor axis
                 will always include the root node
              </p>
           </li>
           
           
        </ul>
        
        
        <blockquote><b>NOTE: </b>The <code>ancestor</code>, <code>descendant</code>,
           <code>following</code>, <code>preceding</code> and <code>self</code>
           axes partition a document (ignoring attribute and namespace nodes):
           they do not overlap and together they contain all the nodes in the
           document.
        </blockquote>
        
        
        <h5>Axes</h5>
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-AxisName"></a>[6]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AxisName</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'ancestor'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'ancestor-or-self'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'attribute'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'child'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'descendant'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'descendant-or-self'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'following'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'following-sibling'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'namespace'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'parent'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'preceding'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'preceding-sibling'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'self'</td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="node-tests"></a>2.3 Node Tests
        </h3>
        
        
        <p><a name="dt-principal-node-type"></a>Every axis has a <b>principal node type</b>.  If an axis
           can contain elements, then the principal node type is element;
           otherwise, it is the type of the nodes that the axis can
           contain. Thus,
        </p>
        
        
        <ul>
           
           
           <li>For the attribute axis, the principal node type is attribute.</li>
           
           
           <li>For the namespace axis, the principal node type is namespace.</li>
           
           
           <li>For other axes, the principal node type is element.</li>
           
           
        </ul>
        
        
        <p>A node test that is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>
           is true if and only if the type of the node (see <a href="#data-model">[<b>5 Data Model</b>]
           </a>)
           is the principal node type and has
           an <a href="#dt-expanded-name">expanded-name</a> equal to
           the <a href="#dt-expanded-name">expanded-name</a> specified
           by the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  For example,
           <code>child::para</code> selects the <code>para</code> element
           children of the context node; if the context node has no
           <code>para</code> children, it will select an empty set of nodes.
           <code>attribute::href</code> selects the <code>href</code> attribute
           of the context node; if the context node has no <code>href</code>
           attribute, it will select an empty set of nodes.
        </p>
        
        
        <p>A <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> in the node test is
           expanded into an <a href="#dt-expanded-name">expanded-name</a> using the namespace
           declarations from the expression context.  This is the same way
           expansion is done for element type names in start and end-tags except
           that the default namespace declared with <code>xmlns</code> is not
           used: if the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> does not have
           a prefix, then the namespace URI is null (this is the same way
           attribute names are expanded).  It is an error if the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> has a prefix for which there is
           no namespace declaration in the expression context.
        </p>
        
        
        <p>A node test <code>*</code> is true for any node of the principal
           node type.  For example, <code>child::*</code> will select all element
           children of the context node, and <code>attribute::*</code> will
           select all attributes of the context node.
        </p>
        
        
        <p>A node test can have the form <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a><code>:*</code>.  In this
           case, the prefix is expanded in the same way as with a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, using the context namespace
           declarations.  It is an error if there is no namespace declaration for
           the prefix in the expression context.  The node test will be true for
           any node of the principal type whose <a href="#dt-expanded-name">expanded-name</a> has the namespace URI
           to which the prefix expands, regardless of the local part of the
           name.
        </p>
        
        
        <p>The node test <code>text()</code> is true for any text node. For
           example, <code>child::text()</code> will select the text node
           children of the context node.  Similarly, the node test
           <code>comment()</code> is true for any comment node, and the node test
           <code>processing-instruction()</code> is true for any processing
           instruction. The <code>processing-instruction()</code> test may have
           an argument that is <a href="#NT-Literal">Literal</a>; in this case, it
           is true for any processing instruction that has a name equal to the
           value of the <a href="#NT-Literal">Literal</a>.
        </p>
        
        
        <p>A node test <code>node()</code> is true for any node of any type
           whatsoever.
        </p>
        
        
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-NodeTest"></a>[7]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>NodeTest</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-NameTest">NameTest</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-NodeType">NodeType</a> '(' ')'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'processing-instruction' '(' <a href="#NT-Literal">Literal</a> ')'
                 </td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="predicates"></a>2.4 Predicates
        </h3>
        
        
        <p>An axis is either a forward axis or a reverse axis.  An axis that
           only ever contains the context node or nodes that are after the
           context node in <a href="#dt-document-order">document
              order
           </a> is a forward axis.  An axis that only ever contains
           the context node or nodes that are before the context node in <a href="#dt-document-order">document order</a> is a reverse axis.
           Thus, the ancestor, ancestor-or-self, preceding, and preceding-sibling
           axes are reverse axes; all other axes are forward axes. Since the self
           axis always contains at most one node, it makes no difference whether
           it is a forward or reverse axis.  <a name="dt-proximity-position"></a>The <b>proximity position</b> of a
           member of a node-set with respect to an axis is defined to be the
           position of the node in the node-set ordered in document order if the
           axis is a forward axis and ordered in reverse document order if the
           axis is a reverse axis. The first position is 1.
        </p>
        
        
        <p>A predicate filters a node-set with respect to an axis to produce a
           new node-set.  For each node in the node-set to be filtered, the <a href="#NT-PredicateExpr">PredicateExpr</a> is evaluated with that node
           as the context node, with the number of nodes in the node-set as the
           context size, and with the <a href="#dt-proximity-position">proximity position</a> of the node
           in the node-set with respect to the axis as the context position; if
           <a href="#NT-PredicateExpr">PredicateExpr</a> evaluates to true for
           that node, the node is included in the new node-set; otherwise, it is
           not included.
        </p>
        
        
        <p>A <a href="#NT-PredicateExpr">PredicateExpr</a> is evaluated by
           evaluating the <a href="#NT-Expr">Expr</a> and converting the result
           to a boolean.  If the result is a number, the result will be converted
           to true if the number is equal to the context position and will be
           converted to false otherwise; if the result is not a number, then the
           result will be converted as if by a call to the
           <b><a href="#function-boolean">boolean</a></b> function.  Thus a location path
           <code>para[3]</code> is equivalent to
           <code>para[position()=3]</code>.
        </p>
        
        
        <h5>Predicates</h5>
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-Predicate"></a>[8]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Predicate</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'[' <a href="#NT-PredicateExpr">PredicateExpr</a> ']'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-PredicateExpr"></a>[9]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>PredicateExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-Expr">Expr</a></td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="path-abbrev"></a>2.5 Abbreviated Syntax
        </h3>
        
        
        <p>Here are some examples of location paths using abbreviated
           syntax:
        </p>
        
        
        <ul>
           
           
           <li>
              <p><code>para</code> selects the <code>para</code> element children of
                 the context node
              </p>
           </li>
           
           
           <li>
              <p><code>*</code> selects all element children of the
                 context node
              </p>
           </li>
           
           
           <li>
              <p><code>text()</code> selects all text node children of the
                 context node
              </p>
           </li>
           
           
           <li>
              <p><code>@name</code> selects the <code>name</code> attribute of
                 the context node
              </p>
           </li>
           
           
           <li>
              <p><code>@*</code> selects all the attributes of the
                 context node
              </p>
           </li>
           
           
           <li>
              <p><code>para[1]</code> selects the first <code>para</code> child of
                 the context node
              </p>
           </li>
           
           
           <li>
              <p><code>para[last()]</code> selects the last <code>para</code> child
                 of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>*/para</code> selects all <code>para</code> grandchildren of
                 the context node
              </p>
           </li>
           
           
           <li>
              <p><code>/doc/chapter[5]/section[2]</code> selects the second
                 <code>section</code> of the fifth <code>chapter</code> of the
                 <code>doc</code></p>
           </li>
           
           
           <li>
              <p><code>chapter//para</code> selects the <code>para</code> element
                 descendants of the <code>chapter</code> element children of the
                 context node
              </p>
           </li>
           
           
           <li>
              <p><code>//para</code> selects all the <code>para</code> descendants of
                 the document root and thus selects all <code>para</code> elements in the
                 same document as the context node
              </p>
           </li>
           
           
           <li>
              <p><code>//olist/item</code> selects all the <code>item</code>
                 elements in the same document as the context node that have an
                 <code>olist</code> parent
              </p>
           </li>
           
           
           <li>
              <p><code>.</code> selects the context node
              </p>
           </li>
           
           
           <li>
              <p><code>.//para</code> selects the <code>para</code> element
                 descendants of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>..</code> selects the parent of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>../@lang</code> selects the <code>lang</code> attribute
                 of the parent of the context node
              </p>
           </li>
           
           
           <li>
              <p><code>para[@type="warning"]</code> selects all <code>para</code>
                 children of the context node that have a <code>type</code> attribute with
                 value <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>para[@type="warning"][5]</code> selects the fifth
                 <code>para</code> child of the context node that has a <code>type</code>
                 attribute with value <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>para[5][@type="warning"]</code> selects the fifth
                 <code>para</code> child of the context node if that child has a
                 <code>type</code> attribute with value <code>warning</code></p>
           </li>
           
           
           <li>
              <p><code>chapter[title="Introduction"]</code> selects the
                 <code>chapter</code> children of the context node that have one or
                 more <code>title</code> children with <a href="#dt-string-value">string-value</a> equal to
                 <code>Introduction</code></p>
           </li>
           
           
           <li>
              <p><code>chapter[title]</code> selects the <code>chapter</code>
                 children of the context node that have one or more <code>title</code>
                 children
              </p>
           </li>
           
           
           <li>
              <p><code>employee[@secretary and @assistant]</code> selects all
                 the <code>employee</code> children of the context node that have both a
                 <code>secretary</code> attribute and an <code>assistant</code>
                 attribute
              </p>
           </li>
           
           
        </ul>
        
        
        <p>The most important abbreviation is that <code>child::</code> can be
           omitted from a location step.  In effect, <code>child</code> is the
           default axis.  For example, a location path <code>div/para</code> is
           short for <code>child::div/child::para</code>.
        </p>
        
        
        <p>There is also an abbreviation for attributes:
           <code>attribute::</code> can be abbreviated to <code>@</code>. For
           example, a location path <code>para[@type="warning"]</code> is short
           for <code>child::para[attribute::type="warning"]</code> and so selects
           <code>para</code> children with a <code>type</code> attribute with
           value equal to <code>warning</code>.
        </p>
        
        
        <p><code>//</code> is short for
           <code>/descendant-or-self::node()/</code>.  For example,
           <code>//para</code> is short for
           <code>/descendant-or-self::node()/child::para</code> and so will
           select any <code>para</code> element in the document (even a
           <code>para</code> element that is a document element will be selected
           by <code>//para</code> since the document element node is a child of
           the root node); <code>div//para</code> is short for
           <code>div/descendant-or-self::node()/child::para</code> and so
           will select all <code>para</code> descendants of <code>div</code>
           children.
        </p>
        
        
        <blockquote><b>NOTE: </b>The location path <code>//para[1]</code> does
           <i>not</i> mean the same as the location path
           <code>/descendant::para[1]</code>.  The latter selects the first
           descendant <code>para</code> element; the former selects all descendant
           <code>para</code> elements that are the first <code>para</code>
           children of their parents.
        </blockquote>
        
        
        <p>A location step of <code>.</code> is short for
           <code>self::node()</code>. This is particularly useful in
           conjunction with <code>//</code>. For example, the location path
           <code>.//para</code> is short for
        </p>
        
        <pre>self::node()/descendant-or-self::node()/child::para</pre>
        
        <p>and so will select all <code>para</code> descendant elements of the
           context node.
        </p>
        
        
        <p>Similarly, a location step of <code>..</code> is short for
           <code>parent::node()</code>. For example, <code>../title</code> is
           short for <code>parent::node()/child::title</code> and so will
           select the <code>title</code> children of the parent of the context
           node.
        </p>
        
        
        <h5>Abbreviations</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-AbbreviatedAbsoluteLocationPath"></a>[10]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AbbreviatedAbsoluteLocationPath</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'//' <a href="#NT-RelativeLocationPath">RelativeLocationPath</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-AbbreviatedRelativeLocationPath"></a>[11]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AbbreviatedRelativeLocationPath</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-RelativeLocationPath">RelativeLocationPath</a> '//' <a href="#NT-Step">Step</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-AbbreviatedStep"></a>[12]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AbbreviatedStep</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'.'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '..'</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-AbbreviatedAxisSpecifier"></a>[13]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AbbreviatedAxisSpecifier</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'@'?</td>
                 <td></td>
              </tr>
              
           </tbody>
        </table>
        
        
        
        
        
        
        
        <h2><a name="section-Expressions"></a>3 Expressions
        </h2>
        
        
        
        <h3><a name="section-Basics"></a>3.1 Basics
        </h3>
        
        
        <p>A <a href="#NT-VariableReference">VariableReference</a> evaluates
           to the value to which the variable name is bound in the set of
           variable bindings in the context.  It is an error if the variable name
           is not bound to any value in the set of variable bindings in the
           expression context.
        </p>
        
        
        <p>Parentheses may be used for grouping.</p>
        
        
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-Expr"></a>[14]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Expr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-OrExpr">OrExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-PrimaryExpr"></a>[15]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>PrimaryExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-VariableReference">VariableReference</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '(' <a href="#NT-Expr">Expr</a> ')'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Literal">Literal</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Number">Number</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FunctionCall">FunctionCall</a></td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="section-Function-Calls"></a>3.2 Function Calls
        </h3>
        
        
        <p>A <a href="#NT-FunctionCall">FunctionCall</a> expression is
           evaluated by using the <a href="#NT-FunctionName">FunctionName</a> to
           identify a function in the expression evaluation context function
           library, evaluating each of the <a href="#NT-Argument">Argument</a>s,
           converting each argument to the type required by the function, and
           finally calling the function, passing it the converted arguments.  It
           is an error if the number of arguments is wrong or if an argument
           cannot be converted to the required type.  The result of the <a href="#NT-FunctionCall">FunctionCall</a> expression is the result
           returned by the function.
        </p>
        
        
        <p>An argument is converted to type string as if by calling the
           <b><a href="#function-string">string</a></b> function.  An argument is converted to
           type number as if by calling the <b><a href="#function-number">number</a></b> function.
           An argument is converted to type boolean as if by calling the
           <b><a href="#function-boolean">boolean</a></b> function.  An argument that is not of
           type node-set cannot be converted to a node-set.
        </p>
        
        
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-FunctionCall"></a>[16]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>FunctionCall</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-FunctionName">FunctionName</a> '(' ( <a href="#NT-Argument">Argument</a> ( ',' <a href="#NT-Argument">Argument</a> )* )? ')'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-Argument"></a>[17]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Argument</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-Expr">Expr</a></td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="node-sets"></a>3.3 Node-sets
        </h3>
        
        
        <p>A location path can be used as an expression.  The expression
           returns the set of nodes selected by the path.
        </p>
        
        
        <p>The <code>|</code> operator computes the union of its operands,
           which must be node-sets.
        </p>
        
        
        <p><a href="#NT-Predicate">Predicate</a>s are used to filter
           expressions in the same way that they are used in location paths. It
           is an error if the expression to be filtered does not evaluate to a
           node-set.  The <a href="#NT-Predicate">Predicate</a> filters the
           node-set with respect to the child axis.
        </p>
        
        
        <blockquote><b>NOTE: </b>The meaning of a <a href="#NT-Predicate">Predicate</a>
           depends crucially on which axis applies. For example,
           <code>preceding::foo[1]</code> returns the first <code>foo</code>
           element in <i>reverse document order</i>, because the axis that
           applies to the <code>[1]</code> predicate is the preceding axis; by
           contrast, <code>(preceding::foo)[1]</code> returns the first
           <code>foo</code> element in <i>document order</i>, because the
           axis that applies to the <code>[1]</code> predicate is the child
           axis.
        </blockquote>
        
        
        <p>The <code>/</code> and <code>//</code> operators compose an
           expression and a relative location path.  It is an error if the
           expression does not evaluate to a node-set.  The <code>/</code>
           operator does composition in the same way as when <code>/</code> is
           used in a location path. As in location paths, <code>//</code> is
           short for <code>/descendant-or-self::node()/</code>.
        </p>
        
        
        <p>There are no types of objects that can be converted to node-sets.</p>
        
        
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-UnionExpr"></a>[18]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>UnionExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-PathExpr">PathExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-UnionExpr">UnionExpr</a> '|' <a href="#NT-PathExpr">PathExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-PathExpr"></a>[19]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>PathExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-LocationPath">LocationPath</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FilterExpr">FilterExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FilterExpr">FilterExpr</a> '/' <a href="#NT-RelativeLocationPath">RelativeLocationPath</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FilterExpr">FilterExpr</a> '//' <a href="#NT-RelativeLocationPath">RelativeLocationPath</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-FilterExpr"></a>[20]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>FilterExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-PrimaryExpr">PrimaryExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FilterExpr">FilterExpr</a> <a href="#NT-Predicate">Predicate</a></td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="booleans"></a>3.4 Booleans
        </h3>
        
        
        <p>An object of type boolean can have one of two values, true and
           false.
        </p>
        
        
        <p>An <code>or</code> expression is evaluated by evaluating each
           operand and converting its value to a boolean as if by a call to the
           <b><a href="#function-boolean">boolean</a></b> function.  The result is true if either
           value is true and false otherwise.  The right operand is not evaluated
           if the left operand evaluates to true.
        </p>
        
        
        <p>An <code>and</code> expression is evaluated by evaluating each
           operand and converting its value to a boolean as if by a call to the
           <b><a href="#function-boolean">boolean</a></b> function.  The result is true if both
           values are true and false otherwise.  The right operand is not
           evaluated if the left operand evaluates to false.
        </p>
        
        
        <p>An <a href="#NT-EqualityExpr">EqualityExpr</a> (that is not just
           a <a href="#NT-RelationalExpr">RelationalExpr</a>) or a <a href="#NT-RelationalExpr">RelationalExpr</a> (that is not just an <a href="#NT-AdditiveExpr">AdditiveExpr</a>) is evaluated by comparing the
           objects that result from evaluating the two operands.  Comparison of
           the resulting objects is defined in the following three paragraphs.
           First, comparisons that involve node-sets are defined in terms of
           comparisons that do not involve node-sets; this is defined uniformly
           for <code>=</code>, <code>!=</code>, <code>&lt;=</code>,
           <code>&lt;</code>, <code>>=</code> and <code>></code>.  Second,
           comparisons that do not involve node-sets are defined for
           <code>=</code> and <code>!=</code>.  Third, comparisons that do not
           involve node-sets are defined for <code>&lt;=</code>,
           <code>&lt;</code>, <code>>=</code> and <code>></code>.
        </p>
        
        
        <p>If both objects to be compared are node-sets, then the comparison
           will be true if and only if there is a node in the first node-set and
           a node in the second node-set such that the result of performing the
           comparison on the <a href="#dt-string-value">string-value</a>s of the two nodes is
           true.  If one object to be compared is a node-set and the other is a
           number, then the comparison will be true if and only if there is a
           node in the node-set such that the result of performing the comparison
           on the number to be compared and on the result of converting the
           <a href="#dt-string-value">string-value</a> of that node to
           a number using the <b><a href="#function-number">number</a></b> function is true.  If
           one object to be compared is a node-set and the other is a string,
           then the comparison will be true if and only if there is a node in the
           node-set such that the result of performing the comparison on the
           <a href="#dt-string-value">string-value</a> of the node and
           the other string is true. If one object to be compared is a node-set
           and the other is a boolean, then the comparison will be true if and
           only if the result of performing the comparison on the boolean and on
           the result of converting the node-set to a boolean using the
           <b><a href="#function-boolean">boolean</a></b> function is true.
        </p>
        
        
        <p>When neither object to be compared is a node-set and the operator
           is <code>=</code> or <code>!=</code>, then the objects are compared by
           converting them to a common type as follows and then comparing them.
           If at least one object to be compared is a boolean, then each object
           to be compared is converted to a boolean as if by applying the
           <b><a href="#function-boolean">boolean</a></b> function.  Otherwise, if at least one
           object to be compared is a number, then each object to be compared is
           converted to a number as if by applying the
           <b><a href="#function-number">number</a></b> function.  Otherwise, both objects to be
           compared are converted to strings as if by applying the
           <b><a href="#function-string">string</a></b> function.  The <code>=</code> comparison
           will be true if and only if the objects are equal; the <code>!=</code>
           comparison will be true if and only if the objects are not equal.
           Numbers are compared for equality according to IEEE 754 <a href="#IEEE754">[IEEE 754]</a>.  Two booleans are equal if either both are true or
           both are false.  Two strings are equal if and only if they consist of
           the same sequence of UCS characters.
        </p>
        
        
        <blockquote><b>NOTE: </b>If <code>$x</code> is bound to a node-set, then
           <code>$x="foo"</code> does not mean the same as
           <code>not($x!="foo")</code>: the former is true if and only if
           <i>some</i> node in <code>$x</code> has the string-value
           <code>foo</code>; the latter is true if and only if <i>all</i>
           nodes in <code>$x</code> have the string-value
           <code>foo</code>.
        </blockquote>
        
        
        <p>When neither object to be compared is a node-set and the operator
           is <code>&lt;=</code>, <code>&lt;</code>, <code>>=</code> or
           <code>></code>, then the objects are compared by converting both
           objects to numbers and comparing the numbers according to IEEE 754.
           The <code>&lt;</code> comparison will be true if and only if the first
           number is less than the second number.  The <code>&lt;=</code>
           comparison will be true if and only if the first number is less than
           or equal to the second number.  The <code>></code> comparison will
           be true if and only if the first number is greater than the second
           number.  The <code>>=</code> comparison will be true if and only if
           the first number is greater than or equal to the second number.
        </p>
        
        
        <blockquote><b>NOTE: </b>
           
           When an XPath expression occurs in an XML document, any
           <code>&lt;</code> and <code>&lt;=</code> operators must be quoted
           according to XML 1.0 rules by using, for example,
           <code>&amp;lt;</code> and <code>&amp;lt;=</code>. In the following
           example the value of the <code>test</code> attribute is an XPath
           expression:
           
           <pre>&lt;xsl:if test="@value &amp;lt; 10">...&lt;/xsl:if></pre>
           
           </blockquote>
        
        
        <table class="scrap">
           <tbody>
              <tr valign="baseline">
                 <td><a name="NT-OrExpr"></a>[21]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>OrExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-AndExpr">AndExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-OrExpr">OrExpr</a> 'or' <a href="#NT-AndExpr">AndExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-AndExpr"></a>[22]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AndExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-EqualityExpr">EqualityExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AndExpr">AndExpr</a> 'and' <a href="#NT-EqualityExpr">EqualityExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-EqualityExpr"></a>[23]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>EqualityExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-RelationalExpr">RelationalExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-EqualityExpr">EqualityExpr</a> '=' <a href="#NT-RelationalExpr">RelationalExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-EqualityExpr">EqualityExpr</a> '!=' <a href="#NT-RelationalExpr">RelationalExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td><a name="NT-RelationalExpr"></a>[24]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>RelationalExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-AdditiveExpr">AdditiveExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelationalExpr">RelationalExpr</a> '&lt;' <a href="#NT-AdditiveExpr">AdditiveExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelationalExpr">RelationalExpr</a> '>' <a href="#NT-AdditiveExpr">AdditiveExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelationalExpr">RelationalExpr</a> '&lt;=' <a href="#NT-AdditiveExpr">AdditiveExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelationalExpr">RelationalExpr</a> '>=' <a href="#NT-AdditiveExpr">AdditiveExpr</a></td>
                 <td></td>
              </tr>
           </tbody>
        </table>
        
        
        <blockquote><b>NOTE: </b>The effect of the above grammar is that the order of
           precedence is (lowest precedence first):
           
           
           <ul>
              
              
              <li>
                 <p><code>or</code></p>
              </li>
              
              
              <li>
                 <p><code>and</code></p>
              </li>
              
              
              <li>
                 <p><code>=</code>, <code>!=</code></p>
              </li>
              
              
              <li>
                 <p><code>&lt;=</code>, <code>&lt;</code>, <code>>=</code>,
                    <code>></code></p>
              </li>
              
              
           </ul>
           
           and the operators are all left associative.
           
           For example, <code>3 > 2 > 1</code> is equivalent to <code>(3
              > 2) > 1
           </code>, which evaluates to false.
           
           
        </blockquote>
        
        
        
        
        
        <h3><a name="numbers"></a>3.5 Numbers
        </h3>
        
        
        <p>A number represents a floating-point number.  A number can have any
           double-precision 64-bit format IEEE 754 value <a href="#IEEE754">[IEEE 754]</a>.
           These include a special "Not-a-Number" (NaN) value,
           positive and negative infinity, and positive and negative zero.  See
           <a href="http://java.sun.com/docs/books/jls/html/4.doc.html#9208">Section 4.2.3</a> of <a href="#JLS">[JLS]</a> for a summary of the key
           rules of the IEEE 754 standard.
        </p>
        
        
        <p>The numeric operators convert their operands to numbers as if by
           calling the <b><a href="#function-number">number</a></b> function.
        </p>
        
        
        <p>The <code>+</code> operator performs addition.
        </p>
        
        
        <p>The <code>-</code> operator performs subtraction.
        </p>
        
        
        <blockquote><b>NOTE: </b>Since XML allows <code>-</code> in names, the <code>-</code>
           operator typically needs to be preceded by whitespace.  For example,
           <code>foo-bar</code> evaluates to a node-set containing the child
           elements named <code>foo-bar</code>; <code>foo - bar</code> evaluates
           to the difference of the result of converting the <a href="#dt-string-value">string-value</a> of the first
           <code>foo</code> child element to a number and the result of
           converting the <a href="#dt-string-value">string-value</a>
           of the first <code>bar</code> child to a number.
        </blockquote>
        
        
        <p>The <code>div</code> operator performs floating-point division
           according to IEEE 754.
        </p>
        
        
        <p>The <code>mod</code> operator returns the remainder from a
           truncating division.  For example,
        </p>
        
        
        <ul>
           
           <li>
              <p><code>5 mod 2</code> returns <code>1</code></p>
           </li>
           
           <li>
              <p><code>5 mod -2</code> returns <code>1</code></p>
           </li>
           
           <li>
              <p><code>-5 mod 2</code> returns <code>-1</code></p>
           </li>
           
           <li>
              <p><code>-5 mod -2</code> returns <code>-1</code></p>
           </li>
           
        </ul>
        
        
        <blockquote><b>NOTE: </b>This is the same as the <code>%</code> operator in Java and
           ECMAScript.
        </blockquote>
        
        
        <blockquote><b>NOTE: </b>This is not the same as the IEEE 754 remainder operation, which
           returns the remainder from a rounding division.
        </blockquote>
        
        
        <h5>Numeric Expressions</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-AdditiveExpr"></a>[25]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>AdditiveExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AdditiveExpr">AdditiveExpr</a> '+' <a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AdditiveExpr">AdditiveExpr</a> '-' <a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-MultiplicativeExpr"></a>[26]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>MultiplicativeExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-UnaryExpr">UnaryExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a> <a href="#NT-MultiplyOperator">MultiplyOperator</a> <a href="#NT-UnaryExpr">UnaryExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a> 'div' <a href="#NT-UnaryExpr">UnaryExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-MultiplicativeExpr">MultiplicativeExpr</a> 'mod' <a href="#NT-UnaryExpr">UnaryExpr</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-UnaryExpr"></a>[27]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>UnaryExpr</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-UnionExpr">UnionExpr</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '-' <a href="#NT-UnaryExpr">UnaryExpr</a></td>
                 <td></td>
              </tr>
              
           </tbody>
        </table>
        
        
        
        
        
        <h3><a name="strings"></a>3.6 Strings
        </h3>
        
        
        <p>Strings consist of a sequence of zero or more characters, where a
           character is defined as in the XML Recommendation <a href="#XML">[XML]</a>.
           A single character in XPath thus corresponds to a single Unicode
           abstract character with a single corresponding Unicode scalar value
           (see <a href="#UNICODE">[Unicode]</a>); this is not the same thing as a 16-bit
           Unicode code value: the Unicode coded character representation for an
           abstract character with Unicode scalar value greater that U+FFFF is a
           pair of 16-bit Unicode code values (a surrogate pair).  In many
           programming languages, a string is represented by a sequence of 16-bit
           Unicode code values; implementations of XPath in such languages must
           take care to ensure that a surrogate pair is correctly treated as a
           single XPath character.
        </p>
        
        
        <blockquote><b>NOTE: </b>It is possible in Unicode for there to be two strings that
           should be treated as identical even though they consist of the
           distinct sequences of Unicode abstract characters.  For example, some
           accented characters may be represented in either a precomposed or
           decomposed form.  Therefore, XPath expressions may return unexpected
           results unless both the characters in the XPath expression and in the
           XML document have been normalized into a canonical form.  See <a href="#CHARMOD">[Character Model]</a>.
        </blockquote>
        
        
        
        
        
        <h3><a name="exprlex"></a>3.7 Lexical Structure
        </h3>
        
        
        <p>When tokenizing, the longest possible token is always returned.</p>
        
        
        <p>For readability, whitespace may be used in expressions even though not
           explicitly allowed by the grammar: <a href="#NT-ExprWhitespace">ExprWhitespace</a> may be freely added within
           patterns before or after any <a href="#NT-ExprToken">ExprToken</a>.
        </p>
        
        
        <p>The following special tokenization rules must be applied in the
           order specified to disambiguate the <a href="#NT-ExprToken">ExprToken</a> grammar:
        </p>
        
        
        <ul>
           
           
           <li>
              <p>If there is a preceding token and the preceding token is not
                 one of <code>@</code>, <code>::</code>, <code>(</code>,
                 <code>[</code>, <code>,</code> or an <a href="#NT-Operator">Operator</a>, then a <code>*</code> must be
                 recognized as a <a href="#NT-MultiplyOperator">MultiplyOperator</a>
                 and an <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> must be
                 recognized as an <a href="#NT-OperatorName">OperatorName</a>.
              </p>
           </li>
           
           
           <li>
              <p>If the character following an <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> (possibly after intervening
                 <a href="#NT-ExprWhitespace">ExprWhitespace</a>) is <code>(</code>,
                 then the token must be recognized as a <a href="#NT-NodeType">NodeType</a> or a <a href="#NT-FunctionName">FunctionName</a>.
              </p>
           </li>
           
           
           <li>
              <p>If the two characters following an <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> (possibly after intervening
                 <a href="#NT-ExprWhitespace">ExprWhitespace</a>) are <code>::</code>,
                 then the token must be recognized as an <a href="#NT-AxisName">AxisName</a>.
              </p>
           </li>
           
           
           <li>
              <p>Otherwise, the token must not be recognized as a <a href="#NT-MultiplyOperator">MultiplyOperator</a>, an <a href="#NT-OperatorName">OperatorName</a>, a <a href="#NT-NodeType">NodeType</a>, a <a href="#NT-FunctionName">FunctionName</a>, or an <a href="#NT-AxisName">AxisName</a>.
              </p>
           </li>
           
           
        </ul>
        
        
        <h5>Expression Lexical Structure</h5>
        <table class="scrap">
           <tbody>
              
              <tr valign="baseline">
                 <td><a name="NT-ExprToken"></a>[28]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>ExprToken</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-NameTest">NameTest</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-NodeType">NodeType</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Operator">Operator</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-FunctionName">FunctionName</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-AxisName">AxisName</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Literal">Literal</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Number">Number</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-VariableReference">VariableReference</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-Literal"></a>[29]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Literal</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'"' [^"]* '"'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| "'" [^']* "'"</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-Number"></a>[30]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Number</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-Digits">Digits</a> ('.' <a href="#NT-Digits">Digits</a>?)?
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '.' <a href="#NT-Digits">Digits</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-Digits"></a>[31]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Digits</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>[0-9]+</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-Operator"></a>[32]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Operator</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-OperatorName">OperatorName</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-MultiplyOperator">MultiplyOperator</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '/' | '//' | '|' | '+' | '-' | '=' | '!=' | '&lt;' | '&lt;=' | '>' | '>='</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-OperatorName"></a>[33]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>OperatorName</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'and' | 'or' | 'mod' | 'div'</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-MultiplyOperator"></a>[34]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>MultiplyOperator</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'*'</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-FunctionName"></a>[35]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>FunctionName</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>
                    <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>
                    - <a href="#NT-NodeType">NodeType</a>
                    
                 </td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-VariableReference"></a>[36]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>VariableReference</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'$' <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-NameTest"></a>[37]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>NameTest</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'*'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> ':' '*'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a></td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-NodeType"></a>[38]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>NodeType</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'comment'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'text'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'processing-instruction'</td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'node'</td>
                 <td></td>
              </tr>
              
              <tr valign="baseline">
                 <td><a name="NT-ExprWhitespace"></a>[39]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>ExprWhitespace</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="http://www.w3.org/TR/REC-xml#NT-S">S</a></td>
                 <td></td>
              </tr>
              
           </tbody>
        </table>
        
        
        
        
        
        
        
        <h2><a name="corelib"></a>4 Core Function Library
        </h2>
        
        
        <p>This section describes functions that XPath implementations must
           always include in the function library that is used to evaluate
           expressions.
        </p>
        
        
        <p>Each function in the function library is specified using a function
           prototype, which gives the return type, the name of the function, and
           the type of the arguments.  If an argument type is followed by a
           question mark, then the argument is optional; otherwise, the argument
           is required.
        </p>
        
        
        
        <h3><a name="section-Node-Set-Functions"></a>4.1 Node Set Functions
        </h3>
        
        
        <p><a name="function-last"><b>Function: </b><i>number</i> <b>last</b>()
           </a>
        </p>
        
        
        <p>The <b><a href="#function-last">last</a></b> function returns a number equal to
           the <a href="#dt-context-size">context size</a> from the
           expression evaluation context.
        </p>
        
        
        <p><a name="function-position"><b>Function: </b><i>number</i> <b>position</b>()
           </a>
        </p>
        
        
        <p>The <b><a href="#function-position">position</a></b> function returns a number equal to
           the <a href="#dt-context-position">context position</a> from
           the expression evaluation context.
        </p>
        
        
        <p><a name="function-count"><b>Function: </b><i>number</i> <b>count</b>(<i>node-set</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-count">count</a></b> function returns the number of nodes in the
           argument node-set.
        </p>
        
        
        <p><a name="function-id"><b>Function: </b><i>node-set</i> <b>id</b>(<i>object</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-id">id</a></b> function selects elements by their
           unique ID (see <a href="#unique-id">[<b>5.2.1 Unique IDs</b>]
           </a>).  When the argument to
           <b><a href="#function-id">id</a></b> is of type node-set, then the result is the
           union of the result of applying <b><a href="#function-id">id</a></b> to the
           <a href="#dt-string-value">string-value</a> of each of the
           nodes in the argument node-set.  When the argument to
           <b><a href="#function-id">id</a></b> is of any other type, the argument is
           converted to a string as if by a call to the
           <b><a href="#function-string">string</a></b> function; the string is split into a
           whitespace-separated list of tokens (whitespace is any sequence of
           characters matching the production <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a>);
           the result is a node-set containing the elements in the same document
           as the context node that have a unique ID equal to any of the tokens
           in the list.
        </p>
        
        
        <ul>
           
           <li>
              <p><code>id("foo")</code> selects the element with unique ID
                 <code>foo</code></p>
           </li>
           
           <li>
              <p><code>id("foo")/child::para[position()=5]</code> selects
                 the fifth <code>para</code> child of the element with unique ID
                 <code>foo</code></p>
           </li>
           
        </ul>
        
        
        <p><a name="function-local-name"><b>Function: </b><i>string</i> <b>local-name</b>(<i>node-set</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-local-name">local-name</a></b> function returns the local part
           of the <a href="#dt-expanded-name">expanded-name</a> of the
           node in the argument node-set that is first in <a href="#dt-document-order">document order</a>. If the argument
           node-set is empty or the first node has no <a href="#dt-expanded-name">expanded-name</a>, an empty string is
           returned.  If the argument is omitted, it defaults to a node-set with
           the context node as its only member.
        </p>
        
        
        <p><a name="function-namespace-uri"><b>Function: </b><i>string</i> <b>namespace-uri</b>(<i>node-set</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-namespace-uri">namespace-uri</a></b> function returns the
           namespace URI of the <a href="#dt-expanded-name">expanded-name</a> of the node in the
           argument node-set that is first in <a href="#dt-document-order">document order</a>. If the argument
           node-set is empty, the first node has no <a href="#dt-expanded-name">expanded-name</a>, or the namespace URI
           of the <a href="#dt-expanded-name">expanded-name</a> is
           null, an empty string is returned.  If the argument is omitted, it
           defaults to a node-set with the context node as its only member.
        </p>
        
        
        <blockquote><b>NOTE: </b>The string returned by the
           <b><a href="#function-namespace-uri">namespace-uri</a></b> function will be empty except for
           element nodes and attribute nodes.
        </blockquote>
        
        
        <p><a name="function-name"><b>Function: </b><i>string</i> <b>name</b>(<i>node-set</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-name">name</a></b> function returns a string containing
           a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> representing the
           <a href="#dt-expanded-name">expanded-name</a> of the node in
           the argument node-set that is first in <a href="#dt-document-order">document order</a>. The <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> must represent the <a href="#dt-expanded-name">expanded-name</a> with respect to the
           namespace declarations in effect on the node whose <a href="#dt-expanded-name">expanded-name</a> is being represented.
           Typically, this will be the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> that occurred in the XML
           source.  This need not be the case if there are namespace declarations
           in effect on the node that associate multiple prefixes with the same
           namespace.  However, an implementation may include information about
           the original prefix in its representation of nodes; in this case, an
           implementation can ensure that the returned string is always the same
           as the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> used in the XML
           source. If the argument node-set is empty or the first node has no
           <a href="#dt-expanded-name">expanded-name</a>, an empty
           string is returned.  If the argument it omitted, it defaults to a
           node-set with the context node as its only member.
        </p>
        
        
        <blockquote><b>NOTE: </b>The string returned by the <b><a href="#function-name">name</a></b> function
           will be the same as the string returned by the
           <b><a href="#function-local-name">local-name</a></b> function except for element nodes and
           attribute nodes.
        </blockquote>
        
        
        
        
        
        <h3><a name="section-String-Functions"></a>4.2 String Functions
        </h3>
        
        
        <p><a name="function-string"><b>Function: </b><i>string</i> <b>string</b>(<i>object</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-string">string</a></b> function converts an object to a string
           as follows:
        </p>
        
        
        <ul>
           
           
           <li>
              <p>A node-set is converted to a string by returning the <a href="#dt-string-value">string-value</a> of the node in the
                 node-set that is first in <a href="#dt-document-order">document
                    order
                 </a>.  If the node-set is empty, an empty string is
                 returned.
              </p>
           </li>
           
           
           <li>
              <p>A number is converted to a string as follows</p>
              
              
              <ul>
                 
                 
                 <li>
                    <p>NaN is converted to the string <code>NaN</code></p>
                 </li>
                 
                 
                 <li>
                    <p>positive zero is converted to the string
                       <code>0</code></p>
                 </li>
                 
                 
                 <li>
                    <p>negative zero is converted to the string
                       <code>0</code></p>
                 </li>
                 
                 
                 <li>
                    <p>positive infinity is converted to the string
                       <code>Infinity</code></p>
                 </li>
                 
                 
                 <li>
                    <p>negative infinity is converted to the string
                       <code>-Infinity</code></p>
                 </li>
                 
                 
                 <li>
                    <p>if the number is an integer, the number is represented in
                       decimal form as a <a href="#NT-Number">Number</a> with no decimal
                       point and no leading zeros, preceded by a minus sign (<code>-</code>)
                       if the number is negative
                    </p>
                 </li>
                 
                 
                 <li>
                    <p>otherwise, the number is represented in decimal form as a <a href="#NT-Number">Number</a> including a decimal point with at least
                       one digit before the decimal point and at least one digit after the
                       decimal point, preceded by a minus sign (<code>-</code>) if the number
                       is negative; there must be no leading zeros before the decimal point
                       apart possibly from the one required digit immediately before the
                       decimal point; beyond the one required digit after the decimal point
                       there must be as many, but only as many, more digits as are needed to
                       uniquely distinguish the number from all other IEEE 754 numeric
                       values.
                    </p>
                 </li>
                 
                 
              </ul>
              
              
           </li>
           
           
           <li>
              <p>The boolean false value is converted to the string
                 <code>false</code>.  The boolean true value is converted to the
                 string <code>true</code>.
              </p>
           </li>
           
           
           <li>
              <p>An object of a type other than the four basic types is
                 converted to a string in a way that is dependent on that
                 type.
              </p>
           </li>
           
           
        </ul>
        
        
        <p>If the argument is omitted, it defaults to a node-set with the
           context node as its only member.
        </p>
        
        
        <blockquote><b>NOTE: </b>The <code>string</code> function is not intended for
           converting numbers into strings for presentation to users.  The
           <code>format-number</code> function and <code>xsl:number</code>
           element in <a href="#XSLT">[XSLT]</a> provide this
           functionality.
        </blockquote>
        
        
        <p><a name="function-concat"><b>Function: </b><i>string</i> <b>concat</b>(<i>string</i>, <i>string</i>, <i>string</i>*)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-concat">concat</a></b> function returns the concatenation of its
           arguments.
        </p>
        
        
        <p><a name="function-starts-with"><b>Function: </b><i>boolean</i> <b>starts-with</b>(<i>string</i>, <i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-starts-with">starts-with</a></b> function returns true if the
           first argument string starts with the second argument string, and
           otherwise returns false.
        </p>
        
        
        <p><a name="function-contains"><b>Function: </b><i>boolean</i> <b>contains</b>(<i>string</i>, <i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-contains">contains</a></b> function returns true if the first
           argument string contains the second argument string, and otherwise
           returns false.
        </p>
        
        
        <p><a name="function-substring-before"><b>Function: </b><i>string</i> <b>substring-before</b>(<i>string</i>, <i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-substring-before">substring-before</a></b> function returns the substring
           of the first argument string that precedes the first occurrence of the
           second argument string in the first argument string, or the empty
           string if the first argument string does not contain the second
           argument string.  For example,
           <code>substring-before("1999/04/01","/")</code> returns
           <code>1999</code>.
        </p>
        
        
        <p><a name="function-substring-after"><b>Function: </b><i>string</i> <b>substring-after</b>(<i>string</i>, <i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-substring-after">substring-after</a></b> function returns the
           substring of the first argument string that follows the first
           occurrence of the second argument string in the first argument string,
           or the empty string if the first argument string does not contain the
           second argument string. For example,
           <code>substring-after("1999/04/01","/")</code> returns
           <code>04/01</code>, and
           <code>substring-after("1999/04/01","19")</code> returns
           <code>99/04/01</code>.
        </p>
        
        
        <p><a name="function-substring"><b>Function: </b><i>string</i> <b>substring</b>(<i>string</i>, <i>number</i>, <i>number</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-substring">substring</a></b> function returns the substring of the
           first argument starting at the position specified in the second
           argument with length specified in the third argument. For example,
           <code>substring("12345",2,3)</code> returns <code>"234"</code>.
           If the third argument is not specified, it returns
           the substring starting at the position specified in the second
           argument and continuing to the end of the string. For example,
           <code>substring("12345",2)</code> returns <code>"2345"</code>.
        </p>
        
        
        <p>More precisely, each character in the string (see <a href="#strings">[<b>3.6 Strings</b>]
           </a>) is considered to have a numeric position: the
           position of the first character is 1, the position of the second
           character is 2 and so on.
        </p>
        
        
        <blockquote><b>NOTE: </b>This differs from Java and ECMAScript, in which the
           <code>String.substring</code> method treats the position of the first
           character as 0.
        </blockquote>
        
        
        <p>The returned substring contains those
           characters for which the position of the character is greater than or
           equal to the rounded value of the second argument and, if the third
           argument is specified, less than the sum of the rounded value of the
           second argument and the rounded value of the third argument; the
           comparisons and addition used for the above follow the standard IEEE
           754 rules; rounding is done as if by a call to the
           <b><a href="#function-round">round</a></b> function. The following examples illustrate
           various unusual cases:
        </p>
        
        
        <ul>
           
           
           <li>
              <p><code>substring("12345", 1.5, 2.6)</code> returns
                 <code>"234"</code></p>
           </li>
           
           
           <li>
              <p><code>substring("12345", 0, 3)</code> returns
                 <code>"12"</code></p>
           </li>
           
           
           <li>
              <p><code>substring("12345", 0 div 0, 3)</code> returns
                 <code>""</code></p>
           </li>
           
           
           <li>
              <p><code>substring("12345", 1, 0 div 0)</code> returns
                 <code>""</code></p>
           </li>
           
           
           <li>
              <p><code>substring("12345", -42, 1 div 0)</code> returns
                 <code>"12345"</code></p>
           </li>
           
           
           <li>
              <p><code>substring("12345", -1 div 0, 1 div 0)</code> returns
                 <code>""</code></p>
           </li>
           
           
        </ul>
        
        
        <p><a name="function-string-length"><b>Function: </b><i>number</i> <b>string-length</b>(<i>string</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-string-length">string-length</a></b> returns the number of
           characters in the string (see <a href="#strings">[<b>3.6 Strings</b>]
           </a>).  If the
           argument is omitted, it defaults to the context node converted to a
           string, in other words the <a href="#dt-string-value">string-value</a> of the context node.
        </p>
        
        
        <p><a name="function-normalize-space"><b>Function: </b><i>string</i> <b>normalize-space</b>(<i>string</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-normalize-space">normalize-space</a></b> function returns the argument
           string with whitespace normalized by stripping leading and trailing
           whitespace and replacing sequences of whitespace characters by a
           single space.  Whitespace characters are the same as those allowed by the <a href="http://www.w3.org/TR/REC-xml#NT-S">S</a> production in XML.  If the argument is
           omitted, it defaults to the context node converted to a string, in
           other words the <a href="#dt-string-value">string-value</a>
           of the context node.
        </p>
        
        
        <p><a name="function-translate"><b>Function: </b><i>string</i> <b>translate</b>(<i>string</i>, <i>string</i>, <i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-translate">translate</a></b> function returns the first
           argument string with occurrences of characters in the second argument
           string replaced by the character at the corresponding position in the
           third argument string.  For example,
           <code>translate("bar","abc","ABC")</code> returns the string
           <code>BAr</code>.  If there is a character in the second argument
           string with no character at a corresponding position in the third
           argument string (because the second argument string is longer than the
           third argument string), then occurrences of that character in the
           first argument string are removed.  For example,
           <code>translate("--aaa--","abc-","ABC")</code> returns
           <code>"AAA"</code>. If a character occurs more than once in the second
           argument string, then the first occurrence determines the replacement
           character.  If the third argument string is longer than the second
           argument string, then excess characters are ignored.
        </p>
        
        
        <blockquote><b>NOTE: </b>The <b><a href="#function-translate">translate</a></b> function is not a sufficient
           solution for case conversion in all languages.  A future version of
           XPath may provide additional functions for case conversion.
        </blockquote>
        
        
        
        
        
        <h3><a name="section-Boolean-Functions"></a>4.3 Boolean Functions
        </h3>
        
        
        <p><a name="function-boolean"><b>Function: </b><i>boolean</i> <b>boolean</b>(<i>object</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-boolean">boolean</a></b> function converts its argument to a
           boolean as follows:
        </p>
        
        
        <ul>
           
           
           <li>
              <p>a number is true if and only if it is neither positive or
                 negative zero nor NaN
              </p>
           </li>
           
           
           <li>
              <p>a node-set is true if and only if it is non-empty</p>
           </li>
           
           
           <li>
              <p>a string is true if and only if its length is non-zero</p>
           </li>
           
           
           <li>
              <p>an object of a type other than the four basic types is
                 converted to a boolean in a way that is dependent on that
                 type
              </p>
           </li>
           
           
        </ul>
        
        
        <p><a name="function-not"><b>Function: </b><i>boolean</i> <b>not</b>(<i>boolean</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-not">not</a></b> function returns true if its argument is
           false, and false otherwise.
        </p>
        
        
        <p><a name="function-true"><b>Function: </b><i>boolean</i> <b>true</b>()
           </a>
        </p>
        
        
        <p>The <b><a href="#function-true">true</a></b> function returns true.
        </p>
        
        
        <p><a name="function-false"><b>Function: </b><i>boolean</i> <b>false</b>()
           </a>
        </p>
        
        
        <p>The <b><a href="#function-false">false</a></b> function returns false.
        </p>
        
        
        <p><a name="function-lang"><b>Function: </b><i>boolean</i> <b>lang</b>(<i>string</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-lang">lang</a></b> function returns true or false depending on
           whether the language of the context node as specified by
           <code>xml:lang</code> attributes is the same as or is a sublanguage of
           the language specified by the argument string.  The language of the
           context node is determined by the value of the <code>xml:lang</code>
           attribute on the context node, or, if the context node has no
           <code>xml:lang</code> attribute, by the value of the
           <code>xml:lang</code> attribute on the nearest ancestor of the context
           node that has an <code>xml:lang</code> attribute.  If there is no such
           attribute, then <b><a href="#function-lang">lang</a></b> returns false. If there is such an
           attribute, then <b><a href="#function-lang">lang</a></b> returns true if the attribute
           value is equal to the argument ignoring case, or if there is some
           suffix starting with <code>-</code> such that the attribute value is
           equal to the argument ignoring that suffix of the attribute value and
           ignoring case. For example, <code>lang("en")</code> would return true
           if the context node is any of these five elements:
        </p>
        
        <pre>&lt;para xml:lang="en"/>
  &lt;div xml:lang="en">&lt;para/>&lt;/div>
  &lt;para xml:lang="EN"/>
  &lt;para xml:lang="en-us"/></pre>
        
        
        
        <h3><a name="section-Number-Functions"></a>4.4 Number Functions
        </h3>
        
        
        <p><a name="function-number"><b>Function: </b><i>number</i> <b>number</b>(<i>object</i>?)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-number">number</a></b> function converts its argument to a
           number as follows:
        </p>
        
        
        <ul>
           
           
           <li>
              <p>a string that consists of optional whitespace followed by an
                 optional minus sign followed by a <a href="#NT-Number">Number</a>
                 followed by whitespace is converted to the IEEE 754 number that is
                 nearest (according to the IEEE 754 round-to-nearest rule)
                 to the mathematical value represented by the string; any other
                 string is converted to NaN
              </p>
           </li>
           
           
           <li>
              <p>boolean true is converted to 1; boolean false is converted to
                 0
              </p>
           </li>
           
           
           <li>
              
              
              <p>a node-set is first converted to a string as if by a call to the
                 <b><a href="#function-string">string</a></b> function and then converted in the same way as a
                 string argument
              </p>
              
              
           </li>
           
           
           <li>
              <p>an object of a type other than the four basic types is
                 converted to a number in a way that is dependent on that
                 type
              </p>
           </li>
           
           
        </ul>
        
        
        <p>If the argument is omitted, it defaults to a node-set with the
           context node as its only member.
        </p>
        
        
        <blockquote><b>NOTE: </b>The <b><a href="#function-number">number</a></b> function should not be used
           for conversion of numeric data occurring in an element in an XML
           document unless the element is of a type that represents numeric data
           in a language-neutral format (which would typically be transformed
           into a language-specific format for presentation to a user). In
           addition, the <b><a href="#function-number">number</a></b> function cannot be used
           unless the language-neutral format used by the element is consistent
           with the XPath syntax for a <a href="#NT-Number">Number</a>.
        </blockquote>
        
        
        <p><a name="function-sum"><b>Function: </b><i>number</i> <b>sum</b>(<i>node-set</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-sum">sum</a></b> function returns the sum, for each
           node in the argument node-set, of the result of converting the
           <a href="#dt-string-value">string-value</a>s of the node to
           a number.
        </p>
        
        
        <p><a name="function-floor"><b>Function: </b><i>number</i> <b>floor</b>(<i>number</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-floor">floor</a></b> function returns the largest (closest to
           positive infinity) number that is not greater than the argument and
           that is an integer.
        </p>
        
        
        <p><a name="function-ceiling"><b>Function: </b><i>number</i> <b>ceiling</b>(<i>number</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-ceiling">ceiling</a></b> function returns the smallest (closest
           to negative infinity) number that is not less than the argument and
           that is an integer.
        </p>
        
        
        <p><a name="function-round"><b>Function: </b><i>number</i> <b>round</b>(<i>number</i>)
           </a>
        </p>
        
        
        <p>The <b><a href="#function-round">round</a></b> function returns the number that is
           closest to the argument and that is an integer.  If there are two such
           numbers, then the one that is closest to positive infinity is
           returned. If the argument is NaN, then NaN is returned. If the
           argument is positive infinity, then positive infinity is returned.  If
           the argument is negative infinity, then negative infinity is
           returned. If the argument is positive zero, then positive zero is
           returned.  If the argument is negative zero, then negative zero is
           returned.  If the argument is less than zero, but greater than or
           equal to -0.5, then negative zero is returned.
        </p>
        
        
        <blockquote><b>NOTE: </b>For these last two cases, the result of calling the
           <b><a href="#function-round">round</a></b> function is not the same as the result of
           adding 0.5 and then calling the <b><a href="#function-floor">floor</a></b>
           function.
        </blockquote>
        
        
        
        
        
        
        
        
        
        <h2><a name="data-model"></a>5 Data Model
        </h2>
        
        
        <p>XPath operates on an XML document as a tree. This section describes
           how XPath models an XML document as a tree.  This model is conceptual
           only and does not mandate any particular implementation.  The
           relationship of this model to the XML Information Set <a href="#XINFO">[XML Infoset]</a> is described in <a href="#infoset">[<b>B XML Information Set Mapping</b>]
           </a>.
        </p>
        
        
        <p>XML documents operated on by XPath must conform to the XML
           Namespaces Recommendation <a href="#XMLNAMES">[XML Names]</a>.
        </p>
        
        
        <p>The tree contains nodes.  There are seven types of node:</p>
        
        
        <ul>
           
           
           <li>
              <p>root nodes</p>
           </li>
           
           
           <li>
              <p>element nodes</p>
           </li>
           
           
           <li>
              <p>text nodes</p>
           </li>
           
           
           <li>
              <p>attribute nodes</p>
           </li>
           
           
           <li>
              <p>namespace nodes</p>
           </li>
           
           
           <li>
              <p>processing instruction nodes</p>
           </li>
           
           
           <li>
              <p>comment nodes</p>
           </li>
           
           
        </ul>
        
        
        <p><a name="dt-string-value"></a>For every type of
           node, there is a way of determining a <b>string-value</b> for a
           node of that type.  For some types of node, the string-value is part
           of the node; for other types of node, the string-value is computed
           from the string-value of descendant nodes.
        </p>
        
        
        <blockquote><b>NOTE: </b>For element nodes and root nodes, the string-value of a node
           is not the same as the string returned by the DOM
           <code>nodeValue</code> method (see <a href="#DOM">[DOM]</a>).
        </blockquote>
        
        
        <p><a name="dt-expanded-name"></a>Some types of
           node also have an <b>expanded-name</b>, which is a pair
           consisting of a local part and a namespace URI. The local part is a
           string.  The namespace URI is either null or a string.  The namespace
           URI specified in the XML document can be a URI reference as defined in
           <a href="#RFC2396">[RFC2396]</a>; this means it can have a fragment identifier
           and can be relative.  A relative URI should be resolved into an
           absolute URI during namespace processing: the namespace URIs of
           <a href="#dt-expanded-name">expanded-name</a>s of nodes in
           the data model should be absolute. Two <a href="#dt-expanded-name">expanded-name</a>s are equal if they have
           the same local part, and either both have a null namespace URI or both
           have non-null namespace URIs that are equal.
        </p>
        
        
        <p><a name="dt-document-order"></a>There is an
           ordering, <b>document order</b>, defined on all the nodes in the
           document corresponding to the order in which the first character of
           the XML representation of each node occurs in the XML representation
           of the document after expansion of general entities.  Thus, the root
           node will be the first node. Element nodes occur before their
           children. Thus, document order orders element nodes in order of the
           occurrence of their start-tag in the XML (after expansion of
           entities). The attribute nodes and namespace nodes of an element occur
           before the children of the element.  The namespace nodes are defined
           to occur before the attribute nodes. The relative order of namespace
           nodes is implementation-dependent.  The relative order of attribute
           nodes is implementation-dependent. <a name="dt-reverse-document-order"></a><b>Reverse document order</b> is the reverse of <a href="#dt-document-order">document order</a>.
        </p>
        
        
        <p>Root nodes and element nodes have an ordered list of child nodes.
           Nodes never share children: if one node is not the same node as
           another node, then none of the children of the one node will be the
           same node as any of the children of another node.  <a name="dt-parent"></a>Every node other than the root node has
           exactly one <b>parent</b>, which is either an element node or
           the root node. A root node or an element node is the parent
           of each of its child nodes. <a name="dt-descendants"></a>The <b>descendants</b> of a node are the
           children of the node and the descendants of the children of the
           node.
        </p>
        
        
        
        <h3><a name="root-node"></a>5.1 Root Node
        </h3>
        
        
        <p>The root node is the root of the tree.  A root node does not occur
           except as the root of the tree.  The element node for the document
           element is a child of the root node.  The root node also has as
           children processing instruction and comment nodes for processing
           instructions and comments that occur in the prolog and after the end
           of the document element.
        </p>
        
        
        <p>The <a href="#dt-string-value">string-value</a> of the
           root node is the concatenation of the <a href="#dt-string-value">string-value</a>s of all text node
           <a href="#dt-descendants">descendants</a> of the root
           node in document order.
        </p>
        
        
        <p>The root node does not have an <a href="#dt-expanded-name">expanded-name</a>.
        </p>
        
        
        
        
        
        <h3><a name="element-nodes"></a>5.2 Element Nodes
        </h3>
        
        
        <p>There is an element node for every element in the document.  An
           element node has an <a href="#dt-expanded-name">expanded-name</a> computed by expanding
           the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> of the element
           specified in the tag in accordance with the XML Namespaces
           Recommendation <a href="#XMLNAMES">[XML Names]</a>.  The namespace URI of the
           element's <a href="#dt-expanded-name">expanded-name</a> will
           be null if the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> has no
           prefix and there is no applicable default namespace.
        </p>
        
        
        <blockquote><b>NOTE: </b>In the notation of Appendix A.3 of <a href="#XMLNAMES">[XML Names]</a>,
           the local part of the expanded-name corresponds to the
           <code>type</code> attribute of the <code>ExpEType</code> element; the
           namespace URI of the expanded-name corresponds to the <code>ns</code>
           attribute of the <code>ExpEType</code> element, and is null if the
           <code>ns</code> attribute of the <code>ExpEType</code> element is
           omitted.
        </blockquote>
        
        
        <p>The children of an element node are the element nodes, comment
           nodes, processing instruction nodes and text nodes for its content.
           Entity references to both internal and external entities are expanded.
           Character references are resolved.
        </p>
        
        
        <p>The <a href="#dt-string-value">string-value</a> of an
           element node is the concatenation of the <a href="#dt-string-value">string-value</a>s of all text node
           <a href="#dt-descendants">descendants</a> of the element
           node in document order.
        </p>
        
        
        
        <h4><a name="unique-id"></a>5.2.1 Unique IDs
        </h4>
        
        
        <p>An element node may have a unique identifier (ID).  This is the
           value of the attribute that is declared in the DTD as type
           <code>ID</code>.  No two elements in a document may have the same
           unique ID.  If an XML processor reports two elements in a document as
           having the same unique ID (which is possible only if the document is
           invalid) then the second element in document order must be treated as
           not having a unique ID.
        </p>
        
        
        <blockquote><b>NOTE: </b>If a document does not have a DTD, then no element in the
           document will have a unique ID.
        </blockquote>
        
        
        
        
        
        
        
        <h3><a name="attribute-nodes"></a>5.3 Attribute Nodes
        </h3>
        
        
        <p>Each element node has an associated set of attribute nodes; the
           element is the <a href="#dt-parent">parent</a> of each of
           these attribute nodes; however, an attribute node is not a child of
           its parent element.
        </p>
        
        
        <blockquote><b>NOTE: </b>This is different from the DOM, which does not treat the
           element bearing an attribute as the parent of the attribute (see
           <a href="#DOM">[DOM]</a>).
        </blockquote>
        
        
        <p>Elements never share attribute nodes: if one element node is not
           the same node as another element node, then none of the attribute
           nodes of the one element node will be the same node as the attribute
           nodes of another element node.
        </p>
        
        
        <blockquote><b>NOTE: </b>The <code>=</code> operator tests whether two nodes have the
           same value, <i>not</i> whether they are the same node.  Thus
           attributes of two different elements may compare as equal using
           <code>=</code>, even though they are not the same node.
        </blockquote>
        
        
        <p>A defaulted attribute is treated the same as a specified attribute.
           If an attribute was declared for the element type in the DTD, but the
           default was declared as <code>#IMPLIED</code>, and the attribute was
           not specified on the element, then the element's attribute set does
           not contain a node for the attribute.
        </p>
        
        
        <p>Some attributes, such as <code>xml:lang</code> and
           <code>xml:space</code>, have the semantics that they apply to all
           elements that are descendants of the element bearing the attribute,
           unless overridden with an instance of the same attribute on another
           descendant element.  However, this does not affect where attribute
           nodes appear in the tree: an element has attribute nodes only for
           attributes that were explicitly specified in the start-tag or
           empty-element tag of that element or that were explicitly declared in
           the DTD with a default value.
        </p>
        
        
        <p>An attribute node has an <a href="#dt-expanded-name">expanded-name</a> and a <a href="#dt-string-value">string-value</a>.  The <a href="#dt-expanded-name">expanded-name</a> is computed by
           expanding the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> specified in
           the tag in the XML document in accordance with the XML Namespaces
           Recommendation <a href="#XMLNAMES">[XML Names]</a>.  The namespace URI of the
           attribute's name will be null if the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> of the attribute does not have
           a prefix.
        </p>
        
        
        <blockquote><b>NOTE: </b>In the notation of Appendix A.3 of <a href="#XMLNAMES">[XML Names]</a>,
           the local part of the expanded-name corresponds to the
           <code>name</code> attribute of the <code>ExpAName</code> element; the
           namespace URI of the expanded-name corresponds to the <code>ns</code>
           attribute of the <code>ExpAName</code> element, and is null if the
           <code>ns</code> attribute of the <code>ExpAName</code> element is
           omitted.
        </blockquote>
        
        
        <p>An attribute node has a <a href="#dt-string-value">string-value</a>.  The <a href="#dt-string-value">string-value</a> is the normalized value
           as specified by the XML Recommendation <a href="#XML">[XML]</a>.  An
           attribute whose normalized value is a zero-length string is not
           treated specially: it results in an attribute node whose <a href="#dt-string-value">string-value</a> is a zero-length
           string.
        </p>
        
        
        <blockquote><b>NOTE: </b>It is possible for default attributes to be declared in an
           external DTD or an external parameter entity.  The XML Recommendation
           does not require an XML processor to read an external DTD or an
           external parameter unless it is validating. A stylesheet or other facility that assumes
           that the XPath tree contains default attribute values declared in an
           external DTD or parameter entity may not work with some non-validating
           XML processors.
        </blockquote>
        
        
        <p>There are no attribute nodes corresponding to attributes that
           declare namespaces (see <a href="#XMLNAMES">[XML Names]</a>).
        </p>
        
        
        
        
        
        <h3><a name="namespace-nodes"></a>5.4 Namespace Nodes
        </h3>
        
        
        <p>Each element has an associated set of namespace nodes, one for each
           distinct namespace prefix that is in scope for the element (including
           the <code>xml</code> prefix, which is implicitly declared by the XML
           Namespaces Recommendation <a href="#XMLNAMES">[XML Names]</a>) and one for
           the default namespace if one is in scope for the element.  The element
           is the <a href="#dt-parent">parent</a> of each of these
           namespace nodes; however, a namespace node is not a child of
           its parent element.  Elements never share namespace nodes: if one element
           node is not the same node as another element node, then none of the
           namespace nodes of the one element node will be the same node as the
           namespace nodes of another element node. This means that an element
           will have a namespace node:
        </p>
        
        
        <ul>
           
           
           <li>
              <p>for every attribute on the element whose name starts with
                 <code>xmlns:</code>;
              </p>
           </li>
           
           
           <li>
              <p>for every attribute on an ancestor element whose name starts
                 <code>xmlns:</code> unless the element itself or a nearer ancestor
                 redeclares the prefix;
              </p>
           </li>
           
           
           <li>
              
              
              <p>for an <code>xmlns</code> attribute, if the element or some
                 ancestor has an <code>xmlns</code> attribute, and the value of the
                 <code>xmlns</code> attribute for the nearest such element is
                 non-empty
              </p>
              
              
              <blockquote><b>NOTE: </b>An attribute <code>xmlns=""</code> "undeclares"
                 the default namespace (see <a href="#XMLNAMES">[XML Names]</a>).
              </blockquote>
              
              
           </li>
           
           
        </ul>
        
        
        <p>A namespace node has an <a href="#dt-expanded-name">expanded-name</a>: the local part is
           the namespace prefix (this is empty if the namespace node is for the
           default namespace); the namespace URI is always null.
        </p>
        
        
        <p>The <a href="#dt-string-value">string-value</a> of a
           namespace node is the namespace URI that is being bound to the
           namespace prefix; if it is relative, it must be resolved just like a
           namespace URI in an <a href="#dt-expanded-name">expanded-name</a>.
        </p>
        
        
        
        
        
        
        <h3><a name="section-Processing-Instruction-Nodes"></a>5.5 Processing Instruction Nodes
        </h3>
        
        
        <p>There is a processing instruction node for every processing
           instruction, except for any processing instruction that occurs within
           the document type declaration.
        </p>
        
        
        <p>A processing instruction has an <a href="#dt-expanded-name">expanded-name</a>: the local part is
           the processing instruction's target; the namespace URI is null.  The
           <a href="#dt-string-value">string-value</a> of a processing
           instruction node is the part of the processing instruction following
           the target and any whitespace.  It does not include the terminating
           <code>?></code>.
        </p>
        
        
        <blockquote><b>NOTE: </b>The XML declaration is not a processing instruction.
           Therefore, there is no processing instruction node corresponding to the
           XML declaration.
        </blockquote>
        
        
        
        
        
        <h3><a name="section-Comment-Nodes"></a>5.6 Comment Nodes
        </h3>
        
        
        <p>There is a comment node for every comment, except for any comment that
           occurs within the document type declaration.
        </p>
        
        
        <p>The <a href="#dt-string-value">string-value</a> of
           comment is the content of the comment not including the opening
           <code>&lt;!--</code> or the closing <code>--></code>.
        </p>
        
        
        <p>A comment node does not have an <a href="#dt-expanded-name">expanded-name</a>.
        </p>
        
        
        
        
        
        <h3><a name="section-Text-Nodes"></a>5.7 Text Nodes
        </h3>
        
        
        <p>Character data is grouped into text nodes.  As much character data
           as possible is grouped into each text node: a text node never has an
           immediately following or preceding sibling that is a text node.  The
           <a href="#dt-string-value">string-value</a> of a text node
           is the character data.  A text node always has at least one character
           of data.
        </p>
        
        
        <p>Each character within a CDATA section is treated as character data.
           Thus, <code>&lt;![CDATA[&lt;]]></code> in the source document will
           treated the same as <code>&amp;lt;</code>.  Both will result in a
           single <code>&lt;</code> character in a text node in the tree.  Thus, a
           CDATA section is treated as if the <code>&lt;![CDATA[</code> and
           <code>]]></code> were removed and every occurrence of
           <code>&lt;</code> and <code>&amp;</code> were replaced by
           <code>&amp;lt;</code> and <code>&amp;amp;</code> respectively.
        </p>
        
        
        <blockquote><b>NOTE: </b>When a text node that contains a <code>&lt;</code> character
           is written out as XML, the <code>&lt;</code> character must be escaped
           by, for example, using <code>&amp;lt;</code>, or including it in a
           CDATA section.
        </blockquote>
        
        
        <p>Characters inside comments, processing instructions and attribute
           values do not produce text nodes. Line-endings in external entities
           are normalized to #xA as specified in the XML Recommendation <a href="#XML">[XML]</a>.
        </p>
        
        
        <p>A text node does not have an <a href="#dt-expanded-name">expanded-name</a>.
        </p>
        
        
        
        
        
        
        
        <h2><a name="section-Conformance"></a>6 Conformance
        </h2>
        
        
        <p>XPath is intended primarily as a component that can be used by
           other specifications. Therefore, XPath relies on specifications that
           use XPath (such as <a href="#XPTR">[XPointer]</a> and <a href="#XSLT">[XSLT]</a>) to
           specify criteria for conformance of implementations of XPath and does
           not define any conformance criteria for independent implementations of
           XPath.
        </p>
        
        
        
        
        
        
        <hr title="Separator from footer">
        
        
        <h2><a name="section-References"></a>A References
        </h2>
        
        
        <h3><a name="section-Normative-References"></a>A.1 Normative References
        </h3>
        
        
        <dl>
           
           
           <dt><a name="IEEE754">IEEE 754</a></dt>
           <dd>Institute of Electrical and
              Electronics Engineers. <i>IEEE Standard for Binary Floating-Point
                 Arithmetic
              </i>. ANSI/IEEE Std 754-1985.
           </dd>
           
           
           <dt><a name="RFC2396">RFC2396</a></dt>
           <dd>T. Berners-Lee, R. Fielding, and
              L. Masinter.  <i>Uniform Resource Identifiers (URI): Generic
                 Syntax
              </i>. IETF RFC 2396. See <a href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a>.
           </dd>
           
           
           <dt><a name="XML">XML</a></dt>
           <dd>World Wide Web Consortium. <i>Extensible
                 Markup Language (XML) 1.0.
              </i> W3C Recommendation. See <a href="http://www.w3.org/TR/1998/REC-xml-19980210">http://www.w3.org/TR/1998/REC-xml-19980210</a></dd>
           
           
           <dt><a name="XMLNAMES">XML Names</a></dt>
           <dd>World Wide Web
              Consortium. <i>Namespaces in XML.</i> W3C Recommendation. See
              <a href="http://www.w3.org/TR/REC-xml-names">http://www.w3.org/TR/REC-xml-names</a></dd>
           
           
        </dl>
        
        
        
        <h3><a name="section-Other-References"></a>A.2 Other References
        </h3>
        
        
        <dl>
           
           
           <dt><a name="CHARMOD">Character Model</a></dt>
           <dd>World Wide Web Consortium.
              <i>Character Model for the World Wide Web.</i> W3C Working
              Draft. See <a href="http://www.w3.org/TR/WD-charmod">http://www.w3.org/TR/WD-charmod</a></dd>
           
           
           <dt><a name="DOM">DOM</a></dt>
           <dd>World Wide Web Consortium.  <i>Document
                 Object Model (DOM) Level 1 Specification.
              </i> W3C
              Recommendation. See <a href="http://www.w3.org/TR/REC-DOM-Level-1">http://www.w3.org/TR/REC-DOM-Level-1</a></dd>
           
           
           <dt><a name="JLS">JLS</a></dt>
           <dd>J. Gosling, B. Joy, and G. Steele.  <i>The
                 Java Language Specification
              </i>. See <a href="http://java.sun.com/docs/books/jls/index.html">http://java.sun.com/docs/books/jls/index.html</a>.
           </dd>
           
           
           <dt><a name="ISO10646">ISO/IEC 10646</a></dt>
           <dd>ISO (International
              Organization for Standardization).  <i>ISO/IEC 10646-1:1993,
                 Information technology -- Universal Multiple-Octet Coded Character Set
                 (UCS) -- Part 1: Architecture and Basic Multilingual Plane
              </i>.
              International Standard. See <a href="http://www.iso.ch/cate/d18741.html">http://www.iso.ch/cate/d18741.html</a>.
           </dd>
           
           
           <dt><a name="TEI">TEI</a></dt>
           <dd>C.M. Sperberg-McQueen, L. Burnard
              <i>Guidelines for Electronic Text Encoding and
                 Interchange
              </i>. See <a href="http://etext.virginia.edu/TEI.html">http://etext.virginia.edu/TEI.html</a>.
           </dd>
           
           
           <dt><a name="UNICODE">Unicode</a></dt>
           <dd>Unicode Consortium. <i>The Unicode
                 Standard
              </i>.  See <a href="http://www.unicode.org/unicode/standard/standard.html">http://www.unicode.org/unicode/standard/standard.html</a>.
           </dd>
           
           
           <dt><a name="XINFO">XML Infoset</a></dt>
           <dd>World Wide Web
              Consortium. <i>XML Information Set.</i> W3C Working Draft. See
              <a href="http://www.w3.org/TR/xml-infoset">http://www.w3.org/TR/xml-infoset</a>
              
           </dd>
           
           
           <dt><a name="XPTR">XPointer</a></dt>
           <dd>World Wide Web Consortium. <i>XML
                 Pointer Language (XPointer).
              </i> W3C Working Draft. See <a href="http://www.w3.org/TR/WD-xptr">http://www.w3.org/TR/WD-xptr</a></dd>
           
           
           <dt><a name="XQL">XQL</a></dt>
           <dd>J. Robie, J. Lapp, D. Schach.
              <i>XML Query Language (XQL)</i>. See
              <a href="http://www.w3.org/TandS/QL/QL98/pp/xql.html">http://www.w3.org/TandS/QL/QL98/pp/xql.html</a></dd>
           
           
           <dt><a name="XSLT">XSLT</a></dt>
           <dd>World Wide Web Consortium.  <i>XSL
                 Transformations (XSLT).
              </i> W3C Recommendation.  See <a href="http://www.w3.org/TR/xslt">http://www.w3.org/TR/xslt</a></dd>
           
           
        </dl>
        
        
        
        
        
        
        <h2><a name="infoset"></a>B XML Information Set Mapping (Non-Normative)
        </h2>
        
        
        <p>The nodes in the XPath data model can be derived from the
           information items provided by the XML Information Set <a href="#XINFO">[XML Infoset]</a> as follows:
        </p>
        
        
        <blockquote><b>NOTE: </b>A new version of the XML Information Set Working Draft, which
           will replace the May 17 version, was close to completion at the time
           when the preparation of this version of XPath was completed and was
           expected to be released at the same time or shortly after the release
           of this version of XPath.  The mapping is given for this new version
           of the XML Information Set Working Draft. If the new version of the
           XML Information Set Working has not yet been released, W3C members may
           consult the internal Working Group version <a href="http://www.w3.org/XML/Group/1999/09/WD-xml-infoset-19990915.html">
              http://www.w3.org/XML/Group/1999/09/WD-xml-infoset-19990915.html
           </a>
           (<a href="http://cgi.w3.org/MemberAccess/">members
              only
           </a>).
        </blockquote>
        
        
        <ul>
           
           
           <li>
              <p>The root node comes from the document information item.  The
                 children of the root node come from the <i>children</i> and <i>children - comments</i>
                 properties.
              </p>
           </li>
           
           
           <li>
              <p>An element node comes from an element information item.  The
                 children of an element node come from the <i>children</i> and <i>children - comments</i> properties. The
                 attributes of an element node come from the <i>attributes</i> property.  The namespaces
                 of an element node come from the <i>in-scope namespaces</i> property.  The
                 local part of the <a href="#dt-expanded-name">expanded-name</a> of the element node
                 comes from the <i>local name</i>
                 property.  The namespace URI of the <a href="#dt-expanded-name">expanded-name</a> of the element node
                 comes from the <i>namespace URI</i>
                 property. The unique ID of the element node comes from the <i>children</i> property of the attribute
                 information item in the <i>attributes</i> property that has an <i>attribute type</i> property equal to
                 <code>ID</code>.
              </p>
           </li>
           
           
           <li>
              <p>An attribute node comes from an attribute information item.
                 The local part of the <a href="#dt-expanded-name">expanded-name</a> of the attribute node
                 comes from the <i>local name</i>
                 property.  The namespace URI of the <a href="#dt-expanded-name">expanded-name</a> of the attribute node
                 comes from the <i>namespace URI</i>
                 property. The <a href="#dt-string-value">string-value</a> of
                 the node comes from concatenating the <i>character code</i> property of each member
                 of the <i>children</i>
                 property.
              </p>
           </li>
           
           
           <li>
              <p>A text node comes from a sequence of one or more consecutive
                 character information items.  The <a href="#dt-string-value">string-value</a> of the node comes from
                 concatenating the <i>character code</i>
                 property of each of the character information items.
              </p>
           </li>
           
           
           <li>
              <p>A processing instruction node comes from a processing
                 instruction information item.  The local part of the <a href="#dt-expanded-name">expanded-name</a> of the node comes from
                 the <i>target</i> property. (The
                 namespace URI part of the <a href="#dt-expanded-name">expanded-name</a> of the node is null.)
                 The <a href="#dt-string-value">string-value</a> of the node
                 comes from the <i>content</i>
                 property. There are no processing instruction nodes for processing
                 instruction items that are children of document type declaration
                 information item.
              </p>
           </li>
           
           
           <li>
              <p>A comment node comes from a comment information item.  The
                 <a href="#dt-string-value">string-value</a> of the node
                 comes from the <i>content</i> property.
                 There are no comment nodes for comment information items that are
                 children of document type declaration information item.
              </p>
           </li>
           
           
           <li>
              <p>A namespace node comes from a namespace declaration
                 information item.  The local part of the <a href="#dt-expanded-name">expanded-name</a> of the node comes from
                 the <i>prefix</i> property.  (The
                 namespace URI part of the <a href="#dt-expanded-name">expanded-name</a> of the node is null.)
                 The <a href="#dt-string-value">string-value</a> of the node
                 comes from the <i>namespace URI</i>
                 property.
              </p>
           </li>
           
           
        </ul>
        
        
        
        
        
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk056.out
  
  Index: mk056.out
  ===================================================================
  
  <!DOCTYPE html
    PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>XSL Transformations (XSLT)</title>
        <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC"><style type="text/css">p.element-syntax { border: solid thin }code { font-family: monospace }</style></head>
     <body>
        
        
        <div class="head"><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/WWW/w3c_home" alt="W3C" height="48" width="72"></a><h1>XSL Transformations (XSLT)<br>Version 1.0
           </h1>
           <h2>W3C Recommendation 16 November 1999</h2>
           <dl>
              <dt>This version:</dt>
              <dd>
                 
                 <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">http://www.w3.org/TR/1999/REC-xslt-19991116</a><br>
                 
                 (available in <a href="http://www.w3.org/TR/1999/REC-xslt-19991116.xml">XML</a> or 
                 
                 <a href="http://www.w3.org/TR/1999/REC-xslt-19991116.html">HTML</a>)
                 
                 
                 
                 
              </dd>
              <dt>Latest version:</dt>
              <dd>
                 
                 <a href="http://www.w3.org/TR/xslt">http://www.w3.org/TR/xslt</a><br>
                 
                 
              </dd>
              <dt>Previous versions:</dt>
              <dd>
                 
                 <a href="http://www.w3.org/TR/1999/PR-xslt-19991008">http://www.w3.org/TR/1999/PR-xslt-19991008</a><br>
                 
                 <a href="http://www.w3.org/1999/08/WD-xslt-19990813">http://www.w3.org/1999/08/WD-xslt-19990813</a><br>
                 
                 <a href="http://www.w3.org/1999/07/WD-xslt-19990709">http://www.w3.org/1999/07/WD-xslt-19990709</a><br>
                 
                 <a href="http://www.w3.org/TR/1999/WD-xslt-19990421">http://www.w3.org/TR/1999/WD-xslt-19990421</a><br>
                 
                 <a href="http://www.w3.org/TR/1998/WD-xsl-19981216">http://www.w3.org/TR/1998/WD-xsl-19981216</a><br>
                 
                 <a href="http://www.w3.org/TR/1998/WD-xsl-19980818">http://www.w3.org/TR/1998/WD-xsl-19980818</a><br>
                 
                 
              </dd>
              <dt>Editor:</dt>
              <dd>
                 
                 
                 
                 James Clark
                 
                 <a href="mailto:jjc@jclark.com">&lt;jjc@jclark.com></a>
                 
                 <br>
                 
                 
              </dd>
           </dl>
           <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright">
                 		Copyright
              </a> &nbsp;&copy;&nbsp; 1999 <a href="http://www.w3.org">W3C</a>
              		(<a href="http://www.lcs.mit.edu">MIT</a>,
              		<a href="http://www.inria.fr/">INRIA</a>,
              		<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal_Disclaimer">liability</a>,
              		<a href="http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C_Trademarks">trademark</a>,
              		<a href="http://www.w3.org/Consortium/Legal/copyright-documents.html">document use</a> and
              		<a href="http://www.w3.org/Consortium/Legal/copyright-software.html">software licensing</a> rules apply.
              	
           </p>
           <hr title="Separator for header">
        </div>
        <h2><a name="abstract">Abstract</a></h2>
        
        
        
        
        <p>This specification defines the syntax and semantics of XSLT, which
           
           is a language for transforming XML documents into other XML
           
           documents.
        </p>
        
        
        
        
        <p>XSLT is designed for use as part of XSL, which is a stylesheet
           
           language for XML. In addition to XSLT, XSL includes an XML vocabulary
           
           for specifying formatting.  XSL specifies the styling of an XML
           
           document by using XSLT to describe how the document is transformed
           
           into another XML document that uses the formatting vocabulary.
        </p>
        
        
        
        
        <p>XSLT is also designed to be used independently of XSL.  However,
           
           XSLT is not intended as a completely general-purpose XML
           
           transformation language.  Rather it is designed primarily for the
           
           kinds of transformations that are needed when XSLT is used as part of
           
           XSL.
        </p>
        
        
        
        
        <h2><a name="status">Status of this document</a></h2>
        
        
        
        
        <p>This document has been reviewed by W3C Members and other interested
           
           parties and has been endorsed by the Director as a W3C <a href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</a>. It
           
           is a stable document and may be used as reference material or cited as
           
           a normative reference from other documents. W3C's role in making the
           
           Recommendation is to draw attention to the specification and to
           
           promote its widespread deployment. This enhances the functionality and
           
           interoperability of the Web.
        </p>
        
        
        
        
        <p>The list of known errors in this specification is available at
           
           <a href="http://www.w3.org/1999/11/REC-xslt-19991116-errata">http://www.w3.org/1999/11/REC-xslt-19991116-errata</a>.
        </p>
        
        
        
        
        <p>Comments on this specification may be sent to <a href="mailto:xsl-editors@w3.org">xsl-editors@w3.org</a>; <a href="http://lists.w3.org/Archives/Public/xsl-editors">archives</a>
           
           of the comments are available.  Public discussion of XSL, including
           
           XSL Transformations, takes place on the <a href="http://www.mulberrytech.com/xsl/xsl-list/index.html">XSL-List</a>
           
           mailing list.
        </p>
        
        
        
        
        <p>The English version of this specification is the only normative
           
           version. However, for translations of this document, see <a href="http://www.w3.org/Style/XSL/translations.html">http://www.w3.org/Style/XSL/translations.html</a>.
        </p>
        
        
        
        
        <p>A list of current W3C Recommendations and other technical documents
           
           can be found at <a href="http://www.w3.org/TR">http://www.w3.org/TR</a>.
        </p>
        
        
        
        
        <p>This specification has been produced as part of the <a href="http://www.w3.org/Style/Activity">W3C Style activity</a>.
        </p>
        
        
        
        
        
        
        <h2><a name="contents">Table of contents</a></h2>1 <a href="#section-Introduction">Introduction</a><br>2 <a href="#section-Stylesheet-Structure">Stylesheet Structure</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.1 <a href="#xslt-namespace">XSLT Namespace</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.2 <a href="#stylesheet-element">Stylesheet Element</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.3 <a href="#result-element-stylesheet">Literal Result Element as Stylesheet</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.4 <a href="#qname">Qualified Names</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.5 <a href="#forwards">Forwards-Compatible Processing</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.6 <a href="#section-Combining-Stylesheets">Combining Stylesheets</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.6.1 <a href="#include">Stylesheet Inclusion</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.6.2 <a href="#import">Stylesheet Import</a><br>&nbsp;&nbsp;&nbsp;&nbsp;2.7 <a href="#section-Embedding-Stylesheets">Embedding Stylesheets</a><br>3 <a href="#data-model">Data Model</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.1 <a href="#root-node-children">Root Node Children</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.2 <a href="#base-uri">Base URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.3 <a href="#unparsed-entities">Unparsed Entities</a><br>&nbsp;&nbsp;&nbsp;&nbsp;3.4 <a href="#strip">Whitespace Stripping</a><br>4 <a href="#section-Expressions">Expressions</a><br>5 <a href="#rules">Template Rules</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.1 <a href="#section-Processing-Model">Processing Model</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.2 <a href="#patterns">Patterns</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.3 <a href="#section-Defining-Template-Rules">Defining Template Rules</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.4 <a href="#section-Applying-Template-Rules">Applying Template Rules</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.5 <a href="#conflict">Conflict Resolution for Template Rules</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.6 <a href="#apply-imports">Overriding Template Rules</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.7 <a href="#modes">Modes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;5.8 <a href="#built-in-rule">Built-in Template Rules</a><br>6 <a href="#named-templates">Named Templates</a><br>7 <a href="#section-Creating-the-Result-Tree">Creating the Result Tree</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.1 <a href="#section-Creating-Elements-and-Attributes">Creating Elements and Attributes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.1 <a href="#literal-result-element">Literal Result Elements</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.2 <a href="#section-Creating-Elements-with-xsl:element">Creating Elements with xsl:element</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.3 <a href="#creating-attributes">Creating Attributes with xsl:attribute</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.1.4 <a href="#attribute-sets">Named Attribute Sets</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.2 <a href="#section-Creating-Text">Creating Text</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.3 <a href="#section-Creating-Processing-Instructions">Creating Processing Instructions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.4 <a href="#section-Creating-Comments">Creating Comments</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.5 <a href="#copying">Copying</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.6 <a href="#section-Computing-Generated-Text">Computing Generated Text</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.6.1 <a href="#value-of">Generating Text with xsl:value-of</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.6.2 <a href="#attribute-value-templates">Attribute Value Templates</a><br>&nbsp;&nbsp;&nbsp;&nbsp;7.7 <a href="#number">Numbering</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7.7.1 <a href="#convert">Number to String Conversion Attributes</a><br>8 <a href="#for-each">Repetition</a><br>9 <a href="#section-Conditional-Processing">Conditional Processing</a><br>&nbsp;&nbsp;&nbsp;&nbsp;9.1 <a href="#section-Conditional-Processing-with-xsl:if">Conditional Processing with xsl:if</a><br>&nbsp;&nbsp;&nbsp;&nbsp;9.2 <a href="#section-Conditional-Processing-with-xsl:choose">Conditional Processing with xsl:choose</a><br>10 <a href="#sorting">Sorting</a><br>11 <a href="#variables">Variables and Parameters</a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.1 <a href="#section-Result-Tree-Fragments">Result Tree Fragments</a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.2 <a href="#variable-values">Values of Variables and Parameters</a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.3 <a href="#copy-of">Using Values of Variables and Parameters with
           
           xsl:copy-of
        </a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.4 <a href="#top-level-variables">Top-level Variables and Parameters</a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.5 <a href="#local-variables">Variables and Parameters within Templates</a><br>&nbsp;&nbsp;&nbsp;&nbsp;11.6 <a href="#section-Passing-Parameters-to-Templates">Passing Parameters to Templates</a><br>12 <a href="#add-func">Additional Functions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;12.1 <a href="#document">Multiple Source Documents</a><br>&nbsp;&nbsp;&nbsp;&nbsp;12.2 <a href="#key">Keys</a><br>&nbsp;&nbsp;&nbsp;&nbsp;12.3 <a href="#format-number">Number Formatting</a><br>&nbsp;&nbsp;&nbsp;&nbsp;12.4 <a href="#misc-func">Miscellaneous Additional Functions</a><br>13 <a href="#message">Messages</a><br>14 <a href="#extension">Extensions</a><br>&nbsp;&nbsp;&nbsp;&nbsp;14.1 <a href="#extension-element">Extension Elements</a><br>&nbsp;&nbsp;&nbsp;&nbsp;14.2 <a href="#section-Extension-Functions">Extension Functions</a><br>15 <a href="#fallback">Fallback</a><br>16 <a href="#output">Output</a><br>&nbsp;&nbsp;&nbsp;&nbsp;16.1 <a href="#section-XML-Output-Method">XML Output Method</a><br>&nbsp;&nbsp;&nbsp;&nbsp;16.2 <a href="#section-HTML-Output-Method">HTML Output Method</a><br>&nbsp;&nbsp;&nbsp;&nbsp;16.3 <a href="#section-Text-Output-Method">Text Output Method</a><br>&nbsp;&nbsp;&nbsp;&nbsp;16.4 <a href="#disable-output-escaping">Disabling Output Escaping</a><br>17 <a href="#conformance">Conformance</a><br>18 <a href="#notation">Notation</a><br><h3>Appendices</h3>A <a href="#section-References">References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.1 <a href="#section-Normative-References">Normative References</a><br>&nbsp;&nbsp;&nbsp;&nbsp;A.2 <a href="#section-Other-References">Other References</a><br>B <a href="#element-syntax-summary">Element Syntax Summary</a><br>C <a href="#dtd">DTD Fragment for XSLT Stylesheets</a> (Non-Normative)<br>D <a href="#section-Examples">Examples</a> (Non-Normative)<br>&nbsp;&nbsp;&nbsp;&nbsp;D.1 <a href="#section-Document-Example">Document Example</a><br>&nbsp;&nbsp;&nbsp;&nbsp;D.2 <a href="#data-example">Data Example</a><br>E <a href="#section-Acknowledgements">Acknowledgements</a> (Non-Normative)<br>F <a href="#section-Changes-from-Proposed-Recommendation">Changes from Proposed Recommendation</a> (Non-Normative)<br>G <a href="#section-Features-under-Consideration-for-Future-Versions-of-XSLT">Features under Consideration for Future Versions of XSLT</a> (Non-Normative)<br><hr>
        
        
        
        
        <h2><a name="section-Introduction"></a>1 Introduction
        </h2>
        
        
        
        
        <p>This specification defines the syntax and semantics of the XSLT
           
           language.  A transformation in the XSLT language is expressed as a
           
           well-formed XML document <a href="#XML">[XML]</a> conforming to the
           
           Namespaces in XML Recommendation <a href="#XMLNAMES">[XML Names]</a>, which may
           
           include both elements that are defined by XSLT and elements that are
           
           not defined by XSLT.  <a name="dt-xslt-namespace"></a>XSLT-defined elements are distinguished by belonging to a
           
           specific XML namespace (see <a href="#xslt-namespace">[<b>2.1 XSLT Namespace</b>]
           </a>), which is
           
           referred to in this specification as the <b>XSLT
              
              namespace
           </b>. Thus this specification is a definition of
           
           the syntax and semantics of the XSLT namespace.
        </p>
        
        
        
        
        <p>A transformation expressed in XSLT describes rules for transforming
           
           a source tree into a result tree.  The transformation is achieved by
           
           associating patterns with templates.  A pattern is matched against
           
           elements in the source tree.  A template is instantiated to create
           
           part of the result tree.  The result tree is separate from the source
           
           tree.  The structure of the result tree can be completely different
           
           from the structure of the source tree. In constructing the result
           
           tree, elements from the source tree can be filtered and reordered, and
           
           arbitrary structure can be added.
        </p>
        
        
        
        
        <p>A transformation expressed in XSLT is called a stylesheet.  This is
           
           because, in the case when XSLT is transforming into the XSL formatting
           
           vocabulary, the transformation functions as a stylesheet.
        </p>
        
        
        
        
        <p>This document does not specify how an XSLT stylesheet is associated
           
           with an XML document.  It is recommended that XSL processors support
           
           the mechanism described in <a href="#XMLSTYLE">[XML Stylesheet]</a>.  When this or any
           
           other mechanism yields a sequence of more than one XSLT stylesheet to
           
           be applied simultaneously to a XML document, then the effect
           
           should be the same as applying a single stylesheet that imports each
           
           member of the sequence in order (see <a href="#import">[<b>2.6.2 Stylesheet Import</b>]
           </a>).
        </p>
        
        
        
        
        <p>A stylesheet contains a set of template rules.  A template rule has
           
           two parts: a pattern which is matched against nodes in the source tree
           
           and a template which can be instantiated to form part of the result
           
           tree.  This allows a stylesheet to be applicable to a wide class of
           
           documents that have similar source tree structures.
        </p>
        
        
        
        
        <p>A template is instantiated for a particular source element
           
           to create part of the result tree. A template can contain elements
           
           that specify literal result element structure.  A template can also
           
           contain elements from the XSLT namespace
           
           that are instructions for creating result tree
           
           fragments.  When a template is instantiated, each instruction is
           
           executed and replaced by the result tree fragment that it creates.
           
           Instructions can select and process descendant source elements.  Processing a
           
           descendant element creates a result tree fragment by finding the
           
           applicable template rule and instantiating its template. Note
           
           that elements are only processed when they have been selected by the
           
           execution of an instruction.  The result tree is constructed by
           
           finding the template rule for the root node and instantiating
           
           its template.
        </p>
        
        
        
        
        <p>In the process of finding the applicable template rule, more
           
           than one template rule may have a pattern that matches a given
           
           element. However, only one template rule will be applied. The
           
           method for deciding which template rule to apply is described
           
           in <a href="#conflict">[<b>5.5 Conflict Resolution for Template Rules</b>]
           </a>.
        </p>
        
        
        
        
        <p>A single template by itself has considerable power: it can create
           
           structures of arbitrary complexity; it can pull string values out of
           
           arbitrary locations in the source tree; it can generate structures
           
           that are repeated according to the occurrence of elements in the
           
           source tree.  For simple transformations where the structure of the
           
           result tree is independent of the structure of the source tree, a
           
           stylesheet can often consist of only a single template, which
           
           functions as a template for the complete result tree.  Transformations
           
           on XML documents that represent data are often of this kind (see
           
           <a href="#data-example">[<b>D.2 Data Example</b>]
           </a>). XSLT allows a simplified syntax for
           
           such stylesheets (see <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
           </a>).
        </p>
        
        
        
        
        <p>When a template is instantiated, it is always instantiated with
           
           respect to a <a name="dt-current-node"></a><b>current node</b> and a <a name="dt-current-node-list"></a><b>current node
              
              list
           </b>. The current node is always a member of the
           
           current node list.  Many operations in XSLT are relative to the
           
           current node. Only a few instructions change the current node list or
           
           the current node (see <a href="#rules">[<b>5 Template Rules</b>]
           </a> and <a href="#for-each">[<b>8 Repetition</b>]
           </a>); during the instantiation of one of these
           
           instructions, the current node list changes to a new list of nodes and
           
           each member of this new list becomes the current node in turn; after
           
           the instantiation of the instruction is complete, the current node and
           
           current node list revert to what they were before the instruction was
           
           instantiated.
        </p>
        
        
        
        
        <p>XSLT makes use of the expression language defined by <a href="#XPATH">[XPath]</a> for selecting elements for processing, for conditional
           
           processing and for generating text.
        </p>
        
        
        
        
        <p>XSLT provides two "hooks" for extending the language,
           
           one hook for extending the set of instruction elements used in
           
           templates and one hook for extending the set of functions used in
           
           XPath expressions.  These hooks are both based on XML namespaces.
           
           This version of XSLT does not define a mechanism for implementing the
           
           hooks. See <a href="#extension">[<b>14 Extensions</b>]
           </a>.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>The XSL WG intends to define such a mechanism in a future
           
           version of this specification or in a separate
           
           specification.
        </blockquote>
        
        
        
        
        <p>The element syntax summary notation used to describe the syntax of
           
           XSLT-defined elements is described in <a href="#notation">[<b>18 Notation</b>]
           </a>.
        </p>
        
        
        
        
        <p>The MIME media types <code>text/xml</code> and
           
           <code>application/xml</code> <a href="#RFC2376">[RFC2376]</a> should be used
           
           for XSLT stylesheets.  It is possible that a media type will be
           
           registered specifically for XSLT stylesheets; if and when it is, that
           
           media type may also be used.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Stylesheet-Structure"></a>2 Stylesheet Structure
        </h2>
        
        
        
        
        
        
        <h3><a name="xslt-namespace"></a>2.1 XSLT Namespace
        </h3>
        
        
        
        
        <p>The XSLT namespace has the URI <code>http://www.w3.org/1999/XSL/Transform</code>.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>The <code>1999</code> in the URI indicates the year in which
           
           the URI was allocated by the W3C.  It does not indicate the version of
           
           XSLT being used, which is specified by attributes (see <a href="#stylesheet-element">[<b>2.2 Stylesheet Element</b>]
           </a> and <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
           </a>).
        </blockquote>
        
        
        
        
        <p>XSLT processors must use the XML namespaces mechanism <a href="#XMLNAMES">[XML Names]</a> to recognize elements and attributes from this
           
           namespace. Elements from the XSLT namespace are recognized only in the
           
           stylesheet not in the source document. The complete list of
           
           XSLT-defined elements is specified in <a href="#element-syntax-summary">[<b>B Element Syntax Summary</b>]
           </a>.  Vendors must not extend the XSLT
           
           namespace with additional elements or attributes. Instead, any
           
           extension must be in a separate namespace.  Any namespace that is used
           
           for additional instruction elements must be identified by means of the
           
           extension element mechanism specified in <a href="#extension-element">[<b>14.1 Extension Elements</b>]
           </a>.
        </p>
        
        
        
        
        <p>This specification uses a prefix of <code>xsl:</code> for referring
           
           to elements in the XSLT namespace. However, XSLT stylesheets are free
           
           to use any prefix, provided that there is a namespace declaration that
           
           binds the prefix to the URI of the XSLT namespace.
        </p>
        
        
        
        
        <p>An element from the XSLT namespace may have any attribute not from
           
           the XSLT namespace, provided that the <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> of the
           
           attribute has a non-null namespace URI.  The presence of such
           
           attributes must not change the behavior of XSLT elements and functions
           
           defined in this document. Thus, an XSLT processor is always free to
           
           ignore such attributes, and must ignore such attributes without giving
           
           an error if it does not recognize the namespace URI. Such attributes
           
           can provide, for example, unique identifiers, optimization hints, or
           
           documentation.
        </p>
        
        
        
        
        <p>It is an error for an element from the XSLT namespace to have
           
           attributes with expanded-names that have null namespace URIs
           
           (i.e. attributes with unprefixed names) other than attributes defined
           
           for the element in this document.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>The conventions used for the names of XSLT elements,
           
           attributes and functions are that names are all lower-case, use
           
           hyphens to separate words, and use abbreviations only if they already
           
           appear in the syntax of a related language such as XML or
           
           HTML.
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="stylesheet-element"></a>2.2 Stylesheet Element
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-stylesheet"></a><code>&lt;xsl:stylesheet<br>&nbsp;&nbsp;id = <var>id</var><br>&nbsp;&nbsp;extension-element-prefixes = <var>tokens</var><br>&nbsp;&nbsp;exclude-result-prefixes = <var>tokens</var><br>&nbsp;&nbsp;<b>version</b> = <var>number</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-import">xsl:import</a>*, <var>top-level-elements</var>) --><br>&lt;/xsl:stylesheet>
           </code>
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-transform"></a><code>&lt;xsl:transform<br>&nbsp;&nbsp;id = <var>id</var><br>&nbsp;&nbsp;extension-element-prefixes = <var>tokens</var><br>&nbsp;&nbsp;exclude-result-prefixes = <var>tokens</var><br>&nbsp;&nbsp;<b>version</b> = <var>number</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-import">xsl:import</a>*, <var>top-level-elements</var>) --><br>&lt;/xsl:transform>
           </code>
        </p>
        
        
        
        
        <p>A stylesheet is represented by an <code>xsl:stylesheet</code>
           
           element in an XML document.  <code>xsl:transform</code> is allowed as
           
           a synonym for <code>xsl:stylesheet</code>.
        </p>
        
        
        
        
        <p>An <code>xsl:stylesheet</code> element must have a
           
           <code>version</code> attribute, indicating the version of XSLT that
           
           the stylesheet requires.  For this version of XSLT, the value should
           
           be <code>1.0</code>.  When the value is not equal to <code>1.0</code>,
           
           forwards-compatible processing mode is enabled (see <a href="#forwards">[<b>2.5 Forwards-Compatible Processing</b>]
           </a>).
        </p>
        
        
        
        
        <p>The <code>xsl:stylesheet</code> element may contain the following types
           
           of elements:
        </p>
        
        
        <ul>
           
           
           <li>
              <p><code>xsl:import</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:include</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:strip-space</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:preserve-space</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:output</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:key</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:decimal-format</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:namespace-alias</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:attribute-set</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:variable</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:param</code></p>
           </li>
           
           
           <li>
              <p><code>xsl:template</code></p>
           </li>
           
           
        </ul>
        
        
        
        
        <p><a name="dt-top-level"></a>An element occurring as
           
           a child of an <code>xsl:stylesheet</code> element is called a
           
           <b>top-level</b> element.
        </p>
        
        
        
        
        <p>This example shows the structure of a stylesheet.  Ellipses
           
           (<code>...</code>) indicate where attribute values or content have
           
           been omitted.  Although this example shows one of each type of allowed
           
           element, stylesheets may contain zero or more of each of these
           
           elements.
        </p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    &lt;xsl:import href="..."/>
  
  
  
    &lt;xsl:include href="..."/>
  
  
  
    &lt;xsl:strip-space elements="..."/>
  
    
  
    &lt;xsl:preserve-space elements="..."/>
  
  
  
    &lt;xsl:output method="..."/>
  
  
  
    &lt;xsl:key name="..." match="..." use="..."/>
  
  
  
    &lt;xsl:decimal-format name="..."/>
  
  
  
    &lt;xsl:namespace-alias stylesheet-prefix="..." result-prefix="..."/>
  
  
  
    &lt;xsl:attribute-set name="...">
  
      ...
  
    &lt;/xsl:attribute-set>
  
  
  
    &lt;xsl:variable name="...">...&lt;/xsl:variable>
  
  
  
    &lt;xsl:param name="...">...&lt;/xsl:param>
  
  
  
    &lt;xsl:template match="...">
  
      ...
  
    &lt;/xsl:template>
  
  
  
    &lt;xsl:template name="...">
  
      ...
  
    &lt;/xsl:template>
  
  
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>The order in which the children of the <code>xsl:stylesheet</code>
           
           element occur is not significant except for <code>xsl:import</code>
           
           elements and for error recovery.  Users are free to order the elements
           
           as they prefer, and stylesheet creation tools need not provide control
           
           over the order in which the elements occur.
        </p>
        
        
        
        
        <p>In addition, the <code>xsl:stylesheet</code> element may contain
           
           any element not from the XSLT namespace, provided that the
           
           expanded-name of the element has a non-null namespace URI.  The presence of
           
           such top-level elements must not change the behavior of XSLT elements
           
           and functions defined in this document; for example, it would not be
           
           permitted for such a top-level element to specify that
           
           <code>xsl:apply-templates</code> was to use different rules to resolve
           
           conflicts. Thus, an XSLT processor is always free to ignore such
           
           top-level elements, and must ignore a top-level element without giving
           
           an error if it does not recognize the namespace URI. Such elements can
           
           provide, for example,
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>information used by extension elements or extension functions
                 
                 (see <a href="#extension">[<b>14 Extensions</b>]
                 </a>),
              </p>
           </li>
           
           
           
           
           <li>
              <p>information about what to do with the result tree,</p>
           </li>
           
           
           
           
           <li>
              <p>information about how to obtain the source tree,</p>
           </li>
           
           
           
           
           <li>
              <p>metadata about the stylesheet,</p>
           </li>
           
           
           
           
           <li>
              <p>structured documentation for the stylesheet.</p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="result-element-stylesheet"></a>2.3 Literal Result Element as Stylesheet
        </h3>
        
        
        
        
        <p>A simplified syntax is allowed for stylesheets that consist of only
           
           a single template for the root node.  The stylesheet may consist of
           
           just a literal result element (see <a href="#literal-result-element">[<b>7.1.1 Literal Result Elements</b>]
           </a>).  Such a stylesheet is equivalent to a
           
           stylesheet with an <code>xsl:stylesheet</code> element containing a
           
           template rule containing the literal result element; the template rule
           
           has a match pattern of <code>/</code>. For example
        </p>
        
        
        
        <pre>&lt;html xsl:version="1.0"
  
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
        xmlns="http://www.w3.org/TR/xhtml1/strict">
  
    &lt;head>
  
      &lt;title>Expense Report Summary&lt;/title>
  
    &lt;/head>
  
    &lt;body>
  
      &lt;p>Total Amount: &lt;xsl:value-of select="expense-report/total"/>&lt;/p>
  
    &lt;/body>
  
  &lt;/html></pre>
        
        
        
        <p>has the same meaning as</p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
                  xmlns="http://www.w3.org/TR/xhtml1/strict">
  
  &lt;xsl:template match="/">
  
  &lt;html>
  
    &lt;head>
  
      &lt;title>Expense Report Summary&lt;/title>
  
    &lt;/head>
  
    &lt;body>
  
      &lt;p>Total Amount: &lt;xsl:value-of select="expense-report/total"/>&lt;/p>
  
    &lt;/body>
  
  &lt;/html>
  
  &lt;/xsl:template>
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>A literal result element that is the document element of a
           
           stylesheet must have an <code>xsl:version</code> attribute, which
           
           indicates the version of XSLT that the stylesheet requires.  For this
           
           version of XSLT, the value should be <code>1.0</code>; the value must
           
           be a <a href="http://www.w3.org/TR/xpath#NT-Number">Number</a>.  Other literal result
           
           elements may also have an <code>xsl:version</code> attribute. When the
           
           <code>xsl:version</code> attribute is not equal to <code>1.0</code>,
           
           forwards-compatible processing mode is enabled (see <a href="#forwards">[<b>2.5 Forwards-Compatible Processing</b>]
           </a>).
        </p>
        
        
        
        
        <p>The allowed content of a literal result element when used as a
           
           stylesheet is no different from when it occurs within a
           
           stylesheet. Thus, a literal result element used as a stylesheet cannot
           
           contain <a href="#dt-top-level">top-level</a> elements.
        </p>
        
        
        
        
        <p>In some situations, the only way that a system can recognize that an
           
           XML document needs to be processed by an XSLT processor as an XSLT
           
           stylesheet is by examining the XML document itself.  Using the
           
           simplified syntax makes this harder.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>For example, another XML language (AXL) might also use an
           
           <code>axl:version</code> on the document element to indicate that an
           
           XML document was an AXL document that required processing by an AXL
           
           processor; if a document had both an <code>axl:version</code>
           
           attribute and an <code>xsl:version</code> attribute, it would be
           
           unclear whether the document should be processed by an XSLT processor
           
           or an AXL processor.
        </blockquote>
        
        
        
        
        <p>Therefore, the simplified syntax should not be used for XSLT
           
           stylesheets that may be used in such a situation.  This situation can,
           
           for example, arise when an XSLT stylesheet is transmitted as a message
           
           with a MIME media type of <code>text/xml</code> or
           
           <code>application/xml</code> to a recipient that will use the MIME
           
           media type to determine how the message is processed.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="qname"></a>2.4 Qualified Names
        </h3>
        
        
        
        
        <p>The name of an internal XSLT object, specifically a named template
           
           (see <a href="#named-templates">[<b>6 Named Templates</b>]
           </a>), a mode (see <a href="#modes">[<b>5.7 Modes</b>]
           </a>), an attribute set (see <a href="#attribute-sets">[<b>7.1.4 Named Attribute Sets</b>]
           </a>), a key (see <a href="#key">[<b>12.2 Keys</b>]
           </a>), a
           
           decimal-format (see <a href="#format-number">[<b>12.3 Number Formatting</b>]
           </a>), a variable or a
           
           parameter (see <a href="#variables">[<b>11 Variables and Parameters</b>]
           </a>) is specified as a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  If it has a prefix, then the
           
           prefix is expanded into a URI reference using the namespace
           
           declarations in effect on the attribute in which the name occurs.  The
           
           <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a>
           
           consisting of the local part of the name and the possibly null URI
           
           reference is used as the name of the object.  The default namespace is
           
           <i>not</i> used for unprefixed names.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="forwards"></a>2.5 Forwards-Compatible Processing
        </h3>
        
        
        
        
        <p>An element enables forwards-compatible mode for itself, its
           
           attributes, its descendants and their attributes if either it is an
           
           <code>xsl:stylesheet</code> element whose <code>version</code>
           
           attribute is not equal to <code>1.0</code>, or it is a literal result
           
           element that has an <code>xsl:version</code> attribute whose value is
           
           not equal to <code>1.0</code>, or it is a literal result element that
           
           does not have an <code>xsl:version</code> attribute and that is the
           
           document element of a stylesheet using the simplified syntax (see
           
           <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
           </a>).  A literal result element
           
           that has an <code>xsl:version</code> attribute whose value is equal to
           
           <code>1.0</code> disables forwards-compatible mode for itself, its
           
           attributes, its descendants and their attributes.
        </p>
        
        
        
        
        <p>If an element is processed in forwards-compatible mode, then:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>if it is a <a href="#dt-top-level">top-level</a>
                 
                 element and XSLT 1.0 does not allow such elements as top-level
                 
                 elements, then the element must be ignored along with its
                 
                 content;
              </p>
           </li>
           
           
           
           
           <li>
              <p>if it is an element in a template and XSLT 1.0 does not allow
                 
                 such elements to occur in templates, then if the element is not
                 
                 instantiated, an error must not be signaled, and if the element is
                 
                 instantiated, the XSLT must perform fallback for the element as
                 
                 specified in <a href="#fallback">[<b>15 Fallback</b>]
                 </a>;
              </p>
           </li>
           
           
           
           
           <li>
              <p>if the element has an attribute that XSLT 1.0 does not allow
                 
                 the element to have or if the element has an optional attribute with a
                 
                 value that the XSLT 1.0 does not allow the attribute to have, then the
                 
                 attribute must be ignored.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>Thus, any XSLT 1.0 processor must be able to process the following
           
           stylesheet without error, although the stylesheet includes elements
           
           from the XSLT namespace that are not defined in this
           
           specification:
        </p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.1"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    &lt;xsl:template match="/">
  
      &lt;xsl:choose>
  
        &lt;xsl:when test="system-property('xsl:version') >= 1.1">
  
          &lt;xsl:exciting-new-1.1-feature/>
  
        &lt;/xsl:when>
  
        &lt;xsl:otherwise>
  
          &lt;html>
  
          &lt;head>
  
            &lt;title>XSLT 1.1 required&lt;/title>
  
          &lt;/head>
  
          &lt;body>
  
            &lt;p>Sorry, this stylesheet requires XSLT 1.1.&lt;/p>
  
          &lt;/body>
  
          &lt;/html>
  
        &lt;/xsl:otherwise>
  
      &lt;/xsl:choose>
  
    &lt;/xsl:template>
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <blockquote><b>NOTE: </b>If a stylesheet depends crucially on a top-level element
           
           introduced by a version of XSL after 1.0, then the stylesheet can use
           
           an <code>xsl:message</code> element with <code>terminate="yes"</code>
           
           (see <a href="#message">[<b>13 Messages</b>]
           </a>) to ensure that XSLT processors
           
           implementing earlier versions of XSL will not silently ignore the
           
           top-level element. For example,
           
           
           
           <pre>&lt;xsl:stylesheet version="1.5"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
  
    &lt;xsl:important-new-1.1-declaration/>
  
  
  
    &lt;xsl:template match="/">
  
      &lt;xsl:choose>
  
        &lt;xsl:when test="system-property('xsl:version') &amp;lt; 1.1">
  
          &lt;xsl:message terminate="yes">
  
            &lt;xsl:text>Sorry, this stylesheet requires XSLT 1.1.&lt;/xsl:text>
  
          &lt;/xsl:message>
  
        &lt;/xsl:when>
  
        &lt;xsl:otherwise>
  
          ...
  
        &lt;/xsl:otherwise>
  
      &lt;/xsl:choose>
  
    &lt;/xsl:template>
  
    ...
  
  &lt;/xsl:stylesheet></pre>
           
           </blockquote>
        
        
        
        
        <p>If an <a href="#dt-expression">expression</a> occurs in
           
           an attribute that is processed in forwards-compatible mode, then an
           
           XSLT processor must recover from errors in the expression as
           
           follows:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>if the expression does not match the syntax allowed by the
                 
                 XPath grammar, then an error must not be signaled unless the
                 
                 expression is actually evaluated;
              </p>
           </li>
           
           
           
           
           <li>
              <p>if the expression calls a function with an unprefixed name
                 
                 that is not part of the XSLT library, then an error must not be
                 
                 signaled unless the function is actually called;
              </p>
           </li>
           
           
           
           
           <li>
              <p>if the expression calls a function with a number of arguments
                 
                 that XSLT does not allow or with arguments of types that XSLT does not
                 
                 allow, then an error must not be signaled unless the function is
                 
                 actually called.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Combining-Stylesheets"></a>2.6 Combining Stylesheets
        </h3>
        
        
        
        
        <p>XSLT provides two mechanisms to combine stylesheets:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>an inclusion mechanism that allows stylesheets to be combined
              
              without changing the semantics of the stylesheets being combined,
              
              and
           </li>
           
           
           
           
           <li>an import mechanism that allows stylesheets to override each
              
              other.
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        <h4><a name="include"></a>2.6.1 Stylesheet Inclusion
        </h4>
        
        
        
        
        <p class="element-syntax"><a name="element-include"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:include<br>&nbsp;&nbsp;<b>href</b> = <var>uri-reference</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>An XSLT stylesheet may include another XSLT stylesheet using an
           
           <code>xsl:include</code> element. The <code>xsl:include</code> element
           
           has an <code>href</code> attribute whose value is a URI reference
           
           identifying the stylesheet to be included.  A relative URI is resolved
           
           relative to the base URI of the <code>xsl:include</code> element (see
           
           <a href="#base-uri">[<b>3.2 Base URI</b>]
           </a>).
        </p>
        
        
        
        
        <p>The <code>xsl:include</code> element is only allowed as a <a href="#dt-top-level">top-level</a> element.
        </p>
        
        
        
        
        <p>The inclusion works at the XML tree level.  The resource located by
           
           the <code>href</code> attribute value is parsed as an XML document,
           
           and the children of the <code>xsl:stylesheet</code> element in this
           
           document replace the <code>xsl:include</code> element in the including
           
           document.  The fact that template rules or definitions are included
           
           does not affect the way they are processed.
        </p>
        
        
        
        
        <p>The included stylesheet may use the simplified syntax described in
           
           <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
           </a>.  The included stylesheet
           
           is treated the same as the equivalent <code>xsl:stylesheet</code>
           
           element.
        </p>
        
        
        
        
        <p>It is an error if a stylesheet directly or indirectly includes
           
           itself.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Including a stylesheet multiple times can cause errors
           
           because of duplicate definitions.  Such multiple inclusions are less
           
           obvious when they are indirect. For example, if stylesheet
           
           <var>B</var> includes stylesheet <var>A</var>, stylesheet <var>C</var>
           
           includes stylesheet <var>A</var>, and stylesheet <var>D</var> includes
           
           both stylesheet <var>B</var> and stylesheet <var>C</var>, then
           
           <var>A</var> will be included indirectly by <var>D</var> twice.  If
           
           all of <var>B</var>, <var>C</var> and <var>D</var> are used as
           
           independent stylesheets, then the error can be avoided by separating
           
           everything in <var>B</var> other than the inclusion of <var>A</var>
           
           into a separate stylesheet <var>B'</var> and changing <var>B</var> to
           
           contain just inclusions of <var>B'</var> and <var>A</var>, similarly
           
           for <var>C</var>, and then changing <var>D</var> to include
           
           <var>A</var>, <var>B'</var>, <var>C'</var>.
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        <h4><a name="import"></a>2.6.2 Stylesheet Import
        </h4>
        
        
        
        
        <p class="element-syntax"><a name="element-import"></a><code>&lt;xsl:import<br>&nbsp;&nbsp;<b>href</b> = <var>uri-reference</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>An XSLT stylesheet may import another XSLT stylesheet using an
           
           <code>xsl:import</code> element.  Importing a stylesheet is the same
           
           as including it (see <a href="#include">[<b>2.6.1 Stylesheet Inclusion</b>]
           </a>) except that definitions
           
           and template rules in the importing stylesheet take precedence over
           
           template rules and definitions in the imported stylesheet; this is
           
           described in more detail below.  The <code>xsl:import</code> element
           
           has an <code>href</code> attribute whose value is a URI reference
           
           identifying the stylesheet to be imported.  A relative URI is resolved
           
           relative to the base URI of the <code>xsl:import</code> element (see
           
           <a href="#base-uri">[<b>3.2 Base URI</b>]
           </a>).
        </p>
        
        
        
        
        <p>The <code>xsl:import</code> element is only allowed as a <a href="#dt-top-level">top-level</a> element.  The
           
           <code>xsl:import</code> element children must precede all other
           
           element children of an <code>xsl:stylesheet</code> element, including
           
           any <code>xsl:include</code> element children.  When
           
           <code>xsl:include</code> is used to include a stylesheet, any
           
           <code>xsl:import</code> elements in the included document are moved up
           
           in the including document to after any existing
           
           <code>xsl:import</code> elements in the including document.
        </p>
        
        
        
        
        <p>For example,</p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    &lt;xsl:import href="article.xsl"/>
  
    &lt;xsl:import href="bigfont.xsl"/>
  
    &lt;xsl:attribute-set name="note-style">
  
      &lt;xsl:attribute name="font-style">italic&lt;/xsl:attribute>
  
    &lt;/xsl:attribute-set>
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p><a name="dt-import-tree"></a>The
           
           <code>xsl:stylesheet</code> elements encountered during processing of
           
           a stylesheet that contains <code>xsl:import</code> elements are
           
           treated as forming an <b>import tree</b>.  In the import tree,
           
           each <code>xsl:stylesheet</code> element has one import child for each
           
           <code>xsl:import</code> element that it contains. Any
           
           <code>xsl:include</code> elements are resolved before constructing the
           
           import tree. <a name="dt-import-precedence"></a>An <code>xsl:stylesheet</code> element in the import tree
           
           is defined to have lower <b>import precedence</b> than another
           
           <code>xsl:stylesheet</code> element in the import tree if it would be
           
           visited before that <code>xsl:stylesheet</code> element in a
           
           post-order traversal of the import tree (i.e. a traversal of the
           
           import tree in which an <code>xsl:stylesheet</code> element is visited
           
           after its import children). Each definition and template
           
           rule has import precedence determined by the
           
           <code>xsl:stylesheet</code> element that contains it.
        </p>
        
        
        
        
        <p>For example, suppose</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>stylesheet <var>A</var> imports stylesheets <var>B</var>
                 
                 and <var>C</var> in that order;
              </p>
           </li>
           
           
           
           
           <li>
              <p>stylesheet <var>B</var> imports stylesheet
                 
                 <var>D</var>;
              </p>
           </li>
           
           
           
           
           <li>
              <p>stylesheet <var>C</var> imports stylesheet
                 
                 <var>E</var>.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>Then the order of import precedence (lowest first) is
           
           <var>D</var>, <var>B</var>, <var>E</var>, <var>C</var>,
           
           <var>A</var>.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Since <code>xsl:import</code> elements are required to occur
           
           before any definitions or template rules, an implementation that
           
           processes imported stylesheets at the point at which it encounters the
           
           <code>xsl:import</code> element will encounter definitions and
           
           template rules in increasing order of import precedence.
        </blockquote>
        
        
        
        
        <p>In general, a definition or template rule with higher import
           
           precedence takes precedence over a definition or template rule with
           
           lower import precedence.  This is defined in detail for each kind of
           
           definition and for template rules.
        </p>
        
        
        
        
        <p>It is an error if a stylesheet directly or indirectly imports
           
           itself. Apart from this, the case where a stylesheet with a particular
           
           URI is imported in multiple places is not treated specially. The
           
           <a href="#dt-import-tree">import tree</a> will have a
           
           separate <code>xsl:stylesheet</code> for each place that it is
           
           imported.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>If <code>xsl:apply-imports</code> is used (see <a href="#apply-imports">[<b>5.6 Overriding Template Rules</b>]
           </a>), the behavior may be different from the
           
           behavior if the stylesheet had been imported only at the place with
           
           the highest <a href="#dt-import-precedence">import
              
              precedence
           </a>.
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Embedding-Stylesheets"></a>2.7 Embedding Stylesheets
        </h3>
        
        
        
        
        <p>Normally an XSLT stylesheet is a complete XML document with the
           
           <code>xsl:stylesheet</code> element as the document element. However,
           
           an XSLT stylesheet may also be embedded in another resource. Two forms
           
           of embedding are possible:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>the XSLT stylesheet may be textually embedded in a non-XML
              
              resource, or
           </li>
           
           
           
           
           <li>the <code>xsl:stylesheet</code> element may occur in an XML
              
              document other than as the document element.
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>To facilitate the second form of embedding, the
           
           <code>xsl:stylesheet</code> element is allowed to have an ID attribute
           
           that specifies a unique identifier.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>In order for such an attribute to be used with the XPath
           
           <b><a href="http://www.w3.org/TR/xpath#function-id">id</a></b> function, it must actually be declared in
           
           the DTD as being an ID.
        </blockquote>
        
        
        
        
        <p>The following example shows how the <code>xml-stylesheet</code>
           
           processing instruction <a href="#XMLSTYLE">[XML Stylesheet]</a> can be used to allow a
           
           document to contain its own stylesheet.  The URI reference uses a
           
           relative URI with a fragment identifier to locate the
           
           <code>xsl:stylesheet</code> element:
        </p>
        
        
        
        <pre>&lt;?xml-stylesheet type="text/xml" href="#style1"?>
  
  &lt;!DOCTYPE doc SYSTEM "doc.dtd">
  
  &lt;doc>
  
  &lt;head>
  
  &lt;xsl:stylesheet id="style1"
  
                  version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
                  xmlns:fo="http://www.w3.org/1999/XSL/Format">
  
  &lt;xsl:import href="doc.xsl"/>
  
  &lt;xsl:template match="id('foo')">
  
    &lt;fo:block font-weight="bold">&lt;xsl:apply-templates/>&lt;/fo:block>
  
  &lt;/xsl:template>
  
  &lt;xsl:template match="xsl:stylesheet">
  
    &lt;!-- ignore -->
  
  &lt;/xsl:template>
  
  &lt;/xsl:stylesheet>
  
  &lt;/head>
  
  &lt;body>
  
  &lt;para id="foo">
  
  ...
  
  &lt;/para>
  
  &lt;/body>
  
  &lt;/doc>
  
  </pre>
        
        
        
        <blockquote><b>NOTE: </b>A stylesheet that is embedded in the document to which it is
           
           to be applied or that may be included or imported into an stylesheet
           
           that is so embedded typically needs to contain a template rule that
           
           specifies that <code>xsl:stylesheet</code> elements are to be
           
           ignored.
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="data-model"></a>3 Data Model
        </h2>
        
        
        
        
        <p>The data model used by XSLT is the same as that used by <a href="http://www.w3.org/TR/xpath#data-model">XPath</a> with the additions
           
           described in this section.  XSLT operates on source, result and
           
           stylesheet documents using the same data model.  Any two XML documents
           
           that have the same tree will be treated the same by XSLT.
        </p>
        
        
        
        
        <p>Processing instructions and comments in the stylesheet are ignored:
           
           the stylesheet is treated as if neither processing instruction nodes
           
           nor comment nodes were included in the tree that represents the
           
           stylesheet.
        </p>
        
        
        
        
        
        
        <h3><a name="root-node-children"></a>3.1 Root Node Children
        </h3>
        
        
        
        
        <p>The normal restrictions on the children of the root node are
           
           relaxed for the result tree.  The result tree may have any sequence of
           
           nodes as children that would be possible for an element node. In
           
           particular, it may have text node children, and any number of element
           
           node children. When written out using the XML output method (see
           
           <a href="#output">[<b>16 Output</b>]
           </a>), it is possible that a result tree will not
           
           be a well-formed XML document; however, it will always be a
           
           well-formed external general parsed entity.
        </p>
        
        
        
        
        <p>When the source tree is created by parsing a well-formed XML
           
           document, the root node of the source tree will automatically satisfy
           
           the normal restrictions of having no text node children and exactly
           
           one element child.  When the source tree is created in some other way,
           
           for example by using the DOM, the usual restrictions are relaxed for
           
           the source tree as for the result tree.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="base-uri"></a>3.2 Base URI
        </h3>
        
        
        
        
        <p>Every node also has an associated URI called its base URI, which is
           
           used for resolving attribute values that represent relative URIs into
           
           absolute URIs.  If an element or processing instruction occurs in an
           
           external entity, the base URI of that element or processing
           
           instruction is the URI of the external entity; otherwise, the base URI
           
           is the base URI of the document.  The base URI of the document node is
           
           the URI of the document entity.  The base URI for a text node, a
           
           comment node, an attribute node or a namespace node is the base URI of
           
           the parent of the node.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="unparsed-entities"></a>3.3 Unparsed Entities
        </h3>
        
        
        
        
        <p>The root node has a mapping that gives the URI for each unparsed
           
           entity declared in the document's DTD.  The URI is generated from the
           
           system identifier and public identifier specified in the entity
           
           declaration. The XSLT processor may use the public identifier to
           
           generate a URI for the entity instead of the URI specified in the
           
           system identifier.  If the XSLT processor does not use the public
           
           identifier to generate the URI, it must use the system identifier; if
           
           the system identifier is a relative URI, it must be resolved into an
           
           absolute URI using the URI of the resource containing the entity
           
           declaration as the base URI <a href="#RFC2396">[RFC2396]</a>.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="strip"></a>3.4 Whitespace Stripping
        </h3>
        
        
        
        
        <p>After the tree for a source document or stylesheet document has
           
           been constructed, but before it is otherwise processed by XSLT,
           
           some text nodes are stripped.  A text node is never stripped
           
           unless it contains only whitespace characters.  Stripping the text
           
           node removes the text node from the tree.  The stripping process takes
           
           as input a set of element names for which whitespace must be
           
           preserved.  The stripping process is applied to both stylesheets and
           
           source documents, but the set of whitespace-preserving element names
           
           is determined differently for stylesheets and for source
           
           documents.
        </p>
        
        
        
        
        <p>A text node is preserved if any of the following apply:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>The element name of the parent of the text node is in the set
                 
                 of whitespace-preserving element names.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The text node contains at least one non-whitespace character.
                 
                 As in XML, a whitespace character is #x20, #x9, #xD or #xA.
              </p>
           </li>
           
           
           
           
           <li>
              <p>An ancestor element of the text node has an
                 
                 <code>xml:space</code> attribute with a value of
                 
                 <code>preserve</code>, and no closer ancestor element has
                 
                 <code>xml:space</code> with a value of
                 
                 <code>default</code>.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>Otherwise, the text node is stripped.</p>
        
        
        
        
        <p>The <code>xml:space</code> attributes are not stripped from the
           
           tree.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>This implies that if an <code>xml:space</code> attribute is
           
           specified on a literal result element, it will be included in the
           
           result.
        </blockquote>
        
        
        
        
        <p>For stylesheets, the set of whitespace-preserving element names
           
           consists of just <code>xsl:text</code>.
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-strip-space"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:strip-space<br>&nbsp;&nbsp;<b>elements</b> = <var>tokens</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-preserve-space"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:preserve-space<br>&nbsp;&nbsp;<b>elements</b> = <var>tokens</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>For source documents, the set of whitespace-preserving element
           
           names is specified by <code>xsl:strip-space</code> and
           
           <code>xsl:preserve-space</code> <a href="#dt-top-level">top-level</a> elements.  These elements each
           
           have an <code>elements</code> attribute whose value is a
           
           whitespace-separated list of <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a>s.  Initially, the
           
           set of whitespace-preserving element names contains all element names.
           
           If an element name matches a <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> in an
           
           <code>xsl:strip-space</code> element, then it is removed from the set
           
           of whitespace-preserving element names.  If an element name matches a
           
           <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> in an
           
           <code>xsl:preserve-space</code> element, then it is added to the set
           
           of whitespace-preserving element names.  An element matches a <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> if and only if the
           
           <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> would be true
           
           for the element as an <a href="http://www.w3.org/TR/xpath#node-tests">XPath node
              
              test
           </a>.  Conflicts between matches to
           
           <code>xsl:strip-space</code> and <code>xsl:preserve-space</code>
           
           elements are resolved the same way as conflicts between template rules
           
           (see <a href="#conflict">[<b>5.5 Conflict Resolution for Template Rules</b>]
           </a>).  Thus, the applicable match for a
           
           particular element name is determined as follows:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>First, any match with lower <a href="#dt-import-precedence">import precedence</a> than another
                 
                 match is ignored.
              </p>
           </li>
           
           
           
           
           <li>
              <p>Next, any match with a <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> that has a lower
                 
                 <a href="#dt-default-priority">default priority</a> than the
                 
                 <a href="#dt-default-priority">default priority</a> of the
                 
                 <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a> of another
                 
                 match is ignored.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>It is an error if this leaves more than one match.  An XSLT
           
           processor may signal the error; if it does not signal the error, it
           
           must recover by choosing, from amongst the matches that are left, the
           
           one that occurs last in the stylesheet.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Expressions"></a>4 Expressions
        </h2>
        
        
        
        
        <p>XSLT uses the expression language defined by XPath <a href="#XPATH">[XPath]</a>.  Expressions are used in XSLT for a variety of purposes
           
           including:
        </p>
        
        
        
        
        <ul>
           
           
           <li>selecting nodes for processing;</li>
           
           
           <li>specifying conditions for different ways of processing a node;</li>
           
           
           <li>generating text to be inserted in the result tree.</li>
           
           
        </ul>
        
        
        
        
        <p><a name="dt-expression"></a>An
           
           <b>expression</b> must match the XPath production <a href="http://www.w3.org/TR/xpath#NT-Expr">Expr</a>.
        </p>
        
        
        
        
        <p>Expressions occur as the value of certain attributes on
           
           XSLT-defined elements and within curly braces in <a href="#dt-attribute-value-template">attribute value
              
              template
           </a>s.
        </p>
        
        
        
        
        <p>In XSLT, an outermost expression (i.e. an expression that is not
           
           part of another expression) gets its context as follows:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>the context node comes from the <a href="#dt-current-node">current node</a></p>
           </li>
           
           
           
           
           <li>
              <p>the context position comes from the position of the <a href="#dt-current-node">current node</a> in the <a href="#dt-current-node-list">current node list</a>; the first
                 
                 position is 1
              </p>
           </li>
           
           
           
           
           <li>
              <p>the context size comes from the size of the <a href="#dt-current-node-list">current node list</a></p>
           </li>
           
           
           
           
           <li>
              <p>the variable bindings are the bindings in scope on the
                 
                 element which has the attribute in which the expression occurs (see
                 
                 <a href="#variables">[<b>11 Variables and Parameters</b>]
                 </a>)
              </p>
           </li>
           
           
           
           
           <li>
              <p>the set of namespace declarations are those in scope on the
                 
                 element which has the attribute in which the expression occurs;
                 
                 this includes the implicit declaration of the prefix <code>xml</code>
                 
                 required by the the XML Namespaces Recommendation <a href="#XMLNAMES">[XML Names]</a>;
                 
                 the default
                 
                 namespace (as declared by <code>xmlns</code>) is not part of this
                 
                 set
              </p>
           </li>
           
           
           
           
           <li>
              <p>the function library consists of the core function library
                 
                 together with the additional functions defined in <a href="#add-func">[<b>12 Additional Functions</b>]
                 </a> and extension functions as described in <a href="#extension">[<b>14 Extensions</b>]
                 </a>; it is an error for an expression to include a call
                 
                 to any other function
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="rules"></a>5 Template Rules
        </h2>
        
        
        
        
        
        
        <h3><a name="section-Processing-Model"></a>5.1 Processing Model
        </h3>
        
        
        
        
        <p>A list of source nodes is processed to create a result tree
           
           fragment.  The result tree is constructed by processing a list
           
           containing just the root node.  A list of source nodes is processed by
           
           appending the result tree structure created by processing each of the
           
           members of the list in order.  A node is processed by finding all the
           
           template rules with patterns that match the node, and choosing the
           
           best amongst them; the chosen rule's template is then instantiated
           
           with the node as the <a href="#dt-current-node">current
              
              node
           </a> and with the list of source nodes as the <a href="#dt-current-node-list">current node list</a>.  A template
           
           typically contains instructions that select an additional list of
           
           source nodes for processing.  The process of matching, instantiation
           
           and selection is continued recursively until no new source nodes are
           
           selected for processing.
        </p>
        
        
        
        
        <p>Implementations are free to process the source document in any way
           
           that produces the same result as if it were processed using this
           
           processing model.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="patterns"></a>5.2 Patterns
        </h3>
        
        
        
        
        <p><a name="dt-pattern"></a>Template rules identify the
           
           nodes to which they apply by using a <b>pattern</b>.  As well as
           
           being used in template rules, patterns are used for numbering (see
           
           <a href="#number">[<b>7.7 Numbering</b>]
           </a>) and for declaring keys (see <a href="#key">[<b>12.2 Keys</b>]
           </a>).  A pattern specifies a set of conditions on a node.  A
           
           node that satisfies the conditions matches the pattern; a node that
           
           does not satisfy the conditions does not match the pattern.  The
           
           syntax for patterns is a subset of the syntax for expressions. In
           
           particular, location paths that meet certain restrictions can be used
           
           as patterns.  An expression that is also a pattern always evaluates to
           
           an object of type node-set.  A node matches a pattern if the node is a
           
           member of the result of evaluating the pattern as an expression with
           
           respect to some possible context; the possible contexts are those
           
           whose context node is the node being matched or one of its
           
           ancestors.
        </p>
        
        
        
        
        <p>Here are some examples of patterns:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>para</code> matches any <code>para</code> element
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>*</code> matches any element
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>chapter|appendix</code> matches any
                 
                 <code>chapter</code> element and any <code>appendix</code>
                 
                 element
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>olist/item</code> matches any <code>item</code> element with
                 
                 an <code>olist</code> parent
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>appendix//para</code> matches any <code>para</code> element with
                 
                 an <code>appendix</code> ancestor element
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>/</code> matches the root node
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>text()</code> matches any text node
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>processing-instruction()</code> matches any processing
                 
                 instruction
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>node()</code> matches any node other than an attribute
                 
                 node and the root node
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>id("W11")</code> matches the element with unique ID
                 
                 <code>W11</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>para[1]</code> matches any <code>para</code> element
                 
                 that is the first <code>para</code> child element of its
                 
                 parent
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>*[position()=1 and self::para]</code> matches any
                 
                 <code>para</code> element that is the first child element of its
                 
                 parent
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>para[last()=1]</code> matches any <code>para</code>
                 
                 element that is the only <code>para</code> child element of its
                 
                 parent
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>items/item[position()>1]</code> matches any
                 
                 <code>item</code> element that has a <code>items</code> parent and
                 
                 that is not the first <code>item</code> child of its parent
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>item[position() mod 2 = 1]</code> would be true for any
                 
                 <code>item</code> element that is an odd-numbered <code>item</code>
                 
                 child of its parent.
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>div[@class="appendix"]//p</code> matches any
                 
                 <code>p</code> element with a <code>div</code> ancestor element that
                 
                 has a <code>class</code> attribute with value
                 
                 <code>appendix</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>@class</code> matches any <code>class</code> attribute
                 
                 (<i>not</i> any element that has a <code>class</code>
                 
                 attribute)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>@*</code> matches any attribute
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>A pattern must match the grammar for <a href="#NT-Pattern">Pattern</a>.  A <a href="#NT-Pattern">Pattern</a> is
           
           a set of location path patterns separated by <code>|</code>.  A
           
           location path pattern is a location path whose steps all use only the
           
           <code>child</code> or <code>attribute</code> axes.  Although patterns
           
           must not use the <code>descendant-or-self</code> axis, patterns may
           
           use the <code>//</code> operator as well as the <code>/</code>
           
           operator.  Location path patterns can also start with an
           
           <b><a href="http://www.w3.org/TR/xpath#function-id">id</a></b> or <b><a href="#function-key">key</a></b> function call
           
           with a literal argument.  Predicates in a pattern can use arbitrary
           
           expressions just like predicates in a location path.
        </p>
        
        
        
        
        <h5>Patterns</h5>
        <table class="scrap">
           <tbody>
              
              
              <tr valign="baseline">
                 <td><a name="NT-Pattern"></a>[1]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>Pattern</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-LocationPathPattern">LocationPathPattern</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-Pattern">Pattern</a> '|' <a href="#NT-LocationPathPattern">LocationPathPattern</a></td>
                 <td></td>
              </tr>
              
              
              <tr valign="baseline">
                 <td><a name="NT-LocationPathPattern"></a>[2]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>LocationPathPattern</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'/' <a href="#NT-RelativePathPattern">RelativePathPattern</a>?
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-IdKeyPattern">IdKeyPattern</a> (('/' | '//') <a href="#NT-RelativePathPattern">RelativePathPattern</a>)?
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| '//'? <a href="#NT-RelativePathPattern">RelativePathPattern</a></td>
                 <td></td>
              </tr>
              
              
              <tr valign="baseline">
                 <td><a name="NT-IdKeyPattern"></a>[3]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>IdKeyPattern</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>'id' '(' <a href="http://www.w3.org/TR/xpath#NT-Literal">Literal</a> ')'
                 </td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| 'key' '(' <a href="http://www.w3.org/TR/xpath#NT-Literal">Literal</a> ',' <a href="http://www.w3.org/TR/xpath#NT-Literal">Literal</a> ')'
                 </td>
                 <td></td>
              </tr>
              
              
              <tr valign="baseline">
                 <td><a name="NT-RelativePathPattern"></a>[4]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>RelativePathPattern</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="#NT-StepPattern">StepPattern</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelativePathPattern">RelativePathPattern</a> '/' <a href="#NT-StepPattern">StepPattern</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| <a href="#NT-RelativePathPattern">RelativePathPattern</a> '//' <a href="#NT-StepPattern">StepPattern</a></td>
                 <td></td>
              </tr>
              
              
              <tr valign="baseline">
                 <td><a name="NT-StepPattern"></a>[5]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>StepPattern</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td>
                    
                    <a href="#NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</a>
                    
                    <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a>
                    
                    <a href="http://www.w3.org/TR/xpath#NT-Predicate">Predicate</a>*
                    
                    
                 </td>
                 <td></td>
              </tr>
              
              
              <tr valign="baseline">
                 <td><a name="NT-ChildOrAttributeAxisSpecifier"></a>[6]&nbsp;&nbsp;&nbsp;
                 </td>
                 <td>ChildOrAttributeAxisSpecifier</td>
                 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
                 <td><a href="http://www.w3.org/TR/xpath#NT-AbbreviatedAxisSpecifier">AbbreviatedAxisSpecifier</a></td>
                 <td></td>
              </tr>
              <tr valign="baseline">
                 <td></td>
                 <td></td>
                 <td></td>
                 <td>| ('child' | 'attribute') '::'</td>
                 <td></td>
              </tr>
              
              
           </tbody>
        </table>
        
        
        
        
        <p>A pattern is defined to match a node if and only if there is
           
           possible context such that when the pattern is evaluated as an
           
           expression with that context, the node is a member of the resulting
           
           node-set.  When a node is being matched, the possible contexts have a
           
           context node that is the node being matched or any ancestor of that
           
           node, and a context node list containing just the context node.
        </p>
        
        
        
        
        <p>For example, <code>p</code> matches any <code>p</code> element,
           
           because for any <code>p</code> if the expression <code>p</code> is
           
           evaluated with the parent of the <code>p</code> element as context the
           
           resulting node-set will contain that <code>p</code> element as one of
           
           its members.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>This matches even a <code>p</code> element that is the
           
           document element, since the document root is the parent of the
           
           document element.
        </blockquote>
        
        
        
        
        <p>Although the semantics of patterns are specified indirectly in
           
           terms of expression evaluation, it is easy to understand the meaning
           
           of a pattern directly without thinking in terms of expression
           
           evaluation.  In a pattern, <code>|</code> indicates alternatives; a
           
           pattern with one or more <code>|</code> separated alternatives matches
           
           if any one of the alternative matches.  A pattern that consists of a
           
           sequence of <a href="#NT-StepPattern">StepPattern</a>s separated by
           
           <code>/</code> or <code>//</code> is matched from right to left.  The
           
           pattern only matches if the rightmost <a href="#NT-StepPattern">StepPattern</a> matches and a suitable element
           
           matches the rest of the pattern; if the separator is <code>/</code>
           
           then only the parent is a suitable element; if the separator is
           
           <code>//</code>, then any ancestor is a suitable element.  A <a href="#NT-StepPattern">StepPattern</a> that uses the child axis matches
           
           if the <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a> is true for the
           
           node and the node is not an attribute node.  A <a href="#NT-StepPattern">StepPattern</a> that uses the attribute axis
           
           matches if the <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a> is true
           
           for the node and the node is an attribute node.  When <code>[]</code>
           
           is present, then the first <a href="http://www.w3.org/TR/xpath#NT-PredicateExpr">PredicateExpr</a> in a <a href="#NT-StepPattern">StepPattern</a> is evaluated with the node being
           
           matched as the context node and the siblings of the context node that
           
           match the <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a> as the
           
           context node list, unless the node being matched is an attribute node,
           
           in which case the context node list is all the attributes that have
           
           the same parent as the attribute being matched and that match the <a href="http://www.w3.org/TR/xpath#NT-NameTest">NameTest</a>.
        </p>
        
        
        
        
        <p>For example</p>
        
        
        
        <pre>appendix//ulist/item[position()=1]</pre>
        
        
        
        <p>matches a node if and only if all of the following are true:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>the <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a> <code>item</code> is
                 
                 true for the node and the node is not an attribute; in other words the
                 
                 node is an <code>item</code> element
              </p>
           </li>
           
           
           
           
           <li>
              <p>evaluating the <a href="http://www.w3.org/TR/xpath#NT-PredicateExpr">PredicateExpr</a>
                 
                 <code>position()=1</code> with the node as context node and the
                 
                 siblings of the node that are <code>item</code> elements as the
                 
                 context node list yields true
              </p>
           </li>
           
           
           
           
           <li>
              <p>the node has a parent that matches
                 
                 <code>appendix//ulist</code>; this will be true if the parent is a
                 
                 <code>ulist</code> element that has an <code>appendix</code> ancestor
                 
                 element.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Defining-Template-Rules"></a>5.3 Defining Template Rules
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-template"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:template<br>&nbsp;&nbsp;match = <var>pattern</var><br>&nbsp;&nbsp;name = <var>qname</var><br>&nbsp;&nbsp;priority = <var>number</var><br>&nbsp;&nbsp;mode = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-param">xsl:param</a>*, <var>template</var>) --><br>&lt;/xsl:template>
           </code>
        </p>
        
        
        
        
        <p>A template rule is specified with the <code>xsl:template</code>
           
           element. The <code>match</code> attribute is a <a href="#NT-Pattern">Pattern</a> that identifies the source node or nodes
           
           to which the rule applies.  The <code>match</code> attribute is
           
           required unless the <code>xsl:template</code> element has a
           
           <code>name</code> attribute (see <a href="#named-templates">[<b>6 Named Templates</b>]
           </a>).
           
           It is an error for the value of the <code>match</code> attribute to
           
           contain a <a href="http://www.w3.org/TR/xpath#NT-VariableReference">VariableReference</a>. The
           
           content of the <code>xsl:template</code> element is the template that
           
           is instantiated when the template rule is applied.
        </p>
        
        
        
        
        <p>For example, an XML document might contain:</p>
        
        
        
        <pre>This is an &lt;emph>important&lt;/emph> point.</pre>
        
        
        
        <p>The following template rule matches <code>emph</code> elements and
           
           produces a <code>fo:inline-sequence</code> formatting object with a
           
           <code>font-weight</code> property of <code>bold</code>.
        </p>
        
        
        
        <pre>&lt;xsl:template match="emph">
  
    &lt;fo:inline-sequence font-weight="bold">
  
      &lt;xsl:apply-templates/>
  
    &lt;/fo:inline-sequence>
  
  &lt;/xsl:template>
  
  </pre>
        
        
        
        <blockquote><b>NOTE: </b>Examples in this document use the <code>fo:</code> prefix for
           
           the namespace <code>http://www.w3.org/1999/XSL/Format</code>, which is
           
           the namespace of the formatting objects defined in <a href="#XSL">[XSL]</a>.
        </blockquote>
        
        
        
        
        <p>As described next, the <code>xsl:apply-templates</code> element
           
           recursively processes the children of the source element.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Applying-Template-Rules"></a>5.4 Applying Template Rules
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-apply-templates"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:apply-templates<br>&nbsp;&nbsp;select = <var>node-set-expression</var><br>&nbsp;&nbsp;mode = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-sort">xsl:sort</a> | <a href="#element-with-param">xsl:with-param</a>)* --><br>&lt;/xsl:apply-templates>
           </code>
        </p>
        
        
        
        
        <p>This example creates a block for a <code>chapter</code> element and
           
           then processes its immediate children.
        </p>
        
        
        
        <pre>&lt;xsl:template match="chapter">
  
    &lt;fo:block>
  
      &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>In the absence of a <code>select</code> attribute, the
           
           <code>xsl:apply-templates</code> instruction processes all of the
           
           children of the current node, including text nodes.  However, text
           
           nodes that have been stripped as specified in <a href="#strip">[<b>3.4 Whitespace Stripping</b>]
           </a>
           
           will not be processed.  If stripping of whitespace nodes has not been
           
           enabled for an element, then all whitespace in the content of the
           
           element will be processed as text, and thus whitespace
           
           between child elements will count in determining the position of a
           
           child element as returned by the <b><a href="http://www.w3.org/TR/xpath#function-position">position</a></b>
           
           function.
        </p>
        
        
        
        
        <p>A <code>select</code> attribute can be used to process nodes
           
           selected by an expression instead of processing all children.  The
           
           value of the <code>select</code> attribute is an <a href="#dt-expression">expression</a>.  The expression must
           
           evaluate to a node-set.  The selected set of nodes is processed in
           
           document order, unless a sorting specification is present (see
           
           <a href="#sorting">[<b>10 Sorting</b>]
           </a>).  The following example processes all of the
           
           <code>author</code> children of the <code>author-group</code>:
        </p>
        
        
        
        <pre>&lt;xsl:template match="author-group">
  
    &lt;fo:inline-sequence>
  
      &lt;xsl:apply-templates select="author"/>
  
    &lt;/fo:inline-sequence>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The following example processes all of the <code>given-name</code>s
           
           of the <code>author</code>s that are children of
           
           <code>author-group</code>:
        </p>
        
        
        
        <pre>&lt;xsl:template match="author-group">
  
    &lt;fo:inline-sequence>
  
      &lt;xsl:apply-templates select="author/given-name"/>
  
    &lt;/fo:inline-sequence>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>This example processes all of the <code>heading</code> descendant
           
           elements of the <code>book</code> element.
        </p>
        
        
        
        <pre>&lt;xsl:template match="book">
  
    &lt;fo:block>
  
      &lt;xsl:apply-templates select=".//heading"/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>It is also possible to process elements that are not descendants of
           
           the current node.  This example assumes that a <code>department</code>
           
           element has <code>group</code> children and <code>employee</code>
           
           descendants. It finds an employee's department and then processes
           
           the <code>group</code> children of the <code>department</code>.
        </p>
        
        
        
        <pre>&lt;xsl:template match="employee">
  
    &lt;fo:block>
  
      Employee &lt;xsl:apply-templates select="name"/> belongs to group
  
      &lt;xsl:apply-templates select="ancestor::department/group"/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>Multiple <code>xsl:apply-templates</code> elements can be used within a
           
           single template to do simple reordering.  The following example
           
           creates two HTML tables. The first table is filled with domestic sales
           
           while the second table is filled with foreign sales.
        </p>
        
        
        
        <pre>&lt;xsl:template match="product">
  
    &lt;table>
  
      &lt;xsl:apply-templates select="sales/domestic"/>
  
    &lt;/table>
  
    &lt;table>
  
      &lt;xsl:apply-templates select="sales/foreign"/>
  
    &lt;/table>
  
  &lt;/xsl:template></pre>
        
        
        
        <blockquote><b>NOTE: </b>
           
           
           
           It is possible for there to be two matching descendants where one
           
           is a descendant of the other.  This case is not treated specially:
           
           both descendants will be processed as usual. For example, given a
           
           source document
           
           
           
           <pre>&lt;doc>&lt;div>&lt;div>&lt;/div>&lt;/div>&lt;/doc></pre>
           
           
           
           the rule
           
           
           
           <pre>&lt;xsl:template match="doc">
  
    &lt;xsl:apply-templates select=".//div"/>
  
  &lt;/xsl:template></pre>
           
           
           
           will process both the outer <code>div</code> and inner <code>div</code>
           
           elements.
           
           
           
           
        </blockquote>
        
        
        
        
        <blockquote><b>NOTE: </b>Typically, <code>xsl:apply-templates</code> is used to
           
           process only nodes that are descendants of the current node.  Such use
           
           of <code>xsl:apply-templates</code> cannot result in non-terminating
           
           processing loops.  However, when <code>xsl:apply-templates</code> is
           
           used to process elements that are not descendants of the current node,
           
           the possibility arises of non-terminating loops. For example,
           
           
           
           <pre style="color: red">&lt;xsl:template match="foo">
  
    &lt;xsl:apply-templates select="."/>
  
  &lt;/xsl:template></pre>
           
           
           
           Implementations may be able to detect such loops in some cases, but
           
           the possibility exists that a stylesheet may enter a non-terminating
           
           loop that an implementation is unable to detect. This may present a
           
           denial of service security risk.</blockquote>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="conflict"></a>5.5 Conflict Resolution for Template Rules
        </h3>
        
        
        
        
        <p>It is possible for a source node to match more than one template
           
           rule. The template rule to be used is determined as follows:
        </p>
        
        
        
        
        <ol>
           
           
           
           
           <li>
              <p>First, all matching template rules that have lower <a href="#dt-import-precedence">import precedence</a> than the
                 
                 matching template rule or rules with the highest import precedence are
                 
                 eliminated from consideration.
              </p>
           </li>
           
           
           
           
           <li>
              <p>Next, all matching template rules that have lower priority
                 
                 than the matching template rule or rules with the highest priority are
                 
                 eliminated from consideration.  The priority of a template rule is
                 
                 specified by the <code>priority</code> attribute on the template rule.
                 
                 The value of this must be a real number (positive or negative),
                 
                 matching the production <a href="http://www.w3.org/TR/xpath#NT-Number">Number</a>
                 
                 with an optional leading minus sign (<code>-</code>).  <a name="dt-default-priority"></a>The <b>default
                    
                    priority
                 </b> is computed as follows:
              </p>
              
              
              
              
              <ul>
                 
                 
                 
                 
                 <li>
                    <p>If the pattern contains multiple alternatives separated by
                       
                       <code>|</code>, then it is treated equivalently to a set of template
                       
                       rules, one for each alternative.
                    </p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p>If the pattern has the form of a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> preceded by a <a href="#NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</a>
                       
                       or has the form
                       
                       <code>processing-instruction(</code><a href="http://www.w3.org/TR/xpath#NT-Literal">Literal</a><code>)</code> preceded by a <a href="#NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</a>,
                       
                       then the priority is 0.
                    </p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p>If the pattern has the form <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a><code>:*</code> preceded by a
                       
                       <a href="#NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</a>,
                       
                       then the priority is -0.25.
                    </p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p>Otherwise, if the pattern consists of just a <a href="http://www.w3.org/TR/xpath#NT-NodeTest">NodeTest</a> preceded by a <a href="#NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</a>,
                       
                       then the priority is -0.5.
                    </p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p>Otherwise, the priority is 0.5.</p>
                 </li>
                 
                 
                 
                 
              </ul>
              
              
              
              
              <p>Thus, the most common kind of pattern (a pattern that tests for a
                 
                 node with a particular type and a particular expanded-name) has
                 
                 priority 0. The next less specific kind of pattern (a pattern that
                 
                 tests for a node with a particular type and an expanded-name with a
                 
                 particular namespace URI) has priority -0.25.  Patterns less specific
                 
                 than this (patterns that just tests for nodes with particular types)
                 
                 have priority -0.5.  Patterns more specific than the most common kind
                 
                 of pattern have priority 0.5.
              </p>
              
              
              
              
           </li>
           
           
           
           
        </ol>
        
        
        
        
        <p>It is an error if this leaves more than one matching template
           
           rule.  An XSLT processor may signal the error; if it does not signal
           
           the error, it must recover by choosing, from amongst the matching
           
           template rules that are left, the one that occurs last in the
           
           stylesheet.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="apply-imports"></a>5.6 Overriding Template Rules
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-apply-imports"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:apply-imports&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>A template rule that is being used to override a template rule in
           
           an imported stylesheet (see <a href="#conflict">[<b>5.5 Conflict Resolution for Template Rules</b>]
           </a>) can use the
           
           <code>xsl:apply-imports</code> element to invoke the overridden
           
           template rule.
        </p>
        
        
        
        
        <p><a name="dt-current-template-rule"></a>At any point in the processing of a stylesheet, there is a
           
           <b>current template rule</b>.  Whenever a template rule is
           
           chosen by matching a pattern, the template rule becomes the current
           
           template rule for the instantiation of the rule's template. When an
           
           <code>xsl:for-each</code> element is instantiated, the current
           
           template rule becomes null for the instantiation of the content of the
           
           <code>xsl:for-each</code> element.
        </p>
        
        
        
        
        <p><code>xsl:apply-imports</code> processes the current node using
           
           only template rules that were imported into the stylesheet element
           
           containing the current template rule; the node is processed in the
           
           current template rule's mode.  It is an error if
           
           <code>xsl:apply-imports</code> is instantiated when the current
           
           template rule is null.
        </p>
        
        
        
        
        <p>For example, suppose the stylesheet <code>doc.xsl</code> contains a
           
           template rule for <code>example</code> elements:
        </p>
        
        
        
        <pre>&lt;xsl:template match="example">
  
    &lt;pre>&lt;xsl:apply-templates/>&lt;/pre>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>Another stylesheet could import <code>doc.xsl</code> and modify the
           
           treatment of <code>example</code> elements as follows:
        </p>
        
        
        
        <pre>&lt;xsl:import href="doc.xsl"/>
  
  
  
  &lt;xsl:template match="example">
  
    &lt;div style="border: solid red">
  
       &lt;xsl:apply-imports/>
  
    &lt;/div>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The combined effect would be to transform an <code>example</code>
           
           into an element of the form:
        </p>
        
        
        
        <pre>&lt;div style="border: solid red">&lt;pre>...&lt;/pre>&lt;/div></pre>
        
        
        
        
        
        
        
        
        
        <h3><a name="modes"></a>5.7 Modes
        </h3>
        
        
        
        
        <p>Modes allow an element to be processed multiple times, each time
           
           producing a different result.
        </p>
        
        
        
        
        <p>Both <code>xsl:template</code> and <code>xsl:apply-templates</code>
           
           have an optional <code>mode</code> attribute.  The value of the
           
           <code>mode</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>. If <code>xsl:template</code> does not have
           
           a <code>match</code> attribute, it must not have a <code>mode</code>
           
           attribute.  If an <code>xsl:apply-templates</code> element has a
           
           <code>mode</code> attribute, then it applies only to those template
           
           rules from <code>xsl:template</code> elements that have a
           
           <code>mode</code> attribute with the same value; if an
           
           <code>xsl:apply-templates</code> element does not have a
           
           <code>mode</code> attribute, then it applies only to those template
           
           rules from <code>xsl:template</code> elements that do not have a
           
           <code>mode</code> attribute.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="built-in-rule"></a>5.8 Built-in Template Rules
        </h3>
        
        
        
        
        <p>There is a built-in template rule to allow recursive processing to
           
           continue in the absence of a successful pattern match by an explicit
           
           template rule in the stylesheet.  This template rule applies to both
           
           element nodes and the root node.  The following shows the equivalent
           
           of the built-in template rule:
        </p>
        
        
        
        <pre>&lt;xsl:template match="*|/">
  
    &lt;xsl:apply-templates/>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>There is also a built-in template rule for each mode, which allows
           
           recursive processing to continue in the same mode in the absence of a
           
           successful pattern match by an explicit template rule in the
           
           stylesheet.  This template rule applies to both element nodes and the
           
           root node.  The following shows the equivalent of the built-in
           
           template rule for mode <code><var>m</var></code>.
        </p>
        
        
        
        <pre>&lt;xsl:template match="*|/" mode="<var>m</var>">
           
           &lt;xsl:apply-templates mode="<var>m</var>"/>
           
           &lt;/xsl:template>
        </pre>
        
        
        
        
        <p>There is also a built-in template rule for text and attribute nodes
           
           that copies text through:
        </p>
        
        
        
        <pre>&lt;xsl:template match="text()|@*">
  
    &lt;xsl:value-of select="."/>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The built-in template rule for processing instructions and comments
           
           is to do nothing.
        </p>
        
        
        
        <pre>&lt;xsl:template match="processing-instruction()|comment()"/></pre>
        
        
        
        <p>The built-in template rule for namespace nodes is also to do
           
           nothing. There is no pattern that can match a namespace node; so, the
           
           built-in template rule is the only template rule that is applied for
           
           namespace nodes.
        </p>
        
        
        
        
        <p>The built-in template rules are treated as if they were imported
           
           implicitly before the stylesheet and so have lower <a href="#dt-import-precedence">import precedence</a> than all other
           
           template rules.  Thus, the author can override a built-in template
           
           rule by including an explicit template rule.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="named-templates"></a>6 Named Templates
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-call-template"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:call-template<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: <a href="#element-with-param">xsl:with-param</a>* --><br>&lt;/xsl:call-template>
           </code>
        </p>
        
        
        
        
        <p>Templates can be invoked by name.  An <code>xsl:template</code>
           
           element with a <code>name</code> attribute specifies a named template.
           
           The value of the <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>. If an <code>xsl:template</code> element has
           
           a <code>name</code> attribute, it may, but need not, also have a
           
           <code>match</code> attribute.  An <code>xsl:call-template</code>
           
           element invokes a template by name; it has a required
           
           <code>name</code> attribute that identifies the template to be
           
           invoked.  Unlike <code>xsl:apply-templates</code>,
           
           <code>xsl:call-template</code> does not change the current node or the
           
           current node list.
        </p>
        
        
        
        
        <p>The <code>match</code>, <code>mode</code> and <code>priority</code> attributes on an
           
           <code>xsl:template</code> element do not affect whether the template
           
           is invoked by an <code>xsl:call-template</code> element.  Similarly,
           
           the <code>name</code> attribute on an <code>xsl:template</code>
           
           element does not affect whether the template is invoked by an
           
           <code>xsl:apply-templates</code> element.
        </p>
        
        
        
        
        <p>It is an error if a stylesheet contains more than one template with
           
           the same name and same <a href="#dt-import-precedence">import
              
              precedence
           </a>.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Creating-the-Result-Tree"></a>7 Creating the Result Tree
        </h2>
        
        
        
        
        <p>This section describes instructions that directly create nodes in
           
           the result tree.
        </p>
        
        
        
        
        
        
        <h3><a name="section-Creating-Elements-and-Attributes"></a>7.1 Creating Elements and Attributes
        </h3>
        
        
        
        
        
        
        <h4><a name="literal-result-element"></a>7.1.1 Literal Result Elements
        </h4>
        
        
        
        
        <p>In a template, an element in the stylesheet that does not belong to
           
           the XSLT namespace and that is not an extension element (see <a href="#extension-element">[<b>14.1 Extension Elements</b>]
           </a>) is instantiated to create an element node
           
           with the same <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a>.  The content
           
           of the element is a template, which is instantiated to give the
           
           content of the created element node. The created element node will
           
           have the attribute nodes that were present on the element node in the
           
           stylesheet tree, other than attributes with names in the XSLT
           
           namespace.
        </p>
        
        
        
        
        <p>The created element node will also have a copy of the namespace
           
           nodes that were present on the element node in the stylesheet tree
           
           with the exception of any namespace node whose string-value is the
           
           XSLT namespace URI (<code>http://www.w3.org/1999/XSL/Transform</code>), a
           
           namespace URI declared as an extension namespace (see <a href="#extension-element">[<b>14.1 Extension Elements</b>]
           </a>), or a namespace URI designated as an
           
           excluded namespace.  A namespace URI is designated as an excluded
           
           namespace by using an <code>exclude-result-prefixes</code> attribute
           
           on an <code>xsl:stylesheet</code> element or an
           
           <code>xsl:exclude-result-prefixes</code> attribute on a literal result
           
           element.  The value of both these attributes is a whitespace-separated
           
           list of namespace prefixes. The namespace bound to each of the
           
           prefixes is designated as an excluded namespace.  It is an error if
           
           there is no namespace bound to the prefix on the element bearing the
           
           <code>exclude-result-prefixes</code> or
           
           <code>xsl:exclude-result-prefixes</code> attribute.  The default
           
           namespace (as declared by <code>xmlns</code>) may be designated as an
           
           excluded namespace by including <code>#default</code> in the list of
           
           namespace prefixes.  The designation of a namespace as an excluded
           
           namespace is effective within the subtree of the stylesheet rooted at
           
           the element bearing the <code>exclude-result-prefixes</code> or
           
           <code>xsl:exclude-result-prefixes</code> attribute;
           
           a subtree rooted at an <code>xsl:stylesheet</code> element
           
           does not include any stylesheets imported or included by children
           
           of that <code>xsl:stylesheet</code> element.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>When a stylesheet uses a namespace declaration only for the
           
           purposes of addressing the source tree, specifying the prefix in the
           
           <code>exclude-result-prefixes</code> attribute will avoid superfluous
           
           namespace declarations in the result tree.
        </blockquote>
        
        
        
        
        <p>The value of an attribute of a literal result element is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>: it can contain expressions contained
           
           in curly braces (<code>{}</code>).
        </p>
        
        
        
        
        <p><a name="dt-literal-namespace-uri"></a>A namespace URI in the stylesheet tree that is being used to
           
           specify a namespace URI in the result tree is called a <b>literal
              
              namespace URI
           </b>. This applies to:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>the namespace URI in the expanded-name of a literal
                 
                 result element in the stylesheet
              </p>
           </li>
           
           
           
           
           <li>
              <p>the namespace URI in the expanded-name of an attribute
                 
                 specified on a literal result element in the stylesheet
              </p>
           </li>
           
           
           
           
           <li>
              <p>the string-value of a namespace node on a literal result
                 
                 element in the stylesheet
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p class="element-syntax"><a name="element-namespace-alias"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:namespace-alias<br>&nbsp;&nbsp;<b>stylesheet-prefix</b> = <var>prefix</var> | "#default"<br>&nbsp;&nbsp;<b>result-prefix</b> = <var>prefix</var> | "#default"&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p><a name="dt-alias"></a>A stylesheet can use the
           
           <code>xsl:namespace-alias</code> element to declare that one namespace
           
           URI is an <b>alias</b> for another namespace URI. When
           
           a <a href="#dt-literal-namespace-uri">literal namespace
              
              URI
           </a> has been declared to be an alias for another namespace
           
           URI, then the namespace URI in the result tree will be the namespace
           
           URI that the literal namespace URI is an alias for, instead of the
           
           literal namespace URI itself.  The <code>xsl:namespace-alias</code>
           
           element declares that the namespace URI bound to the prefix specified
           
           by the <code>stylesheet-prefix</code> attribute is an alias for the
           
           namespace URI bound to the prefix specified by the
           
           <code>result-prefix</code> attribute.  Thus, the
           
           <code>stylesheet-prefix</code> attribute specifies the namespace URI
           
           that will appear in the stylesheet, and the
           
           <code>result-prefix</code> attribute specifies the corresponding
           
           namespace URI that will appear in the result tree.  The default
           
           namespace (as declared by <code>xmlns</code>) may be specified by
           
           using <code>#default</code> instead of a prefix.  If a namespace URI
           
           is declared to be an alias for multiple different namespace URIs, then
           
           the declaration with the highest <a href="#dt-import-precedence">import precedence</a> is used. It is
           
           an error if there is more than one such declaration.  An XSLT
           
           processor may signal the error; if it does not signal the error, it
           
           must recover by choosing, from amongst the declarations with the
           
           highest import precedence, the one that occurs last in the
           
           stylesheet.
        </p>
        
        
        
        
        <p>When literal result elements are being used to create element,
           
           attribute, or namespace nodes that use the XSLT namespace URI, the
           
           stylesheet must use an alias.  For example, the stylesheet
        </p>
        
        
        
        <pre>&lt;xsl:stylesheet
  
    version="1.0"
  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
  
    xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
  
  
  
  &lt;xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
  
  
  
  &lt;xsl:template match="/">
  
    &lt;axsl:stylesheet>
  
      &lt;xsl:apply-templates/>
  
    &lt;/axsl:stylesheet>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="block">
  
    &lt;axsl:template match="{.}">
  
       &lt;fo:block>&lt;axsl:apply-templates/>&lt;/fo:block>
  
    &lt;/axsl:template>
  
  &lt;/xsl:template>
  
  
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>will generate an XSLT stylesheet from a document of the form:</p>
        
        
        
        <pre>&lt;elements>
  
  &lt;block>p&lt;/block>
  
  &lt;block>h1&lt;/block>
  
  &lt;block>h2&lt;/block>
  
  &lt;block>h3&lt;/block>
  
  &lt;block>h4&lt;/block>
  
  &lt;/elements></pre>
        
        
        
        <blockquote><b>NOTE: </b>It may be necessary also to use aliases for namespaces other
           
           than the XSLT namespace URI.  For example, literal result elements
           
           belonging to a namespace dealing with digital signatures might cause
           
           XSLT stylesheets to be mishandled by general-purpose security
           
           software; using an alias for the namespace would avoid the possibility
           
           of such mishandling.
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        <h4><a name="section-Creating-Elements-with-xsl:element"></a>7.1.2 Creating Elements with <code>xsl:element</code></h4>
        
        
        
        
        <p class="element-syntax"><a name="element-element"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:element<br>&nbsp;&nbsp;<b>name</b> = { <var>qname</var> }<br>&nbsp;&nbsp;namespace = { <var>uri-reference</var> }<br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:element>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:element</code> element allows an element to be
           
           created with a computed name.  The <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> of the
           
           element to be created is specified by a required <code>name</code>
           
           attribute and an optional <code>namespace</code> attribute.  The
           
           content of the <code>xsl:element</code> element is a template for the
           
           attributes and children of the created element.
        </p>
        
        
        
        
        <p>The <code>name</code> attribute is interpreted as an <a href="#dt-attribute-value-template">attribute value template</a>.
           
           It is an error if the string that results from instantiating the
           
           attribute value template is not a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  An XSLT processor may signal
           
           the error; if it does not signal the error, then it must recover
           
           by making the the result of instantiating the <code>xsl:element</code>
           
           element be the sequence of nodes created by instantiating
           
           the content of the  <code>xsl:element</code> element, excluding
           
           any initial attribute nodes. If the <code>namespace</code> attribute is
           
           not present then the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is
           
           expanded into an expanded-name using the namespace declarations in
           
           effect for the <code>xsl:element</code> element, including any default
           
           namespace declaration.
        </p>
        
        
        
        
        <p>If the <code>namespace</code> attribute is present, then it also is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>. The string that results from instantiating
           
           the attribute value template should be a URI reference.  It is not an
           
           error if the string is not a syntactically legal URI reference.  If
           
           the string is empty, then the expanded-name of the element has a null
           
           namespace URI.  Otherwise, the string is used as the namespace URI of
           
           the expanded-name of the element to be created. The local part of the
           
           <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> specified by the
           
           <code>name</code> attribute is used as the local part of the
           
           expanded-name of the element to be created.
        </p>
        
        
        
        
        <p>XSLT processors may make use of the prefix of the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> specified in the
           
           <code>name</code> attribute when selecting the prefix used for
           
           outputting the created element as XML; however, they are not required
           
           to do so.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h4><a name="creating-attributes"></a>7.1.3 Creating Attributes with <code>xsl:attribute</code></h4>
        
        
        
        
        <p class="element-syntax"><a name="element-attribute"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:attribute<br>&nbsp;&nbsp;<b>name</b> = { <var>qname</var> }<br>&nbsp;&nbsp;namespace = { <var>uri-reference</var> }><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:attribute>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:attribute</code> element can be used to add
           
           attributes to result elements whether created by literal result
           
           elements in the stylesheet or by instructions such as
           
           <code>xsl:element</code>. The <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> of the
           
           attribute to be created is specified by a required <code>name</code>
           
           attribute and an optional <code>namespace</code> attribute.
           
           Instantiating an <code>xsl:attribute</code> element adds an attribute
           
           node to the containing result element node. The content of the
           
           <code>xsl:attribute</code> element is a template for the value of the
           
           created attribute.
        </p>
        
        
        
        
        <p>The <code>name</code> attribute is interpreted as an <a href="#dt-attribute-value-template">attribute value template</a>.
           
           It is an error if the string that results from instantiating the
           
           attribute value template is not a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> or is the string
           
           <code>xmlns</code>.  An XSLT processor may signal the error; if it
           
           does not signal the error, it must recover by not adding the attribute
           
           to the result tree. If the <code>namespace</code> attribute is not
           
           present, then the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is
           
           expanded into an expanded-name using the namespace declarations in
           
           effect for the <code>xsl:attribute</code> element, <i>not</i>
           
           including any default namespace declaration.
        </p>
        
        
        
        
        <p>If the <code>namespace</code> attribute is present, then it also is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>. The string that results from instantiating
           
           it should be a URI reference.  It is not an error if the string is not
           
           a syntactically legal URI reference.  If the string is empty, then the
           
           expanded-name of the attribute has a null namespace URI.  Otherwise,
           
           the string is used as the namespace URI of the expanded-name of the
           
           attribute to be created. The local part of the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> specified by the
           
           <code>name</code> attribute is used as the local part of the
           
           expanded-name of the attribute to be created.
        </p>
        
        
        
        
        <p>XSLT processors may make use of the prefix of the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> specified in the
           
           <code>name</code> attribute when selecting the prefix used for
           
           outputting the created attribute as XML; however, they are not
           
           required to do so and, if the prefix is <code>xmlns</code>, they must
           
           not do so. Thus, although it is not an error to do:
        </p>
        
        
        
        <pre>&lt;xsl:attribute name="xmlns:xsl" namespace="whatever">http://www.w3.org/1999/XSL/Transform&lt;/xsl:attribute></pre>
        
        
        
        <p>it will not result in a namespace declaration being output.</p>
        
        
        
        
        <p>Adding an attribute to an element replaces any existing attribute
           
           of that element with the same expanded-name.
        </p>
        
        
        
        
        <p>The following are all errors:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>Adding an attribute to an element after children have been
                 
                 added to it; implementations may either signal the error or ignore the
                 
                 attribute.
              </p>
           </li>
           
           
           
           
           <li>
              <p>Adding an attribute to a node that is not an element;
                 
                 implementations may either signal the error or ignore the
                 
                 attribute.
              </p>
           </li>
           
           
           
           
           <li>
              <p>Creating nodes other than text nodes during the
                 
                 instantiation of the content of the <code>xsl:attribute</code>
                 
                 element; implementations may either signal the error or ignore the
                 
                 offending nodes.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <blockquote><b>NOTE: </b>When an <code>xsl:attribute</code> contains a text node with
           
           a newline, then the XML output must contain a character reference.
           
           For example,
           
           
           
           <pre>&lt;xsl:attribute name="a">x
  
  y&lt;/xsl:attribute></pre>
           
           
           
           will result in the output
           
           
           
           <pre>a="x&amp;#xA;y"</pre>
           
           
           
           (or with any equivalent character reference). The XML output cannot
           
           be
           
           
           
           <pre>a="x
  
  y"</pre>
           
           
           
           This is because XML 1.0 requires newline characters in attribute
           
           values to be normalized into spaces but requires character references
           
           to newline characters not to be normalized.  The attribute values in
           
           the data model represent the attribute value after normalization.  If
           
           a newline occurring in an attribute value in the tree were output as a
           
           newline character rather than as character reference, then the
           
           attribute value in the tree created by reparsing the XML would contain
           
           a space not a newline, which would mean that the tree had not been
           
           output correctly.</blockquote>
        
        
        
        
        
        
        
        
        
        
        
        
        <h4><a name="attribute-sets"></a>7.1.4 Named Attribute Sets
        </h4>
        
        
        
        
        <p class="element-syntax"><a name="element-attribute-set"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:attribute-set<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <a href="#element-attribute">xsl:attribute</a>* --><br>&lt;/xsl:attribute-set>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:attribute-set</code> element defines a named set of
           
           attributes.  The <code>name</code> attribute specifies the name of the
           
           attribute set.  The value of the <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>. The content of the <code>xsl:attribute-set</code>
           
           element consists of zero or more <code>xsl:attribute</code> elements
           
           that specify the attributes in the set.
        </p>
        
        
        
        
        <p>Attribute sets are used by specifying a
           
           <code>use-attribute-sets</code> attribute on <code>xsl:element</code>,
           
           <code>xsl:copy</code> (see <a href="#copying">[<b>7.5 Copying</b>]
           </a>) or
           
           <code>xsl:attribute-set</code> elements.  The value of the
           
           <code>use-attribute-sets</code> attribute is a whitespace-separated
           
           list of names of attribute sets.  Each name is specified as a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>.  Specifying a
           
           <code>use-attribute-sets</code> attribute is equivalent to adding
           
           <code>xsl:attribute</code> elements for each of the attributes in each
           
           of the named attribute sets to the beginning of the content of the
           
           element with the <code>use-attribute-sets</code> attribute, in the
           
           same order in which the names of the attribute sets are specified in
           
           the <code>use-attribute-sets</code> attribute.  It is an error if use
           
           of <code>use-attribute-sets</code> attributes on
           
           <code>xsl:attribute-set</code> elements causes an attribute set to
           
           directly or indirectly use itself.
        </p>
        
        
        
        
        <p>Attribute sets can also be used by specifying an
           
           <code>xsl:use-attribute-sets</code> attribute on a literal result
           
           element.  The value of the <code>xsl:use-attribute-sets</code>
           
           attribute is a whitespace-separated list of names of attribute sets.
           
           The <code>xsl:use-attribute-sets</code> attribute has the same effect
           
           as the <code>use-attribute-sets</code> attribute on
           
           <code>xsl:element</code> with the additional rule that attributes
           
           specified on the literal result element itself are treated as if they
           
           were specified by <code>xsl:attribute</code> elements before any
           
           actual <code>xsl:attribute</code> elements but after any
           
           <code>xsl:attribute</code> elements implied by the
           
           <code>xsl:use-attribute-sets</code> attribute.  Thus, for a literal
           
           result element, attributes from attribute sets named in an
           
           <code>xsl:use-attribute-sets</code> attribute will be added first, in
           
           the order listed in the attribute; next, attributes specified on the
           
           literal result element will be added; finally, any attributes
           
           specified by <code>xsl:attribute</code> elements will be added.  Since
           
           adding an attribute to an element replaces any existing attribute of
           
           that element with the same name, this means that attributes specified
           
           in attribute sets can be overridden by attributes specified on the
           
           literal result element itself.
        </p>
        
        
        
        
        <p>The template within each <code>xsl:attribute</code> element in an
           
           <code>xsl:attribute-set</code> element is instantiated each time the
           
           attribute set is used; it is instantiated using the same current node
           
           and current node list as is used for instantiating the element bearing
           
           the <code>use-attribute-sets</code> or
           
           <code>xsl:use-attribute-sets</code> attribute. However, it is the
           
           position in the stylesheet of the <code>xsl:attribute</code> element
           
           rather than of the element bearing the <code>use-attribute-sets</code>
           
           or <code>xsl:use-attribute-sets</code> attribute that determines which
           
           variable bindings are visible (see <a href="#variables">[<b>11 Variables and Parameters</b>]
           </a>); thus,
           
           only variables and parameters declared by <a href="#dt-top-level">top-level</a> <code>xsl:variable</code> and
           
           <code>xsl:param</code> elements are visible.
        </p>
        
        
        
        
        <p>The following example creates a named attribute set
           
           <code>title-style</code> and uses it in a template rule.
        </p>
        
        
        
        <pre>&lt;xsl:template match="chapter/heading">
  
    &lt;fo:block quadding="start" xsl:use-attribute-sets="title-style">
  
      &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:attribute-set name="title-style">
  
    &lt;xsl:attribute name="font-size">12pt&lt;/xsl:attribute>
  
    &lt;xsl:attribute name="font-weight">bold&lt;/xsl:attribute>
  
  &lt;/xsl:attribute-set></pre>
        
        
        
        <p>Multiple definitions of an attribute set with the same
           
           expanded-name are merged.  An attribute from a definition that has
           
           higher <a href="#dt-import-precedence">import precedence</a>
           
           takes precedence over an attribute from a definition that has lower
           
           <a href="#dt-import-precedence">import precedence</a>.  It
           
           is an error if there are two attribute sets that have the same
           
           expanded-name and equal import precedence and that both contain
           
           the same attribute, unless there is a definition of the attribute set
           
           with higher <a href="#dt-import-precedence">import
              
              precedence
           </a> that also contains the attribute.  An XSLT
           
           processor may signal the error; if it does not signal the error, it
           
           must recover by choosing from amongst the definitions that specify the
           
           attribute that have the highest import precedence the one that was
           
           specified last in the stylesheet.  Where the attributes in an
           
           attribute set were specified is relevant only in merging the
           
           attributes into the attribute set; it makes no difference when the
           
           attribute set is used.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Creating-Text"></a>7.2 Creating Text
        </h3>
        
        
        
        
        <p>A template can also contain text nodes.  Each text node in a
           
           template remaining after whitespace has been stripped as specified in
           
           <a href="#strip">[<b>3.4 Whitespace Stripping</b>]
           </a> will create a text node with the same
           
           string-value in the result tree.  Adjacent text nodes in the result
           
           tree are automatically merged.
        </p>
        
        
        
        
        <p>Note that text is processed at the tree level. Thus, markup of
           
           <code>&amp;lt;</code> in a template will be represented in the
           
           stylesheet tree by a text node that includes the character
           
           <code>&lt;</code>. This will create a text node in the result tree
           
           that contains a <code>&lt;</code> character, which will be represented
           
           by the markup <code>&amp;lt;</code> (or an equivalent character
           
           reference) when the result tree is externalized as an XML document
           
           (unless output escaping is disabled as described in <a href="#disable-output-escaping">[<b>16.4 Disabling Output Escaping</b>]
           </a>).
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-text"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:text<br>&nbsp;&nbsp;disable-output-escaping = "yes" | "no"><br>&nbsp;&nbsp;&lt;!-- Content: #PCDATA --><br>&lt;/xsl:text>
           </code>
        </p>
        
        
        
        
        <p>Literal data characters may also be wrapped in an
           
           <code>xsl:text</code> element.  This wrapping may change what
           
           whitespace characters are stripped (see <a href="#strip">[<b>3.4 Whitespace Stripping</b>]
           </a>) but
           
           does not affect how the characters are handled by the XSLT processor
           
           thereafter.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>The <code>xml:lang</code> and <code>xml:space</code>
           
           attributes are not treated specially by XSLT. In particular,
           
           
           
           
           <ul>
              
              
              <li>
                 <p>it is the responsibility of the stylesheet author explicitly
                    
                    to generate any <code>xml:lang</code> or <code>xml:space</code>
                    
                    attributes that are needed in the result;
                 </p>
              </li>
              
              
              
              
              <li>
                 <p>specifying an <code>xml:lang</code> or <code>xml:space</code>
                    
                    attribute on an element in the XSLT namespace will not cause any
                    
                    <code>xml:lang</code> or <code>xml:space</code> attributes to appear
                    
                    in the result.
                 </p>
              </li>
              
              
           </ul>
           
           
        </blockquote>
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Creating-Processing-Instructions"></a>7.3 Creating Processing Instructions
        </h3>
        
        
        
        
        
        
        <p class="element-syntax"><a name="element-processing-instruction"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:processing-instruction<br>&nbsp;&nbsp;<b>name</b> = { <var>ncname</var> }><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:processing-instruction>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:processing-instruction</code> element is instantiated
           
           to create a processing instruction node.  The content of the
           
           <code>xsl:processing-instruction</code> element is a template for the
           
           string-value of the processing instruction node.  The
           
           <code>xsl:processing-instruction</code> element has a required
           
           <code>name</code> attribute that specifies the name of the processing
           
           instruction node.  The value of the <code>name</code> attribute is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>.
        </p>
        
        
        
        
        <p>For example, this</p>
        
        
        
        <pre>&lt;xsl:processing-instruction name="xml-stylesheet">href="book.css" type="text/css"&lt;/xsl:processing-instruction></pre>
        
        
        
        <p>would create the processing instruction</p>
        
        
        
        <pre>&lt;?xml-stylesheet href="book.css" type="text/css"?></pre>
        
        
        
        <p>It is an error if the string that results from instantiating the
           
           <code>name</code> attribute is not both an <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> and a <a href="http://www.w3.org/TR/REC-xml#NT-PITarget">PITarget</a>.  An XSLT processor may signal
           
           the error; if it does not signal the error, it must recover by not
           
           adding the processing instruction to the result tree.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>This means that <code>xsl:processing-instruction</code>
           
           cannot be used to output an XML declaration.  The
           
           <code>xsl:output</code> element should be used instead (see <a href="#output">[<b>16 Output</b>]
           </a>).
        </blockquote>
        
        
        
        
        <p>It is an error if instantiating the content of
           
           <code>xsl:processing-instruction</code> creates nodes other than
           
           text nodes.  An XSLT processor may signal the error; if it does not
           
           signal the error, it must recover by ignoring the offending nodes
           
           together with their content.
        </p>
        
        
        
        
        <p>It is an error if the result of instantiating the content of the
           
           <code>xsl:processing-instruction</code> contains the string
           
           <code>?></code>.  An XSLT processor may signal the error; if it does
           
           not signal the error, it must recover by inserting a space after any
           
           occurrence of <code>?</code> that is followed by a <code>></code>.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Creating-Comments"></a>7.4 Creating Comments
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-comment"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:comment><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:comment>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:comment</code> element is instantiated to create a
           
           comment node in the result tree.  The content of the
           
           <code>xsl:comment</code> element is a template for the string-value of
           
           the comment node.
        </p>
        
        
        
        
        <p>For example, this</p>
        
        
        
        <pre>&lt;xsl:comment>This file is automatically generated. Do not edit!&lt;/xsl:comment></pre>
        
        
        
        <p>would create the comment</p>
        
        
        
        <pre>&lt;!--This file is automatically generated. Do not edit!--></pre>
        
        
        
        <p>It is an error if instantiating the content of
           
           <code>xsl:comment</code> creates nodes other than text nodes.  An
           
           XSLT processor may signal the error; if it does not signal the error,
           
           it must recover by ignoring the offending nodes together with their
           
           content.
        </p>
        
        
        
        
        <p>It is an error if the result of instantiating the content of the
           
           <code>xsl:comment</code> contains the string <code>--</code> or ends
           
           with <code>-</code>.  An XSLT processor may signal the error; if it
           
           does not signal the error, it must recover by inserting a space after
           
           any occurrence of <code>-</code> that is followed by another
           
           <code>-</code> or that ends the comment.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="copying"></a>7.5 Copying
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-copy"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:copy<br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:copy>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:copy</code> element provides an easy way of copying
           
           the current node. Instantiating the <code>xsl:copy</code> element
           
           creates a copy of the current node.  The namespace nodes of the
           
           current node are automatically copied as well, but the attributes and
           
           children of the node are not automatically copied.  The content of the
           
           <code>xsl:copy</code> element is a template for the attributes and
           
           children of the created node; the content is instantiated only for
           
           nodes of types that can have attributes or children (i.e. root
           
           nodes and element nodes).
        </p>
        
        
        
        
        <p>The <code>xsl:copy</code> element may have a
           
           <code>use-attribute-sets</code> attribute (see <a href="#attribute-sets">[<b>7.1.4 Named Attribute Sets</b>]
           </a>). This is used only when copying element
           
           nodes.
        </p>
        
        
        
        
        <p>The root node is treated specially because the root node of the
           
           result tree is created implicitly.  When the current node is the root
           
           node, <code>xsl:copy</code> will not create a root node, but will just
           
           use the content template.
        </p>
        
        
        
        
        <p>For example, the identity transformation can be written using
           
           <code>xsl:copy</code> as follows:
        </p>
        
        
        
        <pre>&lt;xsl:template match="@*|node()">
  
    &lt;xsl:copy>
  
      &lt;xsl:apply-templates select="@*|node()"/>
  
    &lt;/xsl:copy>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>When the current node is an attribute, then if it would be an error
           
           to use <code>xsl:attribute</code> to create an attribute with the same
           
           name as the current node, then it is also an error to use
           
           <code>xsl:copy</code> (see <a href="#creating-attributes">[<b>7.1.3 Creating Attributes with <code>xsl:attribute</code></b>]
           </a>).
        </p>
        
        
        
        
        <p>The following example shows how <code>xml:lang</code> attributes
           
           can be easily copied through from source to result. If a stylesheet
           
           defines the following named template:
        </p>
        
        
        
        <pre>&lt;xsl:template name="apply-templates-copy-lang">
  
   &lt;xsl:for-each select="@xml:lang">
  
     &lt;xsl:copy/>
  
   &lt;/xsl:for-each>
  
   &lt;xsl:apply-templates/>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>then it can simply do</p>
        
        
        
        <pre>&lt;xsl:call-template name="apply-templates-copy-lang"/></pre>
        
        
        
        <p>instead of</p>
        
        
        
        <pre>&lt;xsl:apply-templates/></pre>
        
        
        
        <p>when it wants to copy the <code>xml:lang</code> attribute.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Computing-Generated-Text"></a>7.6 Computing Generated Text
        </h3>
        
        
        
        
        <p>Within a template, the <code>xsl:value-of</code> element can be
           
           used to compute generated text, for example by extracting text from
           
           the source tree or by inserting the value of a variable.  The
           
           <code>xsl:value-of</code> element does this with an <a href="#dt-expression">expression</a> that is specified as the
           
           value of the <code>select</code> attribute.  Expressions can
           
           also be used inside attribute values of literal result elements by
           
           enclosing the expression in curly braces (<code>{}</code>).
        </p>
        
        
        
        
        
        
        <h4><a name="value-of"></a>7.6.1 Generating Text with <code>xsl:value-of</code></h4>
        
        
        
        
        <p class="element-syntax"><a name="element-value-of"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:value-of<br>&nbsp;&nbsp;<b>select</b> = <var>string-expression</var><br>&nbsp;&nbsp;disable-output-escaping = "yes" | "no"&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:value-of</code> element is instantiated to create a
           
           text node in the result tree.  The required <code>select</code>
           
           attribute is an <a href="#dt-expression">expression</a>;
           
           this expression is evaluated and the resulting object is converted to
           
           a string as if by a call to the <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b>
           
           function. The string specifies the string-value of the created text
           
           node.  If the string is empty, no text node will be created.  The
           
           created text node will be merged with any adjacent text nodes.
        </p>
        
        
        
        
        <p>The <code>xsl:copy-of</code> element can be used to copy a node-set
           
           over to the result tree without converting it to a string. See <a href="#copy-of">[<b>11.3 Using Values of Variables and Parameters with
                 
                 <code>xsl:copy-of</code></b>]
           </a>.
        </p>
        
        
        
        
        <p>For example, the following creates an HTML paragraph from a
           
           <code>person</code> element with <code>given-name</code> and
           
           <code>family-name</code> attributes.  The paragraph will contain the value
           
           of the <code>given-name</code> attribute of the current node followed
           
           by a space and the value of the <code>family-name</code> attribute of the
           
           current node.
        </p>
        
        
        
        <pre>&lt;xsl:template match="person">
  
    &lt;p>
  
     &lt;xsl:value-of select="@given-name"/>
  
     &lt;xsl:text> &lt;/xsl:text>
  
     &lt;xsl:value-of select="@family-name"/>
  
    &lt;/p>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>For another example, the following creates an HTML paragraph from a
           
           <code>person</code> element with <code>given-name</code> and
           
           <code>family-name</code> children elements.  The paragraph will
           
           contain the string-value of the first <code>given-name</code> child
           
           element of the current node followed by a space and the string-value
           
           of the first <code>family-name</code> child element of the current
           
           node.
        </p>
        
        
        
        <pre>&lt;xsl:template match="person">
  
    &lt;p>
  
     &lt;xsl:value-of select="given-name"/>
  
     &lt;xsl:text> &lt;/xsl:text>
  
     &lt;xsl:value-of select="family-name"/>
  
    &lt;/p>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The following precedes each <code>procedure</code> element with a
           
           paragraph containing the security level of the procedure.  It assumes
           
           that the security level that applies to a procedure is determined by a
           
           <code>security</code> attribute on the procedure element or on an
           
           ancestor element of the procedure. It also assumes that if more than
           
           one such element has a <code>security</code> attribute then the
           
           security level is determined by the element that is closest to the
           
           procedure.
        </p>
        
        
        
        <pre>&lt;xsl:template match="procedure">
  
    &lt;fo:block>
  
      &lt;xsl:value-of select="ancestor-or-self::*[@security][1]/@security"/>
  
    &lt;/fo:block>
  
    &lt;xsl:apply-templates/>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        <h4><a name="attribute-value-templates"></a>7.6.2 Attribute Value Templates
        </h4>
        
        
        
        
        <p><a name="dt-attribute-value-template"></a>In an attribute value that is interpreted as an
           
           <b>attribute value template</b>, such as an attribute of a
           
           literal result element, an <a href="#dt-expression">expression</a> can be used by surrounding
           
           the expression with curly braces (<code>{}</code>).  The
           
           attribute value template is instantiated by replacing the expression
           
           together with surrounding curly braces by the result of evaluating the
           
           expression and converting the resulting object to a string as if by a
           
           call to the <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b> function.  Curly braces are
           
           not recognized in an attribute value in an XSLT stylesheet unless the
           
           attribute is specifically stated to be one that is interpreted as an
           
           attribute value template; in an element syntax summary, the value
           
           of such attributes is surrounded by curly braces.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Not all attributes are interpreted as attribute value
           
           templates.  Attributes whose value is an expression or pattern,
           
           attributes of <a href="#dt-top-level">top-level</a> elements
           
           and attributes that refer to named XSLT objects are not interpreted as
           
           attribute value templates. In addition, <code>xmlns</code> attributes
           
           are not interpreted as attribute value templates; it would not be
           
           conformant with the XML Namespaces Recommendation to do
           
           this.
        </blockquote>
        
        
        
        
        <p>The following example creates an <code>img</code> result element
           
           from a <code>photograph</code> element in the source; the value of the
           
           <code>src</code> attribute of the <code>img</code> element is computed
           
           from the value of the <code>image-dir</code> variable and the
           
           string-value of the <code>href</code> child of the
           
           <code>photograph</code> element; the value of the <code>width</code>
           
           attribute of the <code>img</code> element is computed from the value
           
           of the <code>width</code> attribute of the <code>size</code> child of
           
           the <code>photograph</code> element:
        </p>
        
        
        
        <pre>&lt;xsl:variable name="image-dir">/images&lt;/xsl:variable>
  
  
  
  &lt;xsl:template match="photograph">
  
  &lt;img src="{$image-dir}/{href}" width="{size/@width}"/>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>With this source</p>
        
        
        
        <pre>&lt;photograph>
  
    &lt;href>headquarters.jpg&lt;/href>
  
    &lt;size width="300"/>
  
  &lt;/photograph></pre>
        
        
        
        <p>the result would be</p>
        
        
        
        <pre>&lt;img src="/images/headquarters.jpg" width="300"/></pre>
        
        
        
        <p>When an attribute value template is instantiated, a double left or
           
           right curly brace outside an expression will be replaced by a single
           
           curly brace.  It is an error if a right curly brace occurs in an
           
           attribute value template outside an expression without being followed
           
           by a second right curly brace.  A right curly brace inside a <a href="http://www.w3.org/TR/xpath#NT-Literal">Literal</a> in an expression is not
           
           recognized as terminating the expression.
        </p>
        
        
        
        
        <p>Curly braces are <i>not</i> recognized recursively inside
           
           expressions.  For example:
        </p>
        
        
        
        <pre style="color: red">&lt;a href="#{id({@ref})/title}"></pre>
        
        
        
        <p>is <i>not</i> allowed.  Instead, use simply:
        </p>
        
        
        
        <pre>&lt;a href="#{id(@ref)/title}"></pre>
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="number"></a>7.7 Numbering
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-number"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:number<br>&nbsp;&nbsp;level = "single" | "multiple" | "any"<br>&nbsp;&nbsp;count = <var>pattern</var><br>&nbsp;&nbsp;from = <var>pattern</var><br>&nbsp;&nbsp;value = <var>number-expression</var><br>&nbsp;&nbsp;format = { <var>string</var> }<br>&nbsp;&nbsp;lang = { <var>nmtoken</var> }<br>&nbsp;&nbsp;letter-value = { "alphabetic" | "traditional" }<br>&nbsp;&nbsp;grouping-separator = { <var>char</var> }<br>&nbsp;&nbsp;grouping-size = { <var>number</var> }&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:number</code> element is used to insert a formatted
           
           number into the result tree.  The number to be inserted may be
           
           specified by an expression. The <code>value</code> attribute contains
           
           an <a href="#dt-expression">expression</a>.  The expression
           
           is evaluated and the resulting object is converted to a number as if
           
           by a call to the <b><a href="http://www.w3.org/TR/xpath#function-number">number</a></b> function.  The number is
           
           rounded to an integer and then converted to a string using the
           
           attributes specified in <a href="#convert">[<b>7.7.1 Number to String Conversion Attributes</b>]
           </a>; in this
           
           context, the value of each of these attributes is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>.  After conversion, the resulting string is
           
           inserted in the result tree. For example, the following example
           
           numbers a sorted list:
        </p>
        
        
        
        <pre>&lt;xsl:template match="items">
  
    &lt;xsl:for-each select="item">
  
      &lt;xsl:sort select="."/>
  
      &lt;p>
  
        &lt;xsl:number value="position()" format="1. "/>
  
        &lt;xsl:value-of select="."/>
  
      &lt;/p>
  
    &lt;/xsl:for-each>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>If no <code>value</code> attribute is specified, then the
           
           <code>xsl:number</code> element inserts a number based on the position
           
           of the current node in the source tree. The following attributes
           
           control how the current node is to be numbered:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>The <code>level</code> attribute specifies what levels of the
                 
                 source tree should be considered; it has the values
                 
                 <code>single</code>, <code>multiple</code> or <code>any</code>. The
                 
                 default is <code>single</code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The <code>count</code> attribute is a pattern that specifies
                 
                 what nodes should be counted at those levels.  If <code>count</code>
                 
                 attribute is not specified, then it defaults to the pattern that
                 
                 matches any node with the same node type as the current node and, if
                 
                 the current node has an expanded-name, with the same expanded-name as
                 
                 the current node.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The <code>from</code> attribute is a pattern that specifies
                 
                 where counting starts.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>In addition, the attributes specified in <a href="#convert">[<b>7.7.1 Number to String Conversion Attributes</b>]
           </a>
           
           are used for number to string conversion, as in the case when the
           
           <code>value</code> attribute is specified.
        </p>
        
        
        
        
        <p>The <code>xsl:number</code> element first constructs a list of
           
           positive integers using the <code>level</code>, <code>count</code> and
           
           <code>from</code> attributes:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>When <code>level="single"</code>, it goes up to the first
                 
                 node in the ancestor-or-self axis that matches
                 
                 the <code>count</code> pattern, and constructs a list of length one
                 
                 containing one plus the number of preceding siblings of that ancestor
                 
                 that match the <code>count</code> pattern. If there is no such
                 
                 ancestor, it constructs an empty list.  If the <code>from</code>
                 
                 attribute is specified, then the only ancestors that are searched are
                 
                 those that are descendants of the nearest ancestor that matches the
                 
                 <code>from</code> pattern. Preceding siblings has the same meaning
                 
                 here as with the <code>preceding-sibling</code> axis.
              </p>
           </li>
           
           
           
           
           <li>
              <p>When <code>level="multiple"</code>, it constructs a list of all
                 
                 ancestors of the current node in document order followed by the
                 
                 element itself; it then selects from the list those nodes that match
                 
                 the <code>count</code> pattern; it then maps each node in the list to
                 
                 one plus the number of preceding siblings of that node that match the
                 
                 <code>count</code> pattern.  If the <code>from</code> attribute is
                 
                 specified, then the only ancestors that are searched are those that
                 
                 are descendants of the nearest ancestor that matches the
                 
                 <code>from</code> pattern. Preceding siblings has the same meaning
                 
                 here as with the <code>preceding-sibling</code> axis.
              </p>
           </li>
           
           
           
           
           <li>
              <p>When <code>level="any"</code>, it constructs a list of length
                 
                 one containing the number of nodes that match the <code>count</code>
                 
                 pattern and belong to the set containing the current node and all
                 
                 nodes at any level of the document that are before the current node in
                 
                 document order, excluding any namespace and attribute nodes (in other
                 
                 words the union of the members of the <code>preceding</code> and
                 
                 <code>ancestor-or-self</code> axes). If the <code>from</code>
                 
                 attribute is specified, then only nodes after the first node before
                 
                 the current node that match the <code>from</code> pattern are
                 
                 considered.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>The list of numbers is then converted into a string using the
           
           attributes specified in <a href="#convert">[<b>7.7.1 Number to String Conversion Attributes</b>]
           </a>; in this
           
           context, the value of each of these attributes is
           
           interpreted as an <a href="#dt-attribute-value-template">attribute
              
              value template
           </a>.  After conversion, the resulting string is
           
           inserted in the result tree.
        </p>
        
        
        
        
        <p>The following would number the items in an ordered list:</p>
        
        
        
        <pre>&lt;xsl:template match="ol/item">
  
    &lt;fo:block>
  
      &lt;xsl:number/>&lt;xsl:text>. &lt;/xsl:text>&lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;xsl:template></pre>
        
        
        
        <p>The following two rules would number <code>title</code> elements.
           
           This is intended for a document that contains a sequence of chapters
           
           followed by a sequence of appendices, where both chapters and
           
           appendices contain sections, which in turn contain subsections.
           
           Chapters are numbered 1, 2, 3; appendices are numbered A, B, C;
           
           sections in chapters are numbered 1.1, 1.2, 1.3; sections in
           
           appendices are numbered A.1, A.2, A.3.
        </p>
        
        
        
        <pre>&lt;xsl:template match="title">
  
    &lt;fo:block>
  
       &lt;xsl:number level="multiple"
  
                   count="chapter|section|subsection"
  
                   format="1.1 "/>
  
       &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="appendix//title" priority="1">
  
    &lt;fo:block>
  
       &lt;xsl:number level="multiple"
  
                   count="appendix|section|subsection"
  
                   format="A.1 "/>
  
       &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The following example numbers notes sequentially within a
           
           chapter:
        </p>
        
        
        
        <pre>&lt;xsl:template match="note">
  
    &lt;fo:block>
  
       &lt;xsl:number level="any" from="chapter" format="(1) "/>
  
       &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The following example would number <code>H4</code> elements in HTML
           
           with a three-part label:
        </p>
        
        
        
        <pre>&lt;xsl:template match="H4">
  
   &lt;fo:block>
  
     &lt;xsl:number level="any" from="H1" count="H2"/>
  
     &lt;xsl:text>.&lt;/xsl:text>
  
     &lt;xsl:number level="any" from="H2" count="H3"/>
  
     &lt;xsl:text>.&lt;/xsl:text>
  
     &lt;xsl:number level="any" from="H3" count="H4"/>
  
     &lt;xsl:text> &lt;/xsl:text>
  
     &lt;xsl:apply-templates/>
  
   &lt;/fo:block>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        <h4><a name="convert"></a>7.7.1 Number to String Conversion Attributes
        </h4>
        
        
        
        
        <p>The following attributes are used to control conversion of a list
           
           of numbers into a string. The numbers are integers greater than
           
           0. The attributes are all optional.
        </p>
        
        
        
        
        <p>The main attribute is <code>format</code>.  The default value for
           
           the <code>format</code> attribute is <code>1</code>.  The
           
           <code>format</code> attribute is split into a sequence of tokens where
           
           each token is a maximal sequence of alphanumeric characters or a
           
           maximal sequence of non-alphanumeric characters.  Alphanumeric means
           
           any character that has a Unicode category of Nd, Nl, No, Lu, Ll, Lt,
           
           Lm or Lo.  The alphanumeric tokens (format tokens) specify the format
           
           to be used for each number in the list.  If the first token is a
           
           non-alphanumeric token, then the constructed string will start with
           
           that token; if the last token is non-alphanumeric token, then the
           
           constructed string will end with that token.  Non-alphanumeric tokens
           
           that occur between two format tokens are separator tokens that are
           
           used to join numbers in the list.  The <var>n</var>th format token
           
           will be used to format the <var>n</var>th number in the list.  If
           
           there are more numbers than format tokens, then the last format token
           
           will be used to format remaining numbers.  If there are no format
           
           tokens, then a format token of <code>1</code> is used to format all
           
           numbers.  The format token specifies the string to be used to
           
           represent the number 1.  Each number after the first will be separated
           
           from the preceding number by the separator token preceding the format
           
           token used to format that number, or, if there are no separator
           
           tokens, then by <code>.</code> (a period character).
        </p>
        
        
        
        
        <p>Format tokens are a superset of the allowed values for the
           
           <code>type</code> attribute for the <code>OL</code> element in HTML
           
           4.0 and are interpreted as follows:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>Any token where the last character has a decimal digit value
                 
                 of 1 (as specified in the Unicode character property database),
                 
                 and the Unicode value of preceding characters is one less than the
                 
                 Unicode value of the last character generates a decimal
                 
                 representation of the number where each number is at least as long as
                 
                 the format token.  Thus, a format token <code>1</code> generates the
                 
                 sequence <code>1 2 ... 10 11 12 ...</code>, and a format token
                 
                 <code>01</code> generates the sequence <code>01 02 ... 09 10 11 12
                    
                    ... 99 100 101
                 </code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A format token <code>A</code> generates the sequence <code>A
                    
                    B C ... Z AA AB AC...
                 </code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A format token <code>a</code> generates the sequence <code>a
                    
                    b c ... z aa ab ac...
                 </code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A format token <code>i</code> generates the sequence <code>i
                    
                    ii iii iv v vi vii viii ix x ...
                 </code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A format token <code>I</code> generates the sequence <code>I
                    
                    II III IV V VI VII VIII IX X ...
                 </code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>Any other format token indicates a numbering sequence that
                 
                 starts with that token.  If an implementation does not support a
                 
                 numbering sequence that starts with that token, it must use a format
                 
                 token of <code>1</code>.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>When numbering with an alphabetic sequence, the <code>lang</code>
           
           attribute specifies which language's alphabet is to be used; it has
           
           the same range of values as <code>xml:lang</code> <a href="#XML">[XML]</a>;
           
           if no <code>lang</code> value is specified, the language should be
           
           determined from the system environment.  Implementers should document
           
           for which languages they support numbering.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Implementers should not make any assumptions about how
           
           numbering works in particular languages and should properly research
           
           the languages that they wish to support.  The numbering conventions of
           
           many languages are very different from English.
        </blockquote>
        
        
        
        
        <p>The <code>letter-value</code> attribute disambiguates between
           
           numbering sequences that use letters.  In many languages there are two
           
           commonly used numbering sequences that use letters.  One numbering
           
           sequence assigns numeric values to letters in alphabetic sequence, and
           
           the other assigns numeric values to each letter in some other manner
           
           traditional in that language.  In English, these would correspond to
           
           the numbering sequences specified by the format tokens <code>a</code>
           
           and <code>i</code>.  In some languages, the first member of each
           
           sequence is the same, and so the format token alone would be
           
           ambiguous.  A value of <code>alphabetic</code> specifies the
           
           alphabetic sequence; a value of <code>traditional</code> specifies the
           
           other sequence.  If the <code>letter-value</code> attribute is not
           
           specified, then it is implementation-dependent how any ambiguity is
           
           resolved.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>It is possible for two conforming XSLT processors not to
           
           convert a number to exactly the same string.  Some XSLT processors may not
           
           support some languages.  Furthermore, there may be variations possible
           
           in the way conversions are performed for any particular language that
           
           are not specifiable by the attributes on <code>xsl:number</code>.
           
           Future versions of XSLT may provide additional attributes to provide
           
           control over these variations.  Implementations may also use
           
           implementation-specific namespaced attributes on
           
           <code>xsl:number</code> for this.
        </blockquote>
        
        
        
        
        <p>The <code>grouping-separator</code> attribute gives the separator
           
           used as a grouping (e.g. thousands) separator in decimal numbering
           
           sequences, and the optional <code>grouping-size</code> specifies the
           
           size (normally 3) of the grouping.  For example,
           
           <code>grouping-separator=","</code> and <code>grouping-size="3"</code>
           
           would produce numbers of the form <code>1,000,000</code>.  If only one
           
           of the <code>grouping-separator</code> and <code>grouping-size</code>
           
           attributes is specified, then it is ignored.
        </p>
        
        
        
        
        <p>Here are some examples of conversion specifications:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>format="&amp;#x30A2;"</code> specifies Katakana
                 
                 numbering
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x30A4;"</code> specifies Katakana
                 
                 numbering in the "iroha" order
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x0E51;"</code> specifies numbering with
                 
                 Thai digits
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x05D0;" letter-value="traditional"</code>
                 
                 specifies "traditional" Hebrew numbering
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x10D0;" letter-value="traditional"</code>
                 
                 specifies Georgian numbering
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x03B1;" letter-value="traditional"</code>
                 
                 specifies "classical" Greek numbering
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>format="&amp;#x0430;" letter-value="traditional"</code>
                 
                 specifies Old Slavic numbering
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="for-each"></a>8 Repetition
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-for-each"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:for-each<br>&nbsp;&nbsp;<b>select</b> = <var>node-set-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-sort">xsl:sort</a>*, <var>template</var>) --><br>&lt;/xsl:for-each>
           </code>
        </p>
        
        
        
        
        <p>When the result has a known regular structure, it is useful to be
           
           able to specify directly the template for selected nodes.  The
           
           <code>xsl:for-each</code> instruction contains a template, which is
           
           instantiated for each node selected by the <a href="#dt-expression">expression</a> specified by the
           
           <code>select</code> attribute. The <code>select</code> attribute is
           
           required.  The expression must evaluate to a node-set.  The template
           
           is instantiated with the selected node as the <a href="#dt-current-node">current node</a>, and with a list of all
           
           of the selected nodes as the <a href="#dt-current-node-list">current node list</a>.  The nodes are
           
           processed in document order, unless a sorting specification is present
           
           (see <a href="#sorting">[<b>10 Sorting</b>]
           </a>).
        </p>
        
        
        
        
        <p>For example, given an XML document with this structure</p>
        
        
        
        <pre>&lt;customers>
  
    &lt;customer>
  
      &lt;name>...&lt;/name>
  
      &lt;order>...&lt;/order>
  
      &lt;order>...&lt;/order>
  
    &lt;/customer>
  
    &lt;customer>
  
      &lt;name>...&lt;/name>
  
      &lt;order>...&lt;/order>
  
      &lt;order>...&lt;/order>
  
    &lt;/customer>
  
  &lt;/customers></pre>
        
        
        
        <p>the following would create an HTML document containing a table with
           
           a row for each <code>customer</code> element
        </p>
        
        
        
        <pre>&lt;xsl:template match="/">
  
    &lt;html>
  
      &lt;head>
  
        &lt;title>Customers&lt;/title>
  
      &lt;/head>
  
      &lt;body>
  
        &lt;table>
  
  	&lt;tbody>
  
  	  &lt;xsl:for-each select="customers/customer">
  
  	    &lt;tr>
  
  	      &lt;th>
  
  		&lt;xsl:apply-templates select="name"/>
  
  	      &lt;/th>
  
  	      &lt;xsl:for-each select="order">
  
  		&lt;td>
  
  		  &lt;xsl:apply-templates/>
  
  		&lt;/td>
  
  	      &lt;/xsl:for-each>
  
  	    &lt;/tr>
  
  	  &lt;/xsl:for-each>
  
  	&lt;/tbody>
  
        &lt;/table>
  
      &lt;/body>
  
    &lt;/html>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Conditional-Processing"></a>9 Conditional Processing
        </h2>
        
        
        
        
        <p>There are two instructions in XSLT that support conditional
           
           processing in a template: <code>xsl:if</code> and
           
           <code>xsl:choose</code>. The <code>xsl:if</code> instruction provides
           
           simple if-then conditionality; the <code>xsl:choose</code> instruction
           
           supports selection of one choice when there are several
           
           possibilities.
        </p>
        
        
        
        
        
        
        <h3><a name="section-Conditional-Processing-with-xsl:if"></a>9.1 Conditional Processing with <code>xsl:if</code></h3>
        
        
        
        
        <p class="element-syntax"><a name="element-if"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:if<br>&nbsp;&nbsp;<b>test</b> = <var>boolean-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:if>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:if</code> element has a <code>test</code> attribute,
           
           which specifies an <a href="#dt-expression">expression</a>.
           
           The content is a template.  The expression is evaluated and the
           
           resulting object is converted to a boolean as if by a call to the
           
           <b><a href="http://www.w3.org/TR/xpath#function-boolean">boolean</a></b> function.  If the result is true, then
           
           the content template is instantiated; otherwise, nothing is created.
           
           In the following example, the names in a group of names are formatted
           
           as a comma separated list:
        </p>
        
        
        
        <pre>&lt;xsl:template match="namelist/name">
  
    &lt;xsl:apply-templates/>
  
    &lt;xsl:if test="not(position()=last())">, &lt;/xsl:if>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The following colors every other table row yellow:</p>
        
        
        
        <pre>&lt;xsl:template match="item">
  
    &lt;tr>
  
      &lt;xsl:if test="position() mod 2 = 0">
  
         &lt;xsl:attribute name="bgcolor">yellow&lt;/xsl:attribute>
  
      &lt;/xsl:if>
  
      &lt;xsl:apply-templates/>
  
    &lt;/tr>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Conditional-Processing-with-xsl:choose"></a>9.2 Conditional Processing with <code>xsl:choose</code></h3>
        
        
        
        
        <p class="element-syntax"><a name="element-choose"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:choose><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-when">xsl:when</a>+, <a href="#element-otherwise">xsl:otherwise</a>?) --><br>&lt;/xsl:choose>
           </code>
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-when"></a><code>&lt;xsl:when<br>&nbsp;&nbsp;<b>test</b> = <var>boolean-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:when>
           </code>
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-otherwise"></a><code>&lt;xsl:otherwise><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:otherwise>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:choose</code> element selects one among a number of
           
           possible alternatives. It consists of a sequence of
           
           <code>xsl:when</code> elements followed by an optional
           
           <code>xsl:otherwise</code> element.  Each <code>xsl:when</code>
           
           element has a single attribute, <code>test</code>, which specifies an
           
           <a href="#dt-expression">expression</a>. The content of the
           
           <code>xsl:when</code> and <code>xsl:otherwise</code> elements is a
           
           template.  When an <code>xsl:choose</code> element is processed, each
           
           of the <code>xsl:when</code> elements is tested in turn, by evaluating
           
           the expression and converting the resulting object to a boolean as if
           
           by a call to the <b><a href="http://www.w3.org/TR/xpath#function-boolean">boolean</a></b> function.  The content
           
           of the first, and only the first, <code>xsl:when</code> element whose
           
           test is true is instantiated.  If no <code>xsl:when</code> is true,
           
           the content of the <code>xsl:otherwise</code> element is
           
           instantiated. If no <code>xsl:when</code> element is true, and no
           
           <code>xsl:otherwise</code> element is present, nothing is created.
        </p>
        
        
        
        
        <p>The following example enumerates items in an ordered list using
           
           arabic numerals, letters, or roman numerals depending on the depth to
           
           which the ordered lists are nested.
        </p>
        
        
        
        <pre>&lt;xsl:template match="orderedlist/listitem">
  
    &lt;fo:list-item indent-start='2pi'>
  
      &lt;fo:list-item-label>
  
        &lt;xsl:variable name="level"
  
                      select="count(ancestor::orderedlist) mod 3"/>
  
        &lt;xsl:choose>
  
          &lt;xsl:when test='$level=1'>
  
            &lt;xsl:number format="i"/>
  
          &lt;/xsl:when>
  
          &lt;xsl:when test='$level=2'>
  
            &lt;xsl:number format="a"/>
  
          &lt;/xsl:when>
  
          &lt;xsl:otherwise>
  
            &lt;xsl:number format="1"/>
  
          &lt;/xsl:otherwise>
  
        &lt;/xsl:choose>
  
        &lt;xsl:text>. &lt;/xsl:text>
  
      &lt;/fo:list-item-label>
  
      &lt;fo:list-item-body>
  
        &lt;xsl:apply-templates/>
  
      &lt;/fo:list-item-body>
  
    &lt;/fo:list-item>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="sorting"></a>10 Sorting
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-sort"></a><code>&lt;xsl:sort<br>&nbsp;&nbsp;select = <var>string-expression</var><br>&nbsp;&nbsp;lang = { <var>nmtoken</var> }<br>&nbsp;&nbsp;data-type = { "text" | "number" | <var>qname-but-not-ncname</var> }<br>&nbsp;&nbsp;order = { "ascending" | "descending" }<br>&nbsp;&nbsp;case-order = { "upper-first" | "lower-first" }&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>Sorting is specified by adding <code>xsl:sort</code> elements as
           
           children of an <code>xsl:apply-templates</code> or
           
           <code>xsl:for-each</code> element.  The first <code>xsl:sort</code>
           
           child specifies the primary sort key, the second <code>xsl:sort</code>
           
           child specifies the secondary sort key and so on.  When an
           
           <code>xsl:apply-templates</code> or <code>xsl:for-each</code> element
           
           has one or more <code>xsl:sort</code> children, then instead of
           
           processing the selected nodes in document order, it sorts the nodes
           
           according to the specified sort keys and then processes them in sorted
           
           order.  When used in <code>xsl:for-each</code>, <code>xsl:sort</code>
           
           elements must occur first.  When a template is instantiated by
           
           <code>xsl:apply-templates</code> and <code>xsl:for-each</code>, the
           
           <a href="#dt-current-node-list">current node list</a> list
           
           consists of the complete list of nodes being processed in sorted
           
           order.
        </p>
        
        
        
        
        <p><code>xsl:sort</code> has a <code>select</code> attribute whose
           
           value is an <a href="#dt-expression">expression</a>. For
           
           each node to be processed, the expression is evaluated with that node
           
           as the current node and with the complete list of nodes being
           
           processed in unsorted order as the current node list.
           
           The resulting object is converted to a string as
           
           if by a call to the <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b> function; this string
           
           is used as the sort key for that node. The default value of the
           
           <code>select</code> attribute is <code>.</code>, which will cause the
           
           string-value of the current node to be used as the sort key.
        </p>
        
        
        
        
        <p>This string serves as a sort key for the node.  The following
           
           optional attributes on <code>xsl:sort</code> control how the list of
           
           sort keys are sorted; the values of all of these attributes are
           
           interpreted as <a href="#dt-attribute-value-template">attribute
              
              value templates
           </a>.
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>order</code> specifies whether the strings should be
                 
                 sorted in ascending or descending order; <code>ascending</code>
                 
                 specifies ascending order; <code>descending</code> specifies
                 
                 descending order; the default is <code>ascending</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>lang</code> specifies the language of the sort keys; it
                 
                 has the same range of values as <code>xml:lang</code> <a href="#XML">[XML]</a>; if no <code>lang</code> value is specified, the language
                 
                 should be determined from the system environment
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>data-type</code> specifies the data type of the
                 
                 strings; the following values are allowed:
              </p>
              
              
              
              
              <ul>
                 
                 
                 
                 
                 <li>
                    <p><code>text</code> specifies that the sort keys should be
                       
                       sorted lexicographically in the culturally correct manner for the
                       
                       language specified by <code>lang</code></p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p><code>number</code> specifies that the sort keys should be
                       
                       converted to numbers and then sorted according to the numeric value;
                       
                       the sort key is converted to a number as if by a call to the
                       
                       <b><a href="http://www.w3.org/TR/xpath#function-number">number</a></b> function; the <code>lang</code>
                       
                       attribute is ignored
                    </p>
                 </li>
                 
                 
                 
                 
                 <li>
                    <p>a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> with a prefix
                       
                       is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> as described
                       
                       in <a href="#qname">[<b>2.4 Qualified Names</b>]
                       </a>; the expanded-name identifies the data-type;
                       
                       the behavior in this case is not specified by this document
                    </p>
                 </li>
                 
                 
                 
                 
              </ul>
              
              
              
              
              <p>The default value is <code>text</code>.
              </p>
              
              
              
              
              <blockquote><b>NOTE: </b>The XSL Working Group plans that future versions of XSLT will
                 
                 leverage XML Schemas to define further values for this
                 
                 attribute.
              </blockquote>
              
              
              
              
           </li>
           
           
           
           
           <li>
              <p><code>case-order</code> has the value
                 
                 <code>upper-first</code> or <code>lower-first</code>; this applies
                 
                 when <code>data-type="text"</code>, and specifies that upper-case
                 
                 letters should sort before lower-case letters or vice-versa
                 
                 respectively. For example, if <code>lang="en"</code>, then <code>A a B
                    
                    b
                 </code> are sorted with <code>case-order="upper-first"</code> and
                 
                 <code>a A b B</code> are sorted with
                 
                 <code>case-order="lower-first"</code>. The default value is language
                 
                 dependent.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <blockquote><b>NOTE: </b>It is possible for two conforming XSLT processors not to sort
           
           exactly the same.  Some XSLT processors may not support some
           
           languages.  Furthermore, there may be variations possible in the
           
           sorting of any particular language that are not specified by the
           
           attributes on <code>xsl:sort</code>, for example, whether Hiragana or
           
           Katakana is sorted first in Japanese.  Future versions of XSLT may
           
           provide additional attributes to provide control over these
           
           variations.  Implementations may also use implementation-specific
           
           namespaced attributes on <code>xsl:sort</code> for this.
        </blockquote>
        
        
        
        
        <blockquote><b>NOTE: </b>It is recommended that implementers consult <a href="#UNICODE-TR10">[UNICODE TR10]</a> for information on internationalized
           
           sorting.
        </blockquote>
        
        
        
        
        <p>The sort must be stable: in the sorted list of nodes, any sub list
           
           that has sort keys that all compare equal must be in document
           
           order.
        </p>
        
        
        
        
        <p>For example, suppose an employee database has the form</p>
        
        
        
        <pre>&lt;employees>
  
    &lt;employee>
  
      &lt;name>
  
        &lt;given>James&lt;/given>
  
        &lt;family>Clark&lt;/family>
  
      &lt;/name>
  
      ...
  
    &lt;/employee>
  
  &lt;/employees>
  
  </pre>
        
        
        
        <p>Then a list of employees sorted by name could be generated
           
           using:
        </p>
        
        
        
        <pre>&lt;xsl:template match="employees">
  
    &lt;ul>
  
      &lt;xsl:apply-templates select="employee">
  
        &lt;xsl:sort select="name/family"/>
  
        &lt;xsl:sort select="name/given"/>
  
      &lt;/xsl:apply-templates>
  
    &lt;/ul>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="employee">
  
    &lt;li>
  
      &lt;xsl:value-of select="name/given"/>
  
      &lt;xsl:text> &lt;/xsl:text>
  
      &lt;xsl:value-of select="name/family"/>
  
    &lt;/li>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        <h2><a name="variables"></a>11 Variables and Parameters
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-variable"></a><code>&lt;!-- Category: top-level-element --><br>&lt;!-- Category: instruction --><br>&lt;xsl:variable<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:variable>
           </code>
        </p>
        
        
        
        
        <p class="element-syntax"><a name="element-param"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:param<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:param>
           </code>
        </p>
        
        
        
        
        <p>A variable is a name that may be bound to a value.  The value to
           
           which a variable is bound (the <b>value</b> of the variable) can
           
           be an object of any of the types that can be returned by expressions.
           
           There are two elements that can be used to bind variables:
           
           <code>xsl:variable</code> and <code>xsl:param</code>. The difference
           
           is that the value specified on the <code>xsl:param</code> variable is
           
           only a default value for the binding; when the template or stylesheet
           
           within which the <code>xsl:param</code> element occurs is invoked,
           
           parameters may be passed that are used in place of the default
           
           values.
        </p>
        
        
        
        
        <p>Both <code>xsl:variable</code> and <code>xsl:param</code> have a
           
           required <code>name</code> attribute, which specifies the name of the
           
           variable.  The value of the <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>.
        </p>
        
        
        
        
        <p>For any use of these variable-binding elements, there is a region
           
           of the stylesheet tree within which the binding is visible; within
           
           this region, any binding of the variable that was visible on the
           
           variable-binding element itself is hidden.  Thus, only the innermost
           
           binding of a variable is visible.  The set of variable bindings in
           
           scope for an expression consists of those bindings that are visible at
           
           the point in the stylesheet where the expression occurs.
        </p>
        
        
        
        
        
        
        <h3><a name="section-Result-Tree-Fragments"></a>11.1 Result Tree Fragments
        </h3>
        
        
        
        
        <p>Variables introduce an additional data-type into the expression
           
           language.  <a name="dt-result-tree-fragment"></a>This additional data type is called <b>result tree
              
              fragment
           </b>.  A variable may be bound to a result tree fragment
           
           instead of one of the four basic XPath data-types (string, number,
           
           boolean, node-set).  A result tree fragment represents a fragment of
           
           the result tree. A result tree fragment is treated equivalently to a
           
           node-set that contains just a single root node. However, the
           
           operations permitted on a result tree fragment are a subset of those
           
           permitted on a node-set.  An operation is permitted on a result tree
           
           fragment only if that operation would be permitted on a string (the
           
           operation on the string may involve first converting the string to a
           
           number or boolean). In particular, it is not permitted to use the
           
           <code>/</code>, <code>//</code>, and <code>[]</code> operators on
           
           result tree fragments.  When a permitted operation is performed on a
           
           result tree fragment, it is performed exactly as it would be on the
           
           equivalent node-set.
        </p>
        
        
        
        
        <p>When a result tree fragment is copied into the result tree (see
           
           <a href="#copy-of">[<b>11.3 Using Values of Variables and Parameters with
                 
                 <code>xsl:copy-of</code></b>]
           </a>), then all the nodes that are children of the
           
           root node in the equivalent node-set are added in sequence to the
           
           result tree.
        </p>
        
        
        
        
        <p>Expressions can only return values of type result tree fragment by
           
           referencing variables of type result tree fragment or calling
           
           extension functions that return a result tree fragment or getting a
           
           system property whose value is a result tree fragment.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="variable-values"></a>11.2 Values of Variables and Parameters
        </h3>
        
        
        
        
        <p>A variable-binding element can specify the value of the variable in
           
           three alternative ways.
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>If the variable-binding element has a <code>select</code>
                 
                 attribute, then the value of the attribute must be an <a href="#dt-expression">expression</a> and the value of the variable
                 
                 is the object that results from evaluating the expression.  In this
                 
                 case, the content must be empty.
              </p>
           </li>
           
           
           
           
           <li>
              
              
              
              
              <p>If the variable-binding element does not have a <code>select</code>
                 
                 attribute and has non-empty content (i.e. the variable-binding element
                 
                 has one or more child nodes), then the content of the
                 
                 variable-binding element specifies the value. The content of the
                 
                 variable-binding element is a template, which is instantiated to give
                 
                 the value of the variable. The value is a result tree fragment
                 
                 equivalent to a node-set containing just a single root node having as
                 
                 children the sequence of nodes produced by instantiating the template.
                 
                 The base URI of the nodes in the result tree fragment is the base URI
                 
                 of the variable-binding element.
              </p>
              
              
              
              
              <p>It is an error if a member of the sequence of nodes created by
                 
                 instantiating the template is an attribute node or a namespace node,
                 
                 since a root node cannot have an attribute node or a namespace node as
                 
                 a child. An XSLT processor may signal the error; if it does not signal
                 
                 the error, it must recover by not adding the attribute node or
                 
                 namespace node.
              </p>
              
              
              
              
           </li>
           
           
           
           
           <li>
              
              
              
              
              <p>If the variable-binding element has empty content and does not have
                 
                 a <code>select</code> attribute, then the value of the variable is an
                 
                 empty string. Thus
              </p>
              
              
              
              <pre>&lt;xsl:variable name="x"/></pre>
              
              
              
              <p>is equivalent to</p>
              
              
              
              <pre>&lt;xsl:variable name="x" select="''"/></pre>
              
              
              
              </li>
           
           
           
           
        </ul>
        
        
        
        
        <blockquote><b>NOTE: </b>When a variable is used to select nodes by position, be careful
           
           not to do:
           
           
           
           <pre>&lt;xsl:variable name="n">2&lt;/xsl:variable>
  
  ...
  
  &lt;xsl:value-of select="item[$n]"/></pre>
           
           
           
           This will output the value of the first item element, because the
           
           variable <code>n</code> will be bound to a result tree fragment, not a
           
           number. Instead, do either
           
           
           
           <pre>&lt;xsl:variable name="n" select="2"/>
  
  ...
  
  &lt;xsl:value-of select="item[$n]"/></pre>
           
           
           
           or
           
           
           
           <pre>&lt;xsl:variable name="n">2&lt;/xsl:variable>
  
  ...
  
  &lt;xsl:value-of select="item[position()=$n]"/></pre>
           
           </blockquote>
        
        
        
        
        <blockquote><b>NOTE: </b>One convenient way to specify the empty node-set as the default
           
           value of a parameter is:
           
           
           
           <pre>&lt;xsl:param name="x" select="/.."/></pre>
           
           </blockquote>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="copy-of"></a>11.3 Using Values of Variables and Parameters with
           
           <code>xsl:copy-of</code></h3>
        
        
        
        
        <p class="element-syntax"><a name="element-copy-of"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:copy-of<br>&nbsp;&nbsp;<b>select</b> = <var>expression</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:copy-of</code> element can be used to insert a result
           
           tree fragment into the result tree, without first converting it to a
           
           string as <code>xsl:value-of</code> does (see <a href="#value-of">[<b>7.6.1 Generating Text with <code>xsl:value-of</code></b>]
           </a>).  The required <code>select</code> attribute
           
           contains an <a href="#dt-expression">expression</a>.  When
           
           the result of evaluating the expression is a result tree fragment, the
           
           complete fragment is copied into the result tree.  When the result is
           
           a node-set, all the nodes in the set are copied in document order into
           
           the result tree; copying an element node copies the attribute nodes,
           
           namespace nodes and children of the element node as well as the
           
           element node itself; a root node is copied by copying its children.
           
           When the result is neither a node-set nor a result tree fragment, the
           
           result is converted to a string and then inserted into the result
           
           tree, as with <code>xsl:value-of</code>.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="top-level-variables"></a>11.4 Top-level Variables and Parameters
        </h3>
        
        
        
        
        <p>Both <code>xsl:variable</code> and <code>xsl:param</code> are
           
           allowed as <a href="#dt-top-level">top-level</a> elements.
           
           A top-level variable-binding element declares a global variable that
           
           is visible everywhere.  A top-level <code>xsl:param</code> element
           
           declares a parameter to the stylesheet; XSLT does not define the
           
           mechanism by which parameters are passed to the stylesheet.  It is an
           
           error if a stylesheet contains more than one binding of a top-level
           
           variable with the same name and same <a href="#dt-import-precedence">import precedence</a>. At the
           
           top-level, the expression or template specifying the variable value is
           
           evaluated with the same context as that used to process the root node
           
           of the source document: the current node is the root node of the
           
           source document and the current node list is a list containing just
           
           the root node of the source document.  If the template or expression
           
           specifying the value of a global variable <var>x</var> references a
           
           global variable <var>y</var>, then the value for <var>y</var> must
           
           be computed before the value of <var>x</var>.  It is an error if it
           
           is impossible to do this for all global variable definitions; in other
           
           words, it is an error if the definitions are circular.
        </p>
        
        
        
        
        <p>This example declares a global variable <code>para-font-size</code>,
           
           which it references in an attribute value template.
        </p>
        
        
        
        <pre>&lt;xsl:variable name="para-font-size">12pt&lt;/xsl:variable>
  
  
  
  &lt;xsl:template match="para">
  
   &lt;fo:block font-size="{$para-font-size}">
  
     &lt;xsl:apply-templates/>
  
   &lt;/fo:block>
  
  &lt;/xsl:template>
  
  </pre>
        
        
        
        
        
        
        
        
        
        <h3><a name="local-variables"></a>11.5 Variables and Parameters within Templates
        </h3>
        
        
        
        
        <p>As well as being allowed at the top-level, both
           
           <code>xsl:variable</code> and <code>xsl:param</code> are also
           
           allowed in templates.  <code>xsl:variable</code> is allowed anywhere
           
           within a template that an instruction is allowed.  In this case, the
           
           binding is visible for all following siblings and their descendants.
           
           Note that the binding is not visible for the <code>xsl:variable</code>
           
           element itself.  <code>xsl:param</code> is allowed as a child
           
           at the beginning of an <code>xsl:template</code> element.  In this
           
           context, the binding is visible for all following siblings and their
           
           descendants.  Note that the binding is not visible for the
           
           <code>xsl:param</code> element itself.
        </p>
        
        
        
        
        <p><a name="dt-shadows"></a>A binding
           
           <b>shadows</b> another binding if the binding occurs at a point
           
           where the other binding is visible, and the bindings have the same
           
           name. It is an error if a binding established by an
           
           <code>xsl:variable</code> or <code>xsl:param</code> element within a
           
           template <a href="#dt-shadows">shadows</a> another binding
           
           established by an <code>xsl:variable</code> or <code>xsl:param</code>
           
           element also within the template.  It is not an error if a binding
           
           established by an <code>xsl:variable</code> or <code>xsl:param</code>
           
           element in a template <a href="#dt-shadows">shadows</a>
           
           another binding established by an <code>xsl:variable</code> or
           
           <code>xsl:param</code> <a href="#dt-top-level">top-level</a>
           
           element.  Thus, the following is an error:
        </p>
        
        
        
        <pre style="color: red">&lt;xsl:template name="foo">
  
  &lt;xsl:param name="x" select="1"/>
  
  &lt;xsl:variable name="x" select="2"/>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>However, the following is allowed:</p>
        
        
        
        <pre>&lt;xsl:param name="x" select="1"/>
  
  &lt;xsl:template name="foo">
  
  &lt;xsl:variable name="x" select="2"/>
  
  &lt;/xsl:template></pre>
        
        
        
        <blockquote><b>NOTE: </b>The nearest equivalent in Java to an <code>xsl:variable</code>
           
           element in a template is a final local variable declaration with an
           
           initializer.  For example,
           
           
           
           <pre>&lt;xsl:variable name="x" select="'value'"/></pre>
           
           
           
           has similar semantics to
           
           
           
           <pre>final Object x = "value";</pre>
           
           
           
           XSLT does not provide an equivalent to the Java assignment operator
           
           
           
           <pre>x = "value";</pre>
           
           
           
           because this would make it harder to create an implementation that
           
           processes a document other than in a batch-like way, starting at the
           
           beginning and continuing through to the end.</blockquote>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Passing-Parameters-to-Templates"></a>11.6 Passing Parameters to Templates
        </h3>
        
        
        
        
        <p class="element-syntax"><a name="element-with-param"></a><code>&lt;xsl:with-param<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:with-param>
           </code>
        </p>
        
        
        
        
        <p>Parameters are passed to templates using the
           
           <code>xsl:with-param</code> element.  The required <code>name</code>
           
           attribute specifies the name of the parameter (the variable the value
           
           of whose binding is to be replaced).  The value of the
           
           <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>.  <code>xsl:with-param</code> is allowed
           
           within both <code>xsl:call-template</code> and
           
           <code>xsl:apply-templates</code>.  The value of the parameter is
           
           specified in the same way as for <code>xsl:variable</code> and
           
           <code>xsl:param</code>.  The current node and current node list used
           
           for computing the value specified by <code>xsl:with-param</code>
           
           element is the same as that used for the
           
           <code>xsl:apply-templates</code> or <code>xsl:call-template</code>
           
           element within which it occurs.  It is not an error to pass a
           
           parameter <var>x</var> to a template that does not have an
           
           <code>xsl:param</code> element for <var>x</var>; the parameter is
           
           simply ignored.
        </p>
        
        
        
        
        <p>This example defines a named template for a
           
           <code>numbered-block</code> with an argument to control the format of
           
           the number.
        </p>
        
        
        
        <pre>&lt;xsl:template name="numbered-block">
  
    &lt;xsl:param name="format">1. &lt;/xsl:param>
  
    &lt;fo:block>
  
      &lt;xsl:number format="{$format}"/>
  
      &lt;xsl:apply-templates/>
  
    &lt;/fo:block>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="ol//ol/li">
  
    &lt;xsl:call-template name="numbered-block">
  
      &lt;xsl:with-param name="format">a. &lt;/xsl:with-param>
  
    &lt;/xsl:call-template>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="add-func"></a>12 Additional Functions
        </h2>
        
        
        
        
        <p>This section describes XSLT-specific additions to the core XPath
           
           function library.  Some of these additional functions also make use of
           
           information specified by <a href="#dt-top-level">top-level</a>
           
           elements in the stylesheet; this section also describes these
           
           elements.
        </p>
        
        
        
        
        
        
        
        
        <h3><a name="document"></a>12.1 Multiple Source Documents
        </h3>
        
        
        
        
        <p><a name="function-document"><b>Function: </b><i>node-set</i> <b>document</b>(<i>object</i>, <i>node-set</i>?)
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-document">document</a></b> function allows
           
           access to XML documents other than the main source document.
        </p>
        
        
        
        
        <p>When the <b><a href="#function-document">document</a></b> function has exactly one
           
           argument and the argument is a node-set, then the result is the union,
           
           for each node in the argument node-set, of the result of calling the
           
           <b><a href="#function-document">document</a></b> function with the first argument being
           
           the <a href="http://www.w3.org/TR/xpath#dt-string-value">string-value</a>
           
           of the node, and the second argument being a node-set with the node as
           
           its only member. When the <b><a href="#function-document">document</a></b> function has
           
           two arguments and the first argument is a node-set, then the result is
           
           the union, for each node in the argument node-set, of the result of
           
           calling the <b><a href="#function-document">document</a></b> function with the first
           
           argument being the <a href="http://www.w3.org/TR/xpath#dt-string-value">string-value</a> of the node,
           
           and with the second argument being the second argument passed to the
           
           <b><a href="#function-document">document</a></b> function.
        </p>
        
        
        
        
        <p>When the first argument to the <b><a href="#function-document">document</a></b>
           
           function is not a node-set, the first argument is converted to a
           
           string as if by a call to the <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b> function.
           
           This string is treated as a URI reference; the resource identified by
           
           the URI is retrieved. The data resulting from the retrieval action is
           
           parsed as an XML document and a tree is constructed in accordance with
           
           the data model (see <a href="#data-model">[<b>3 Data Model</b>]
           </a>).  If there is an
           
           error retrieving the resource, then the XSLT processor may signal an
           
           error; if it does not signal an error, it must recover by returning an
           
           empty node-set.  One possible kind of retrieval error is that the XSLT
           
           processor does not support the URI scheme used by the URI.  An XSLT
           
           processor is not required to support any particular URI schemes.  The
           
           documentation for an XSLT processor should specify which URI schemes
           
           the XSLT processor supports.
        </p>
        
        
        
        
        <p>If the URI reference does not contain a fragment identifier, then a
           
           node-set containing just the root node of the document is returned.
           
           If the URI reference does contain a fragment identifier, the function
           
           returns a node-set containing the nodes in the tree identified by the
           
           fragment identifier of the URI reference. The semantics of the
           
           fragment identifier is dependent on the media type of the result of
           
           retrieving the URI.  If there is an error in processing the fragment
           
           identifier, the XSLT processor may signal the error; if it does not
           
           signal the error, it must recover by returning an empty node-set.
           
           Possible errors include:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>The fragment identifier identifies something that cannot be
                 
                 represented by an XSLT node-set (such as a range of characters within
                 
                 a text node).
              </p>
           </li>
           
           
           
           
           <li>
              <p>The XSLT processor does not support fragment identifiers for
                 
                 the media-type of the retrieval result.  An XSLT processor is not
                 
                 required to support any particular media types.  The documentation for
                 
                 an XSLT processor should specify for which media types the XSLT
                 
                 processor supports fragment identifiers.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>The data resulting from the retrieval action is parsed as an XML
           
           document regardless of the media type of the retrieval result; if the
           
           top-level media type is <code>text</code>, then it is parsed in the
           
           same way as if the media type were <code>text/xml</code>; otherwise,
           
           it is parsed in the same way as if the media type were
           
           <code>application/xml</code>.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Since there is no top-level <code>xml</code> media type, data
           
           with a media type other than <code>text/xml</code> or
           
           <code>application/xml</code> may in fact be XML.
        </blockquote>
        
        
        
        
        <p>The URI reference may be relative. The base URI (see <a href="#base-uri">[<b>3.2 Base URI</b>]
           </a>) of the node in the second argument node-set that is
           
           first in document order is used as the base URI for resolving the
           
           relative URI into an absolute URI.  If the second argument is omitted,
           
           then it defaults to the node in the stylesheet that contains the
           
           expression that includes the call to the <b><a href="#function-document">document</a></b>
           
           function.  Note that a zero-length URI reference is a reference to the
           
           document relative to which the URI reference is being resolved; thus
           
           <code>document("")</code> refers to the root node of the stylesheet;
           
           the tree representation of the stylesheet is exactly the same as if
           
           the XML document containing the stylesheet was the initial source
           
           document.
        </p>
        
        
        
        
        <p>Two documents are treated as the same document if they are
           
           identified by the same URI. The URI used for the comparison is the
           
           absolute URI into which any relative URI was resolved and does not
           
           include any fragment identifier.  One root node is treated as the same
           
           node as another root node if the two nodes are from the same document.
           
           Thus, the following expression will always be true:
        </p>
        
        
        
        <pre>generate-id(document("foo.xml"))=generate-id(document("foo.xml"))</pre>
        
        
        
        <p>The <b><a href="#function-document">document</a></b> function gives rise to the
           
           possibility that a node-set may contain nodes from more than one
           
           document.  With such a node-set, the relative document order of two
           
           nodes in the same document is the normal <a href="http://www.w3.org/TR/xpath#dt-document-order">document order</a> defined by
           
           XPath <a href="#XPATH">[XPath]</a>.  The relative document order of two nodes
           
           in different documents is determined by an implementation-dependent
           
           ordering of the documents containing the two nodes.  There are no
           
           constraints on how the implementation orders documents other than that
           
           it must do so consistently: an implementation must always use the same
           
           order for the same set of documents.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="key"></a>12.2 Keys
        </h3>
        
        
        
        
        <p>Keys provide a way to work with documents that contain an implicit
           
           cross-reference structure.  The <code>ID</code>, <code>IDREF</code>
           
           and <code>IDREFS</code> attribute types in XML provide a mechanism to
           
           allow XML documents to make their cross-reference explicit.  XSLT
           
           supports this through the XPath <b><a href="http://www.w3.org/TR/xpath#function-id">id</a></b> function.
           
           However, this mechanism has a number of limitations:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>ID attributes must be declared as such in the DTD.  If an ID
                 
                 attribute is declared as an ID attribute only in the external DTD
                 
                 subset, then it will be recognized as an ID attribute only if the XML
                 
                 processor reads the external DTD subset.  However, XML does not require
                 
                 XML processors to read the external DTD, and they may well choose not
                 
                 to do so, especially if the document is declared
                 
                 <code>standalone="yes"</code>.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A document can contain only a single set of unique IDs.
                 
                 There cannot be separate independent sets of unique IDs.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The ID of an element can only be specified in an attribute;
                 
                 it cannot be specified by the content of the element, or by a child
                 
                 element.
              </p>
           </li>
           
           
           
           
           <li>
              <p>An ID is constrained to be an XML name.  For example, it
                 
                 cannot contain spaces.
              </p>
           </li>
           
           
           
           
           <li>
              <p>An element can have at most one ID.</p>
           </li>
           
           
           
           
           <li>
              <p>At most one element can have a particular ID.</p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>Because of these limitations XML documents sometimes contain a
           
           cross-reference structure that is not explicitly declared by
           
           ID/IDREF/IDREFS attributes.
        </p>
        
        
        
        
        <p>A key is a triple containing:</p>
        
        
        
        
        <ol>
           
           
           
           
           <li>
              <p>the node which has the key</p>
           </li>
           
           
           
           
           <li>
              <p>the name of the key (an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a>)
              </p>
           </li>
           
           
           
           
           <li>
              <p>the value of the key (a string)</p>
           </li>
           
           
           
           
        </ol>
        
        
        
        
        <p>A stylesheet declares a set of keys for each document using the
           
           <code>xsl:key</code> element.  When this set of keys contains a member
           
           with node <var>x</var>, name <var>y</var> and value
           
           <var>z</var>, we say that node <var>x</var> has a key with name
           
           <var>y</var> and value <var>z</var>.
        </p>
        
        
        
        
        <p>Thus, a key is a kind of generalized ID, which is not subject to the
           
           same limitations as an XML ID:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>Keys are declared in the stylesheet using
                 
                 <code>xsl:key</code> elements.
              </p>
           </li>
           
           
           
           
           <li>
              <p>A key has a name as well as a value; each key name may be
                 
                 thought of as distinguishing a separate, independent space of
                 
                 identifiers.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The value of a named key for an element may be specified in
                 
                 any convenient place; for example, in an attribute, in a child element
                 
                 or in content.  An XPath expression is used to specify where to find
                 
                 the value for a particular named key.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The value of a key can be an arbitrary string; it is not
                 
                 constrained to be a name.
              </p>
           </li>
           
           
           
           
           <li>
              <p>There can be multiple keys in a document with the same node,
                 
                 same key name, but different key values.
              </p>
           </li>
           
           
           
           
           <li>
              <p>There can be multiple keys in a document with the same key
                 
                 name, same key value, but different nodes.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p class="element-syntax"><a name="element-key"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:key<br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;<b>match</b> = <var>pattern</var><br>&nbsp;&nbsp;<b>use</b> = <var>expression</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:key</code> element is used to declare keys.  The
           
           <code>name</code> attribute specifies the name of the key.  The value
           
           of the <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>. The <code>match</code> attribute is a <a href="#NT-Pattern">Pattern</a>; an <code>xsl:key</code> element gives
           
           information about the keys of any node that matches the pattern
           
           specified in the match attribute.  The <code>use</code> attribute is
           
           an <a href="#dt-expression">expression</a> specifying the
           
           values of the key; the expression is evaluated once for each node that
           
           matches the pattern.  If the result is a node-set, then for each node
           
           in the node-set, the node that matches the pattern has a key of the
           
           specified name whose value is the string-value of the node in the
           
           node-set; otherwise, the result is converted to a string, and the node
           
           that matches the pattern has a key of the specified name with value
           
           equal to that string.  Thus, a node <var>x</var> has a key with name
           
           <var>y</var> and value <var>z</var> if and only if there is an
           
           <code>xsl:key</code> element such that:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><var>x</var> matches the pattern specified in the
                 
                 <code>match</code> attribute of the <code>xsl:key</code> element;
              </p>
           </li>
           
           
           
           
           <li>
              <p>the value of the <code>name</code> attribute of the
                 
                 <code>xsl:key</code> element is equal to <var>y</var>;
                 
                 and
              </p>
           </li>
           
           
           
           
           <li>
              <p>when the expression specified in the <code>use</code>
                 
                 attribute of the <code>xsl:key</code> element is evaluated with
                 
                 <var>x</var> as the current node and with a node list containing
                 
                 just <var>x</var> as the current node list resulting in an object
                 
                 <var>u</var>, then either <var>z</var> is equal to the result of
                 
                 converting <var>u</var> to a string as if by a call to the
                 
                 <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b> function, or <var>u</var> is a
                 
                 node-set and <var>z</var> is equal to the string-value of one or
                 
                 more of the nodes in <var>u</var>.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>Note also that there may be more than one <code>xsl:key</code>
           
           element that matches a given node; all of the matching
           
           <code>xsl:key</code> elements are used, even if they do not have the
           
           same <a href="#dt-import-precedence">import
              
              precedence
           </a>.
        </p>
        
        
        
        
        <p>It is an error for the value of either the <code>use</code>
           
           attribute or the <code>match</code> attribute to contain a <a href="http://www.w3.org/TR/xpath#NT-VariableReference">VariableReference</a>.
        </p>
        
        
        
        
        <p><a name="function-key"><b>Function: </b><i>node-set</i> <b>key</b>(<i>string</i>, <i>object</i>)
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-key">key</a></b> function does for keys what the
           
           <b><a href="http://www.w3.org/TR/xpath#function-id">id</a></b> function does for IDs.  The first argument
           
           specifies the name of the key. The value of the argument must be a
           
           <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as
           
           described in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>. When the second argument to the
           
           <b><a href="#function-key">key</a></b> function is of type node-set, then the result
           
           is the union of the result of applying the <b><a href="#function-key">key</a></b>
           
           function to the string <a href="http://www.w3.org/TR/xpath#dt-value">value</a> of each of the nodes in the
           
           argument node-set.  When the second argument to
           
           <b><a href="#function-key">key</a></b> is of any other type, the argument is
           
           converted to a string as if by a call to the
           
           <b><a href="http://www.w3.org/TR/xpath#function-string">string</a></b> function; it returns a node-set
           
           containing the nodes in the same document as the context node that
           
           have a value for the named key equal to this string.
        </p>
        
        
        
        
        <p>For example, given a declaration</p>
        
        
        
        <pre>&lt;xsl:key name="idkey" match="div" use="@id"/></pre>
        
        
        
        <p>an expression <code>key("idkey",@ref)</code> will return the same
           
           node-set as <code>id(@ref)</code>, assuming that the only ID attribute
           
           declared in the XML source document is:
        </p>
        
        
        
        <pre>&lt;!ATTLIST div id ID #IMPLIED></pre>
        
        
        
        <p>and that the <code>ref</code> attribute of the current node
           
           contains no whitespace.
        </p>
        
        
        
        
        <p>Suppose a document describing a function library uses a
           
           <code>prototype</code> element to define functions
        </p>
        
        
        
        <pre>&lt;prototype name="key" return-type="node-set">
  
  &lt;arg type="string"/>
  
  &lt;arg type="object"/>
  
  &lt;/prototype></pre>
        
        
        
        <p>and a <code>function</code> element to refer to function names
        </p>
        
        
        
        <pre>&lt;function>key&lt;/function></pre>
        
        
        
        <p>Then the stylesheet could generate hyperlinks between the
           
           references and definitions as follows:
        </p>
        
        
        
        <pre>&lt;xsl:key name="func" match="prototype" use="@name"/>
  
  
  
  &lt;xsl:template match="function">
  
  &lt;b>
  
    &lt;a href="#{generate-id(key('func',.))}">
  
      &lt;xsl:apply-templates/>
  
    &lt;/a>
  
  &lt;/b>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="prototype">
  
  &lt;p>&lt;a name="{generate-id()}">
  
  &lt;b>Function: &lt;/b>
  
  ...
  
  &lt;/a>&lt;/p>
  
  &lt;/xsl:template></pre>
        
        
        
        <p>The <b><a href="#function-key">key</a></b> can be used to retrieve a key from a
           
           document other than the document containing the context node.  For
           
           example, suppose a document contains bibliographic references in the
           
           form <code>&lt;bibref>XSLT&lt;/bibref></code>, and there is a
           
           separate XML document <code>bib.xml</code> containing a bibliographic
           
           database with entries in the form:
        </p>
        
        
        
        <pre>&lt;entry name="XSLT">...&lt;/entry></pre>
        
        
        
        <p>Then the stylesheet could use the following to transform the
           
           <code>bibref</code> elements:
        </p>
        
        
        
        <pre>&lt;xsl:key name="bib" match="entry" use="@name"/>
  
  
  
  &lt;xsl:template match="bibref">
  
    &lt;xsl:variable name="name" select="."/>
  
    &lt;xsl:for-each select="document('bib.xml')">
  
      &lt;xsl:apply-templates select="key('bib',$name)"/>
  
    &lt;/xsl:for-each>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        <h3><a name="format-number"></a>12.3 Number Formatting
        </h3>
        
        
        
        
        <p><a name="function-format-number"><b>Function: </b><i>string</i> <b>format-number</b>(<i>number</i>, <i>string</i>, <i>string</i>?)
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-format-number">format-number</a></b> function converts its first
           
           argument to a string using the format pattern string specified by the
           
           second argument and the decimal-format named by the third argument, or
           
           the default decimal-format, if there is no third argument.  The format
           
           pattern string is in the syntax specified by the JDK 1.1 <a href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html">DecimalFormat</a> class. The format pattern string is in a
           
           localized notation: the decimal-format determines what characters have
           
           a special meaning in the pattern (with the exception of the quote
           
           character, which is not localized).  The format pattern must not
           
           contain the currency sign (#x00A4); support for this feature was added
           
           after the initial release of JDK 1.1.  The decimal-format name must be
           
           a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as
           
           described in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>.  It is an error if the stylesheet
           
           does not contain a declaration of the decimal-format with the specified
           
           <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a>.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Implementations are not required to use the JDK 1.1
           
           implementation, nor are implementations required to be implemented in
           
           Java.
        </blockquote>
        
        
        
        
        <blockquote><b>NOTE: </b>Stylesheets can use other facilities in XPath to control
           
           rounding.
        </blockquote>
        
        
        
        
        <p class="element-syntax"><a name="element-decimal-format"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:decimal-format<br>&nbsp;&nbsp;name = <var>qname</var><br>&nbsp;&nbsp;decimal-separator = <var>char</var><br>&nbsp;&nbsp;grouping-separator = <var>char</var><br>&nbsp;&nbsp;infinity = <var>string</var><br>&nbsp;&nbsp;minus-sign = <var>char</var><br>&nbsp;&nbsp;NaN = <var>string</var><br>&nbsp;&nbsp;percent = <var>char</var><br>&nbsp;&nbsp;per-mille = <var>char</var><br>&nbsp;&nbsp;zero-digit = <var>char</var><br>&nbsp;&nbsp;digit = <var>char</var><br>&nbsp;&nbsp;pattern-separator = <var>char</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:decimal-format</code> element declares a
           
           decimal-format, which controls the interpretation of a format pattern
           
           used by the <b><a href="#function-format-number">format-number</a></b> function.  If there is
           
           a <code>name</code> attribute, then the element declares a named
           
           decimal-format; otherwise, it declares the default decimal-format.
           
           The value of the <code>name</code> attribute is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>, which is expanded as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>.  It is an error to declare either the
           
           default decimal-format or a decimal-format with a given name more than
           
           once (even with different <a href="#dt-import-precedence">import
              
              precedence
           </a>), unless it is declared every time with the same
           
           value for all attributes (taking into account any default values).
        </p>
        
        
        
        
        <p>The other attributes on <code>xsl:decimal-format</code> correspond
           
           to the methods on the JDK 1.1 <a href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormatSymbols.html">DecimalFormatSymbols</a> class.  For each
           
           <code>get</code>/<code>set</code> method pair there is an attribute
           
           defined for the <code>xsl:decimal-format</code> element.
        </p>
        
        
        
        
        <p>The following attributes both control the interpretation of
           
           characters in the format pattern and specify characters that may
           
           appear in the result of formatting the number:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>decimal-separator</code> specifies the character used
                 
                 for the decimal sign; the default value is the period character
                 
                 (<code>.</code>)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>grouping-separator</code> specifies the character used
                 
                 as a grouping (e.g. thousands) separator; the default value is the
                 
                 comma character (<code>,</code>)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>percent</code> specifies the character used as a
                 
                 percent sign; the default value is the percent character
                 
                 (<code>%</code>)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>per-mille</code> specifies the character used as a per
                 
                 mille sign; the default value is the Unicode per-mille character
                 
                 (#x2030)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>zero-digit</code> specifies the character used as the
                 
                 digit zero; the default value is the digit zero
                 
                 (<code>0</code>)
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>The following attributes control the interpretation of characters
           
           in the format pattern:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>digit</code> specifies the character used for a digit
                 
                 in the format pattern; the default value is the number sign character
                 
                 (<code>#</code>)
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>pattern-separator</code> specifies the character used
                 
                 to separate positive and negative sub patterns in a pattern; the
                 
                 default value is the semi-colon character (<code>;</code>)
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>The following attributes specify characters or strings that may
           
           appear in the result of formatting the number:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>infinity</code> specifies the string used to represent
                 
                 infinity; the default value is the string
                 
                 <code>Infinity</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>NaN</code> specifies the string used to represent the
                 
                 NaN value; the default value is the string <code>NaN</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>minus-sign</code> specifies the character used as the
                 
                 default minus sign; the default value is the hyphen-minus character
                 
                 (<code>-</code>, #x2D)
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="misc-func"></a>12.4 Miscellaneous Additional Functions
        </h3>
        
        
        
        
        <p><a name="function-current"><b>Function: </b><i>node-set</i> <b>current</b>()
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-current">current</a></b> function returns a node-set that
           
           has the <a href="#dt-current-node">current node</a> as its
           
           only member.  For an outermost expression (an expression not occurring
           
           within another expression), the current node is always the same as the
           
           context node.  Thus,
        </p>
        
        
        
        <pre>&lt;xsl:value-of select="current()"/></pre>
        
        
        
        <p>means the same as</p>
        
        
        
        <pre>&lt;xsl:value-of select="."/></pre>
        
        
        
        <p>However, within square brackets the current node is usually
           
           different from the context node. For example,
        </p>
        
        
        
        <pre>&lt;xsl:apply-templates select="//glossary/item[@name=current()/@ref]"/></pre>
        
        
        
        <p>will process all <code>item</code> elements that have a
           
           <code>glossary</code> parent element and that have a <code>name</code>
           
           attribute with value equal to the value of the current node's
           
           <code>ref</code> attribute. This is different from
        </p>
        
        
        
        <pre>&lt;xsl:apply-templates select="//glossary/item[@name=./@ref]"/></pre>
        
        
        
        <p>which means the same as</p>
        
        
        
        <pre>&lt;xsl:apply-templates select="//glossary/item[@name=@ref]"/></pre>
        
        
        
        <p>and so would process all <code>item</code> elements that have a
           
           <code>glossary</code> parent element and that have a <code>name</code>
           
           attribute and a <code>ref</code> attribute with the same value.
        </p>
        
        
        
        
        <p>It is an error to use the <b><a href="#function-current">current</a></b> function in
           
           a <a href="#dt-pattern">pattern</a>.
        </p>
        
        
        
        
        <p><a name="function-unparsed-entity-uri"><b>Function: </b><i>string</i> <b>unparsed-entity-uri</b>(<i>string</i>)
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-unparsed-entity-uri">unparsed-entity-uri</a></b> returns the URI of the
           
           unparsed entity with the specified name in the same document as the
           
           context node (see <a href="#unparsed-entities">[<b>3.3 Unparsed Entities</b>]
           </a>).  It returns the
           
           empty string if there is no such entity.
        </p>
        
        
        
        
        <p><a name="function-generate-id"><b>Function: </b><i>string</i> <b>generate-id</b>(<i>node-set</i>?)
           </a>
        </p>
        
        
        
        
        <p>The <b><a href="#function-generate-id">generate-id</a></b> function returns a string that
           
           uniquely identifies the node in the argument node-set that is first in
           
           document order.  The unique identifier must consist of ASCII
           
           alphanumeric characters and must start with an alphabetic character.
           
           Thus, the string is syntactically an XML name.  An implementation is
           
           free to generate an identifier in any convenient way provided that it
           
           always generates the same identifier for the same node and that
           
           different identifiers are always generated from different nodes. An
           
           implementation is under no obligation to generate the same identifiers
           
           each time a document is transformed.  There is no guarantee that a
           
           generated unique identifier will be distinct from any unique IDs
           
           specified in the source document.  If the argument node-set is empty,
           
           the empty string is returned. If the argument is omitted, it defaults
           
           to the context node.
        </p>
        
        
        
        
        <p><a name="function-system-property"><b>Function: </b><i>object</i> <b>system-property</b>(<i>string</i>)
           </a>
        </p>
        
        
        
        
        <p>The argument must evaluate to a string that is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  The <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is expanded into a name using
           
           the namespace declarations in scope for the expression. The
           
           <b><a href="#function-system-property">system-property</a></b> function returns an object
           
           representing the value of the system property identified by the name.
           
           If there is no such system property, the empty string should be
           
           returned.
        </p>
        
        
        
        
        <p>Implementations must provide the following system properties, which
           
           are all in the XSLT namespace:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li><code>xsl:version</code>, a number giving the version of XSLT
              
              implemented by the processor; for XSLT processors implementing the
              
              version of XSLT specified by this document, this is the number
              
              1.0
           </li>
           
           
           
           
           <li><code>xsl:vendor</code>, a string identifying the vendor of the
              
              XSLT processor
           </li>
           
           
           
           
           <li><code>xsl:vendor-url</code>, a string containing a URL
              
              identifying the vendor of the XSLT processor; typically this is the
              
              host page (home page) of the vendor's Web site.
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="message"></a>13 Messages
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-message"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:message<br>&nbsp;&nbsp;terminate = "yes" | "no"><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:message>
           </code>
        </p>
        
        
        
        
        <p>The <code>xsl:message</code> instruction sends a message in a way
           
           that is dependent on the XSLT processor.  The content of the
           
           <code>xsl:message</code> instruction is a template.  The
           
           <code>xsl:message</code> is instantiated by instantiating the content
           
           to create an XML fragment.  This XML fragment is the content of the
           
           message.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>An XSLT processor might implement <code>xsl:message</code> by
           
           popping up an alert box or by writing to a log file.
        </blockquote>
        
        
        
        
        <p>If the <code>terminate</code> attribute has the value
           
           <code>yes</code>, then the XSLT processor should terminate processing
           
           after sending the message.  The default value is <code>no</code>.
        </p>
        
        
        
        
        <p>One convenient way to do localization is to put the localized
           
           information (message text, etc.) in an XML document, which becomes an
           
           additional input file to the stylesheet.  For example, suppose
           
           messages for a language <code><var>L</var></code> are stored in an XML
           
           file <code>resources/<var>L</var>.xml
           </code> in the form:
        </p>
        
        
        
        <pre>&lt;messages>
  
    &lt;message name="problem">A problem was detected.&lt;/message>
  
    &lt;message name="error">An error was detected.&lt;/message>
  
  &lt;/messages>
  
  </pre>
        
        
        
        <p>Then a stylesheet could use the following approach to localize
           
           messages:
        </p>
        
        
        
        <pre>&lt;xsl:param name="lang" select="en"/>
  
  &lt;xsl:variable name="messages"
  
    select="document(concat('resources/', $lang, '.xml'))/messages"/>
  
  
  
  &lt;xsl:template name="localized-message">
  
    &lt;xsl:param name="name"/>
  
    &lt;xsl:message>
  
      &lt;xsl:value-of select="$messages/message[@name=$name]"/>
  
    &lt;/xsl:message>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template name="problem">
  
    &lt;xsl:call-template name="localized-message"/>
  
      &lt;xsl:with-param name="name">problem&lt;/xsl:with-param>
  
    &lt;/xsl:call-template>
  
  &lt;/xsl:template></pre>
        
        
        
        
        
        
        
        
        
        <h2><a name="extension"></a>14 Extensions
        </h2>
        
        
        
        
        <p>XSLT allows two kinds of extension, extension elements and
           
           extension functions.
        </p>
        
        
        
        
        <p>This version of XSLT does not provide a mechanism for defining
           
           implementations of extensions.  Therefore, an XSLT stylesheet that must
           
           be portable between XSLT implementations cannot rely on particular
           
           extensions being available.  XSLT provides mechanisms that allow an
           
           XSLT stylesheet to determine whether the XSLT processor by which it is
           
           being processed has implementations of particular extensions
           
           available, and to specify what should happen if those extensions are
           
           not available.  If an XSLT stylesheet is careful to make use of these
           
           mechanisms, it is possible for it to take advantage of extensions and
           
           still work with any XSLT implementation.
        </p>
        
        
        
        
        
        
        <h3><a name="extension-element"></a>14.1 Extension Elements
        </h3>
        
        
        
        
        <p><a name="dt-extension-namespace"></a>The
           
           element extension mechanism allows namespaces to be designated as
           
           <b>extension namespace</b>s. When a namespace is designated as
           
           an extension namespace and an element with a name from that namespace
           
           occurs in a template, then the element is treated as an instruction
           
           rather than as a literal result element. The namespace
           
           determines the semantics of the instruction.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Since an element that is a child of an
           
           <code>xsl:stylesheet</code> element is not occurring <i>in a
              
              template
           </i>, non-XSLT <a href="#dt-top-level">top-level</a> elements are not extension
           
           elements as defined here, and nothing in this section applies to
           
           them.
        </blockquote>
        
        
        
        
        <p>A namespace is designated as an extension namespace by using an
           
           <code>extension-element-prefixes</code> attribute on an
           
           <code>xsl:stylesheet</code> element or an
           
           <code>xsl:extension-element-prefixes</code> attribute on a literal
           
           result element or extension element.
           
           The value of both these attributes is a
           
           whitespace-separated list of namespace prefixes. The namespace bound
           
           to each of the prefixes is designated as an extension namespace.  It
           
           is an error if there is no namespace bound to the prefix on the
           
           element bearing the <code>extension-element-prefixes</code> or
           
           <code>xsl:extension-element-prefixes</code> attribute.  The default
           
           namespace (as declared by <code>xmlns</code>) may be designated as an
           
           extension namespace by including <code>#default</code> in the list of
           
           namespace prefixes.  The designation of a namespace as an extension
           
           namespace is effective within the subtree of the stylesheet rooted at
           
           the element bearing the <code>extension-element-prefixes</code> or
           
           <code>xsl:extension-element-prefixes</code> attribute;
           
           a subtree rooted at an <code>xsl:stylesheet</code> element
           
           does not include any stylesheets imported or included by children
           
           of that <code>xsl:stylesheet</code> element.
        </p>
        
        
        
        
        <p>If the XSLT processor does not have an implementation of a
           
           particular extension element available, then the
           
           <b><a href="#function-element-available">element-available</a></b> function must return false for
           
           the name of the element.  When such an extension element is
           
           instantiated, then the XSLT processor must perform fallback for the
           
           element as specified in <a href="#fallback">[<b>15 Fallback</b>]
           </a>.  An XSLT processor
           
           must not signal an error merely because a template contains an
           
           extension element for which no implementation is available.
        </p>
        
        
        
        
        <p>If the XSLT processor has an implementation of a particular
           
           extension element available, then the
           
           <b><a href="#function-element-available">element-available</a></b> function must return true for
           
           the name of the element.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Extension-Functions"></a>14.2 Extension Functions
        </h3>
        
        
        
        
        <p>If a <a href="http://www.w3.org/TR/xpath#NT-FunctionName">FunctionName</a> in a
           
           <a href="http://www.w3.org/TR/xpath#NT-FunctionCall">FunctionCall</a> expression is
           
           not an <a href="http://www.w3.org/TR/REC-xml-names#NT-NCName">NCName</a> (i.e. if it
           
           contains a colon), then it is treated as a call to an extension
           
           function.  The <a href="http://www.w3.org/TR/xpath#NT-FunctionName">FunctionName</a>
           
           is expanded to a name using the namespace declarations from the
           
           evaluation context.
        </p>
        
        
        
        
        <p>If the XSLT processor does not have an implementation of an
           
           extension function of a particular name available, then the
           
           <b><a href="#function-function-available">function-available</a></b> function must return false for
           
           that name.  If such an extension function occurs in an expression and
           
           the extension function is actually called, the XSLT processor must
           
           signal an error.  An XSLT processor must not signal an error merely
           
           because an expression contains an extension function for which no
           
           implementation is available.
        </p>
        
        
        
        
        <p>If the XSLT processor has an implementation of an extension
           
           function of a particular name available, then the
           
           <b><a href="#function-function-available">function-available</a></b> function must return
           
           true for that name. If such an extension is called, then the XSLT
           
           processor must call the implementation passing it the function call
           
           arguments; the result returned by the implementation is returned as
           
           the result of the function call.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="fallback"></a>15 Fallback
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-fallback"></a><code>&lt;!-- Category: instruction --><br>&lt;xsl:fallback><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:fallback>
           </code>
        </p>
        
        
        
        
        <p>Normally, instantiating an <code>xsl:fallback</code> element does
           
           nothing.  However, when an XSLT processor performs fallback for an
           
           instruction element, if the instruction element has one or more
           
           <code>xsl:fallback</code> children, then the content of each of the
           
           <code>xsl:fallback</code> children must be instantiated in sequence;
           
           otherwise, an error must be signaled. The content of an
           
           <code>xsl:fallback</code> element is a template.
        </p>
        
        
        
        
        <p>The following functions can be used with the
           
           <code>xsl:choose</code> and <code>xsl:if</code> instructions to
           
           explicitly control how a stylesheet should behave if particular
           
           elements or functions are not available.
        </p>
        
        
        
        
        <p><a name="function-element-available"><b>Function: </b><i>boolean</i> <b>element-available</b>(<i>string</i>)
           </a>
        </p>
        
        
        
        
        <p>The argument must evaluate to a string that is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  The <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> using the
           
           namespace declarations in scope for the expression. The
           
           <b><a href="#function-element-available">element-available</a></b> function returns true if and
           
           only if the expanded-name is the name of an instruction.  If the
           
           expanded-name has a namespace URI equal to the XSLT namespace URI,
           
           then it refers to an element defined by XSLT.  Otherwise, it refers to
           
           an extension element. If the expanded-name has a null namespace URI,
           
           the <b><a href="#function-element-available">element-available</a></b> function will return
           
           false.
        </p>
        
        
        
        
        <p><a name="function-function-available"><b>Function: </b><i>boolean</i> <b>function-available</b>(<i>string</i>)
           </a>
        </p>
        
        
        
        
        <p>The argument must evaluate to a string that is a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  The <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> using the
           
           namespace declarations in scope for the expression. The
           
           <b><a href="#function-function-available">function-available</a></b> function returns true if and
           
           only if the expanded-name is the name of a function in the function
           
           library. If the expanded-name has a non-null namespace URI, then it
           
           refers to an extension function; otherwise, it refers to a function
           
           defined by XPath or XSLT.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="output"></a>16 Output
        </h2>
        
        
        
        
        <p class="element-syntax"><a name="element-output"></a><code>&lt;!-- Category: top-level-element --><br>&lt;xsl:output<br>&nbsp;&nbsp;method = "xml" | "html" | "text" | <var>qname-but-not-ncname</var><br>&nbsp;&nbsp;version = <var>nmtoken</var><br>&nbsp;&nbsp;encoding = <var>string</var><br>&nbsp;&nbsp;omit-xml-declaration = "yes" | "no"<br>&nbsp;&nbsp;standalone = "yes" | "no"<br>&nbsp;&nbsp;doctype-public = <var>string</var><br>&nbsp;&nbsp;doctype-system = <var>string</var><br>&nbsp;&nbsp;cdata-section-elements = <var>qnames</var><br>&nbsp;&nbsp;indent = "yes" | "no"<br>&nbsp;&nbsp;media-type = <var>string</var>&nbsp;/>
           </code>
        </p>
        
        
        
        
        <p>An XSLT processor may output the result tree as a sequence of
           
           bytes, although it is not required to be able to do so (see <a href="#conformance">[<b>17 Conformance</b>]
           </a>). The <code>xsl:output</code> element allows
           
           stylesheet authors to specify how they wish the result tree to be
           
           output. If an XSLT processor outputs the result tree, it should do so
           
           as specified by the <code>xsl:output</code> element; however, it is
           
           not required to do so.
        </p>
        
        
        
        
        <p>The <code>xsl:output</code> element is only allowed as a <a href="#dt-top-level">top-level</a> element.
        </p>
        
        
        
        
        <p>The <code>method</code> attribute on <code>xsl:output</code>
           
           identifies the overall method that should be used for outputting the
           
           result tree.  The value must be a <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>.  If the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> does not have a prefix, then it
           
           identifies a method specified in this document and must be one of
           
           <code>xml</code>, <code>html</code> or <code>text</code>.  If the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> has a prefix, then the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is expanded into an <a href="http://www.w3.org/TR/xpath#dt-expanded-name">expanded-name</a> as described
           
           in <a href="#qname">[<b>2.4 Qualified Names</b>]
           </a>; the expanded-name identifies the output
           
           method; the behavior in this case is not specified by this
           
           document.
        </p>
        
        
        
        
        <p>The default for the <code>method</code> attribute is chosen as
           
           follows.  If
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>the root node of the result tree has an element
                 
                 child,
              </p>
           </li>
           
           
           
           
           <li>
              <p>the expanded-name of the first element child of the root node
                 
                 (i.e. the document element) of the result tree has local part
                 
                 <code>html</code> (in any combination of upper and lower case) and a
                 
                 null namespace URI, and
              </p>
           </li>
           
           
           
           
           <li>
              <p>any text nodes preceding the first element child of the root
                 
                 node of the result tree contain only whitespace characters,
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>then the default output method is <code>html</code>; otherwise, the
           
           default output method is <code>xml</code>.  The default output method
           
           should be used if there are no <code>xsl:output</code> elements or if
           
           none of the <code>xsl:output</code> elements specifies a value for the
           
           <code>method</code> attribute.
        </p>
        
        
        
        
        <p>The other attributes on <code>xsl:output</code> provide parameters
           
           for the output method.  The following attributes are allowed:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p><code>version</code> specifies the version of the output
                 
                 method
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>indent</code> specifies whether the XSLT processor may
                 
                 add additional whitespace when outputting the result tree; the value
                 
                 must be <code>yes</code> or <code>no</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>encoding</code> specifies the preferred character
                 
                 encoding that the XSLT processor should use to encode sequences of
                 
                 characters as sequences of bytes; the value of the attribute should be
                 
                 treated case-insensitively; the value must contain only characters in
                 
                 the range #x21 to #x7E (i.e. printable ASCII characters); the value
                 
                 should either be a <code>charset</code> registered with the Internet
                 
                 Assigned Numbers Authority <a href="#IANA">[IANA]</a>, <a href="#RFC2278">[RFC2278]</a> or start with <code>X-</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>media-type</code> specifies the media type (MIME
                 
                 content type) of the data that results from outputting the result
                 
                 tree; the <code>charset</code> parameter should not be specified
                 
                 explicitly; instead, when the top-level media type is
                 
                 <code>text</code>, a <code>charset</code> parameter should be added
                 
                 according to the character encoding actually used by the output
                 
                 method
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>doctype-system</code> specifies the system identifier
                 
                 to be used in the document type declaration
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>doctype-public</code> specifies the public identifier
                 
                 to be used in the document type declaration
              </p>
           </li>
           
           
           
           
           <li>
              <p><code>omit-xml-declaration</code> specifies whether the XSLT
                 
                 processor should output an XML declaration; the value must be
                 
                 <code>yes</code> or <code>no</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>standalone</code> specifies whether the XSLT processor
                 
                 should output a standalone document declaration; the value must be
                 
                 <code>yes</code> or <code>no</code></p>
           </li>
           
           
           
           
           <li>
              <p><code>cdata-section-elements</code> specifies a list of the
                 
                 names of elements whose text node children should be output using
                 
                 CDATA sections
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>The detailed semantics of each attribute will be described
           
           separately for each output method for which it is applicable.  If the
           
           semantics of an attribute are not described for an output method, then
           
           it is not applicable to that output method.
        </p>
        
        
        
        
        <p>A stylesheet may contain multiple <code>xsl:output</code> elements
           
           and may include or import stylesheets that also contain
           
           <code>xsl:output</code> elements.  All the <code>xsl:output</code>
           
           elements occurring in a stylesheet are merged into a single effective
           
           <code>xsl:output</code> element. For the
           
           <code>cdata-section-elements</code> attribute, the effective value is
           
           the union of the specified values.  For other attributes, the
           
           effective value is the specified value with the highest <a href="#dt-import-precedence">import precedence</a>. It is an error
           
           if there is more than one such value for an attribute.  An XSLT
           
           processor may signal the error; if it does not signal the error, if
           
           should recover by using the value that occurs last in the stylesheet.
           
           The values of attributes are defaulted after the
           
           <code>xsl:output</code> elements have been merged; different output
           
           methods may have different default values for an attribute.
        </p>
        
        
        
        
        
        
        <h3><a name="section-XML-Output-Method"></a>16.1 XML Output Method
        </h3>
        
        
        
        
        <p>The <code>xml</code> output method outputs the result tree as a
           
           well-formed XML external general parsed entity. If the root node of
           
           the result tree has a single element node child and no text node
           
           children, then the entity should also be a well-formed XML document
           
           entity. When the entity is referenced within a trivial XML document
           
           wrapper like this
        </p>
        
        
        
        <pre>
  
  &lt;!DOCTYPE doc [
  
  &lt;!ENTITY e SYSTEM "<var>entity-URI</var>">
           
           ]>
           
           &lt;doc>&amp;e;&lt;/doc>
        </pre>
        
        
        
        
        <p>where <code><var>entity-URI</var></code> is a URI for the entity,
           
           then the wrapper
           
           document as a whole should be a well-formed XML document conforming to
           
           the XML Namespaces Recommendation <a href="#XMLNAMES">[XML Names]</a>.  In
           
           addition, the output should be such that if a new tree was constructed
           
           by parsing the wrapper as an XML document as specified in <a href="#data-model">[<b>3 Data Model</b>]
           </a>, and then removing the document element, making its
           
           children instead be children of the root node, then the new tree would
           
           be the same as the result tree, with the following possible
           
           exceptions:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>The order of attributes in the two trees may be
                 
                 different.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The new tree may contain namespace nodes that were not
                 
                 present in the result tree.
              </p>
              
              
              <blockquote><b>NOTE: </b>An XSLT processor may need to add
                 
                 namespace declarations in the course of outputting the result tree as
                 
                 XML.
              </blockquote>
              
              
           </li>
           
           
           
           
        </ul>
        
        
        
        
        <p>If the XSLT processor generated a document type declaration because
           
           of the <code>doctype-system</code> attribute, then the above
           
           requirements apply to the entity with the generated document type
           
           declaration removed.
        </p>
        
        
        
        
        <p>The <code>version</code> attribute specifies the version of XML to
           
           be used for outputting the result tree.  If the XSLT processor does
           
           not support this version of XML, it should use a version of XML that
           
           it does support.  The version output in the XML declaration (if an XML
           
           declaration is output) should correspond to the version of XML that
           
           the processor used for outputting the result tree. The value of the
           
           <code>version</code> attribute should match the <a href="http://www.w3.org/TR/REC-xml#NT-VersionNum">VersionNum</a> production of the XML
           
           Recommendation <a href="#XML">[XML]</a>. The default value is
           
           <code>1.0</code>.
        </p>
        
        
        
        
        <p>The <code>encoding</code> attribute specifies the preferred
           
           encoding to use for outputting the result tree.  XSLT processors are
           
           required to respect values of <code>UTF-8</code> and
           
           <code>UTF-16</code>.  For other values, if the XSLT processor does not
           
           support the specified encoding it may signal an error; if it does not
           
           signal an error it should use <code>UTF-8</code> or
           
           <code>UTF-16</code> instead.  The XSLT processor must not use an
           
           encoding whose name does not match the <a href="http://www.w3.org/TR/REC-xml#NT-EncName">EncName</a> production of the XML
           
           Recommendation <a href="#XML">[XML]</a>.  If no <code>encoding</code>
           
           attribute is specified, then the XSLT processor should use either
           
           <code>UTF-8</code> or <code>UTF-16</code>.  It is possible that the
           
           result tree will contain a character that cannot be represented in the
           
           encoding that the XSLT processor is using for output.  In this case,
           
           if the character occurs in a context where XML recognizes character
           
           references (i.e. in the value of an attribute node or text node), then
           
           the character should be output as a character reference; otherwise
           
           (for example if the character occurs in the name of an element) the
           
           XSLT processor should signal an error.
        </p>
        
        
        
        
        <p>If the <code>indent</code> attribute has the value
           
           <code>yes</code>, then the <code>xml</code> output method may output
           
           whitespace in addition to the whitespace in the result tree (possibly
           
           based on whitespace stripped from either the source document or the
           
           stylesheet) in order to indent the result nicely; if the
           
           <code>indent</code> attribute has the value <code>no</code>, it should
           
           not output any additional whitespace. The default value is
           
           <code>no</code>.  The <code>xml</code> output method should use an
           
           algorithm to output additional whitespace that ensures that the result
           
           if whitespace were to be stripped from the output using the process
           
           described in <a href="#strip">[<b>3.4 Whitespace Stripping</b>]
           </a> with the set of
           
           whitespace-preserving elements consisting of just
           
           <code>xsl:text</code> would be the same when additional whitespace is
           
           output as when additional whitespace is not output.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>It is usually not safe to use <code>indent="yes"</code> with
           
           document types that include element types with mixed content.
        </blockquote>
        
        
        
        
        <p>The <code>cdata-section-elements</code> attribute contains a
           
           whitespace-separated list of <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>s.  Each <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> is expanded into an
           
           expanded-name using the namespace declarations in effect on the
           
           <code>xsl:output</code> element in which the <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a> occurs; if there is a default
           
           namespace, it is used for <a href="http://www.w3.org/TR/REC-xml-names#NT-QName">QName</a>s
           
           that do not have a prefix.  The expansion is performed before the
           
           merging of multiple <code>xsl:output</code> elements into a single
           
           effective <code>xsl:output</code> element. If the expanded-name of the
           
           parent of a text node is a member of the list, then the text node
           
           should be output as a CDATA section. For example,
        </p>
        
        
        
        <pre>&lt;xsl:output cdata-section-elements="example"/></pre>
        
        
        
        <p>would cause a literal result element written in the stylesheet as</p>
        
        
        
        <pre>&lt;example>&amp;lt;foo>&lt;/example></pre>
        
        
        
        <p>or as</p>
        
        
        
        <pre>&lt;example>&lt;![CDATA[&lt;foo>]]>&lt;/example></pre>
        
        
        
        <p>to be output as</p>
        
        
        
        <pre>&lt;example>&lt;![CDATA[&lt;foo>]]>&lt;/example></pre>
        
        
        
        <p>If the text node contains the sequence of characters
           
           <code>]]></code>, then the currently open CDATA section should be
           
           closed following the <code>]]</code> and a new CDATA section opened
           
           before the <code>></code>. For example, a literal result element
           
           written in the stylesheet as
        </p>
        
        
        
        <pre>&lt;example>]]&amp;gt;&lt;/example></pre>
        
        
        
        <p>would be output as</p>
        
        
        
        <pre>&lt;example>&lt;![CDATA[]]]]>&lt;![CDATA[>]]>&lt;/example></pre>
        
        
        
        <p>If the text node contains a character that is not representable in
           
           the character encoding being used to output the result tree, then the
           
           currently open CDATA section should be closed before the character,
           
           the character should be output using a character reference or entity
           
           reference, and a new CDATA section should be opened for any further
           
           characters in the text node.
        </p>
        
        
        
        
        <p>CDATA sections should not be used except for text nodes that the
           
           <code>cdata-section-elements</code> attribute explicitly specifies
           
           should be output using CDATA sections.
        </p>
        
        
        
        
        <p>The <code>xml</code> output method should output an XML declaration
           
           unless the <code>omit-xml-declaration</code> attribute has the value
           
           <code>yes</code>. The XML declaration should include both version
           
           information and an encoding declaration. If the
           
           <code>standalone</code> attribute is specified, it should include a
           
           standalone document declaration with the same value as the value as
           
           the value of the <code>standalone</code> attribute.  Otherwise, it
           
           should not include a standalone document declaration; this ensures
           
           that it is both a XML declaration (allowed at the beginning of a
           
           document entity) and a text declaration (allowed at the beginning of
           
           an external general parsed entity).
        </p>
        
        
        
        
        <p>If the <code>doctype-system</code> attribute is specified, the
           
           <code>xml</code> output method should output a document type
           
           declaration immediately before the first element.  The name following
           
           <code>&lt;!DOCTYPE</code> should be the name of the first element.  If
           
           <code>doctype-public</code> attribute is also specified, then the
           
           <code>xml</code> output method should output <code>PUBLIC</code>
           
           followed by the public identifier and then the system identifier;
           
           otherwise, it should output <code>SYSTEM</code> followed by the system
           
           identifier.  The internal subset should be empty.  The
           
           <code>doctype-public</code> attribute should be ignored unless the
           
           <code>doctype-system</code> attribute is specified.
        </p>
        
        
        
        
        <p>The <code>media-type</code> attribute is applicable for the
           
           <code>xml</code> output method.  The default value for the
           
           <code>media-type</code> attribute is <code>text/xml</code>.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-HTML-Output-Method"></a>16.2 HTML Output Method
        </h3>
        
        
        
        
        <p>The <code>html</code> output method outputs the result tree as
           
           HTML; for example,
        </p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
  
  &lt;xsl:output method="html"/>
  
  
  
  &lt;xsl:template match="/">
  
    &lt;html>
  
     &lt;xsl:apply-templates/>
  
    &lt;/html>
  
  &lt;/xsl:template>
  
  
  
  ...
  
  
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>The <code>version</code> attribute indicates the version of the
           
           HTML.  The default value is <code>4.0</code>, which specifies that the
           
           result should be output as HTML conforming to the HTML 4.0
           
           Recommendation <a href="#HTML">[HTML]</a>.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should not output an element
           
           differently from the <code>xml</code> output method unless the
           
           expanded-name of the element has a null namespace URI; an element
           
           whose expanded-name has a non-null namespace URI should be output as
           
           XML.  If the expanded-name of the element has a null namespace URI,
           
           but the local part of the expanded-name is not recognized as the name
           
           of an HTML element, the element should output in the same way as a
           
           non-empty, inline element such as <code>span</code>.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should not output an end-tag
           
           for empty elements.  For HTML 4.0, the empty elements are
           
           <code>area</code>, <code>base</code>, <code>basefont</code>,
           
           <code>br</code>, <code>col</code>, <code>frame</code>,
           
           <code>hr</code>, <code>img</code>, <code>input</code>,
           
           <code>isindex</code>, <code>link</code>, <code>meta</code> and
           
           <code>param</code>. For example, an element written as
           
           <code>&lt;br/></code> or <code>&lt;br>&lt;/br></code> in the
           
           stylesheet should be output as <code>&lt;br></code>.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should recognize the names of
           
           HTML elements regardless of case.  For example, elements named
           
           <code>br</code>, <code>BR</code> or <code>Br</code> should all be
           
           recognized as the HTML <code>br</code> element and output without an
           
           end-tag.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should not perform escaping for
           
           the content of the <code>script</code> and <code>style</code>
           
           elements. For example, a literal result element written in the
           
           stylesheet as
        </p>
        
        
        
        <pre>&lt;script>if (a &amp;lt; b) foo()&lt;/script></pre>
        
        
        
        <p>or</p>
        
        
        
        <pre>&lt;script>&lt;![CDATA[if (a &lt; b) foo()]]>&lt;/script></pre>
        
        
        
        <p>should be output as</p>
        
        
        
        <pre>&lt;script>if (a &lt; b) foo()&lt;/script></pre>
        
        
        
        <p>The <code>html</code> output method should not escape
           
           <code>&lt;</code> characters occurring in attribute values.
        </p>
        
        
        
        
        <p>If the <code>indent</code> attribute has the value
           
           <code>yes</code>, then the <code>html</code> output method may add or
           
           remove whitespace as it outputs the result tree, so long as it does
           
           not change how an HTML user agent would render the output.  The
           
           default value is <code>yes</code>.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should escape non-ASCII
           
           characters in URI attribute values using the method recommended in
           
           <a href="http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1">Section
              
              B.2.1
           </a> of the HTML 4.0 Recommendation.
        </p>
        
        
        
        
        <p>The <code>html</code> output method may output a character using a
           
           character entity reference, if one is defined for it in the version of
           
           HTML that the output method is using.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should terminate processing
           
           instructions with <code>></code> rather than
           
           <code>?></code>.
        </p>
        
        
        
        
        <p>The <code>html</code> output method should output boolean
           
           attributes (that is attributes with only a single allowed value that
           
           is equal to the name of the attribute) in minimized form. For example,
           
           a start-tag written in the stylesheet as
        </p>
        
        
        
        <pre>&lt;OPTION selected="selected"></pre>
        
        
        
        <p>should be output as</p>
        
        
        
        <pre>&lt;OPTION selected></pre>
        
        
        
        <p>The <code>html</code> output method should not escape a
           
           <code>&amp;</code> character occurring in an attribute value
           
           immediately followed by a <code>{</code> character (see <a href="http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.7.1.1">Section
              
              B.7.1
           </a> of the HTML 4.0 Recommendation). For example, a start-tag
           
           written in the stylesheet as
        </p>
        
        
        
        <pre>&lt;BODY bgcolor='&amp;amp;{{randomrbg}};'></pre>
        
        
        
        <p>should be output as</p>
        
        
        
        <pre>&lt;BODY bgcolor='&amp;{randomrbg};'></pre>
        
        
        
        <p>The <code>encoding</code> attribute specifies the preferred
           
           encoding to be used. If there is a <code>HEAD</code> element, then the
           
           <code>html</code> output method should add a <code>META</code> element
           
           immediately after the start-tag of the <code>HEAD</code> element
           
           specifying the character encoding actually used. For example,
        </p>
        
        
        
        <pre>&lt;HEAD>
  
  &lt;META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
  
  ...</pre>
        
        
        
        <p>It is possible that the result tree will contain a character that
           
           cannot be represented in the encoding that the XSLT processor is using
           
           for output.  In this case, if the character occurs in a context where
           
           HTML recognizes character references, then the character should be
           
           output as a character entity reference or decimal numeric character
           
           reference; otherwise (for example, in a
           
           <code>script</code> or <code>style</code> element or in a comment),
           
           the XSLT processor should signal an error.
        </p>
        
        
        
        
        <p>If the <code>doctype-public</code> or <code>doctype-system</code>
           
           attributes are specified, then the <code>html</code> output method
           
           should output a document type declaration immediately before the first
           
           element.  The name following <code>&lt;!DOCTYPE</code> should be
           
           <code>HTML</code> or <code>html</code>.  If the
           
           <code>doctype-public</code> attribute is specified, then the output
           
           method should output <code>PUBLIC</code> followed by the specified
           
           public identifier; if the <code>doctype-system</code> attribute is
           
           also specified, it should also output the specified system identifier
           
           following the public identifier.  If the <code>doctype-system</code>
           
           attribute is specified but the <code>doctype-public</code> attribute
           
           is not specified, then the output method should output
           
           <code>SYSTEM</code> followed by the specified system identifier.
        </p>
        
        
        
        
        <p>The <code>media-type</code> attribute is applicable for the
           
           <code>html</code> output method.  The default value is
           
           <code>text/html</code>.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="section-Text-Output-Method"></a>16.3 Text Output Method
        </h3>
        
        
        
        
        <p>The <code>text</code> output method outputs the result tree by
           
           outputting the string-value of every text node in the result tree in
           
           document order without any escaping.
        </p>
        
        
        
        
        <p>The <code>media-type</code> attribute is applicable for the
           
           <code>text</code> output method.  The default value for the
           
           <code>media-type</code> attribute is <code>text/plain</code>.
        </p>
        
        
        
        
        <p>The <code>encoding</code> attribute identifies the encoding that
           
           the <code>text</code> output method should use to convert sequences of
           
           characters to sequences of bytes.  The default is system-dependent. If
           
           the result tree contains a character that cannot be represented in the
           
           encoding that the XSLT processor is using for output, the XSLT
           
           processor should signal an error.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h3><a name="disable-output-escaping"></a>16.4 Disabling Output Escaping
        </h3>
        
        
        
        
        <p>Normally, the <code>xml</code> output method escapes &amp; and &lt;
           
           (and possibly other characters) when outputting text nodes.  This
           
           ensures that the output is well-formed XML. However, it is sometimes
           
           convenient to be able to produce output that is almost, but not quite
           
           well-formed XML; for example, the output may include ill-formed
           
           sections which are intended to be transformed into well-formed XML by
           
           a subsequent non-XML aware process.  For this reason, XSLT provides a
           
           mechanism for disabling output escaping. An <code>xsl:value-of</code>
           
           or <code>xsl:text</code> element may have a
           
           <code>disable-output-escaping</code> attribute; the allowed values are
           
           <code>yes</code> or <code>no</code>; the default is <code>no</code>;
           
           if the value is <code>yes</code>, then a text node generated by
           
           instantiating the <code>xsl:value-of</code> or <code>xsl:text</code>
           
           element should be output without any escaping. For example,
        </p>
        
        
        
        <pre>&lt;xsl:text disable-output-escaping="yes">&amp;lt;&lt;/xsl:text></pre>
        
        
        
        <p>should generate the single character <code>&lt;</code>.
        </p>
        
        
        
        
        <p>It is an error for output escaping to be disabled for a text node
           
           that is used for something other than a text node in the result tree.
           
           Thus, it is an error to disable output escaping for an
           
           <code>xsl:value-of</code> or <code>xsl:text</code> element that is
           
           used to generate the string-value of a comment, processing instruction
           
           or attribute node; it is also an error to convert a <a href="#dt-result-tree-fragment">result tree fragment</a> to a
           
           number or a string if the result tree fragment contains a text node for
           
           which escaping was disabled.  In both cases, an XSLT processor may
           
           signal the error; if it does not signal the error, it must recover by
           
           ignoring the <code>disable-output-escaping</code> attribute.
        </p>
        
        
        
        
        <p>The <code>disable-output-escaping</code> attribute may be used with
           
           the <code>html</code> output method as well as with the
           
           <code>xml</code> output method.  The <code>text</code> output method
           
           ignores the <code>disable-output-escaping</code> attribute, since it
           
           does not perform any output escaping.
        </p>
        
        
        
        
        <p>An XSLT processor will only be able to disable output escaping if
           
           it controls how the result tree is output. This may not always be the
           
           case.  For example, the result tree may be used as the source tree for
           
           another XSLT transformation instead of being output.  An XSLT
           
           processor is not required to support disabling output escaping.  If an
           
           <code>xsl:value-of</code> or <code>xsl:text</code> specifies that
           
           output escaping should be disabled and the XSLT processor does not
           
           support this, the XSLT processor may signal an error; if it does not
           
           signal an error, it must recover by not disabling output escaping.
        </p>
        
        
        
        
        <p>If output escaping is disabled for a character that is not
           
           representable in the encoding that the XSLT processor is using for
           
           output, then the XSLT processor may signal an error; if it does not
           
           signal an error, it must recover by not disabling output escaping.
        </p>
        
        
        
        
        <p>Since disabling output escaping may not work with all XSLT
           
           processors and can result in XML that is not well-formed, it should be
           
           used only when there is no alternative.
        </p>
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="conformance"></a>17 Conformance
        </h2>
        
        
        
        
        <p>A conforming XSLT processor must be able to use a stylesheet to
           
           transform a source tree into a result tree as specified in this
           
           document.  A conforming XSLT processor need not be able to output the
           
           result in XML or in any other form.
        </p>
        
        
        
        
        <blockquote><b>NOTE: </b>Vendors of XSLT processors are strongly encouraged to provide
           
           a way to verify that their processor is behaving conformingly by
           
           allowing the result tree to be output as XML or by providing access to
           
           the result tree through a standard API such as the DOM or
           
           SAX.
        </blockquote>
        
        
        
        
        <p>A conforming XSLT processor must signal any errors except for those
           
           that this document specifically allows an XSLT processor not to
           
           signal. A conforming XSLT processor may but need not recover from any
           
           errors that it signals.
        </p>
        
        
        
        
        <p>A conforming XSLT processor may impose limits on the processing
           
           resources consumed by the processing of a stylesheet.
        </p>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="notation"></a>18 Notation
        </h2>
        
        
        
        
        <p>The specification of each XSLT-defined element type is preceded by
           
           a summary of its syntax in the form of a model for elements of that
           
           element type.  The meaning of syntax summary notation is as
           
           follows:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>An attribute is required if and only if its name is in
                 
                 bold.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The string that occurs in the place of an attribute value
                 
                 specifies the allowed values of the attribute.  If this is surrounded
                 
                 by curly braces, then the attribute value is treated as an <a href="#dt-attribute-value-template">attribute value template</a>,
                 
                 and the string occurring within curly braces specifies the allowed
                 
                 values of the result of instantiating the attribute value template.
                 
                 Alternative allowed values are separated by <code>|</code>.  A quoted
                 
                 string indicates a value equal to that specific string. An unquoted,
                 
                 italicized name specifies a particular type of value.
              </p>
           </li>
           
           
           
           
           <li>
              <p>If the element is allowed not to be empty, then the element
                 
                 contains a comment specifying the allowed content.  The allowed
                 
                 content is specified in a similar way to an element type declaration
                 
                 in XML; <i>template</i> means that any mixture of text nodes,
                 
                 literal result elements, extension elements, and XSLT elements from
                 
                 the <code>instruction</code> category is allowed;
                 
                 <i>top-level-elements</i> means that any mixture of XSLT
                 
                 elements from the <code>top-level-element</code> category is
                 
                 allowed.
              </p>
           </li>
           
           
           
           
           <li>
              <p>The element is prefaced by comments indicating if it belongs
                 
                 to the <code>instruction</code> category or
                 
                 <code>top-level-element</code> category or both.  The category of an
                 
                 element just affects whether it is allowed in the content of elements
                 
                 that allow a <i>template</i> or
                 
                 <i>top-level-elements</i>.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        
        
        <hr title="Separator from footer">
        
        
        
        
        <h2><a name="section-References"></a>A References
        </h2>
        
        
        
        
        <h3><a name="section-Normative-References"></a>A.1 Normative References
        </h3>
        
        
        
        
        <dl>
           
           
           
           
           <dt><a name="XML">XML</a></dt>
           <dd>World Wide Web Consortium. <i>Extensible
                 
                 Markup Language (XML) 1.0.
              </i> W3C Recommendation. See <a href="http://www.w3.org/TR/1998/REC-xml-19980210">http://www.w3.org/TR/1998/REC-xml-19980210</a></dd>
           
           
           
           
           <dt><a name="XMLNAMES">XML Names</a></dt>
           <dd>World Wide Web
              
              Consortium. <i>Namespaces in XML.</i> W3C Recommendation. See
              
              <a href="http://www.w3.org/TR/REC-xml-names">http://www.w3.org/TR/REC-xml-names</a></dd>
           
           
           
           
           <dt><a name="XPATH">XPath</a></dt>
           <dd>World Wide Web Consortium. <i>XML Path
                 
                 Language.
              </i> W3C Recommendation. See <a href="http://www.w3.org/TR/xpath">http://www.w3.org/TR/xpath</a></dd>
           
           
           
           
        </dl>
        
        
        
        
        
        
        <h3><a name="section-Other-References"></a>A.2 Other References
        </h3>
        
        
        
        
        <dl>
           
           
           
           
           <dt><a name="CSS2">CSS2</a></dt>
           <dd>World Wide Web Consortium.  <i>Cascading
                 
                 Style Sheets, level 2 (CSS2)
              </i>.  W3C Recommendation.  See <a href="http://www.w3.org/TR/1998/REC-CSS2-19980512">http://www.w3.org/TR/1998/REC-CSS2-19980512</a></dd>
           
           
           
           
           <dt><a name="DSSSL">DSSSL</a></dt>
           <dd>International Organization
              
              for Standardization, International Electrotechnical Commission.
              
              <i>ISO/IEC 10179:1996.  Document Style Semantics and Specification
                 
                 Language (DSSSL)
              </i>.  International Standard.
           </dd>
           
           
           
           
           <dt><a name="HTML">HTML</a></dt>
           <dd>World Wide Web Consortium. <i>HTML 4.0
                 
                 specification
              </i>. W3C Recommendation. See <a href="http://www.w3.org/TR/REC-html40">http://www.w3.org/TR/REC-html40</a></dd>
           
           
           
           
           <dt><a name="IANA">IANA</a></dt>
           <dd>Internet Assigned Numbers
              
              Authority. <i>Character Sets</i>. See <a href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</a>.
           </dd>
           
           
           
           
           <dt><a name="RFC2278">RFC2278</a></dt>
           <dd>N. Freed, J. Postel.  <i>IANA
                 
                 Charset Registration Procedures
              </i>.  IETF RFC 2278. See <a href="http://www.ietf.org/rfc/rfc2278.txt">http://www.ietf.org/rfc/rfc2278.txt</a>.
           </dd>
           
           
           
           
           <dt><a name="RFC2376">RFC2376</a></dt>
           <dd>E. Whitehead, M. Murata.  <i>XML
                 
                 Media Types
              </i>. IETF RFC 2376. See <a href="http://www.ietf.org/rfc/rfc2376.txt">http://www.ietf.org/rfc/rfc2376.txt</a>.
           </dd>
           
           
           
           
           <dt><a name="RFC2396">RFC2396</a></dt>
           <dd>T. Berners-Lee, R. Fielding, and
              
              L. Masinter.  <i>Uniform Resource Identifiers (URI): Generic
                 
                 Syntax
              </i>. IETF RFC 2396. See <a href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a>.
           </dd>
           
           
           
           
           <dt><a name="UNICODE-TR10">UNICODE TR10</a></dt>
           <dd>Unicode Consortium.
              
              <i>Unicode Technical Report #10. Unicode Collation
                 
                 Algorithm
              </i>.  Unicode Technical Report.  See <a href="http://www.unicode.org/unicode/reports/tr10/index.html">http://www.unicode.org/unicode/reports/tr10/index.html</a>.
           </dd>
           
           
           
           
           <dt><a name="XHTML">XHTML</a></dt>
           <dd>World Wide Web Consortium. <i>XHTML
                 
                 1.0: The Extensible HyperText Markup Language.
              </i> W3C Proposed
              
              Recommendation. See <a href="http://www.w3.org/TR/xhtml1">http://www.w3.org/TR/xhtml1</a></dd>
           
           
           
           
           <dt><a name="XPTR">XPointer</a></dt>
           <dd>World Wide Web
              
              Consortium. <i>XML Pointer Language (XPointer).</i> W3C Working
              
              Draft. See <a href="http://www.w3.org/TR/xptr">http://www.w3.org/TR/xptr</a></dd>
           
           
           
           
           <dt><a name="XMLSTYLE">XML Stylesheet</a></dt>
           <dd>World Wide Web
              
              Consortium. <i>Associating stylesheets with XML documents.</i>
              
              W3C Recommendation. See <a href="http://www.w3.org/TR/xml-stylesheet">http://www.w3.org/TR/xml-stylesheet</a></dd>
           
           
           
           
           <dt><a name="XSL">XSL</a></dt>
           <dd>World Wide Web Consortium.  <i>Extensible
                 
                 Stylesheet Language (XSL).
              </i>  W3C Working Draft.  See <a href="http://www.w3.org/TR/WD-xsl">http://www.w3.org/TR/WD-xsl</a></dd>
           
           
           
           
        </dl>
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="element-syntax-summary"></a>B Element Syntax Summary
        </h2>
        
        
        
        
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-apply-imports">xsl:apply-imports</a>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-apply-templates">xsl:apply-templates</a><br>&nbsp;&nbsp;select = <var>node-set-expression</var><br>&nbsp;&nbsp;mode = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-sort">xsl:sort</a> | <a href="#element-with-param">xsl:with-param</a>)* --><br>&lt;/xsl:apply-templates>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-attribute">xsl:attribute</a><br>&nbsp;&nbsp;<b>name</b> = { <var>qname</var> }<br>&nbsp;&nbsp;namespace = { <var>uri-reference</var> }><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:attribute>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-attribute-set">xsl:attribute-set</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <a href="#element-attribute">xsl:attribute</a>* --><br>&lt;/xsl:attribute-set>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-call-template">xsl:call-template</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: <a href="#element-with-param">xsl:with-param</a>* --><br>&lt;/xsl:call-template>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-choose">xsl:choose</a>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-when">xsl:when</a>+, <a href="#element-otherwise">xsl:otherwise</a>?) --><br>&lt;/xsl:choose>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-comment">xsl:comment</a>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:comment>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-copy">xsl:copy</a><br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:copy>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-copy-of">xsl:copy-of</a><br>&nbsp;&nbsp;<b>select</b> = <var>expression</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-decimal-format">xsl:decimal-format</a><br>&nbsp;&nbsp;name = <var>qname</var><br>&nbsp;&nbsp;decimal-separator = <var>char</var><br>&nbsp;&nbsp;grouping-separator = <var>char</var><br>&nbsp;&nbsp;infinity = <var>string</var><br>&nbsp;&nbsp;minus-sign = <var>char</var><br>&nbsp;&nbsp;NaN = <var>string</var><br>&nbsp;&nbsp;percent = <var>char</var><br>&nbsp;&nbsp;per-mille = <var>char</var><br>&nbsp;&nbsp;zero-digit = <var>char</var><br>&nbsp;&nbsp;digit = <var>char</var><br>&nbsp;&nbsp;pattern-separator = <var>char</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-element">xsl:element</a><br>&nbsp;&nbsp;<b>name</b> = { <var>qname</var> }<br>&nbsp;&nbsp;namespace = { <var>uri-reference</var> }<br>&nbsp;&nbsp;use-attribute-sets = <var>qnames</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:element>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-fallback">xsl:fallback</a>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:fallback>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-for-each">xsl:for-each</a><br>&nbsp;&nbsp;<b>select</b> = <var>node-set-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-sort">xsl:sort</a>*, <var>template</var>) --><br>&lt;/xsl:for-each>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-if">xsl:if</a><br>&nbsp;&nbsp;<b>test</b> = <var>boolean-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:if>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-import">xsl:import</a><br>&nbsp;&nbsp;<b>href</b> = <var>uri-reference</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-include">xsl:include</a><br>&nbsp;&nbsp;<b>href</b> = <var>uri-reference</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-key">xsl:key</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;<b>match</b> = <var>pattern</var><br>&nbsp;&nbsp;<b>use</b> = <var>expression</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-message">xsl:message</a><br>&nbsp;&nbsp;terminate = "yes" | "no"><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:message>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-namespace-alias">xsl:namespace-alias</a><br>&nbsp;&nbsp;<b>stylesheet-prefix</b> = <var>prefix</var> | "#default"<br>&nbsp;&nbsp;<b>result-prefix</b> = <var>prefix</var> | "#default"&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-number">xsl:number</a><br>&nbsp;&nbsp;level = "single" | "multiple" | "any"<br>&nbsp;&nbsp;count = <var>pattern</var><br>&nbsp;&nbsp;from = <var>pattern</var><br>&nbsp;&nbsp;value = <var>number-expression</var><br>&nbsp;&nbsp;format = { <var>string</var> }<br>&nbsp;&nbsp;lang = { <var>nmtoken</var> }<br>&nbsp;&nbsp;letter-value = { "alphabetic" | "traditional" }<br>&nbsp;&nbsp;grouping-separator = { <var>char</var> }<br>&nbsp;&nbsp;grouping-size = { <var>number</var> }&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-otherwise">xsl:otherwise</a>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:otherwise>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-output">xsl:output</a><br>&nbsp;&nbsp;method = "xml" | "html" | "text" | <var>qname-but-not-ncname</var><br>&nbsp;&nbsp;version = <var>nmtoken</var><br>&nbsp;&nbsp;encoding = <var>string</var><br>&nbsp;&nbsp;omit-xml-declaration = "yes" | "no"<br>&nbsp;&nbsp;standalone = "yes" | "no"<br>&nbsp;&nbsp;doctype-public = <var>string</var><br>&nbsp;&nbsp;doctype-system = <var>string</var><br>&nbsp;&nbsp;cdata-section-elements = <var>qnames</var><br>&nbsp;&nbsp;indent = "yes" | "no"<br>&nbsp;&nbsp;media-type = <var>string</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-param">xsl:param</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:param>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-preserve-space">xsl:preserve-space</a><br>&nbsp;&nbsp;<b>elements</b> = <var>tokens</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-processing-instruction">xsl:processing-instruction</a><br>&nbsp;&nbsp;<b>name</b> = { <var>ncname</var> }><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:processing-instruction>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-sort">xsl:sort</a><br>&nbsp;&nbsp;select = <var>string-expression</var><br>&nbsp;&nbsp;lang = { <var>nmtoken</var> }<br>&nbsp;&nbsp;data-type = { "text" | "number" | <var>qname-but-not-ncname</var> }<br>&nbsp;&nbsp;order = { "ascending" | "descending" }<br>&nbsp;&nbsp;case-order = { "upper-first" | "lower-first" }&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-strip-space">xsl:strip-space</a><br>&nbsp;&nbsp;<b>elements</b> = <var>tokens</var>&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-stylesheet">xsl:stylesheet</a><br>&nbsp;&nbsp;id = <var>id</var><br>&nbsp;&nbsp;extension-element-prefixes = <var>tokens</var><br>&nbsp;&nbsp;exclude-result-prefixes = <var>tokens</var><br>&nbsp;&nbsp;<b>version</b> = <var>number</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-import">xsl:import</a>*, <var>top-level-elements</var>) --><br>&lt;/xsl:stylesheet>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;<a href="#element-template">xsl:template</a><br>&nbsp;&nbsp;match = <var>pattern</var><br>&nbsp;&nbsp;name = <var>qname</var><br>&nbsp;&nbsp;priority = <var>number</var><br>&nbsp;&nbsp;mode = <var>qname</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-param">xsl:param</a>*, <var>template</var>) --><br>&lt;/xsl:template>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-text">xsl:text</a><br>&nbsp;&nbsp;disable-output-escaping = "yes" | "no"><br>&nbsp;&nbsp;&lt;!-- Content: #PCDATA --><br>&lt;/xsl:text>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-transform">xsl:transform</a><br>&nbsp;&nbsp;id = <var>id</var><br>&nbsp;&nbsp;extension-element-prefixes = <var>tokens</var><br>&nbsp;&nbsp;exclude-result-prefixes = <var>tokens</var><br>&nbsp;&nbsp;<b>version</b> = <var>number</var>><br>&nbsp;&nbsp;&lt;!-- Content: (<a href="#element-import">xsl:import</a>*, <var>top-level-elements</var>) --><br>&lt;/xsl:transform>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: instruction --><br>&lt;<a href="#element-value-of">xsl:value-of</a><br>&nbsp;&nbsp;<b>select</b> = <var>string-expression</var><br>&nbsp;&nbsp;disable-output-escaping = "yes" | "no"&nbsp;/>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;!-- Category: top-level-element --><br>&lt;!-- Category: instruction --><br>&lt;<a href="#element-variable">xsl:variable</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:variable>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-when">xsl:when</a><br>&nbsp;&nbsp;<b>test</b> = <var>boolean-expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:when>
           </code>
        </p>
        <p class="element-syntax-summary"><code>&lt;<a href="#element-with-param">xsl:with-param</a><br>&nbsp;&nbsp;<b>name</b> = <var>qname</var><br>&nbsp;&nbsp;select = <var>expression</var>><br>&nbsp;&nbsp;&lt;!-- Content: <var>template</var> --><br>&lt;/xsl:with-param>
           </code>
        </p>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="dtd"></a>C DTD Fragment for XSLT Stylesheets (Non-Normative)
        </h2>
        
        
        
        
        <blockquote><b>NOTE: </b>This DTD Fragment is not normative because XML 1.0 DTDs do
           
           not support XML Namespaces and thus cannot correctly describe the
           
           allowed structure of an XSLT stylesheet.
        </blockquote>
        
        
        
        
        <p>The following entity can be used to construct a DTD for XSLT
           
           stylesheets that create instances of a particular result DTD.  Before
           
           referencing the entity, the stylesheet DTD must define a
           
           <code>result-elements</code> parameter entity listing the allowed
           
           result element types.  For example:
        </p>
        
        
        
        <pre>&lt;!ENTITY % result-elements "
  
    | fo:inline-sequence
  
    | fo:block
  
  "></pre>
        
        
        
        <p>Such result elements should be declared to have
           
           <code>xsl:use-attribute-sets</code> and
           
           <code>xsl:extension-element-prefixes</code> attributes.  The following
           
           entity declares the <code>result-element-atts</code> parameter for
           
           this purpose. The content that XSLT allows for result elements is the
           
           same as it allows for the XSLT elements that are declared in the
           
           following entity with a content model of <code>%template;</code>.  The
           
           DTD may use a more restrictive content model than
           
           <code>%template;</code> to reflect the constraints of the result
           
           DTD.
        </p>
        
        
        
        
        <p>The DTD may define the <code>non-xsl-top-level</code> parameter
           
           entity to allow additional top-level elements from namespaces other
           
           than the XSLT namespace.
        </p>
        
        
        
        
        <p>The use of the <code>xsl:</code> prefix in this DTD does not imply
           
           that XSLT stylesheets are required to use this prefix.  Any of the
           
           elements declared in this DTD may have attributes whose name starts
           
           with <code>xmlns:</code> or is equal to <code>xmlns</code> in addition
           
           to the attributes declared in this DTD.
        </p>
        
        
        
        <pre>&lt;!ENTITY % char-instructions "
  
    | xsl:apply-templates
  
    | xsl:call-template
  
    | xsl:apply-imports
  
    | xsl:for-each
  
    | xsl:value-of
  
    | xsl:copy-of
  
    | xsl:number
  
    | xsl:choose
  
    | xsl:if
  
    | xsl:text
  
    | xsl:copy
  
    | xsl:variable
  
    | xsl:message
  
    | xsl:fallback
  
  ">
  
  
  
  &lt;!ENTITY % instructions "
  
    %char-instructions;
  
    | xsl:processing-instruction
  
    | xsl:comment
  
    | xsl:element
  
    | xsl:attribute
  
  ">
  
  
  
  &lt;!ENTITY % char-template "
  
   (#PCDATA
  
    %char-instructions;)*
  
  ">
  
  
  
  &lt;!ENTITY % template "
  
   (#PCDATA
  
    %instructions;
  
    %result-elements;)*
  
  ">
  
  
  
  &lt;!-- Used for the type of an attribute value that is a URI reference.-->
  
  &lt;!ENTITY % URI "CDATA">
  
  
  
  &lt;!-- Used for the type of an attribute value that is a pattern.-->
  
  &lt;!ENTITY % pattern "CDATA">
  
  
  
  &lt;!-- Used for the type of an attribute value that is an
  
       attribute value template.-->
  
  &lt;!ENTITY % avt "CDATA">
  
  
  
  &lt;!-- Used for the type of an attribute value that is a QName; the prefix
  
       gets expanded by the XSLT processor. -->
  
  &lt;!ENTITY % qname "NMTOKEN">
  
  
  
  &lt;!-- Like qname but a whitespace-separated list of QNames. -->
  
  &lt;!ENTITY % qnames "NMTOKENS">
  
  
  
  &lt;!-- Used for the type of an attribute value that is an expression.-->
  
  &lt;!ENTITY % expr "CDATA">
  
  
  
  &lt;!-- Used for the type of an attribute value that consists
  
       of a single character.-->
  
  &lt;!ENTITY % char "CDATA">
  
  
  
  &lt;!-- Used for the type of an attribute value that is a priority. -->
  
  &lt;!ENTITY % priority "NMTOKEN">
  
  
  
  &lt;!ENTITY % space-att "xml:space (default|preserve) #IMPLIED">
  
  
  
  &lt;!-- This may be overridden to customize the set of elements allowed
  
  at the top-level. -->
  
  
  
  &lt;!ENTITY % non-xsl-top-level "">
  
  
  
  &lt;!ENTITY % top-level "
  
   (xsl:import*,
  
    (xsl:include
  
    | xsl:strip-space
  
    | xsl:preserve-space
  
    | xsl:output
  
    | xsl:key
  
    | xsl:decimal-format
  
    | xsl:attribute-set
  
    | xsl:variable
  
    | xsl:param
  
    | xsl:template
  
    | xsl:namespace-alias
  
    %non-xsl-top-level;)*)
  
  ">
  
  
  
  &lt;!ENTITY % top-level-atts '
  
    extension-element-prefixes CDATA #IMPLIED
  
    exclude-result-prefixes CDATA #IMPLIED
  
    id ID #IMPLIED
  
    version NMTOKEN #REQUIRED
  
    xmlns:xsl CDATA #FIXED "http://www.w3.org/1999/XSL/Transform"
  
    %space-att;
  
  '>
  
  
  
  &lt;!-- This entity is defined for use in the ATTLIST declaration
  
  for result elements. -->
  
  
  
  &lt;!ENTITY % result-element-atts '
  
    xsl:extension-element-prefixes CDATA #IMPLIED
  
    xsl:exclude-result-prefixes CDATA #IMPLIED
  
    xsl:use-attribute-sets %qnames; #IMPLIED
  
    xsl:version NMTOKEN #IMPLIED
  
  '>
  
  
  
  &lt;!ELEMENT xsl:stylesheet %top-level;>
  
  &lt;!ATTLIST xsl:stylesheet %top-level-atts;>
  
  
  
  &lt;!ELEMENT xsl:transform %top-level;>
  
  &lt;!ATTLIST xsl:transform %top-level-atts;>
  
  
  
  &lt;!ELEMENT xsl:import EMPTY>
  
  &lt;!ATTLIST xsl:import href %URI; #REQUIRED>
  
  
  
  &lt;!ELEMENT xsl:include EMPTY>
  
  &lt;!ATTLIST xsl:include href %URI; #REQUIRED>
  
  
  
  &lt;!ELEMENT xsl:strip-space EMPTY>
  
  &lt;!ATTLIST xsl:strip-space elements CDATA #REQUIRED>
  
  
  
  &lt;!ELEMENT xsl:preserve-space EMPTY>
  
  &lt;!ATTLIST xsl:preserve-space elements CDATA #REQUIRED>
  
  
  
  &lt;!ELEMENT xsl:output EMPTY>
  
  &lt;!ATTLIST xsl:output
  
    method %qname; #IMPLIED
  
    version NMTOKEN #IMPLIED
  
    encoding CDATA #IMPLIED
  
    omit-xml-declaration (yes|no) #IMPLIED
  
    standalone (yes|no) #IMPLIED
  
    doctype-public CDATA #IMPLIED
  
    doctype-system CDATA #IMPLIED
  
    cdata-section-elements %qnames; #IMPLIED
  
    indent (yes|no) #IMPLIED
  
    media-type CDATA #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:key EMPTY>
  
  &lt;!ATTLIST xsl:key
  
    name %qname; #REQUIRED
  
    match %pattern; #REQUIRED
  
    use %expr; #REQUIRED
  
  >
  
  
  
  &lt;!ELEMENT xsl:decimal-format EMPTY>
  
  &lt;!ATTLIST xsl:decimal-format
  
    name %qname; #IMPLIED
  
    decimal-separator %char; "."
  
    grouping-separator %char; ","
  
    infinity CDATA "Infinity"
  
    minus-sign %char; "-"
  
    NaN CDATA "NaN"
  
    percent %char; "%"
  
    per-mille %char; "&amp;#x2030;"
  
    zero-digit %char; "0"
  
    digit %char; "#"
  
    pattern-separator %char; ";"
  
  >
  
  
  
  &lt;!ELEMENT xsl:namespace-alias EMPTY>
  
  &lt;!ATTLIST xsl:namespace-alias
  
    stylesheet-prefix CDATA #REQUIRED
  
    result-prefix CDATA #REQUIRED
  
  >
  
  
  
  &lt;!ELEMENT xsl:template
  
   (#PCDATA
  
    %instructions;
  
    %result-elements;
  
    | xsl:param)*
  
  >
  
  
  
  &lt;!ATTLIST xsl:template
  
    match %pattern; #IMPLIED
  
    name %qname; #IMPLIED
  
    priority %priority; #IMPLIED
  
    mode %qname; #IMPLIED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:value-of EMPTY>
  
  &lt;!ATTLIST xsl:value-of
  
    select %expr; #REQUIRED
  
    disable-output-escaping (yes|no) "no"
  
  >
  
  
  
  &lt;!ELEMENT xsl:copy-of EMPTY>
  
  &lt;!ATTLIST xsl:copy-of select %expr; #REQUIRED>
  
  
  
  &lt;!ELEMENT xsl:number EMPTY>
  
  &lt;!ATTLIST xsl:number
  
     level (single|multiple|any) "single"
  
     count %pattern; #IMPLIED
  
     from %pattern; #IMPLIED
  
     value %expr; #IMPLIED
  
     format %avt; '1'
  
     lang %avt; #IMPLIED
  
     letter-value %avt; #IMPLIED
  
     grouping-separator %avt; #IMPLIED
  
     grouping-size %avt; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*>
  
  &lt;!ATTLIST xsl:apply-templates
  
    select %expr; "node()"
  
    mode %qname; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:apply-imports EMPTY>
  
  
  
  &lt;!-- xsl:sort cannot occur after any other elements or
  
  any non-whitespace character -->
  
  
  
  &lt;!ELEMENT xsl:for-each
  
   (#PCDATA
  
    %instructions;
  
    %result-elements;
  
    | xsl:sort)*
  
  >
  
  
  
  &lt;!ATTLIST xsl:for-each
  
    select %expr; #REQUIRED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:sort EMPTY>
  
  &lt;!ATTLIST xsl:sort
  
    select %expr; "."
  
    lang %avt; #IMPLIED
  
    data-type %avt; "text"
  
    order %avt; "ascending"
  
    case-order %avt; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:if %template;>
  
  &lt;!ATTLIST xsl:if
  
    test %expr; #REQUIRED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:choose (xsl:when+, xsl:otherwise?)>
  
  &lt;!ATTLIST xsl:choose %space-att;>
  
  
  
  &lt;!ELEMENT xsl:when %template;>
  
  &lt;!ATTLIST xsl:when
  
    test %expr; #REQUIRED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:otherwise %template;>
  
  &lt;!ATTLIST xsl:otherwise %space-att;>
  
  
  
  &lt;!ELEMENT xsl:attribute-set (xsl:attribute)*>
  
  &lt;!ATTLIST xsl:attribute-set
  
    name %qname; #REQUIRED
  
    use-attribute-sets %qnames; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:call-template (xsl:with-param)*>
  
  &lt;!ATTLIST xsl:call-template
  
    name %qname; #REQUIRED
  
  >
  
  
  
  &lt;!ELEMENT xsl:with-param %template;>
  
  &lt;!ATTLIST xsl:with-param
  
    name %qname; #REQUIRED
  
    select %expr; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:variable %template;>
  
  &lt;!ATTLIST xsl:variable 
  
    name %qname; #REQUIRED
  
    select %expr; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:param %template;>
  
  &lt;!ATTLIST xsl:param 
  
    name %qname; #REQUIRED
  
    select %expr; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:text (#PCDATA)>
  
  &lt;!ATTLIST xsl:text
  
    disable-output-escaping (yes|no) "no"
  
  >
  
  
  
  &lt;!ELEMENT xsl:processing-instruction %char-template;>
  
  &lt;!ATTLIST xsl:processing-instruction 
  
    name %avt; #REQUIRED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:element %template;>
  
  &lt;!ATTLIST xsl:element 
  
    name %avt; #REQUIRED
  
    namespace %avt; #IMPLIED
  
    use-attribute-sets %qnames; #IMPLIED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:attribute %char-template;>
  
  &lt;!ATTLIST xsl:attribute 
  
    name %avt; #REQUIRED
  
    namespace %avt; #IMPLIED
  
    %space-att;
  
  >
  
  
  
  &lt;!ELEMENT xsl:comment %char-template;>
  
  &lt;!ATTLIST xsl:comment %space-att;>
  
  
  
  &lt;!ELEMENT xsl:copy %template;>
  
  &lt;!ATTLIST xsl:copy
  
    %space-att;
  
    use-attribute-sets %qnames; #IMPLIED
  
  >
  
  
  
  &lt;!ELEMENT xsl:message %template;>
  
  &lt;!ATTLIST xsl:message
  
    %space-att;
  
    terminate (yes|no) "no"
  
  >
  
  
  
  &lt;!ELEMENT xsl:fallback %template;>
  
  &lt;!ATTLIST xsl:fallback %space-att;></pre>
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Examples"></a>D Examples (Non-Normative)
        </h2>
        
        
        
        
        
        
        <h3><a name="section-Document-Example"></a>D.1 Document Example
        </h3>
        
        
        
        
        <p>This example is a stylesheet for transforming documents that
           
           conform to a simple DTD into XHTML <a href="#XHTML">[XHTML]</a>.  The DTD
           
           is:
        </p>
        
        
        
        <pre>&lt;!ELEMENT doc (title, chapter*)>
  
  &lt;!ELEMENT chapter (title, (para|note)*, section*)>
  
  &lt;!ELEMENT section (title, (para|note)*)>
  
  &lt;!ELEMENT title (#PCDATA|emph)*>
  
  &lt;!ELEMENT para (#PCDATA|emph)*>
  
  &lt;!ELEMENT note (#PCDATA|emph)*>
  
  &lt;!ELEMENT emph (#PCDATA|emph)*></pre>
        
        
        
        <p>The stylesheet is:</p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
                  xmlns="http://www.w3.org/TR/xhtml1/strict">
  
  
  
  &lt;xsl:strip-space elements="doc chapter section"/>
  
  &lt;xsl:output
  
     method="xml"
  
     indent="yes"
  
     encoding="iso-8859-1"
  
  />
  
  
  
  &lt;xsl:template match="doc">
  
   &lt;html>
  
     &lt;head>
  
       &lt;title>
  
         &lt;xsl:value-of select="title"/>
  
       &lt;/title>
  
     &lt;/head>
  
     &lt;body>
  
       &lt;xsl:apply-templates/>
  
     &lt;/body>
  
   &lt;/html>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="doc/title">
  
    &lt;h1>
  
      &lt;xsl:apply-templates/>
  
    &lt;/h1>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="chapter/title">
  
    &lt;h2>
  
      &lt;xsl:apply-templates/>
  
    &lt;/h2>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="section/title">
  
    &lt;h3>
  
      &lt;xsl:apply-templates/>
  
    &lt;/h3>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="para">
  
    &lt;p>
  
      &lt;xsl:apply-templates/>
  
    &lt;/p>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="note">
  
    &lt;p class="note">
  
      &lt;b>NOTE: &lt;/b>
  
      &lt;xsl:apply-templates/>
  
    &lt;/p>
  
  &lt;/xsl:template>
  
  
  
  &lt;xsl:template match="emph">
  
    &lt;em>
  
      &lt;xsl:apply-templates/>
  
    &lt;/em>
  
  &lt;/xsl:template>
  
  
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>With the following input document</p>
        
        
        
        <pre>&lt;!DOCTYPE doc SYSTEM "doc.dtd">
  
  &lt;doc>
  
  &lt;title>Document Title&lt;/title>
  
  &lt;chapter>
  
  &lt;title>Chapter Title&lt;/title>
  
  &lt;section>
  
  &lt;title>Section Title&lt;/title>
  
  &lt;para>This is a test.&lt;/para>
  
  &lt;note>This is a note.&lt;/note>
  
  &lt;/section>
  
  &lt;section>
  
  &lt;title>Another Section Title&lt;/title>
  
  &lt;para>This is &lt;emph>another&lt;/emph> test.&lt;/para>
  
  &lt;note>This is another note.&lt;/note>
  
  &lt;/section>
  
  &lt;/chapter>
  
  &lt;/doc></pre>
        
        
        
        <p>it would produce the following result</p>
        
        
        
        <pre>&lt;?xml version="1.0" encoding="iso-8859-1"?>
  
  &lt;html xmlns="http://www.w3.org/TR/xhtml1/strict">
  
  &lt;head>
  
  &lt;title>Document Title&lt;/title>
  
  &lt;/head>
  
  &lt;body>
  
  &lt;h1>Document Title&lt;/h1>
  
  &lt;h2>Chapter Title&lt;/h2>
  
  &lt;h3>Section Title&lt;/h3>
  
  &lt;p>This is a test.&lt;/p>
  
  &lt;p class="note">
  
  &lt;b>NOTE: &lt;/b>This is a note.&lt;/p>
  
  &lt;h3>Another Section Title&lt;/h3>
  
  &lt;p>This is &lt;em>another&lt;/em> test.&lt;/p>
  
  &lt;p class="note">
  
  &lt;b>NOTE: &lt;/b>This is another note.&lt;/p>
  
  &lt;/body>
  
  &lt;/html></pre>
        
        
        
        
        
        
        
        
        
        <h3><a name="data-example"></a>D.2 Data Example
        </h3>
        
        
        
        
        <p>This is an example of transforming some data represented in XML
           
           using three different XSLT stylesheets to produce three different
           
           representations of the data, HTML, SVG and VRML.
        </p>
        
        
        
        
        <p>The input data is:</p>
        
        
        
        <pre>&lt;sales>
  
  
  
          &lt;division id="North">
  
                  &lt;revenue>10&lt;/revenue>
  
                  &lt;growth>9&lt;/growth>
  
                  &lt;bonus>7&lt;/bonus>
  
          &lt;/division>
  
  
  
          &lt;division id="South">
  
                  &lt;revenue>4&lt;/revenue>
  
                  &lt;growth>3&lt;/growth>
  
                  &lt;bonus>4&lt;/bonus>
  
          &lt;/division>
  
  
  
          &lt;division id="West">
  
                  &lt;revenue>6&lt;/revenue>
  
                  &lt;growth>-1.5&lt;/growth>
  
                  &lt;bonus>2&lt;/bonus>
  
          &lt;/division>
  
  
  
  &lt;/sales></pre>
        
        
        
        <p>The following stylesheet, which uses the simplified syntax
           
           described in <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
           </a>, transforms
           
           the data into HTML:
        </p>
        
        
        
        <pre>&lt;html xsl:version="1.0"
  
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
        lang="en">
  
      &lt;head>
  
  	&lt;title>Sales Results By Division&lt;/title>
  
      &lt;/head>
  
      &lt;body>
  
  	&lt;table border="1">
  
  	    &lt;tr>
  
  		&lt;th>Division&lt;/th>
  
  		&lt;th>Revenue&lt;/th>
  
  		&lt;th>Growth&lt;/th>
  
  		&lt;th>Bonus&lt;/th>
  
  	    &lt;/tr>
  
  	    &lt;xsl:for-each select="sales/division">
  
  		&lt;!-- order the result by revenue -->
  
  		&lt;xsl:sort select="revenue"
  
  			  data-type="number"
  
  			  order="descending"/>
  
  		&lt;tr>
  
  		    &lt;td>
  
  			&lt;em>&lt;xsl:value-of select="@id"/>&lt;/em>
  
  		    &lt;/td>
  
  		    &lt;td>
  
  			&lt;xsl:value-of select="revenue"/>
  
  		    &lt;/td>
  
  		    &lt;td>
  
  			&lt;!-- highlight negative growth in red -->
  
  			&lt;xsl:if test="growth &amp;lt; 0">
  
  			     &lt;xsl:attribute name="style">
  
  				 &lt;xsl:text>color:red&lt;/xsl:text>
  
  			     &lt;/xsl:attribute>
  
  			&lt;/xsl:if>
  
  			&lt;xsl:value-of select="growth"/>
  
  		    &lt;/td>
  
  		    &lt;td>
  
  			&lt;xsl:value-of select="bonus"/>
  
  		    &lt;/td>
  
  		&lt;/tr>
  
  	    &lt;/xsl:for-each>
  
  	&lt;/table>
  
      &lt;/body>
  
  &lt;/html></pre>
        
        
        
        <p>The HTML output is:</p>
        
        
        
        <pre>&lt;html lang="en">
  
  &lt;head>
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  
  &lt;title>Sales Results By Division&lt;/title>
  
  &lt;/head>
  
  &lt;body>
  
  &lt;table border="1">
  
  &lt;tr>
  
  &lt;th>Division&lt;/th>&lt;th>Revenue&lt;/th>&lt;th>Growth&lt;/th>&lt;th>Bonus&lt;/th>
  
  &lt;/tr>
  
  &lt;tr>
  
  &lt;td>&lt;em>North&lt;/em>&lt;/td>&lt;td>10&lt;/td>&lt;td>9&lt;/td>&lt;td>7&lt;/td>
  
  &lt;/tr>
  
  &lt;tr>
  
  &lt;td>&lt;em>West&lt;/em>&lt;/td>&lt;td>6&lt;/td>&lt;td style="color:red">-1.5&lt;/td>&lt;td>2&lt;/td>
  
  &lt;/tr>
  
  &lt;tr>
  
  &lt;td>&lt;em>South&lt;/em>&lt;/td>&lt;td>4&lt;/td>&lt;td>3&lt;/td>&lt;td>4&lt;/td>
  
  &lt;/tr>
  
  &lt;/table>
  
  &lt;/body>
  
  &lt;/html></pre>
        
        
        
        <p>The following stylesheet transforms the data into SVG:</p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  
                  xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd">
  
  
  
  &lt;xsl:output method="xml" indent="yes" media-type="image/svg"/>
  
  
  
  &lt;xsl:template match="/">
  
  
  
  &lt;svg width = "3in" height="3in">
  
      &lt;g style = "stroke: #000000"> 
  
          &lt;!-- draw the axes -->
  
          &lt;line x1="0" x2="150" y1="150" y2="150"/>
  
          &lt;line x1="0" x2="0" y1="0" y2="150"/>
  
          &lt;text x="0" y="10">Revenue&lt;/text>
  
          &lt;text x="150" y="165">Division&lt;/text>
  
          &lt;xsl:for-each select="sales/division">
  
  	    &lt;!-- define some useful variables -->
  
  
  
  	    &lt;!-- the bar's x position -->
  
  	    &lt;xsl:variable name="pos"
  
  	                  select="(position()*40)-30"/>
  
  
  
  	    &lt;!-- the bar's height -->
  
  	    &lt;xsl:variable name="height"
  
  	                  select="revenue*10"/>
  
  
  
  	    &lt;!-- the rectangle -->
  
  	    &lt;rect x="{$pos}" y="{150-$height}"
  
                    width="20" height="{$height}"/>
  
  
  
  	    &lt;!-- the text label -->
  
  	    &lt;text x="{$pos}" y="165">
  
  	        &lt;xsl:value-of select="@id"/>
  
  	    &lt;/text> 
  
  
  
  	    &lt;!-- the bar value -->
  
  	    &lt;text x="{$pos}" y="{145-$height}">
  
  	        &lt;xsl:value-of select="revenue"/>
  
  	    &lt;/text>
  
          &lt;/xsl:for-each>
  
      &lt;/g>
  
  &lt;/svg>
  
  
  
  &lt;/xsl:template>
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>The SVG output is:</p>
        
        
        
        <pre>&lt;svg width="3in" height="3in"
  
       xmlns="http://www.w3.org/Graphics/SVG/svg-19990412.dtd">
  
      &lt;g style="stroke: #000000">
  
  	&lt;line x1="0" x2="150" y1="150" y2="150"/>
  
  	&lt;line x1="0" x2="0" y1="0" y2="150"/>
  
  	&lt;text x="0" y="10">Revenue&lt;/text>
  
  	&lt;text x="150" y="165">Division&lt;/text>
  
  	&lt;rect x="10" y="50" width="20" height="100"/>
  
  	&lt;text x="10" y="165">North&lt;/text>
  
  	&lt;text x="10" y="45">10&lt;/text>
  
  	&lt;rect x="50" y="110" width="20" height="40"/>
  
  	&lt;text x="50" y="165">South&lt;/text>
  
  	&lt;text x="50" y="105">4&lt;/text>
  
  	&lt;rect x="90" y="90" width="20" height="60"/>
  
  	&lt;text x="90" y="165">West&lt;/text>
  
  	&lt;text x="90" y="85">6&lt;/text>
  
      &lt;/g>
  
  &lt;/svg></pre>
        
        
        
        <p>The following stylesheet transforms the data into VRML:</p>
        
        
        
        <pre>&lt;xsl:stylesheet version="1.0"
  
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
  
  &lt;!-- generate text output as mime type model/vrml, using default charset -->
  
  &lt;xsl:output method="text" encoding="UTF-8" media-type="model/vrml"/>  
  
  
  
          &lt;xsl:template match="/">#VRML V2.0 utf8 
  
   
  
  # externproto definition of a single bar element 
  
  EXTERNPROTO bar [ 
  
    field SFInt32 x  
  
    field SFInt32 y  
  
    field SFInt32 z  
  
    field SFString name  
  
    ] 
  
    "http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl" 
  
   
  
  # inline containing the graph axes 
  
  Inline {  
  
          url "http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl" 
  
          } 
  
          
  
                  &lt;xsl:for-each select="sales/division">
  
  bar {
  
          x &lt;xsl:value-of select="revenue"/>
  
          y &lt;xsl:value-of select="growth"/>
  
          z &lt;xsl:value-of select="bonus"/>
  
          name "&lt;xsl:value-of select="@id"/>" 
  
          }
  
                  &lt;/xsl:for-each>
  
          
  
          &lt;/xsl:template> 
  
   
  
  &lt;/xsl:stylesheet></pre>
        
        
        
        <p>The VRML output is:</p>
        
        
        
        <pre>#VRML V2.0 utf8 
  
   
  
  # externproto definition of a single bar element 
  
  EXTERNPROTO bar [ 
  
    field SFInt32 x  
  
    field SFInt32 y  
  
    field SFInt32 z  
  
    field SFString name  
  
    ] 
  
    "http://www.vrml.org/WorkingGroups/dbwork/barProto.wrl" 
  
   
  
  # inline containing the graph axes 
  
  Inline {  
  
          url "http://www.vrml.org/WorkingGroups/dbwork/barAxes.wrl" 
  
          } 
  
          
  
                  
  
  bar {
  
          x 10
  
          y 9
  
          z 7
  
          name "North" 
  
          }
  
                  
  
  bar {
  
          x 4
  
          y 3
  
          z 4
  
          name "South" 
  
          }
  
                  
  
  bar {
  
          x 6
  
          y -1.5
  
          z 2
  
          name "West" 
  
          }</pre>
        
        
        
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Acknowledgements"></a>E Acknowledgements (Non-Normative)
        </h2>
        
        
        <p>The following have contributed to authoring this draft:</p>
        
        
        <ul>
           
           
           <li>Daniel Lipkin, Saba</li>
           
           
           <li>Jonathan Marsh, Microsoft</li>
           
           
           <li>Henry Thompson, University of Edinburgh</li>
           
           
           <li>Norman Walsh, Arbortext</li>
           
           
           <li>Steve Zilles, Adobe</li>
           
           
        </ul>
        
        
        
        
        <p>This specification was developed and approved for publication by the
           
           W3C XSL Working Group (WG). WG approval of this specification does not
           
           necessarily imply that all WG members voted for its approval. The
           
           current members of the XSL WG are:
        </p>
        
        
        
        Sharon Adler, IBM (Co-Chair); Anders Berglund, IBM; Perin Blanchard, Novell; Scott Boag, Lotus; Larry Cable, Sun; Jeff Caruso, Bitstream; James Clark; Peter Danielsen, Bell Labs; Don Day, IBM; Stephen Deach, Adobe; Dwayne Dicks, SoftQuad; Andrew Greene, Bitstream; Paul Grosso, Arbortext; Eduardo Gutentag, Sun; Juliane Harbarth, Software AG; Mickey Kimchi, Enigma; Chris Lilley, W3C; Chris Maden, Exemplary Technologies; Jonathan Marsh, Microsoft; Alex Milowski, Lexica; Steve Muench, Oracle; Scott Parnell, Xerox; Vincent Quint, W3C; Dan Rapp, Novell; Gregg Reynolds, Datalogics; Jonathan Robie, Software AG; Mark Scardina, Oracle; Henry Thompson, University of Edinburgh; Philip Wadler, Bell Labs; Norman Walsh, Arbortext; Sanjiva Weerawarana, IBM; Steve Zilles, Adobe (Co-Chair)
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Changes-from-Proposed-Recommendation"></a>F Changes from Proposed Recommendation (Non-Normative)
        </h2>
        
        
        
        
        <p>The following are the changes since the Proposed Recommendation:</p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>The <code>xsl:version</code> attribute is required on a
                 
                 literal result element used as a stylesheet (see <a href="#result-element-stylesheet">[<b>2.3 Literal Result Element as Stylesheet</b>]
                 </a>).
              </p>
           </li>
           
           
           
           
           <li>
              <p>The <code>data-type</code> attribute on <code>xsl:sort</code>
                 
                 can use a prefixed name to specify a data-type not defined by
                 
                 XSLT (see <a href="#sorting">[<b>10 Sorting</b>]
                 </a>).
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
        <h2><a name="section-Features-under-Consideration-for-Future-Versions-of-XSLT"></a>G Features under Consideration for Future Versions of XSLT (Non-Normative)
        </h2>
        
        
        
        
        <p>The following features are under consideration for versions of XSLT
           
           after XSLT 1.0:
        </p>
        
        
        
        
        <ul>
           
           
           
           
           <li>
              <p>a conditional expression;</p>
           </li>
           
           
           
           
           <li>
              <p>support for XML Schema datatypes and archetypes;</p>
           </li>
           
           
           
           
           <li>
              <p>support for something like style rules in the original XSL
                 
                 submission;
              </p>
           </li>
           
           
           
           
           <li>
              <p>an attribute to control the default namespace for names
                 
                 occurring in XSLT attributes;
              </p>
           </li>
           
           
           
           
           <li>
              <p>support for entity references;</p>
           </li>
           
           
           
           
           <li>
              <p>support for DTDs in the data model;</p>
           </li>
           
           
           
           
           <li>
              <p>support for notations in the data model;</p>
           </li>
           
           
           
           
           <li>
              <p>a way to get back from an element to the elements that
                 
                 reference it (e.g. by IDREF attributes);
              </p>
           </li>
           
           
           
           
           <li>
              <p>an easier way to get an ID or key in another document;</p>
           </li>
           
           
           
           
           <li>
              <p>support for regular expressions for matching against any or
                 
                 all of text nodes, attribute values, attribute names, element type
                 
                 names;
              </p>
           </li>
           
           
           
           
           <li>
              <p>case-insensitive comparisons;</p>
           </li>
           
           
           
           
           <li>
              <p>normalization of strings before comparison, for example for
                 
                 compatibility characters;
              </p>
           </li>
           
           
           
           
           <li>
              <p>a function <code>string resolve(node-set)</code> function
                 
                 that treats the value of the argument as a relative URI and turns it
                 
                 into an absolute URI using the base URI of the node;
              </p>
           </li>
           
           
           
           
           <li>
              <p>multiple result documents;</p>
           </li>
           
           
           
           
           <li>
              <p>defaulting the <code>select</code> attribute on
                 
                 <code>xsl:value-of</code> to the current node;
              </p>
           </li>
           
           
           
           
           <li>
              <p>an attribute on <code>xsl:attribute</code> to control how the
                 
                 attribute value is normalized;
              </p>
           </li>
           
           
           
           
           <li>
              <p>additional attributes on <code>xsl:sort</code> to provide
                 
                 further control over sorting, such as relative order of
                 
                 scripts;
              </p>
           </li>
           
           
           
           
           <li>
              <p>a way to put the text of a resource identified by a URI into
                 
                 the result tree;
              </p>
           </li>
           
           
           
           
           <li>
              <p>allow unions in steps (e.g. <code>foo/(bar|baz)</code>);
              </p>
           </li>
           
           
           
           
           <li>
              <p>allow for result tree fragments all operations that are
                 
                 allowed for node-sets;
              </p>
           </li>
           
           
           
           
           <li>
              <p>a way to group together consecutive nodes having duplicate
                 
                 subelements or attributes;
              </p>
           </li>
           
           
           
           
           <li>
              <p>features to make handling of the HTML <code>style</code>
                 
                 attribute more convenient.
              </p>
           </li>
           
           
           
           
        </ul>
        
        
        
        
        
        
        
        
        
        
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk057.out
  
  Index: mk057.out
  ===================================================================
  
  <html>
     <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     
        <title>Knight's tour</title>
     </head>
     <body>
        <div align="center">
           <h1>Knight's tour starting at a1</h1>
           <table border="1" cellpadding="4">
              <tr>
                 <td align="center" bgcolor="white">36</td>
                 <td align="center" bgcolor="xffff44">19</td>
                 <td align="center" bgcolor="white">22</td>
                 <td align="center" bgcolor="xffff44">05</td>
                 <td align="center" bgcolor="white">38</td>
                 <td align="center" bgcolor="xffff44">09</td>
                 <td align="center" bgcolor="white">24</td>
                 <td align="center" bgcolor="xffff44">07</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="xffff44">21</td>
                 <td align="center" bgcolor="white">04</td>
                 <td align="center" bgcolor="xffff44">37</td>
                 <td align="center" bgcolor="white">42</td>
                 <td align="center" bgcolor="xffff44">23</td>
                 <td align="center" bgcolor="white">06</td>
                 <td align="center" bgcolor="xffff44">39</td>
                 <td align="center" bgcolor="white">10</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="white">18</td>
                 <td align="center" bgcolor="xffff44">35</td>
                 <td align="center" bgcolor="white">20</td>
                 <td align="center" bgcolor="xffff44">49</td>
                 <td align="center" bgcolor="white">44</td>
                 <td align="center" bgcolor="xffff44">41</td>
                 <td align="center" bgcolor="white">08</td>
                 <td align="center" bgcolor="xffff44">25</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="xffff44">03</td>
                 <td align="center" bgcolor="white">50</td>
                 <td align="center" bgcolor="xffff44">43</td>
                 <td align="center" bgcolor="white">46</td>
                 <td align="center" bgcolor="xffff44">55</td>
                 <td align="center" bgcolor="white">62</td>
                 <td align="center" bgcolor="xffff44">11</td>
                 <td align="center" bgcolor="white">40</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="white">34</td>
                 <td align="center" bgcolor="xffff44">17</td>
                 <td align="center" bgcolor="white">54</td>
                 <td align="center" bgcolor="xffff44">59</td>
                 <td align="center" bgcolor="white">48</td>
                 <td align="center" bgcolor="xffff44">45</td>
                 <td align="center" bgcolor="white">26</td>
                 <td align="center" bgcolor="xffff44">63</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="xffff44">51</td>
                 <td align="center" bgcolor="white">02</td>
                 <td align="center" bgcolor="xffff44">47</td>
                 <td align="center" bgcolor="white">56</td>
                 <td align="center" bgcolor="xffff44">61</td>
                 <td align="center" bgcolor="white">58</td>
                 <td align="center" bgcolor="xffff44">29</td>
                 <td align="center" bgcolor="white">12</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="white">16</td>
                 <td align="center" bgcolor="xffff44">33</td>
                 <td align="center" bgcolor="white">60</td>
                 <td align="center" bgcolor="xffff44">53</td>
                 <td align="center" bgcolor="white">14</td>
                 <td align="center" bgcolor="xffff44">31</td>
                 <td align="center" bgcolor="white">64</td>
                 <td align="center" bgcolor="xffff44">27</td>
              </tr>
              <tr>
                 <td align="center" bgcolor="xffff44">01</td>
                 <td align="center" bgcolor="white">52</td>
                 <td align="center" bgcolor="xffff44">15</td>
                 <td align="center" bgcolor="white">32</td>
                 <td align="center" bgcolor="xffff44">57</td>
                 <td align="center" bgcolor="white">28</td>
                 <td align="center" bgcolor="xffff44">13</td>
                 <td align="center" bgcolor="white">30</td>
              </tr>
           </table>
        </div>
     </body>
  </html>
  
  
  1.1                  xml-xalan/test/tests/contrib-gold/xsltc/mk/mk062.out
  
  Index: mk062.out
  ===================================================================
  
  Title,Author,Category
  "Number, the Language of Science","Danzig","S(Science)"
  "Tales of Grandpa Cat","Wardlaw, Lee","F(Fiction)"
  "Language & the Science of Number","Danzig","S(Science)"
  "Evolution of Complexity in Animal Culture","Bonner","S(Science)"
  "Patterns of Crime in Animal Culture","Bonner","X(Crime)"
  "When We Were Very Young","Milne, A. A.","F(Fiction)"
  "Learn Java Now","Stephen R. Davis","C(Computing)"
  "Design Patterns","Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides","U(Unclassified)"
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org