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:54:48 UTC

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

amiro       01/06/20 11:54:48

  Added:       test/tests/contrib/xsltc/mk mk003.xsl mk004.xsl mk005.xsl
                        mk006.xsl mk007.xsl mk008.xsl mk011.xsl mk012.xsl
                        mk013.xsl mk014.xsl mk015.xsl mk016.xsl mk017.xsl
                        mk018.xsl mk019.xsl mk020.xsl mk021.xsl mk022.xsl
                        mk023.xsl mk024.xsl mk025.xsl mk026.xsl mk027.xsl
                        mk028.xsl mk029.xsl mk030.xsl mk031.xsl mk032.xsl
                        mk033.xsl mk034.xsl mk035.xsl mk036.xsl mk037.xsl
                        mk038.xsl mk039.xsl mk040.xsl mk041.xsl mk042.xsl
                        mk043.xsl mk044.xsl mk045.xsl mk046.xsl mk047.xsl
                        mk048.xsl mk049.xsl mk050.xsl mk051.xsl mk052.xsl
                        mk053.xsl mk054.xsl mk055.xsl mk056.xsl mk062.xsl
                        mk003.xml mk004.xml mk005.xml mk006.xml mk007.xml
                        mk008.xml mk011.xml mk012.xml mk013.xml mk014.xml
                        mk015.xml mk016.xml mk017.xml mk018.xml mk019.xml
                        mk020.xml mk021.xml mk022.xml mk023.xml mk024.xml
                        mk025.xml mk026.xml mk027.xml mk028.xml mk029.xml
                        mk030.xml mk031.xml mk032.xml mk033.xml mk034.xml
                        mk035.xml mk036.xml mk037.xml mk038.xml mk039.xml
                        mk040.xml mk041.xml mk042.xml mk043.xml mk044.xml
                        mk045.xml mk046.xml mk047.xml mk048.xml mk049.xml
                        mk050.xml mk051.xml mk052.xml mk053.xml mk054.xml
                        mk055.xml mk056.xml mk062.xml
  Log:
  xsl and xml files for mk tests
  
  Revision  Changes    Path
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk003.xsl
  
  Index: mk003.xsl
  ===================================================================
  <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     version="1.0">
     
    <!-- Test FileName: mk003.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example:  Displaying a Poem (poem.xml, poem.xsl) -->
    <!-- Chapter/Page: 1-36 -->
    <!-- Purpose:  Show rules based approach to formatting -->
  
  <xsl:template match="poem">
  <html>
  <head>
  	<title><xsl:value-of select="title"/></title>
  </head>
  <body>
  	<xsl:apply-templates select="title"/>
  	<xsl:apply-templates select="author"/>
  	<xsl:apply-templates select="stanza"/>
  	<xsl:apply-templates select="date"/>
  </body>
  </html>
  </xsl:template>
  
  <xsl:template match="title">
  <div align="center"><h1><xsl:value-of select="."/></h1></div>
  </xsl:template>
  
  <xsl:template match="author">
  <div align="center"><h2>By <xsl:value-of select="."/></h2></div>
  </xsl:template>
  
  <xsl:template match="stanza">
  <p><xsl:apply-templates select="line"/></p>
  </xsl:template>
  
  <xsl:template match="line">
  <xsl:if test="position() mod 2 = 0">&#160;&#160;</xsl:if>
  <xsl:value-of select="."/><br/>
  </xsl:template>
  
  <xsl:template match="date">
  <p><i><xsl:value-of select="."/></i></p>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk004.xsl
  
  Index: mk004.xsl
  ===================================================================
  <xsl:stylesheet 
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  	version="1.0">
    
    <!-- Test FileName: mk004.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example:  Simple Recursive-Decent Processing (books.xml, booklist.xsl) -->
    <!-- Chapter/Page: 2-70 -->
    <!-- Purpose: Using templates for each kind of node -->
  
  
  <xsl:template match="books">
  	<html><body>
  	<h1>A list of books</h1>
  	<table width="640">
  	<xsl:apply-templates/>
  	</table>
  	</body></html>
  </xsl:template>
  
  <xsl:template match="book">
  	<tr>
  	<td><xsl:number/></td>
  	<xsl:apply-templates/>
  	</tr>
  </xsl:template>
  
  <xsl:template match="author | title | price">
  	<td><xsl:value-of select="."/></td>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk005.xsl
  
  Index: mk005.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
    
    <!-- Test FileName: mk005.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example:  A Simplified Styleshet (books.xml, simplified.xsl) -->
    <!-- Chapter/Page: 3-105 -->
    <!-- Purpose: Using simplified stylesheet with html skeleton -->
  
  <xsl:output method="html" indent="yes"/>
  <xsl:template match="/">
  <html>
    <head>
      <title>A list of books</title>
    </head>
    <body>
    <h1>A list of books</h1>
     <table border="2">
     <xsl:for-each select="//book">
        <xsl:sort select="author"/>
        <tr>
          <td><xsl:value-of select="author"/></td>
          <td><xsl:value-of select="title"/></td>
          <td><xsl:value-of select="@category"/></td>
          <td><xsl:value-of select="price"/></td>
        </tr>
     </xsl:for-each>
     </table>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk006.xsl
  
  Index: mk006.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet 
  		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  		version="1.0">
    
    <!-- Test FileName: mk006.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example:  books.xml, avt.xsl -->
    <!-- Chapter/Page: 3-113 -->
    <!-- Purpose: Using Attribute Value Template in Literal Result Element -->
  
  <xsl:output indent="yes"/>
  <xsl:template match="/">
  <xsl:for-each select="//book">
  <div id="div{position()}">
  <xsl:value-of select="title"/>
  </div>
  </xsl:for-each>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk007.xsl
  
  Index: mk007.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet 
  		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  		version="1.0">
    
    <!-- Test FileName: mk007.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: sample.xml, principal.xsl (includes date.xsl, copyright.xsl) -->
    <!-- Chapter/Page: 3-91 -->
    <!-- Purpose: Including stylesheets -->
  
  <!--<xsl:include href="./inc/date.xsl"/> -->
  <xsl:variable name="date" select="'2001'" />
  <xsl:include href="./inc/copyright.xsl"/>
  
  <xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
  <xsl:strip-space elements="*"/>
  
  <xsl:template match="date">
      <date><xsl:value-of select="$date"/></date>
  </xsl:template>
  
  <xsl:template match="copyright">
      <copyright><xsl:call-template name="copyright"/></copyright>
  </xsl:template>
  
  <xsl:template match="*">
      <xsl:copy>
          <xsl:copy-of select="@*"/>
          <xsl:apply-templates/>
      </xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk008.xsl
  
  Index: mk008.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet 
  		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  		version="1.0"
  >
    
    <!-- Test FileName: mk008.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: sample.xml, principal2.xsl (includes date.xsl, copyright.xsl) -->
    <!-- Chapter/Page: 3-91 -->
    <!-- Purpose: Importing stylesheets -->
  
  <xsl:import href="./inc/copyright.xsl"/>
  <xsl:variable name="owner">Wrox Press Ltd</xsl:variable>
  <xsl:variable name="date">2001</xsl:variable>
  <!--<xsl:include href="./inc/date.xsl/>-->
  
  <xsl:output method="xml" encoding="iso-8859-1" indent="yes"/>
  <xsl:strip-space elements="*"/>
  
  <xsl:template match="date">
      <date><xsl:value-of select="$date"/></date>
  </xsl:template>
  
  <xsl:template match="copyright">
      <copyright><xsl:call-template name="copyright"/></copyright>
  </xsl:template>
  
  <xsl:template match="*">
      <xsl:copy>
          <xsl:copy-of select="@*"/>
          <xsl:apply-templates/>
      </xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk011.xsl
  
  Index: mk011.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk011.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: scene.xml, naming-lines.xsl -->
    <!-- Chapter/Page: 4-173 -->
    <!-- Purpose: Using recursion to process a separated string -->
  
  <xsl:variable name="speakers" select="//SPEAKER"/>
  
  <xsl:template name="contains-name">
     <xsl:param name="line"/>
     <xsl:variable name="line1" 
          select="translate($line, 'abcdefghijklmnopqrstuvwxyz.,:?!;',
                      'ABCDEFGHIJKLMNOPQRSTUVWXYZ      ')"/>
     <xsl:variable name="line2" select="concat(normalize-space($line1), ' ')"/>
     <xsl:variable name="first" select="substring-before($line2,' ')"/>
     <xsl:choose>
     <xsl:when test="$first">
        <xsl:choose>
        <xsl:when test="$speakers[.=$first]">true</xsl:when>
        <xsl:otherwise>
           <xsl:variable name="rest" select="substring-after($line2,' ')"/>    
           <xsl:call-template name="contains-name">
              <xsl:with-param name="line" select="$rest"/>
           </xsl:call-template>
        </xsl:otherwise>
        </xsl:choose>
     </xsl:when>
     <xsl:otherwise>false</xsl:otherwise>
     </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/">
  
  <xsl:for-each select="//LINE">
      <xsl:variable name="contains-name">
          <xsl:call-template name="contains-name">
              <xsl:with-param name="line" select="."/>
          </xsl:call-template>
      </xsl:variable>
      <xsl:if test="$contains-name='true'">
          <xsl:copy-of select="."/>;
      </xsl:if>
  </xsl:for-each>
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk012.xsl
  
  Index: mk012.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk012.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: scene.xml, longest-speech.xsl -->
    <!-- Chapter/Page: 4-171 -->
    <!-- Purpose: Using recursion to process a node set -->
  
  <xsl:template name="max">
  <xsl:param name="list"/>
  <xsl:choose>
  <xsl:when test="$list">
     <xsl:variable name="first" select="count($list[1]/LINE)"/>
     <xsl:variable name="max-of-rest">
        <xsl:call-template name="max">
           <xsl:with-param name="list" select="$list[position()!=1]"/>
        </xsl:call-template>
     </xsl:variable>
     <xsl:choose>
     <xsl:when test="$first &gt; $max-of-rest">
        <xsl:value-of select="$first"/>
     </xsl:when>
     <xsl:otherwise>
        <xsl:value-of select="$max-of-rest"/>
     </xsl:otherwise>
     </xsl:choose>
  </xsl:when>
  <xsl:otherwise>0</xsl:otherwise>
  </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/">
  Longest speech is <xsl:text/>
  	<xsl:call-template name="max">
          <xsl:with-param name="list" select="//SPEECH"/>
  	</xsl:call-template>
  <xsl:text/> lines.  
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk013.xsl
  
  Index: mk013.xsl
  ===================================================================
  <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk013.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, number-lines.xsl -->
    <!-- Chapter/Page: 4-165 -->
    <!-- Purpose: Using an attribute set for numbering -->
  
  <xsl:strip-space elements="*"/>
  <xsl:output method="xml" indent="yes"/>
  
  <xsl:template match="*">
  	<xsl:copy>
  	<xsl:apply-templates/>
  	</xsl:copy>   
  </xsl:template>
  
  <xsl:template match="line">
  	<xsl:copy use-attribute-sets="sequence">
  	<xsl:apply-templates/>
  	</xsl:copy>   
  </xsl:template>
  
  <xsl:attribute-set name="sequence">
  	<xsl:attribute name="number"><xsl:value-of select="position()"/></xsl:attribute>
  	<xsl:attribute name="of"><xsl:value-of select="last()"/></xsl:attribute>
  </xsl:attribute-set>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk014.xsl
  
  Index: mk014.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk014.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: countries.xml, options.xsl -->
    <!-- Chapter/Page: 4-160 -->
    <!-- Purpose: Generating an attribute conditionally -->
  
  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">
  <html>
    <body>
    <h1>Please select a country:</h1>
    <select id="country">
    <xsl:for-each select="//country">
      <option value="{@name}">
  	<xsl:if test="@selected='yes'">
  	    <xsl:attribute name="selected">selected</xsl:attribute>
  	</xsl:if>
      <xsl:value-of select="@name"/>
      </option>
    </xsl:for-each>
    </select>
  <hr/>
  </body>
  </html>
  
  </xsl:template>
  </xsl:stylesheet>
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk015.xsl
  
  Index: mk015.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk015.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: copy-of/soccer.xml, copy-of/soccer.xsl -->
    <!-- Chapter/Page: 4-185 -->
    <!-- Purpose: Using copy-of for repeated output -->
  
  <xsl:variable name="table-heading">
      <tr>
          <td><b>Date</b></td>
          <td><b>Home Team</b></td>
          <td><b>Away Team</b></td>
          <td><b>Result</b></td>
      </tr>
  </xsl:variable>
  
  <xsl:template match="/">
  <html><body>
      <h1>Matches in Group <xsl:value-of select="/*/@group"/></h1>
  
      <xsl:for-each select="//match">
  
      <h2><xsl:value-of select="concat(team[1], ' versus ', team[2])"/></h2>
  
      <table bgcolor="#cccccc" border="1" cellpadding="5">
          <xsl:copy-of select="$table-heading"/>        
          <tr>
          <td><xsl:value-of select="date"/>&#xa0;</td>
          <td><xsl:value-of select="team[1]"/>&#xa0;</td>
          <td><xsl:value-of select="team[2]"/>&#xa0;</td>   
          <td><xsl:value-of select="concat(team[1]/@score, '-', team[2]/@score)"/>&#xa0;</td>   
          </tr>        
      </table>
      </xsl:for-each>   
  </body></html>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk016.xsl
  
  Index: mk016.xsl
  ===================================================================
  <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk016.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: element/book.xml, element/atts-to-elements.xsl -->
    <!-- Chapter/Page: 4-196 -->
    <!-- Purpose: Converting attributes to child elements -->
  
  <xsl:output indent="yes"/>
  <xsl:template match="book">
    <book>
  	<xsl:for-each select="@*">
  	 <xsl:element name="{name()}">
  	    <xsl:value-of select="."/>
  	 </xsl:element>
  	</xsl:for-each>
    </book>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk017.xsl
  
  Index: mk017.xsl
  ===================================================================
  <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk017.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: for-each/poem.xml, for-each/nesting.xsl -->
    <!-- Chapter/Page: 4-203 -->
    <!-- Purpose: Showing the ancestors of a node -->
  
  <xsl:template match="*">
     <xsl:comment>
        <xsl:value-of select="name()"/>
        <xsl:for-each select="ancestor::*">
           <xsl:sort select="position()" order="descending"/>
           <xsl:text> within </xsl:text>
           <xsl:value-of select="name()"/>
        </xsl:for-each>
     </xsl:comment>
     <xsl:apply-templates/>
  </xsl:template>
  
  </xsl:stylesheet>	
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk018.xsl
  
  Index: mk018.xsl
  ===================================================================
  <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk018.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: authors.xml, authors.xsl -->
    <!-- Chapter/Page: 4-207 -->
    <!-- Purpose: Formatting a list of names -->
  
  <xsl:template match="book">
     <xsl:value-of select="title"/>
     by <xsl:for-each select="author">
        <xsl:value-of select="."/>
        <xsl:if test="position()!=last()">, </xsl:if>
        <xsl:if test="position()=last()-1">and </xsl:if>
  </xsl:for-each>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk019.xsl
  
  Index: mk019.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:acme="http://acme.com/xslt"
      exclude-result-prefixes="acme">
  
    <!-- Test FileName: mk019.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: any xml, import/variables.xsl, boilerplate.xsl -->
    <!-- Chapter/Page: 4-215 -->
    <!-- Purpose: Precedence of variables with imported stylesheet -->
  
  <xsl:import href="./inc/boilerplate.xsl"/>
  <xsl:output encoding="iso-8859-1" indent="yes"/>
  
  <xsl:variable name="acme:company-name" select="'Acme Widgets Limited'"/>
  
  <xsl:template match="/">
  <c><xsl:value-of select="$acme:copyright"/></c>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk020.xsl
  
  Index: mk020.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk020.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, standard-style.xsl -->
    <!-- Chapter/Page: 4-216 -->
    <!-- Purpose: Precedence of template rules -->
  
  <xsl:template match="/">
     <html>
     <head>
     <title><xsl:value-of select="//title"/></title>
     </head>
     <body>
        <xsl:apply-templates/>
     </body>
     </html>
  </xsl:template>
  
  <xsl:template match="title">
     <h1><xsl:apply-templates/></h1>
  </xsl:template>
  
  <xsl:template match="author">
     <div align="right"><i>by </i>
        <xsl:apply-templates/>
     </div>
  </xsl:template>
  
  <xsl:template match="stanza">
     <p><xsl:apply-templates/></p>
  </xsl:template>
  
  <xsl:template match="line">
     <xsl:apply-templates/><br/><xsl:text/>
  </xsl:template>
  
  <xsl:template match="date"/>
  
  <xsl:template match="text()">
  <xsl:value-of select="."/><xsl:text />
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk021.xsl
  
  Index: mk021.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk021.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, numbered-style.xsl -->
    <!-- Chapter/Page: 4-217 -->
    <!-- Purpose: Precedence of template rules -->
  
  <xsl:import href="mk020.xsl"/>
  
  <xsl:template match="line">
     <xsl:number level="any" format="001"/>&#xa0;&#xa0;
     <xsl:apply-imports/>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk022.xsl
  
  Index: mk022.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk022.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, picture.xsl, attributes.xsl -->
    <!-- Chapter/Page: 4-221 -->
    <!-- Purpose: Using xsl:include with named attribute sets -->
  
  <xsl:include href="./inc/attributes.xsl"/>
  
  <xsl:template match="/">
     <picture xsl:use-attribute-sets="picture-attributes">
        <xsl:attribute name="color">red</xsl:attribute>
     </picture>
  
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk023.xsl
  
  Index: mk023.xsl
  ===================================================================
  <xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk023.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, author-key.xsl -->
    <!-- Chapter/Page: 4-227 -->
    <!-- Purpose: Multi-valued Non-unique keys -->
  
  <xsl:key name="author-name" match="book" use="author"/>
  
  <xsl:param name="author" select="'John Vlissides'"/>
  
  <xsl:template match="/">
  <xsl:copy-of select="key('author-name', translate($author, '_', ' '))"/>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk024.xsl
  
  Index: mk024.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                        xmlns:out="output.xsl">
  
    <!-- Test FileName: mk024.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: any xml, alias.xsl -->
    <!-- Chapter/Page: 4-236 -->
    <!-- Purpose: Example of namespace alias -->
  
  <xsl:param name="variable-name">v</xsl:param>
  <xsl:param name="default-value"/>
  <xsl:output indent="yes"/>
  <xsl:namespace-alias
                 stylesheet-prefix="out"
                 result-prefix="xsl"/>
  
  <xsl:template match="/">
     <out:stylesheet version="1.0">
     <out:variable name="{$variable-name}">
        <xsl:value-of select="$default-value"/>
     </out:variable>
     </out:stylesheet>
  </xsl:template>
  
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk025.xsl
  
  Index: mk025.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk025.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, poem.xsl -->
    <!-- Chapter/Page: 4-247 -->
    <!-- Purpose: Numbering the lines of a poem -->
  
  <xsl:template match="/">
  <html><body>
  <p><xsl:apply-templates select="/poem/stanza"/></p>
  </body></html>
  </xsl:template>
  
  <xsl:template match="stanza">
  <p><table><xsl:apply-templates/></table></p>
  </xsl:template> 
  
  <xsl:template match="line">
  <tr>
  <td width="350"><xsl:value-of select="."/></td>
  <td width="50">
     <xsl:variable name="line-nr">
        <xsl:number level="any" from="poem"/>
     </xsl:variable>
     <xsl:if test="$line-nr mod 3 = 0">
        <xsl:value-of select="$line-nr"/>
     </xsl:if>
  </td>
  </tr>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk026.xsl
  
  Index: mk026.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk026.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: poem.xml, call.xsl -->
    <!-- Chapter/Page: 4-265 -->
    <!-- Purpose: Using xsl:param with a default value -->
  
  <xsl:output method="text"/>
  
  <xsl:template match="/">
  <xsl:for-each select="//*">
      <xsl:value-of select="concat(name(), ' -- ')"/>
      <xsl:call-template name="depth"/>;
  </xsl:for-each>
  </xsl:template>
  
  <xsl:template name="depth">
      <xsl:param name="node" select="."/>
      <xsl:value-of select="count($node/ancestor::node())"/>
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk027.xsl
  
  Index: mk027.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!-- From MKay Ref manual p-276; was simplified style sheet; converted it -->
  
    <!-- Test FileName: mk027.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: products.xml, products.xsl -->
    <!-- Chapter/Page: 4-276 -->
    <!-- Purpose: Sorting on the result of a calculation -->
  
  <xsl:template match="/">
  <xsl:for-each select="products/product">
     <xsl:sort select="sum(region/@sales)"
                                  data-type="number"
                                  order="descending"/>
     <product name="{@name}" sales="{format-number(sum(region/@sales), '$####0.00')}"/>
  </xsl:for-each>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk028.xsl
  
  Index: mk028.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk028.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: soloist.xml, soloist.xsl -->
    <!-- Chapter/Page: 4-295 -->
    <!-- Purpose: Rules-based processing of template rules -->
  
  <xsl:template match="/">
  <html><body>
  <xsl:apply-templates/>
  </body></html>
  </xsl:template>
  
  
  <xsl:template match="para">
     <p><xsl:apply-templates/></p>
  </xsl:template>
  
  <xsl:template match="publication">
     <font face="arial"><xsl:apply-templates/></font>
  </xsl:template>
  
  <xsl:template match="quote">
     <xsl:text/>"<xsl:apply-templates/>"<xsl:text/>
  </xsl:template>
  
  <xsl:template match="work">
     <i><xsl:apply-templates/></i>
  </xsl:template>
  
  <xsl:template match="role">
     <u><xsl:apply-templates/></u>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk029.xsl
  
  Index: mk029.xsl
  ===================================================================
  <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk030.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: soloist.xml, soloist+index.xsl -->
    <!-- Chapter/Page: 4-296 -->
    <!-- Purpose: Using modes -->
  
  <xsl:import href="inc/soloist.xsl"/>
  
  <xsl:template match="/">
  <html><body>
      <xsl:apply-templates/>
      <table bgcolor="#cccccc" border="1" cellpadding="5">
      <tr>
          <td><b>Date</b></td>
          <td><b>Venue</b></td>
          <td><b>Composer</b></td>
          <td><b>Work</b></td>
          <td><b>Role</b></td>
      </tr>
      <xsl:apply-templates mode="index"/>
      </table>
  </body></html>
  </xsl:template>
  
  <xsl:template match="performance" mode="index">
      <tr>
      <td><xsl:value-of select="date"/>&#xa0;</td>
      <td><xsl:value-of select="venue"/>&#xa0;</td>
      <td><xsl:value-of select="composer"/>&#xa0;</td>   
      <td><xsl:value-of select="work"/>&#xa0;</td>   
      <td><xsl:value-of select="role"/>&#xa0;</td>
      </tr>   
  </xsl:template>
  
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk030.xsl
  
  Index: mk030.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  
    <!-- Test FileName: mk030.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: opera.xml, opera.xsl -->
    <!-- Chapter/Page: 4-312 -->
    <!-- Purpose: Using a variable for context sensitive variables -->
  
  <xsl:output method="html" indent="yes" />
  <xsl:template match="/">
  <html>
    <body>
      <center>
       <h1>Programme</h1>
       <xsl:for-each select="/programme/composer">
         <h2><xsl:value-of select="concat(fullname, ' (', born, '-', died, ')')"/></h2>
         <xsl:variable name="c" select="."/>
         <xsl:for-each select="/programme/opera[composer=$c/@name]">
             <p><xsl:value-of select="title"/></p>
         </xsl:for-each>
       </xsl:for-each>
      </center>
    </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk031.xsl
  
  Index: mk031.xsl
  ===================================================================
  <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xsl:version="1.0">
  
    <!-- Test FileName: mk031.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: opera.xml, composers.xsl -->
    <!-- Chapter/Page: 4-316 -->
    <!-- Purpose: Getting the result of call-template in a variable -->
  
  <xsl:template match="/">
      <xsl:variable name="list">
           <xsl:call-template name="make-list">
                <xsl:with-param name="names" select="/programme/composer/fullname"/>
           </xsl:call-template>
      </xsl:variable>
      This week's composers are:
      <xsl:value-of select="translate($list, ',', ';')"/>
  </xsl:template>
  
  <xsl:template name="make-list">
      <xsl:param name="names"/>
      <xsl:for-each select="$names">
          <xsl:value-of select="."/>
          <xsl:if test="position()!=last()">, </xsl:if>
          <xsl:if test="position()=last()-1">and </xsl:if>
      </xsl:for-each>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk032.xsl
  
  Index: mk032.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet
  	version="1.0"
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk032.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: itinerary.xml, itinerary.xsl -->
    <!-- Chapter/Page: 4-421 -->
    <!-- Purpose: Using the key() pattern to format a specific node -->
  
  <xsl:template match="/">
  	<html>
  	<head>
  		<title>Itinerary</title>
  	</head>
  	<body><center>
  		<xsl:apply-templates select="//day"/>
  	</center></body>
  	</html>
  </xsl:template>
  
  <xsl:template match="day">
      <h3>Day <xsl:value-of select="@number"/></h3>
      <p><xsl:apply-templates/></p>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk033.xsl
  
  Index: mk033.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:stylesheet
  	version="1.0"
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk033.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: itinerary.xml, today.xsl, itinerary.xsl -->
    <!-- Chapter/Page: 4-422 -->
    <!-- Purpose: Using the key() pattern to format a specific node -->
  
  <xsl:import href="mk032.xsl"/>
  <xsl:key name="day-number" match="day" use="@number"/>
  
  <xsl:template match="key('day-number','5')//text()">
      <font color="red"><xsl:value-of select="."/></font>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk034.xsl
  
  Index: mk034.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk034.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: cities.xml, list-cities.xsl -->
    <!-- Chapter/Page: 7-431 -->
    <!-- Purpose: Creating a comma-separated list (concat function) -->
  
  <xsl:output indent="yes"/>
  <xsl:template match="/">
    <out>
      <xsl:for-each select="//city">
        <city><xsl:value-of select="concat(@name, ', ', @country)"/></city>
      </xsl:for-each>
    </out>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk035.xsl
  
  Index: mk035.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet version="1.0"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk035.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: cities.xml, count-countries.xsl -->
    <!-- Chapter/Page: 7-436 -->
    <!-- Purpose: Counting distinct values (count function) -->
  
  <xsl:template match="/">
  <count>
  <xsl:value-of 
        select="count(//city[not(@country=preceding::city/@country)])"/>
  </count>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk036.xsl
  
  Index: mk036.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk036.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, list-books.xsl -->
    <!-- Chapter/Page: 4-438 -->
    <!-- Purpose: Counting distinct values (current function) -->
  
  <xsl:template match="/">
    <html><body>
      <xsl:variable name="all-books" select="//book"/>
      <xsl:for-each select="$all-books">
        <h1><xsl:value-of select="title"/></h1>
        <p><i>by </i><xsl:value-of select="author"/> 
           <xsl:if test="count(author)!=1"> and others</xsl:if>
        </p>
        <xsl:variable name="others"
          select="$all-books[./@category=current()/@category and
                               generate-id(.)!=generate-id(current())]"/>
          <xsl:if test="$others">
            <p>Other books in this category:</p><ul>
            <xsl:for-each select="$others">
               <li><xsl:value-of select="title"/></li>
            </xsl:for-each>
            </ul>
          </xsl:if>
      </xsl:for-each>
    </body></html>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk037.xsl
  
  Index: mk037.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk037.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: dummy.xsl renamed to dummy.xml, list-includes.xsl -->
    <!-- Chapter/Page: 7-444 -->
    <!-- Purpose: Using document function to analyze a stylesheet -->
  
  <xsl:template match="/">
    <html><body>
      <h1>Stylesheet Module Structure</h1>
      <ul>
      <xsl:apply-templates select="*/xsl:include | */xsl:import"/>
      </ul>
    </body></html>
  </xsl:template>
  
  <xsl:template match="xsl:include | xsl:import">
      <li><xsl:value-of select="concat(local-name(),'s ',@href)"/>
      <xsl:variable name="module" select="document(@href)"/>
      <ul>
      <xsl:apply-templates select="$module/*/xsl:include | $module/*/xsl:import"/>
      </ul>
      </li>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk038.xsl
  
  Index: mk038.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
   xmlns:book="books.uri"
   exclude-result-prefixes="book"
  >
  
    <!-- Test FileName: mk038.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, list-categories.xsl -->
    <!-- Chapter/Page: 7-449 -->
    <!-- Purpose: A lookup table in the stylesheet -->
  
  <xsl:template match="/">
    <html><body>
      <xsl:for-each select="//book">
         <h1><xsl:value-of select="title"/></h1>
         <p>Category: <xsl:value-of 
           select="document('')/*/book:category[@code=current()/@category]/@desc"/>
         </p>
      </xsl:for-each>
    </body></html>
  </xsl:template>
  
  <book:category code="S" desc="Science"/>
  <book:category code="CS" desc="Computing"/>
  <book:category code="FC" desc="Children's Fiction"/>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk039.xsl
  
  Index: mk039.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk039.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: resorts.xml, resorts.xsl -->
    <!-- Chapter/Page: 7-464 -->
    <!-- Purpose: Using generate id to create links  -->
  
  <xsl:template match="/">
  <html>
  <body>
     <h1>Hotels</h1>
     <xsl:for-each select="//hotel">
     <xsl:sort select="stars" order="descending" data-type="number"/>
        <h2><xsl:value-of select="name"/></h2>
        <p>Address: <xsl:value-of select="address"/></p>
        <p>Stars: <xsl:value-of select="stars"/></p>
        <p>Resort: <a href="#{generate-id(parent::resort)}">
              <xsl:value-of select="parent::resort/name"/></a></p>
     </xsl:for-each>
  
     <h1>Resorts</h1>
     <xsl:for-each select="//resort">
        <h2><a name="{generate-id()}">
           <xsl:value-of select="name"/>
        </a></h2>
        <p><xsl:value-of select="details"/></p>
     </xsl:for-each>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk040.xsl
  
  Index: mk040.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk040.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, authors.xml, author-biogs.xsl -->
    <!-- Chapter/Page: 7-472 -->
    <!-- Purpose: Using keys -->
  
  <xsl:key name="biog" match="author" use="@name"/>
  <xsl:variable name="biogs" select="document('./inc/authors.xml')"/>
  
  <xsl:template match="/">
    <html><body>
      <xsl:variable name="all-books" select="//book"/>
      <xsl:for-each select="$all-books">
        <h1><xsl:value-of select="title"/></h1>
        <h2>Author<xsl:if test="count(author)!=1">s</xsl:if></h2>
        <xsl:for-each select="author">
           <xsl:variable name="name" select="."/>
           <h3><xsl:value-of select="$name"/></h3>
           <xsl:for-each select="$biogs">
             <xsl:variable name="auth" select="key('biog', $name)"/>
             <p><xsl:value-of select="concat($auth/born, ' - ', $auth/died)"/></p>
             <p><xsl:value-of select="$auth/biog"/></p>
           </xsl:for-each>
        </xsl:for-each>
      </xsl:for-each>
    </body></html>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk041.xsl
  
  Index: mk041.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk041.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: issue-dates.xml, format-dates.xsl -->
    <!-- Chapter/Page: 7-476 -->
    <!-- Purpose: Using lang function for localizing dates -->
  
  <xsl:output encoding="iso-8859-1"/>
  
  <data xmlns="data.uri">
  <months xml:lang="en">
     <m>January</m><m>February</m><m>March</m><m>April</m>
     <m>May</m><m>June</m><m>July</m><m>August</m>
     <m>September</m><m>October</m><m>November</m><m>December</m>
  </months>
  <months xml:lang="fr">
     <m>Janvier</m><m>F�vrier</m><m>Mars</m><m>Avril</m>
     <m>Mai</m><m>Juin</m><m>Juillet</m><m>Ao�t</m>
     <m>Septembre</m><m>Octobre</m><m>Novembre</m><m>D�cembre</m>
  </months>
  <months xml:lang="de">
     <m>Januar</m><m>Februar</m><m>M�rz</m><m>April</m>
     <m>Mai</m><m>Juni</m><m>Juli</m><m>August</m>
     <m>September</m><m>Oktober</m><m>November</m><m>Dezember</m>
  </months>
  </data>
  
  <xsl:param name="language" select="'en'"/>
  
  <xsl:template match="iso-date">
  <date xmlns:data="data.uri" xsl:exclude-result-prefixes="data">
     <xsl:value-of select="substring(., 7, 2)"/>
     <xsl:text> </xsl:text>
     <xsl:variable name="month" select="number(substring(.,5,2))"/>
     <xsl:value-of select="document('')/*/data:data/data:months[lang($language)]/data:m[$month]"/>
     <xsl:text> </xsl:text>
     <xsl:value-of select="substring(., 1, 4)"/>
  </date>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk042.xsl
  
  Index: mk042.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk042.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, format-names.xsl -->
    <!-- Chapter/Page: 7-480 -->
    <!-- Purpose: Formatting a list using position and last functions -->
  
  <xsl:template match="book">
  <auth>
      <xsl:for-each select="author">
          <xsl:value-of select="."/>
          <xsl:choose>
              <xsl:when test="position() = last()"/>
              <xsl:when test="position() = last()-1"> and </xsl:when>
              <xsl:otherwise>, </xsl:otherwise>
          </xsl:choose>
      </xsl:for-each>
  </auth>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk043.xsl
  
  Index: mk043.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk043.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: any xml, list-elements.xsl -->
    <!-- Chapter/Page: 7-489 -->
    <!-- Purpose: Listing the element names that appear in a doc -->
  
  <xsl:template match="/">
  <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>
      <xsl:apply-templates select="//*">
           <xsl:sort select="namespace-uri()"/>
           <xsl:sort select="local-name()"/>
      </xsl:apply-templates>
  </table></body></html>
  </xsl:template>
  
  <xsl:template match="*">
       <xsl:variable name="prefix">
          <xsl:choose>
          <xsl:when test="contains(name(), ':')">
             <xsl:value-of select="substring-before(name(),':')"/>
          </xsl:when>
          <xsl:otherwise/>
          </xsl:choose>
       </xsl:variable>
       <tr>
       <td><xsl:value-of select="name()"/></td>
       <td><xsl:value-of select="$prefix"/></td>
       <td><xsl:value-of select="local-name()"/></td>
       <td><xsl:value-of select="namespace-uri()"/></td>
       </tr>
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk044.xsl
  
  Index: mk044.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk044.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: authors.xml, word-count.xsl -->
    <!-- Chapter/Page: 7-494 -->
    <!-- Purpose: Using normalize-space to get a word count -->
  
  <xsl:template name="word-count">
      <xsl:param name="text"/>
      <xsl:variable name="ntext" select="normalize-space($text)"/>
      <xsl:choose>
      <xsl:when test="$ntext">        
          <xsl:variable name="remainder">
              <xsl:call-template name="word-count">
                  <xsl:with-param name="text" select="substring-after($ntext, ' ')"/>
              </xsl:call-template>
          </xsl:variable>
          <xsl:value-of select="$remainder + 1"/>
      </xsl:when>    
      <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/">
      <xsl:for-each select="//*">
          <xsl:variable name="length">
              <xsl:call-template name="word-count">
                  <xsl:with-param name="text" select="."/>
              </xsl:call-template>
          </xsl:variable>
          <element name="{name()}" words="{$length}"/>;
      </xsl:for-each>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk045.xsl
  
  Index: mk045.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk045.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: shapes.xml, area.xsl -->
    <!-- Chapter/Page: 7-502 -->
    <!-- Purpose: Using position() to process node set recursively -->
    
  <xsl:template match="rectangle" mode="area">
      <xsl:value-of select="@width * @height"/>
  </xsl:template>
  
  <xsl:template match="square" mode="area">
      <xsl:value-of select="@side * @side"/>
  </xsl:template>
  
  <xsl:template match="circle" mode="area">
      <xsl:value-of select="3.14159 * @radius * @radius"/>
  </xsl:template>
  
  <xsl:template name="total-area">
      <xsl:param name="set-of-shapes"/>
      <xsl:choose>
      <xsl:when test="$set-of-shapes">
          <xsl:variable name="first">
              <xsl:apply-templates select="$set-of-shapes[1]" mode="area"/>
          </xsl:variable>
          <xsl:variable name="rest">
              <xsl:call-template name="total-area">
                  <xsl:with-param name="set-of-shapes"
                      select="$set-of-shapes[position()!=1]"/>
              </xsl:call-template>
          </xsl:variable>
          <xsl:value-of select="$first + $rest"/>
      </xsl:when>
      <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
  </xsl:template>
  
  <xsl:template match="shapes">
      <xsl:call-template name="total-area">
          <xsl:with-param name="set-of-shapes" select="*"/>
      </xsl:call-template>
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk046.xsl
  
  Index: mk046.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk046.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: shapes.xml, area.xsl -->
    <!-- Chapter/Page: 7-505 -->
    <!-- Purpose: Using position() to process node set recursively -->
    
  <xsl:template match="sales">
  <html><body>
     <h1>Product sales by period</h1>
     <xsl:variable name="cols" select="count(product[1]/period)"/>
     <table border="1" cellpadding="5" width="100%">
        <tr>
        <th width="50%">Product</th>
        <xsl:for-each select="product[1]/period">
           <th width="{round(50 div $cols)}%">
              <xsl:value-of select="@name"/>
           </th>
        </xsl:for-each>
     </tr>
     <xsl:for-each select="product">
     <tr>
        <td><xsl:value-of select="text()"/></td>
        <xsl:for-each select="period">
           <td>
              <xsl:value-of select="."/>
           </td>
        </xsl:for-each>
     </tr>
     </xsl:for-each>
     </table>
  </body></html>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk047.xsl
  
  Index: mk047.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk047.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: authors.xml, replace.xsl -->
    <!-- Chapter/Page: 7-519 -->
    <!-- Purpose: Replace all occurrences of a string -->
    
  <xsl:param name="replace" select="'author'"/>
  <xsl:param name="by" select="'****'"/>
  
  <xsl:template name="do-replace">
       <xsl:param name="text"/>
     <xsl:choose>
     <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text, $replace)"/>
        <xsl:value-of select="$by"/>
        <xsl:call-template name="do-replace">
           <xsl:with-param name="text"
                           select="substring-after($text, $replace)"/>
        </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
        <xsl:value-of select="$text"/>
     </xsl:otherwise>
     </xsl:choose>
  
  </xsl:template>
  
  <xsl:template match="*">
      <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
      </xsl:copy>
  </xsl:template>
  
  <xsl:template match="text()">
      <xsl:call-template name="do-replace">
          <xsl:with-param name="text" select="."/>
      </xsl:call-template>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk048.xsl
  
  Index: mk048.xsl
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
    <!-- Test FileName: mk048.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: soccer.xml, league.xsl -->
    <!-- Chapter/Page: 7-521 -->
    <!-- Purpose: Creates scorecard for soccer league using count() and sum() functions -->
    
  <xsl:variable name="teams" select="//team[not(.=preceding::team)]"/>
  <xsl:variable name="matches" select="//match"/>
  
  <xsl:template match="results">
  <html><body>
     <h1>Results of Group <xsl:value-of select="@group"/></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>
     <xsl:for-each select="$teams">
          <xsl:variable name="this" select="."/>
          <xsl:variable name="played" select="count($matches[team=$this])"/>
          <xsl:variable name="won" 
              select="count($matches[team[.=$this]/@score &gt; team[.!=$this]/@score])"/>
          <xsl:variable name="lost"
              select="count($matches[team[.=$this]/@score &lt; team[.!=$this]/@score])"/>
          <xsl:variable name="drawn"
              select="count($matches[team[.=$this]/@score = team[.!=$this]/@score])"/>
          <xsl:variable name="for"
              select="sum($matches/team[.=current()]/@score)"/>
          <xsl:variable name="against"
              select="sum($matches[team=current()]/team/@score) - $for"/>
  
          <tr>
          <td><xsl:value-of select="."/></td>
          <td><xsl:value-of select="$played"/></td>
          <td><xsl:value-of select="$won"/></td>
          <td><xsl:value-of select="$drawn"/></td>
          <td><xsl:value-of select="$lost"/></td>
          <td><xsl:value-of select="$for"/></td>
          <td><xsl:value-of select="$against"/></td>
          </tr>
     </xsl:for-each>
     </table>
  </body></html>
  </xsl:template>
  
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk049.xsl
  
  Index: mk049.xsl
  ===================================================================
  <?xml version="1.0" ?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  
    <!-- Test FileName: mk049.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: orgchart.xml, orgchart.xsl -->
    <!-- Chapter/Page: 8-534 -->
    <!-- Purpose: Illustrate a fill-in the blanks stylesheet -->
    
  <xsl:template match="/">
  <html>
  <head>
     <title>Management Structure</title>
  </head>
  <body>
     <h1>Management Structure</h1>
     <p>The following responsibilies were announced on 
        <xsl:value-of select="/orgchart/@date"/>:</p>
     <table border="2" cellpadding="5">
     <tr>
        <th>Name</th><th>Role</th><th>Reporting to</th>
     </tr>
     <xsl:for-each select="//person">
        <tr>
           <td><xsl:value-of select="name"/></td>
           <td><xsl:value-of select="title"/></td>
           <td><xsl:value-of select="ancestor::person[1]/name"/></td>
        </tr>
     </xsl:for-each>
     </table>
     <hr/>
  </body>
  </html>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk050.xsl
  
  Index: mk050.xsl
  ===================================================================
  <xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  
    <!-- Test FileName: mk050.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, booksales.xsl -->
    <!-- Chapter/Page: 8-537 -->
    <!-- Purpose: Illustrate a navigational stylesheet -->
    
  <xsl:key name="pub" match="book" use="publisher"/>
  
  <xsl:variable name="publishers" 
     select="//publisher[not(.=preceding::publisher)]"/>
  
  <xsl:template match="/">
  <html>
  <head>
     <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>
     <xsl:for-each select="$publishers">
        <tr>
           <td><xsl:value-of select="."/></td>
           <td><xsl:call-template name="total-sales"/></td>
        </tr>
     </xsl:for-each>
     </table>
  </body>
  </html>
  </xsl:template>
  
  <!-- calculate total book sales for the current publisher -->
  <xsl:template name="total-sales">
     <xsl:value-of select="sum(key('pub',string(.))/sales)"/>
  </xsl:template>
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk051.xsl
  
  Index: mk051.xsl
  ===================================================================
  <xsl:stylesheet 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0"
  >
  
    <!-- Test FileName: mk051.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: scene.xml, scene.xsl -->
    <!-- Chapter/Page: 8-544 -->
    <!-- Purpose: Illustrate a rules-based stylesheet -->
    
  <xsl:variable name="backcolor" select="'#FFFFCC'" />
  
  <xsl:template match="SCENE|PROLOGUE|EPILOGUE">
      <HTML>
      <HEAD>
          <TITLE><xsl:value-of select="TITLE"/></TITLE>
      </HEAD>
      <BODY BGCOLOR='{$backcolor}'>
          <xsl:apply-templates/>
      </BODY>
      </HTML>
  </xsl:template>
  
  <xsl:template match="SPEECH">
      <TABLE><TR>
      <TD WIDTH="160" VALIGN="TOP">
  	<xsl:apply-templates select="SPEAKER"/>
      </TD>
      <TD VALIGN="TOP">
      <xsl:apply-templates select="STAGEDIR|LINE"/>
      </TD>
  	</TR></TABLE>
  </xsl:template>
  
  <xsl:template match="TITLE">
      <H1><CENTER>
  	<xsl:apply-templates/>
  	</CENTER></H1><HR/>
  </xsl:template>
  
  <xsl:template match="SPEAKER">
      <B>
      <xsl:apply-templates/>
      <xsl:if test="not(position()=last())"><BR/></xsl:if>
      </B>
  </xsl:template>
  
  <xsl:template match="SCENE/STAGEDIR">
      <CENTER><H3>
  	<xsl:apply-templates/>
  	</H3></CENTER>
  </xsl:template>
  
  <xsl:template match="SPEECH/STAGEDIR">
      <P><I>
  	<xsl:apply-templates/>
  	</I></P>
  </xsl:template>
  
  <xsl:template match="LINE/STAGEDIR">
       [ <I>
  	<xsl:apply-templates/>
  	</I> ] 
  </xsl:template>
  
  <xsl:template match="SCENE/SUBHEAD">
      <CENTER><H3>
  	<xsl:apply-templates/>
  	</H3></CENTER>
  </xsl:template>
  
  <xsl:template match="SPEECH/SUBHEAD">
      <P><B>
  	<xsl:apply-templates/>
  	</B></P>
  </xsl:template>
  
  <xsl:template match="LINE">
  	<xsl:apply-templates/>
  	<BR/>
  </xsl:template>
  
  </xsl:stylesheet>	
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk052.xsl
  
  Index: mk052.xsl
  ===================================================================
  <xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  
    <!-- Test FileName: mk052.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: number-list.xml, number-total.xsl -->
    <!-- Chapter/Page: 8-553 -->
    <!-- Purpose: Totaling a list of numbers -->
    
  <xsl:template name="total-numbers">
     <xsl:param name="list"/>
     <xsl:variable name="wlist" 
        select="concat(normalize-space($list), ' ')"/>
     <xsl:choose>
        <xsl:when test="$wlist!=' '">
           <xsl:variable name="first" 
              select="substring-before($wlist, ' ')"/>
           <xsl:variable name="rest" 
              select="substring-after($wlist, ' ')"/>
           <xsl:variable name="total">
              <xsl:call-template name="total-numbers">
                 <xsl:with-param name="list" select="$rest"/>
              </xsl:call-template>
           </xsl:variable>
           <xsl:value-of select="number($first) + number($total)"/>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
     </xsl:choose>
  </xsl:template>
  
  <xsl:template match="/">
     <xsl:call-template name="total-numbers">
        <xsl:with-param name="list" select="."/>
     </xsl:call-template>
  </xsl:template>
  
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk053.xsl
  
  Index: mk053.xsl
  ===================================================================
  <xsl:stylesheet 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  
    <!-- Test FileName: mk053.xsl -->
    <!-- Source Attribution: 
         This test was written by Michael Kay and is taken from 
         'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
         ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved. 
         Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
         No part of this book may be reproduced, stored in a retrieval system or 
         transmitted in any form or by any means - electronic, electrostatic, mechanical, 
         photocopying, recording or otherwise - without the prior written permission of 
         the publisher, except in the case of brief quotations embodied in critical articles or reviews.
    -->
    <!-- Example: booklist.xml, booksales.xsl -->
    <!-- Chapter/Page: 8-555 -->
    <!-- Purpose: Finding the total sales value -->
    
  <xsl:template name="total-sales-value">
     <xsl:param name="list"/>
     <xsl:choose>
        <xsl:when test="$list">
           <xsl:variable name="first" select="$list[1]"/>
           <xsl:variable name="total-of-rest">
              <xsl:call-template name="total-sales-value">
                 <xsl:with-param name="list" select="$list[position()!=1]"/>
              </xsl:call-template>
           </xsl:variable>
           <xsl:value-of select="$first/sales * $first/price + $total-of-rest"/>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
     </xsl:choose>
  </xsl:template>
  
  
  <xsl:template match="/">   
     <xsl:variable name="total">
          <xsl:call-template name="total-sales-value">
              <xsl:with-param name="list" select="//book"/>
          </xsl:call-template>
     </xsl:variable>
  Total sales value is: <xsl:value-of select="format-number($total, '$#.00')"/>   
  </xsl:template>
  
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk054.xsl
  
  Index: mk054.xsl
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!-- @(#)xslspec.xsl 1.3 99/01/11 SMI; Style Sheet for the XML and XSL Recommendations and Working Drafts; written by Eduardo Gutentag -->
  <!-- $Id: mk054.xsl,v 1.1 2001/06/20 18:54:41 amiro Exp $ Hacked by James Clark -->
  <!DOCTYPE xsl:stylesheet [
  <!ENTITY copy   "&#169;">
  <!ENTITY nbsp   "&#160;">
  ]>
  <!-- XSL Style sheet, DTD omitted -->
  <xsl:stylesheet
  	version="1.0"
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
  
  <xsl:param name="w3">http://www.w3.org/</xsl:param>
  <!--
  +++++++++++++++++++++++++
  
  Inclusions
  
  +++++++++++++++++++++++++
  -->
  
  <xsl:template match="spec" mode="css">
  <xsl:text>code { font-family: monospace }</xsl:text>
  </xsl:template>
  
  <!--
  *******************************************************************
  
  Basic framework to format W3C specs (as in the XML spec)
  
  *******************************************************************
  -->
  	<xsl:template match="spec">
  		<html>
  		<head>
  		<title>
  		<xsl:value-of select="header/title"/>
  		</title>
  		<link rel="stylesheet" type="text/css"
                        href="{$w3}StyleSheets/TR/W3C-{substring-before(header/w3c-designation,'-')}"/>
  		<!-- This stops Netscape 4.5 from messing up. -->
  		<style type="text/css">
                  <xsl:apply-templates select="." mode="css"/>
                  </style>
  		</head>
  		<body>
  			<xsl:apply-templates/>
  		</body>
  		</html>
  	</xsl:template>
  <!-- 
  *******************************************************************
  
  Prologue
  
  *******************************************************************
  -->
  
          <xsl:template match="header">
                  <div class="head">
                          <a href="http://www.w3.org/">
  			  <img src="{$w3}Icons/WWW/w3c_home"
  			       alt="W3C" height="48" width="72"/>
                          </a>
  			<h1>
                              <xsl:value-of select="title"/>
  			    <br/>
                              <xsl:value-of select="version"/>
                          </h1>
                          <h2>
  				<xsl:value-of select="w3c-doctype"/>
  				<xsl:text> </xsl:text>
  				<xsl:value-of select="pubdate/day"/>
  				<xsl:text> </xsl:text>
  				<xsl:value-of select="pubdate/month"/>
  				<xsl:text> </xsl:text>
  				<xsl:value-of select="pubdate/year"/>
  			</h2>
                          <dl>
                          	<xsl:apply-templates select="publoc"/>
  		                <xsl:apply-templates select="latestloc"/>
                  		<xsl:apply-templates select="prevlocs"/>
                  		<xsl:apply-templates select="authlist"/>
                  	</dl>
                  	<xsl:call-template name="copyright"/>
                  	<hr title="Separator for header"/>
                  </div>
  		<xsl:apply-templates select="abstract"/>
  		<xsl:apply-templates select="status"/>
          </xsl:template>
  
  	<xsl:template match="publoc">
  		<dt>This version:</dt>
  	        <dd><xsl:apply-templates/></dd>
  	</xsl:template>
  	<xsl:template match="publoc/loc|latestloc/loc|prevlocs/loc">
  			<a href="{@href}"><xsl:apply-templates/></a>
  			<br/>
  	</xsl:template>
  	<xsl:template match="latestloc">
  		<dt>Latest version:</dt>
  	        <dd><xsl:apply-templates/></dd>
  	</xsl:template>
  
  	<xsl:template match="prevlocs">
  		<dt>
                    <xsl:text>Previous version</xsl:text>
                    <xsl:if test="count(loc)>1">s</xsl:if>
  		  <xsl:text>:</xsl:text>
                  </dt>
                  <dd><xsl:apply-templates/></dd>
  	</xsl:template>
  	<xsl:template match="authlist">
  		<dt>
                    <xsl:text>Editor</xsl:text>
                    <xsl:if test="count(author)>1">s</xsl:if>
  		  <xsl:text>:</xsl:text>
                  </dt>
  		<dd> <xsl:apply-templates/></dd>
  	</xsl:template>
  	<xsl:template match="author">
  		<xsl:apply-templates/>
  		<br/>
  	</xsl:template>
  
  	<xsl:template match="author/name">
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="author/affiliation">
  		<xsl:text> (</xsl:text>
  			<xsl:apply-templates/>
  		<xsl:text>) </xsl:text>
  	</xsl:template>
  
  	<xsl:template match="author/email">
  		<a href="{@href}">
  			<xsl:text>&lt;</xsl:text>
  				<xsl:apply-templates/>
  			<xsl:text>&gt;</xsl:text>
  		</a>
  	</xsl:template>
  
  	<xsl:template match="abstract">
  		<h2><a name="abstract">Abstract</a></h2>
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="status">
  		<h2><a name="status">Status of this document</a></h2>
  		<xsl:apply-templates/>
  	</xsl:template>
  		
  <!-- 
  *******************************************************************
  
  Real body work
  
  *******************************************************************
  -->
  
  	<xsl:template match="body">
  		<h2><a name="contents">Table of contents</a></h2>
  		<xsl:call-template name="toc"/>
  		<hr/>
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="back">
  	<hr title="Separator from footer"/>
  	<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="div1/head|inform-div1/head">
  		<h2><xsl:call-template name="head"/></h2>
  	</xsl:template>
  
  	<xsl:template match="div2/head">
  		<h3><xsl:call-template name="head"/></h3>
  	</xsl:template>
  
  	<xsl:template match="div3/head">
  		<h4><xsl:call-template name="head"/></h4>
  	</xsl:template>
  
  	<xsl:template match="div4/head">
  		<h5><xsl:call-template name="head"/></h5>
  	</xsl:template>
  
          <xsl:template name="head">
                  <xsl:for-each select="..">
  			<xsl:call-template name="insertID"/>
                  	<xsl:apply-templates select="." mode="number"/>
                  </xsl:for-each>
  		<xsl:apply-templates/>
                  <xsl:call-template name="inform"/>
          </xsl:template>
  
  <!-- 
  *******************************************************************
  
  Blocks
  
  *******************************************************************
  -->
  	<xsl:template match="item/p" priority="1">
  	<p>
  		<xsl:apply-templates/>
  	</p>
  	</xsl:template>
  
  	<xsl:template match="p">
  		<p>
  			<xsl:apply-templates/>
  		</p>
  	</xsl:template>
  
  
  	<xsl:template match="eg">
  		<pre>
                          <xsl:if test="@role='error'">
                              <xsl:attribute name="style">color: red</xsl:attribute>
                          </xsl:if>
  			<xsl:apply-templates/>
  		</pre>
  	</xsl:template>
  
  	<xsl:template match="htable">
  		<table border="{@border}"
  			   cellpadding="{@cellpadding}"
  			   align="{@align}">
  			<xsl:apply-templates/>
  		</table>
  	</xsl:template>
  
  	<xsl:template match="htbody">
  		<tbody>
  			<xsl:apply-templates/>
  		</tbody>
  	</xsl:template>
  
  	<xsl:template match="tr">
  		<tr align="{@align}"
  			valign="{@valign}">
  			<xsl:apply-templates/>
  		</tr>
  	</xsl:template>
  
  	<xsl:template match="td">
  		<td bgcolor="{@bgcolor}"
  			rowspan="{@rowspan}"
  			colspan="{@colspan}"
  			align="{@align}"
  			valign="{@valign}">
  			<xsl:apply-templates/>
  		</td>
  	</xsl:template>
  
  	<xsl:template match="ednote">
  		<blockquote>
  		<p><b>Ed. Note: </b><xsl:apply-templates/></p>
  		</blockquote>
  	</xsl:template>
  
  	<xsl:template match="edtext">
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="issue">
  		<xsl:call-template name="insertID"/>
  		<blockquote>
  			<p>
  			<b>Issue (<xsl:value-of select="substring-after(@id,'-')"/>): </b>
  			<xsl:apply-templates/>
  			</p>
  		</blockquote>
  	</xsl:template>
  
  
  	<xsl:template match="note">
  	<blockquote>
  		<b>NOTE: </b>
  		<xsl:apply-templates/>
  	</blockquote>
  	</xsl:template>
  
  	<xsl:template match="issue/p|note/p">
  	<xsl:apply-templates/>
  	</xsl:template>
  <!-- 
  *******************************************************************
  
  Productions
  
  *******************************************************************
  -->
  	<xsl:template match="scrap">
                  <xsl:if test="string(head)">
  		  <h5><xsl:value-of select="head"/></h5>
                  </xsl:if>
  		<table class="scrap">
  		<tbody>
  		<xsl:apply-templates select="prodgroup|prod"/>
  		</tbody>
  		</table>
  	</xsl:template>
  
  
  	<xsl:template match="prod">
  	    <!-- select elements that start a row -->
  	    <xsl:apply-templates select="
  *[self::lhs
    or ((self::vc or self::wfc or self::com)
        and not(preceding-sibling::*[1][self::rhs]))
    or (self::rhs
        and not(preceding-sibling::*[1][self::lhs]))]
  "/>
  	</xsl:template>
  
  	<xsl:template match="lhs">
  		<tr valign="baseline">
  		<td><a name="{../@id}"/>
  		<xsl:number from="body" level="any" format="[1]&nbsp;&nbsp;&nbsp;"/>
  		</td>
  		<td><xsl:apply-templates/></td>
  		<td><xsl:text>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</xsl:text></td>
  		<xsl:for-each select="following-sibling::*[1]">
  		  <td><xsl:apply-templates mode="cell" select="."/></td>
  		  <td><xsl:apply-templates mode="cell" select="following-sibling::*[1][self::vc or self::wfc or self::com]"/></td>
  		</xsl:for-each>
  		</tr>
  	</xsl:template>
  
  	<xsl:template match="rhs">
  		<tr valign="baseline">
                    <td></td>
                    <td></td>
  		  <td></td>
  		  <td><xsl:apply-templates mode="cell" select="."/></td>
  		  <td><xsl:apply-templates mode="cell" select="following-sibling::*[1][self::vc or self::wfc or self::com]"/></td>
  		</tr>
  	</xsl:template>
  
  	<xsl:template match="vc|wfc|com">
  		<tr valign="baseline">
                    <td></td>
                    <td></td>
  		<td></td>
  		<td></td>
  		<td><xsl:apply-templates mode="cell" select="."/></td>
  		</tr>
  	</xsl:template>
  
  
  	<xsl:template match="prodgroup">
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="com" mode="cell">
  		<xsl:text>/*</xsl:text>
  		<xsl:apply-templates/>
  		<xsl:text>*/</xsl:text>
  	</xsl:template>
  
  	<xsl:template match="rhs" mode="cell">
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="vc" mode="cell">
  		<xsl:text>[&nbsp;VC:&nbsp;</xsl:text>
  	<a href="#{@def}">
  		<xsl:value-of select="id(@def)/head"/>
  	</a>
  		<xsl:text>&nbsp;]</xsl:text>
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="wfc" mode="cell">
  		<xsl:text>[&nbsp;WFC:&nbsp;</xsl:text>
  	<a href="#{@def}">
  		<xsl:value-of select="id(@def)/head"/>
  	</a>
  		<xsl:text>&nbsp;]</xsl:text>
  		<xsl:apply-templates/>
  	</xsl:template>
  <!-- 
  *******************************************************************
  
  References
  
  *******************************************************************
  -->
  	<xsl:template match="p/loc" priority="1">
  		<a href="{@href}"><xsl:apply-templates/></a>
  	</xsl:template>
  
  	<xsl:template match="publoc/loc|latestloc/loc|prevlocs/loc">
  		<a href="{@href}"><xsl:apply-templates/></a>
  		<br/>
  	</xsl:template>
  
  	<xsl:template match="loc">
  		<a href="{@href}"><xsl:apply-templates/></a>
  	</xsl:template>
  
  
  	<xsl:template match="bibref">
  		<a href="#{@ref}">
  		<xsl:text>[</xsl:text>
  		<xsl:value-of select="id(@ref)/@key"/>
  		<xsl:apply-templates/>
  		<xsl:text>]</xsl:text>
  		</a>
  	</xsl:template>
  
  	<xsl:template match="specref">
  		<a href="#{@ref}">
  		<xsl:text>[</xsl:text>
  		<b>
                  <xsl:for-each select="id(@ref)/head">
                          <xsl:apply-templates select=".." mode="number"/>
                          <xsl:apply-templates/>
  		</xsl:for-each>
  		</b>
  		<xsl:apply-templates/>
  		<xsl:text>]</xsl:text>
  		</a>
  	</xsl:template>
  	<xsl:template match="xspecref|xtermref">
  		<a href="{@href}">
  		<xsl:apply-templates/>
  		</a>
  	</xsl:template>
  	<xsl:template match="termref">
  		<a href="#{@def}">
  		<xsl:apply-templates/>
  		</a>
  	</xsl:template>
  
  	<xsl:template match="titleref">
  		<a href="#{@href}">
  		<xsl:apply-templates/>
  		</a>
  	</xsl:template>
  
  	<xsl:template match="termdef">
  		<a name="{@id}">
  		</a>
  			<xsl:apply-templates/>
  	</xsl:template>
  
  
  	<xsl:template match="vcnote">
  		<a name="{@id}"></a>
  		<p><b>Validity Constraint: <xsl:value-of select="head"/></b></p>
  		<xsl:apply-templates/>
  	</xsl:template>
  
  	<xsl:template match="wfcnote">
  		<a name="{@id}"></a>
  		<p><b>Well Formedness Constraint: <xsl:value-of select="head"/></b></p>
  		<xsl:apply-templates/>
  	</xsl:template>
  
  <!-- 
  *******************************************************************
  
  Inlines
  
  *******************************************************************
  -->
  	<xsl:template match="termdef">
  		<a name="{@id}">
  		</a>
  		<xsl:apply-templates/>
  	</xsl:template>
  	
  	<xsl:template match="term">
  		<b><xsl:apply-templates/></b>
  	</xsl:template>
  
  	<xsl:template match="orglist/member[1]" priority="2">
  		<xsl:apply-templates select="*"/>
  	</xsl:template>
  
  	<xsl:template match="orglist/member">
  	        <xsl:text>; </xsl:text>
  		<xsl:apply-templates select="*"/>
  	</xsl:template>
  	
  	<xsl:template match="orglist/member/affiliation">
                   <xsl:text>, </xsl:text>
                   <xsl:apply-templates/>
          </xsl:template>
  	<xsl:template match="orglist/member/role">
  			<xsl:text> (</xsl:text>
  			<xsl:apply-templates/>
  			<xsl:text>)</xsl:text>
  	</xsl:template>
  
  	<xsl:template match="code">
  		<code>
  			<xsl:apply-templates/>
  		</code>
  	</xsl:template>
  
  	<xsl:template match="emph">
  		<i>
  			<xsl:apply-templates/>
  		</i>
  	</xsl:template>
  <!-- 
  *******************************************************************
  
  Lists
  
  *******************************************************************
  -->
  	<xsl:template match="blist">
  	<dl>
  		<xsl:apply-templates/>
  	</dl>
  	</xsl:template>
  
  	<xsl:template match="slist">
  	<ul>
  		<xsl:apply-templates/>
  	</ul>
  	</xsl:template>
  	<xsl:template match="sitem">
  	<li>
  		<xsl:apply-templates/>
  	</li>
  	</xsl:template>
  
  	<xsl:template match="blist/bibl">
  		<dt>
  			<a name="{@id}">
  			<xsl:value-of select="@key"/>
  			</a>
  		</dt>
  		<dd>
  			<xsl:apply-templates/>
  		</dd>
  	</xsl:template>
  
  	<xsl:template match="olist">
  	<ol>
  		<xsl:apply-templates/>
  	</ol>
  	</xsl:template>
  
  	<xsl:template match="ulist">
  	<!--
  	<ul type="circle">
  	-->
  	<ul>
  		<xsl:apply-templates/>
  	</ul>
  	</xsl:template>
  
  	<xsl:template match="glist">
  		<dl>
  			<xsl:apply-templates/>
  		</dl>
  	</xsl:template>
  
  	<xsl:template match="item">
  	<li>
  		<xsl:apply-templates/>
  	</li>
  	</xsl:template>
  
  	<xsl:template match="label">
  	<dt>
  		<b><xsl:apply-templates/></b>
  	</dt>
  	</xsl:template>
  
  	<xsl:template match="def">
  	<dd>
  		<xsl:apply-templates/>
  	</dd>
  	</xsl:template>
  
  	<xsl:template match="orglist">
  		<xsl:apply-templates select="*"/>
  	</xsl:template>
  
  
  	<xsl:template match="olist">
  	<ol>
  		<xsl:apply-templates/>
  	</ol>
  	</xsl:template>
  
  
  <!-- 
  *******************************************************************
  
  Empty templates
  
  *******************************************************************
  -->
  	<xsl:template match="w3c-designation">
  	</xsl:template>
  
  	<xsl:template match="w3c-doctype">
  	</xsl:template>
  
  	<xsl:template match="header/pubdate">
  	</xsl:template>
  
  
  	<xsl:template match="spec/header/title">
  	</xsl:template>
  
  	<xsl:template match="revisiondesc">
  	</xsl:template>
  	
  	<xsl:template match="pubstmt">
  	</xsl:template>
  
  	<xsl:template match="sourcedesc">
  	</xsl:template>
  
  	<xsl:template match="langusage">
  	</xsl:template>
  
  	<xsl:template match="version">
  	</xsl:template>
  <!-- 
  *******************************************************************
  
  Macros
  
  
  *******************************************************************
  -->
  
  	<xsl:template name="copyright">
  	<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>
  	</xsl:template>
  
  	<xsl:template name="toc">
  		<xsl:for-each select="/spec/body/div1">
  				<xsl:call-template name="makeref"/>
  				<br/>
  
  				<xsl:for-each select="div2">
  					<xsl:text>&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  					<xsl:call-template name="makeref"/>
  					<br/>
  						<xsl:for-each select="div3">
  							<xsl:text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  								<xsl:call-template name="makeref"/>
  							<br/>
  						</xsl:for-each>
  				</xsl:for-each>
  		</xsl:for-each>
  
  		<h3>Appendices</h3>
  
  		<xsl:for-each select="/spec/back/div1 | /spec/back/inform-div1">
  				<xsl:call-template name="makeref"/>
  				<br/>
  
  				<xsl:for-each select="div2">
  						<xsl:text>&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  						<xsl:call-template name="makeref"/>
  						<br/>
  
  						<xsl:for-each select="div3">
  								<xsl:text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text>
  								<xsl:call-template name="makeref"/>
  								<br/>
  						</xsl:for-each>
  				</xsl:for-each>
  		</xsl:for-each>
  	</xsl:template>
  
  	<xsl:template name="insertID">
  		<xsl:choose>
  			<xsl:when test="@id">
  				<a name="{@id}"/>
  			</xsl:when>
  			<xsl:otherwise>
  				<a name="section-{translate(head,' ','-')}"/>
  			</xsl:otherwise>
  		</xsl:choose>
  	</xsl:template>
  
  	<xsl:template name="makeref">
                  <xsl:apply-templates select="." mode="number"/>
  		<xsl:choose>
  			<xsl:when test="@id">
  				<a href="#{@id}">
  					<xsl:value-of select="head"/>
  				</a>
  			</xsl:when>
  			<xsl:otherwise>
  				<a href="#section-{translate(head,' ','-')}">
  					<xsl:value-of select="head"/>
  				</a>
  			</xsl:otherwise>
  		</xsl:choose>
                  <xsl:for-each select="head">
                    <xsl:call-template name="inform"/>
                  </xsl:for-each>
  	</xsl:template>
  
          <xsl:template name="inform">
             <xsl:if test="parent::inform-div1">
                <xsl:text> (Non-Normative)</xsl:text>
             </xsl:if>
          </xsl:template>
  
  	<xsl:template match="nt">
  		<a href="#{@def}"><xsl:apply-templates/></a>
          </xsl:template>
  
  	<xsl:template match="xnt">
  		<a href="{@href}"><xsl:apply-templates/></a>
          </xsl:template>
  
  	<xsl:template match="quote">
  		<xsl:text>"</xsl:text>
  		<xsl:apply-templates/>
  		<xsl:text>"</xsl:text>
  	</xsl:template>
  	
  	<xsl:template mode="number" match="back//*">
             <xsl:number level="multiple"
                         count="inform-div1|div1|div2|div3|div4"
                         format="A.1 "/>
          </xsl:template>
  	<xsl:template mode="number" match="*">
             <xsl:number level="multiple"
                         count="inform-div1|div1|div2|div3|div4"
                         format="1.1 "/>
          </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk055.xsl
  
  Index: mk055.xsl
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <xsl:stylesheet
          version="1.0"
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  	
    <!-- Test FileName: mk055.xsl -->
    <!-- Source Document: XSLT Programmer's Reference by Michael Kay -->
    <!-- Example: REC-xpath-19991116.xml, spec.dtd, xpath.xsl -->
    <!-- Chapter/Page: 9-588 -->
    <!-- Purpose: Formatting the XPath Specification -->
    
  <xsl:import href="mk054.xsl"/>
  <xsl:template match="proto">
  <p><a name="function-{@name}">
  <b>Function: </b>
  <i><xsl:value-of select="@return-type"/></i>
  <xsl:text> </xsl:text>
  <b><xsl:value-of select="@name"/></b>
  <xsl:text>(</xsl:text>
  <xsl:for-each select="arg">
  <xsl:if test="not(position()=1)">
  <xsl:text>, </xsl:text>
  </xsl:if>
  <i><xsl:value-of select="@type"/></i>
  <xsl:choose>
  <xsl:when test="@occur='rep'">*</xsl:when>
  <xsl:when test="@occur='opt'">?</xsl:when>
  </xsl:choose>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
  </a></p>
  </xsl:template>
  <xsl:template match="function">
  <b><a href="#function-{.}"><xsl:apply-templates/></a></b>
  </xsl:template>
  <xsl:template match="xfunction">
  <b><a href="{@href}#function-{.}"><xsl:apply-templates/></a></b>
  </xsl:template>
  
  <!-- Support for <loc role="available-format">...</loc> -->
  <xsl:template match="publoc/loc[@role='available-format']">
    <xsl:if test="not(preceding-sibling::loc[@role='available-format'])">
      <xsl:text>(available in </xsl:text>
    </xsl:if>
    <a href="{@href}"><xsl:apply-templates/></a>
    <xsl:variable name="nf"
      select="count(following-sibling::loc[@role='available-format'])"/>
    <xsl:choose>
     <xsl:when test="not($nf)">
       <xsl:text>)</xsl:text>
     </xsl:when>
     <xsl:when test="$nf = 1">
       <xsl:choose>
         <xsl:when test="count(../loc[@role='available-format'])=2">
  	 <xsl:text> or </xsl:text>
         </xsl:when>
         <xsl:otherwise>
  	 <xsl:text>, or </xsl:text>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:when>
     <xsl:otherwise>
       <xsl:text>, </xsl:text>
     </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk056.xsl
  
  Index: mk056.xsl
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  <!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
  ]>
  <xsl:stylesheet
  	version="1.0"
  	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax"
          exclude-result-prefixes="e"
  >
  	
    <!-- Test FileName: mk056.xsl -->
    <!-- Source Document: XSLT Programmer's Reference by Michael Kay -->
    <!-- Example: REC-xslt-19991116.xml, spec.dtd, xslt.xsl -->
    <!-- Chapter/Page: 9-588 -->
    <!-- Purpose: Formatting the XSLT Specification -->
    
  <xsl:import href="mk055.xsl"/>
  
  <xsl:strip-space elements="e:*"/>
  
  <xsl:template match="spec" mode="css">
  <xsl:text>p.element-syntax { border: solid thin }</xsl:text>
  <xsl:apply-imports/>
  </xsl:template>
  
  <xsl:template match="e:element-syntax-summary">
    <xsl:for-each select="//e:element-syntax">
      <xsl:sort select="@name"/>
      <p class="element-syntax-summary"><code>
        <xsl:apply-templates select="e:in-category"/>
        <xsl:text>&lt;</xsl:text>
        <a href="#element-{@name}">
          <xsl:text>xsl:</xsl:text><xsl:value-of select="@name"/>
        </a>
        <xsl:apply-templates mode="top"/>
     </code></p>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="e:element-syntax">
  <p class="element-syntax"><a name="element-{@name}"/><code>
  <xsl:apply-templates select="e:in-category"/>
  <xsl:text>&lt;xsl:</xsl:text><xsl:value-of select="@name"/>
  <xsl:apply-templates mode="top"/>
  </code></p>
  </xsl:template>
  
  <xsl:template match="e:in-category">
  <xsl:text>&lt;!-- Category: </xsl:text>
  <xsl:value-of select="@name"/>
  <xsl:text> --&gt;</xsl:text>
  <br/>
  </xsl:template>
  
  <xsl:template match="e:sequence|e:choice|e:model|e:element|e:text" mode="top">
  <xsl:text>&gt;</xsl:text>
  <br/>
  <xsl:text>&nbsp;&nbsp;&lt;!-- Content: </xsl:text>
  <xsl:apply-templates select="."/>
  <xsl:text> --&gt;</xsl:text>
  <br/>
  <xsl:text>&lt;/xsl:</xsl:text>
  <xsl:value-of select="../@name"/>
  <xsl:text>&gt;</xsl:text>
  </xsl:template>
  
  <xsl:template match="e:sequence|e:choice">
  <xsl:text>(</xsl:text>
  <xsl:apply-templates/>
  <xsl:text>)</xsl:text>
  <xsl:call-template name="repeat"/>
  </xsl:template>
  
  <xsl:template match="e:model">
  <xsl:call-template name="group"/>
  <var><xsl:value-of select="@name"/></var>
  <xsl:call-template name="repeat"/>
  </xsl:template>
  
  <xsl:template match="e:text">#PCDATA</xsl:template>
  
  <xsl:template match="e:element">
  <xsl:call-template name="group"/>
  <a href="#element-{@name}">
  <xsl:text>xsl:</xsl:text>
  <xsl:value-of select="@name"/>
  </a>
  <xsl:call-template name="repeat"/>
  </xsl:template>
  
  <xsl:template name="group">
  <xsl:if test="position()>1">
  <xsl:choose>
  <xsl:when test="parent :: e:sequence">, </xsl:when>
  <xsl:when test="parent :: e:choice"> | </xsl:when>
  </xsl:choose>
  </xsl:if>
  </xsl:template>
  
  <xsl:template name="repeat">
    <xsl:choose>
     <xsl:when test="@repeat='one-or-more'">
      <xsl:text>+</xsl:text>
     </xsl:when>
     <xsl:when test="@repeat='zero-or-more'">
      <xsl:text>*</xsl:text>
     </xsl:when>
     <xsl:when test="@repeat='zero-or-one'">
      <xsl:text>?</xsl:text>
     </xsl:when>
    </xsl:choose>
  </xsl:template>
  
  
  <xsl:template match="e:empty" mode="top">
  <xsl:text>&nbsp;/&gt;</xsl:text>
  </xsl:template>
  
  <xsl:template match="e:attribute" mode="top">
  <br/>
  
  <xsl:text>&nbsp;&nbsp;</xsl:text>
  <xsl:choose>
  <xsl:when test="@required='yes'">
  <b><xsl:value-of select="@name"/></b>
  </xsl:when>
  <xsl:otherwise>
  <xsl:value-of select="@name"/>
  </xsl:otherwise>
  </xsl:choose>
  <xsl:text> = </xsl:text>
  
  <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="e:data-type">
  <xsl:if test="position()>1"> | </xsl:if>
  <var><xsl:value-of select="@name"/></var>
  </xsl:template>
  
  <xsl:template match="e:constant">
  <xsl:if test="position()>1"> | </xsl:if>
  <xsl:text>"</xsl:text>
  <xsl:value-of select="@value"/>
  <xsl:text>"</xsl:text>
  </xsl:template>
  
  <xsl:template match="e:attribute-value-template">
  <xsl:text>{ </xsl:text>
  <xsl:apply-templates/>
  <xsl:text> }</xsl:text>
  </xsl:template>
  
  <xsl:template match="var">
  <var><xsl:apply-templates/></var>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk062.xsl
  
  Index: mk062.xsl
  ===================================================================
  <xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <!-- Test FileName: mk062.xsl -->
    <!-- Source Document: XSLT Programmer's Reference by Michael Kay -->
    <!-- Example: othello.xml, play.dtd, play.xsl -->
    <!-- Chapter/Page:  -->
    <!-- Purpose: Format a Shakespearean play  -->
    
  <xsl:output method="text"/>
  
  <!-- This stylesheet outputs the book list as a CSV file -->
  
  <xsl:template match="BOOKLIST">
          <xsl:apply-templates select="BOOKS"/>
  </xsl:template>
  
  <xsl:template match="BOOKS">
  Title,Author,Category<xsl:text/>
  <xsl:for-each select="ITEM">
  "<xsl:value-of select="TITLE"/>","<xsl:value-of select="AUTHOR"/>","<xsl:value-of select="@CAT"/>(<xsl:text/>
          <xsl:choose>
          <xsl:when test='@CAT="F"'>Fiction</xsl:when>
          <xsl:when test='@CAT="S"'>Science</xsl:when>
          <xsl:when test='@CAT="C"'>Computing</xsl:when>
          <xsl:when test='@CAT="X"'>Crime</xsl:when>
          <xsl:otherwise>Unclassified</xsl:otherwise>
          </xsl:choose>)"<xsl:text/>
  </xsl:for-each><xsl:text>
  </xsl:text>
  </xsl:template>
  
  </xsl:stylesheet>	
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk003.xml
  
  Index: mk003.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <?xml-stylesheet type="text/xsl" href="poem.xsl"?>
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk004.xml
  
  Index: mk004.xml
  ===================================================================
  <?xml version="1.0"?>
  <books>
  	<book category="reference">
  		<author>Nigel Rees</author>
  		<title>Sayings of the Century</title>
  		<price>8.95</price>
  	</book>
  	<book category="fiction">
  		<author>Evelyn Waugh</author>
  		<title>Sword of Honour</title>
  		<price>12.99</price>
  	</book>
  	<book category="fiction">
  		<author>Herman Melville</author>
  		<title>Moby Dick</title>
  		<price>8.99</price>
  	</book>
  	<book category="fiction">
  		<author>J. R. R. Tolkien</author>
  		<title>The Lord of the Rings</title>
  		<price>22.99</price>
  	</book>
  </books>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk005.xml
  
  Index: mk005.xml
  ===================================================================
  <?xml version="1.0"?>
  <books>
  	<book category="reference">
  		<author>Nigel Rees</author>
  		<title>Sayings of the Century</title>
  		<price>8.95</price>
  	</book>
  	<book category="fiction">
  		<author>Evelyn Waugh</author>
  		<title>Sword of Honour</title>
  		<price>12.99</price>
  	</book>
  	<book category="fiction">
  		<author>Herman Melville</author>
  		<title>Moby Dick</title>
  		<price>8.99</price>
  	</book>
  	<book category="fiction">
  		<author>J. R. R. Tolkien</author>
  		<title>The Lord of the Rings</title>
  		<price>22.99</price>
  	</book>
  </books>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk006.xml
  
  Index: mk006.xml
  ===================================================================
  <?xml version="1.0"?>
  <?xml-stylesheet type="text/xsl" href="simplified.xsl"?>
  <books>
  	<book category="reference">
  		<author>Nigel Rees</author>
  		<title>Sayings of the Century</title>
  		<price>8.95</price>
  	</book>
  	<book category="fiction">
  		<author>Evelyn Waugh</author>
  		<title>Sword of Honour</title>
  		<price>12.99</price>
  	</book>
  	<book category="fiction">
  		<author>Herman Melville</author>
  		<title>Moby Dick</title>
  		<price>8.99</price>
  	</book>
  	<book category="fiction">
  		<author>J. R. R. Tolkien</author>
  		<title>The Lord of the Rings</title>
  		<price>22.99</price>
  	</book>
  </books>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk007.xml
  
  Index: mk007.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <document>
      <author>Michael Kay</author>
      <title>XSLT Programmer's Reference</title>
      <copyright/>
      <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/xsltc/mk/mk008.xml
  
  Index: mk008.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <document>
      <author>Michael Kay</author>
      <title>XSLT Programmer's Reference</title>
      <copyright/>
      <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/xsltc/mk/mk011.xml
  
  Index: mk011.xml
  ===================================================================
  <SCENE><TITLE>SCENE I.  Venice. A street.</TITLE>
  <STAGEDIR>Enter RODERIGO and IAGO</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Tush! never tell me; I take it much unkindly</LINE>
  <LINE>That thou, Iago, who hast had my purse</LINE>
  <LINE>As if the strings were thine, shouldst know of this.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Sblood, but you will not hear me:</LINE>
  <LINE>If ever I did dream of such a matter, Abhor me.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Thou told'st me thou didst hold him in thy hate.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Despise me, if I do not. Three great ones of the city,</LINE>
  <LINE>In personal suit to make me his lieutenant,</LINE>
  <LINE>Off-capp'd to him: and, by the faith of man,</LINE>
  <LINE>I know my price, I am worth no worse a place:</LINE>
  <LINE>But he; as loving his own pride and purposes,</LINE>
  <LINE>Evades them, with a bombast circumstance</LINE>
  <LINE>Horribly stuff'd with epithets of war;</LINE>
  <LINE>And, in conclusion,</LINE>
  <LINE>Nonsuits my mediators; for, 'Certes,' says he,</LINE>
  <LINE>'I have already chose my officer.'</LINE>
  <LINE>And what was he?</LINE>
  <LINE>Forsooth, a great arithmetician,</LINE>
  <LINE>One Michael Cassio, a Florentine,</LINE>
  <LINE>A fellow almost damn'd in a fair wife;</LINE>
  <LINE>That never set a squadron in the field,</LINE>
  <LINE>Nor the division of a battle knows</LINE>
  <LINE>More than a spinster; unless the bookish theoric,</LINE>
  <LINE>Wherein the toged consuls can propose</LINE>
  <LINE>As masterly as he: mere prattle, without practise,</LINE>
  <LINE>Is all his soldiership. But he, sir, had the election:</LINE>
  <LINE>And I, of whom his eyes had seen the proof</LINE>
  <LINE>At Rhodes, at Cyprus and on other grounds</LINE>
  <LINE>Christian and heathen, must be be-lee'd and calm'd</LINE>
  <LINE>By debitor and creditor: this counter-caster,</LINE>
  <LINE>He, in good time, must his lieutenant be,</LINE>
  <LINE>And I--God bless the mark!--his Moorship's ancient.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>By heaven, I rather would have been his hangman.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Why, there's no remedy; 'tis the curse of service,</LINE>
  <LINE>Preferment goes by letter and affection,</LINE>
  <LINE>And not by old gradation, where each second</LINE>
  <LINE>Stood heir to the first. Now, sir, be judge yourself,</LINE>
  <LINE>Whether I in any just term am affined</LINE>
  <LINE>To love the Moor.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>I would not follow him then.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>O, sir, content you;</LINE>
  <LINE>I follow him to serve my turn upon him:</LINE>
  <LINE>We cannot all be masters, nor all masters</LINE>
  <LINE>Cannot be truly follow'd. You shall mark</LINE>
  <LINE>Many a duteous and knee-crooking knave,</LINE>
  <LINE>That, doting on his own obsequious bondage,</LINE>
  <LINE>Wears out his time, much like his master's ass,</LINE>
  <LINE>For nought but provender, and when he's old, cashier'd:</LINE>
  <LINE>Whip me such honest knaves. Others there are</LINE>
  <LINE>Who, trimm'd in forms and visages of duty,</LINE>
  <LINE>Keep yet their hearts attending on themselves,</LINE>
  <LINE>And, throwing but shows of service on their lords,</LINE>
  <LINE>Do well thrive by them and when they have lined</LINE>
  <LINE>their coats</LINE>
  <LINE>Do themselves homage: these fellows have some soul;</LINE>
  <LINE>And such a one do I profess myself. For, sir,</LINE>
  <LINE>It is as sure as you are Roderigo,</LINE>
  <LINE>Were I the Moor, I would not be Iago:</LINE>
  <LINE>In following him, I follow but myself;</LINE>
  <LINE>Heaven is my judge, not I for love and duty,</LINE>
  <LINE>But seeming so, for my peculiar end:</LINE>
  <LINE>For when my outward action doth demonstrate</LINE>
  <LINE>The native act and figure of my heart</LINE>
  <LINE>In compliment extern, 'tis not long after</LINE>
  <LINE>But I will wear my heart upon my sleeve</LINE>
  <LINE>For daws to peck at: I am not what I am.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>What a full fortune does the thicklips owe</LINE>
  <LINE>If he can carry't thus!</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Call up her father,</LINE>
  <LINE>Rouse him: make after him, poison his delight,</LINE>
  <LINE>Proclaim him in the streets; incense her kinsmen,</LINE>
  <LINE>And, though he in a fertile climate dwell,</LINE>
  <LINE>Plague him with flies: though that his joy be joy,</LINE>
  <LINE>Yet throw such changes of vexation on't,</LINE>
  <LINE>As it may lose some colour.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Here is her father's house; I'll call aloud.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Do, with like timorous accent and dire yell</LINE>
  <LINE>As when, by night and negligence, the fire</LINE>
  <LINE>Is spied in populous cities.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>What, ho, Brabantio! Signior Brabantio, ho!</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Awake! what, ho, Brabantio! thieves! thieves! thieves!</LINE>
  <LINE>Look to your house, your daughter and your bags!</LINE>
  <LINE>Thieves! thieves!</LINE>
  </SPEECH>
  
  
  <STAGEDIR>BRABANTIO appears above, at a window</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What is the reason of this terrible summons?</LINE>
  <LINE>What is the matter there?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Signior, is all your family within?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Are your doors lock'd?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Why, wherefore ask you this?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Zounds, sir, you're robb'd; for shame, put on</LINE>
  <LINE>your gown;</LINE>
  <LINE>Your heart is burst, you have lost half your soul;</LINE>
  <LINE>Even now, now, very now, an old black ram</LINE>
  <LINE>Is topping your white ewe. Arise, arise;</LINE>
  <LINE>Awake the snorting citizens with the bell,</LINE>
  <LINE>Or else the devil will make a grandsire of you:</LINE>
  <LINE>Arise, I say.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What, have you lost your wits?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Most reverend signior, do you know my voice?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Not I what are you?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>My name is Roderigo.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>The worser welcome:</LINE>
  <LINE>I have charged thee not to haunt about my doors:</LINE>
  <LINE>In honest plainness thou hast heard me say</LINE>
  <LINE>My daughter is not for thee; and now, in madness,</LINE>
  <LINE>Being full of supper and distempering draughts,</LINE>
  <LINE>Upon malicious bravery, dost thou come</LINE>
  <LINE>To start my quiet.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Sir, sir, sir,--</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>But thou must needs be sure</LINE>
  <LINE>My spirit and my place have in them power</LINE>
  <LINE>To make this bitter to thee.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Patience, good sir.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What tell'st thou me of robbing? this is Venice;</LINE>
  <LINE>My house is not a grange.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Most grave Brabantio,</LINE>
  <LINE>In simple and pure soul I come to you.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Zounds, sir, you are one of those that will not</LINE>
  <LINE>serve God, if the devil bid you. Because we come to</LINE>
  <LINE>do you service and you think we are ruffians, you'll</LINE>
  <LINE>have your daughter covered with a Barbary horse;</LINE>
  <LINE>you'll have your nephews neigh to you; you'll have</LINE>
  <LINE>coursers for cousins and gennets for germans.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What profane wretch art thou?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>I am one, sir, that comes to tell you your daughter</LINE>
  <LINE>and the Moor are now making the beast with two backs.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Thou art a villain.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>You are--a senator.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>This thou shalt answer; I know thee, Roderigo.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Sir, I will answer any thing. But, I beseech you,</LINE>
  <LINE>If't be your pleasure and most wise consent,</LINE>
  <LINE>As partly I find it is, that your fair daughter,</LINE>
  <LINE>At this odd-even and dull watch o' the night,</LINE>
  <LINE>Transported, with no worse nor better guard</LINE>
  <LINE>But with a knave of common hire, a gondolier,</LINE>
  <LINE>To the gross clasps of a lascivious Moor--</LINE>
  <LINE>If this be known to you and your allowance,</LINE>
  <LINE>We then have done you bold and saucy wrongs;</LINE>
  <LINE>But if you know not this, my manners tell me</LINE>
  <LINE>We have your wrong rebuke. Do not believe</LINE>
  <LINE>That, from the sense of all civility,</LINE>
  <LINE>I thus would play and trifle with your reverence:</LINE>
  <LINE>Your daughter, if you have not given her leave,</LINE>
  <LINE>I say again, hath made a gross revolt;</LINE>
  <LINE>Tying her duty, beauty, wit and fortunes</LINE>
  <LINE>In an extravagant and wheeling stranger</LINE>
  <LINE>Of here and every where. Straight satisfy yourself:</LINE>
  <LINE>If she be in her chamber or your house,</LINE>
  <LINE>Let loose on me the justice of the state</LINE>
  <LINE>For thus deluding you.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Strike on the tinder, ho!</LINE>
  <LINE>Give me a taper! call up all my people!</LINE>
  <LINE>This accident is not unlike my dream:</LINE>
  <LINE>Belief of it oppresses me already.</LINE>
  <LINE>Light, I say! light!</LINE>
  </SPEECH>
  
  
  <STAGEDIR>Exit above</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Farewell; for I must leave you:</LINE>
  <LINE>It seems not meet, nor wholesome to my place,</LINE>
  <LINE>To be produced--as, if I stay, I shall--</LINE>
  <LINE>Against the Moor: for, I do know, the state,</LINE>
  <LINE>However this may gall him with some cheque,</LINE>
  <LINE>Cannot with safety cast him, for he's embark'd</LINE>
  <LINE>With such loud reason to the Cyprus wars,</LINE>
  <LINE>Which even now stand in act, that, for their souls,</LINE>
  <LINE>Another of his fathom they have none,</LINE>
  <LINE>To lead their business: in which regard,</LINE>
  <LINE>Though I do hate him as I do hell-pains.</LINE>
  <LINE>Yet, for necessity of present life,</LINE>
  <LINE>I must show out a flag and sign of love,</LINE>
  <LINE>Which is indeed but sign. That you shall surely find him,</LINE>
  <LINE>Lead to the Sagittary the raised search;</LINE>
  <LINE>And there will I be with him. So, farewell.</LINE>
  </SPEECH>
  
  <STAGEDIR>Exit</STAGEDIR>
  <STAGEDIR>Enter, below, BRABANTIO, and Servants with torches</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>It is too true an evil: gone she is;</LINE>
  <LINE>And what's to come of my despised time</LINE>
  <LINE>Is nought but bitterness. Now, Roderigo,</LINE>
  <LINE>Where didst thou see her? O unhappy girl!</LINE>
  <LINE>With the Moor, say'st thou? Who would be a father!</LINE>
  <LINE>How didst thou know 'twas she? O she deceives me</LINE>
  <LINE>Past thought! What said she to you? Get more tapers:</LINE>
  <LINE>Raise all my kindred. Are they married, think you?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Truly, I think they are.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>O heaven! How got she out? O treason of the blood!</LINE>
  <LINE>Fathers, from hence trust not your daughters' minds</LINE>
  <LINE>By what you see them act. Is there not charms</LINE>
  <LINE>By which the property of youth and maidhood</LINE>
  <LINE>May be abused? Have you not read, Roderigo,</LINE>
  <LINE>Of some such thing?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Yes, sir, I have indeed.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Call up my brother. O, would you had had her!</LINE>
  <LINE>Some one way, some another. Do you know</LINE>
  <LINE>Where we may apprehend her and the Moor?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>I think I can discover him, if you please,</LINE>
  <LINE>To get good guard and go along with me.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Pray you, lead on. At every house I'll call;</LINE>
  <LINE>I may command at most. Get weapons, ho!</LINE>
  <LINE>And raise some special officers of night.</LINE>
  <LINE>On, good Roderigo: I'll deserve your pains.</LINE>
  </SPEECH>
  
  
  <STAGEDIR>Exeunt</STAGEDIR>
  </SCENE>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk012.xml
  
  Index: mk012.xml
  ===================================================================
  <SCENE><TITLE>SCENE I.  Venice. A street.</TITLE>
  <STAGEDIR>Enter RODERIGO and IAGO</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Tush! never tell me; I take it much unkindly</LINE>
  <LINE>That thou, Iago, who hast had my purse</LINE>
  <LINE>As if the strings were thine, shouldst know of this.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Sblood, but you will not hear me:</LINE>
  <LINE>If ever I did dream of such a matter, Abhor me.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Thou told'st me thou didst hold him in thy hate.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Despise me, if I do not. Three great ones of the city,</LINE>
  <LINE>In personal suit to make me his lieutenant,</LINE>
  <LINE>Off-capp'd to him: and, by the faith of man,</LINE>
  <LINE>I know my price, I am worth no worse a place:</LINE>
  <LINE>But he; as loving his own pride and purposes,</LINE>
  <LINE>Evades them, with a bombast circumstance</LINE>
  <LINE>Horribly stuff'd with epithets of war;</LINE>
  <LINE>And, in conclusion,</LINE>
  <LINE>Nonsuits my mediators; for, 'Certes,' says he,</LINE>
  <LINE>'I have already chose my officer.'</LINE>
  <LINE>And what was he?</LINE>
  <LINE>Forsooth, a great arithmetician,</LINE>
  <LINE>One Michael Cassio, a Florentine,</LINE>
  <LINE>A fellow almost damn'd in a fair wife;</LINE>
  <LINE>That never set a squadron in the field,</LINE>
  <LINE>Nor the division of a battle knows</LINE>
  <LINE>More than a spinster; unless the bookish theoric,</LINE>
  <LINE>Wherein the toged consuls can propose</LINE>
  <LINE>As masterly as he: mere prattle, without practise,</LINE>
  <LINE>Is all his soldiership. But he, sir, had the election:</LINE>
  <LINE>And I, of whom his eyes had seen the proof</LINE>
  <LINE>At Rhodes, at Cyprus and on other grounds</LINE>
  <LINE>Christian and heathen, must be be-lee'd and calm'd</LINE>
  <LINE>By debitor and creditor: this counter-caster,</LINE>
  <LINE>He, in good time, must his lieutenant be,</LINE>
  <LINE>And I--God bless the mark!--his Moorship's ancient.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>By heaven, I rather would have been his hangman.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Why, there's no remedy; 'tis the curse of service,</LINE>
  <LINE>Preferment goes by letter and affection,</LINE>
  <LINE>And not by old gradation, where each second</LINE>
  <LINE>Stood heir to the first. Now, sir, be judge yourself,</LINE>
  <LINE>Whether I in any just term am affined</LINE>
  <LINE>To love the Moor.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>I would not follow him then.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>O, sir, content you;</LINE>
  <LINE>I follow him to serve my turn upon him:</LINE>
  <LINE>We cannot all be masters, nor all masters</LINE>
  <LINE>Cannot be truly follow'd. You shall mark</LINE>
  <LINE>Many a duteous and knee-crooking knave,</LINE>
  <LINE>That, doting on his own obsequious bondage,</LINE>
  <LINE>Wears out his time, much like his master's ass,</LINE>
  <LINE>For nought but provender, and when he's old, cashier'd:</LINE>
  <LINE>Whip me such honest knaves. Others there are</LINE>
  <LINE>Who, trimm'd in forms and visages of duty,</LINE>
  <LINE>Keep yet their hearts attending on themselves,</LINE>
  <LINE>And, throwing but shows of service on their lords,</LINE>
  <LINE>Do well thrive by them and when they have lined</LINE>
  <LINE>their coats</LINE>
  <LINE>Do themselves homage: these fellows have some soul;</LINE>
  <LINE>And such a one do I profess myself. For, sir,</LINE>
  <LINE>It is as sure as you are Roderigo,</LINE>
  <LINE>Were I the Moor, I would not be Iago:</LINE>
  <LINE>In following him, I follow but myself;</LINE>
  <LINE>Heaven is my judge, not I for love and duty,</LINE>
  <LINE>But seeming so, for my peculiar end:</LINE>
  <LINE>For when my outward action doth demonstrate</LINE>
  <LINE>The native act and figure of my heart</LINE>
  <LINE>In compliment extern, 'tis not long after</LINE>
  <LINE>But I will wear my heart upon my sleeve</LINE>
  <LINE>For daws to peck at: I am not what I am.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>What a full fortune does the thicklips owe</LINE>
  <LINE>If he can carry't thus!</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Call up her father,</LINE>
  <LINE>Rouse him: make after him, poison his delight,</LINE>
  <LINE>Proclaim him in the streets; incense her kinsmen,</LINE>
  <LINE>And, though he in a fertile climate dwell,</LINE>
  <LINE>Plague him with flies: though that his joy be joy,</LINE>
  <LINE>Yet throw such changes of vexation on't,</LINE>
  <LINE>As it may lose some colour.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Here is her father's house; I'll call aloud.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Do, with like timorous accent and dire yell</LINE>
  <LINE>As when, by night and negligence, the fire</LINE>
  <LINE>Is spied in populous cities.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>What, ho, Brabantio! Signior Brabantio, ho!</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Awake! what, ho, Brabantio! thieves! thieves! thieves!</LINE>
  <LINE>Look to your house, your daughter and your bags!</LINE>
  <LINE>Thieves! thieves!</LINE>
  </SPEECH>
  
  
  <STAGEDIR>BRABANTIO appears above, at a window</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What is the reason of this terrible summons?</LINE>
  <LINE>What is the matter there?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Signior, is all your family within?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Are your doors lock'd?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Why, wherefore ask you this?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Zounds, sir, you're robb'd; for shame, put on</LINE>
  <LINE>your gown;</LINE>
  <LINE>Your heart is burst, you have lost half your soul;</LINE>
  <LINE>Even now, now, very now, an old black ram</LINE>
  <LINE>Is topping your white ewe. Arise, arise;</LINE>
  <LINE>Awake the snorting citizens with the bell,</LINE>
  <LINE>Or else the devil will make a grandsire of you:</LINE>
  <LINE>Arise, I say.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What, have you lost your wits?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Most reverend signior, do you know my voice?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Not I what are you?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>My name is Roderigo.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>The worser welcome:</LINE>
  <LINE>I have charged thee not to haunt about my doors:</LINE>
  <LINE>In honest plainness thou hast heard me say</LINE>
  <LINE>My daughter is not for thee; and now, in madness,</LINE>
  <LINE>Being full of supper and distempering draughts,</LINE>
  <LINE>Upon malicious bravery, dost thou come</LINE>
  <LINE>To start my quiet.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Sir, sir, sir,--</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>But thou must needs be sure</LINE>
  <LINE>My spirit and my place have in them power</LINE>
  <LINE>To make this bitter to thee.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Patience, good sir.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What tell'st thou me of robbing? this is Venice;</LINE>
  <LINE>My house is not a grange.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Most grave Brabantio,</LINE>
  <LINE>In simple and pure soul I come to you.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>'Zounds, sir, you are one of those that will not</LINE>
  <LINE>serve God, if the devil bid you. Because we come to</LINE>
  <LINE>do you service and you think we are ruffians, you'll</LINE>
  <LINE>have your daughter covered with a Barbary horse;</LINE>
  <LINE>you'll have your nephews neigh to you; you'll have</LINE>
  <LINE>coursers for cousins and gennets for germans.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>What profane wretch art thou?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>I am one, sir, that comes to tell you your daughter</LINE>
  <LINE>and the Moor are now making the beast with two backs.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Thou art a villain.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>You are--a senator.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>This thou shalt answer; I know thee, Roderigo.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Sir, I will answer any thing. But, I beseech you,</LINE>
  <LINE>If't be your pleasure and most wise consent,</LINE>
  <LINE>As partly I find it is, that your fair daughter,</LINE>
  <LINE>At this odd-even and dull watch o' the night,</LINE>
  <LINE>Transported, with no worse nor better guard</LINE>
  <LINE>But with a knave of common hire, a gondolier,</LINE>
  <LINE>To the gross clasps of a lascivious Moor--</LINE>
  <LINE>If this be known to you and your allowance,</LINE>
  <LINE>We then have done you bold and saucy wrongs;</LINE>
  <LINE>But if you know not this, my manners tell me</LINE>
  <LINE>We have your wrong rebuke. Do not believe</LINE>
  <LINE>That, from the sense of all civility,</LINE>
  <LINE>I thus would play and trifle with your reverence:</LINE>
  <LINE>Your daughter, if you have not given her leave,</LINE>
  <LINE>I say again, hath made a gross revolt;</LINE>
  <LINE>Tying her duty, beauty, wit and fortunes</LINE>
  <LINE>In an extravagant and wheeling stranger</LINE>
  <LINE>Of here and every where. Straight satisfy yourself:</LINE>
  <LINE>If she be in her chamber or your house,</LINE>
  <LINE>Let loose on me the justice of the state</LINE>
  <LINE>For thus deluding you.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Strike on the tinder, ho!</LINE>
  <LINE>Give me a taper! call up all my people!</LINE>
  <LINE>This accident is not unlike my dream:</LINE>
  <LINE>Belief of it oppresses me already.</LINE>
  <LINE>Light, I say! light!</LINE>
  </SPEECH>
  
  
  <STAGEDIR>Exit above</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>IAGO</SPEAKER>
  <LINE>Farewell; for I must leave you:</LINE>
  <LINE>It seems not meet, nor wholesome to my place,</LINE>
  <LINE>To be produced--as, if I stay, I shall--</LINE>
  <LINE>Against the Moor: for, I do know, the state,</LINE>
  <LINE>However this may gall him with some cheque,</LINE>
  <LINE>Cannot with safety cast him, for he's embark'd</LINE>
  <LINE>With such loud reason to the Cyprus wars,</LINE>
  <LINE>Which even now stand in act, that, for their souls,</LINE>
  <LINE>Another of his fathom they have none,</LINE>
  <LINE>To lead their business: in which regard,</LINE>
  <LINE>Though I do hate him as I do hell-pains.</LINE>
  <LINE>Yet, for necessity of present life,</LINE>
  <LINE>I must show out a flag and sign of love,</LINE>
  <LINE>Which is indeed but sign. That you shall surely find him,</LINE>
  <LINE>Lead to the Sagittary the raised search;</LINE>
  <LINE>And there will I be with him. So, farewell.</LINE>
  </SPEECH>
  
  <STAGEDIR>Exit</STAGEDIR>
  <STAGEDIR>Enter, below, BRABANTIO, and Servants with torches</STAGEDIR>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>It is too true an evil: gone she is;</LINE>
  <LINE>And what's to come of my despised time</LINE>
  <LINE>Is nought but bitterness. Now, Roderigo,</LINE>
  <LINE>Where didst thou see her? O unhappy girl!</LINE>
  <LINE>With the Moor, say'st thou? Who would be a father!</LINE>
  <LINE>How didst thou know 'twas she? O she deceives me</LINE>
  <LINE>Past thought! What said she to you? Get more tapers:</LINE>
  <LINE>Raise all my kindred. Are they married, think you?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Truly, I think they are.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>O heaven! How got she out? O treason of the blood!</LINE>
  <LINE>Fathers, from hence trust not your daughters' minds</LINE>
  <LINE>By what you see them act. Is there not charms</LINE>
  <LINE>By which the property of youth and maidhood</LINE>
  <LINE>May be abused? Have you not read, Roderigo,</LINE>
  <LINE>Of some such thing?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>Yes, sir, I have indeed.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Call up my brother. O, would you had had her!</LINE>
  <LINE>Some one way, some another. Do you know</LINE>
  <LINE>Where we may apprehend her and the Moor?</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>RODERIGO</SPEAKER>
  <LINE>I think I can discover him, if you please,</LINE>
  <LINE>To get good guard and go along with me.</LINE>
  </SPEECH>
  
  <SPEECH>
  <SPEAKER>BRABANTIO</SPEAKER>
  <LINE>Pray you, lead on. At every house I'll call;</LINE>
  <LINE>I may command at most. Get weapons, ho!</LINE>
  <LINE>And raise some special officers of night.</LINE>
  <LINE>On, good Roderigo: I'll deserve your pains.</LINE>
  </SPEECH>
  
  
  <STAGEDIR>Exeunt</STAGEDIR>
  </SCENE>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk013.xml
  
  Index: mk013.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk014.xml
  
  Index: mk014.xml
  ===================================================================
  <?xml version="1.0" ?>
  <countries>
  <country name="France"/>
  <country name="Germany"/>
  <country name="Israel"/>
  <country name="Japan"/>
  <country name="Poland"/>
  <country name="United States" selected="yes"/>
  <country name="Venezuela"/>
  </countries>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk015.xml
  
  Index: mk015.xml
  ===================================================================
  <results group="A">
  <match>
  <date>10-Jun-98</date>
  <team score="2">Brazil</team>
  <team score="1">Scotland</team>
  </match>
  <match>
  <date>10-Jun-98</date>
  <team score="2">Morocco</team>
  <team score="2">Norway</team>
  </match>
  <match>
  <date>16-Jun-98</date>
  <team score="1">Scotland</team>
  <team score="1">Norway</team>
  </match>
  <match>
  <date>16-Jun-98</date>
  <team score="3">Brazil</team>
  <team score="0">Morocco</team>
  </match>
  <match>
  <date>23-Jun-98</date>
  <team score="1">Brazil</team>
  <team score="2">Norway</team>
  </match>
  <match>
  <date>23-Jun-98</date>
  <team score="0">Scotland</team>
  <team score="3">Morocco</team>
  </match>
  </results>
  
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk016.xml
  
  Index: mk016.xml
  ===================================================================
  <book title="Object-oriented Languages"
     author="Michel Beaudouin-Lafon"
     translator="Jack Howlett"
     publisher="Chapman &amp; Hall"
     isbn="0 412 55800 9"
     date="1994"/>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk017.xml
  
  Index: mk017.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <?xml-stylesheet type="text/xsl" href="poem.xsl"?>
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk018.xml
  
  Index: mk018.xml
  ===================================================================
  <book>
       <title>Design Patterns</title>
       <author>Erich Gamma</author>
       <author>Richard Helm</author>
       <author>Ralph Johnson</author>
       <author>John Vlissides</author>
  </book>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk019.xml
  
  Index: mk019.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk020.xml
  
  Index: mk020.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk021.xml
  
  Index: mk021.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk022.xml
  
  Index: mk022.xml
  ===================================================================
  <?xml version="1.0"?>
  <books>
  	<book category="reference">
  		<author>Nigel Rees</author>
  		<title>Sayings of the Century</title>
  		<price>8.95</price>
  	</book>
  	<book category="fiction">
  		<author>Evelyn Waugh</author>
  		<title>Sword of Honour</title>
  		<price>12.99</price>
  	</book>
  	<book category="fiction">
  		<author>Herman Melville</author>
  		<title>Moby Dick</title>
  		<price>8.99</price>
  	</book>
  	<book category="fiction">
  		<author>J. R. R. Tolkien</author>
  		<title>The Lord of the Rings</title>
  		<price>22.99</price>
  	</book>
  </books>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk023.xml
  
  Index: mk023.xml
  ===================================================================
  <booklist>
  <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>
  <book>
      <title>Building Applications Frameworks</title>
      <author>Mohamed Fayad</author>
      <author>Douglas C. Schmidt</author>
      <author>Ralph Johnson</author>
  </book>
  <book>
      <title>Implementing Applications Frameworks</title>
      <author>Mohamed Fayad</author>
      <author>Douglas C. Schmidt</author>
      <author>Ralph Johnson</author>
  </book>
  </booklist>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk024.xml
  
  Index: mk024.xml
  ===================================================================
  <?xml version="1.0"?>
  <test></test>
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk025.xml
  
  Index: mk025.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk026.xml
  
  Index: mk026.xml
  ===================================================================
  <poem>
  <author>Rupert Brooke</author>
  <date>1912</date>
  <title>Song</title>
  <stanza>
  <line>And suddenly the wind comes soft,</line>
  <line>And Spring is here again;</line>
  <line>And the hawthorn quickens with buds of green</line>
  <line>And my heart with buds of pain.</line>
  </stanza>
  <stanza>
  <line>My heart all Winter lay so numb,</line>
  <line>The earth so dead and frore,</line>
  <line>That I never thought the Spring would come again</line>
  <line>Or my heart wake any more.</line>
  </stanza>
  <stanza>
  <line>But Winter's broken and earth has woken,</line>
  <line>And the small birds cry again;</line>
  <line>And the hawthorn hedge puts forth its buds,</line>
  <line>And my heart puts forth its pain.</line>
  </stanza>
  </poem>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk027.xml
  
  Index: mk027.xml
  ===================================================================
  <?xml version="1.0" ?>
  <products>
  <product name="strawberry jam">
     <region name="south" sales="20.00"/>
     <region name="north" sales="50.00"/>
  </product>
  <product name="raspberry jam">
     <region name="south" sales="205.16"/>
     <region name="north" sales="10.50"/>
  </product>
  <product name="plum jam">
     <region name="east" sales="320.20"/>
     <region name="north" sales="39.50"/>
  </product>
  </products>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk028.xml
  
  Index: mk028.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <cv>
  <para>
  <performance>
  <publication>Early Music Review</publication> said of his debut <venue>Wigmore</venue> concert with
  <group>Ensemble Sonnerie</group> in <date>1998</date>: <quote>One of the finest concerts I have
  ever heard ... a singer to watch out for</quote>. </performance>
  <performance>Other highlights include a
  televised production of <composer>Bach</composer>'s <work>St. Matthew Passion</work>
  conducted by <artist>Jonathan Miller</artist>, in which he played
  <role>Judas</role>,</performance> <performance>an acclaimed performance of
  <work>Winterreise</work> with <artist>Julius Drake</artist> in <venue>Leamington Hastings</venue>,
  </performance> <performance>
  <work>Die Sch�ne M�llerin</work> <date>last summer</date> at <venue>St. John's Smith Square</venue>,
  and in the same venue the Good Friday <i>St John Passion</i>, conducted
  by <artist>Stephen Layton</artist>, broadcast on Radio Three.</performance> 
  </para>
  </cv>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk029.xml
  
  Index: mk029.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <cv>
  <para>
  <performance>
  <publication>Early Music Review</publication> said of his debut <venue>Wigmore</venue> concert with
  <group>Ensemble Sonnerie</group> in <date>1998</date>: <quote>One of the finest concerts I have
  ever heard ... a singer to watch out for</quote>. </performance>
  <performance>Other highlights include a
  televised production of <composer>Bach</composer>'s <work>St. Matthew Passion</work>
  conducted by <artist>Jonathan Miller</artist>, in which he played
  <role>Judas</role>,</performance> <performance>an acclaimed performance of
  <work>Winterreise</work> with <artist>Julius Drake</artist> in <venue>Leamington Hastings</venue>,
  </performance> <performance>
  <work>Die Sch�ne M�llerin</work> <date>last summer</date> at <venue>St. John's Smith Square</venue>,
  and in the same venue the Good Friday <i>St John Passion</i>, conducted
  by <artist>Stephen Layton</artist>, broadcast on Radio Three.</performance> 
  </para>
  </cv>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk030.xml
  
  Index: mk030.xml
  ===================================================================
  <?xml version="1.0"?>
  <programme>
  	<opera>
  		<title>The Magic Flute</title>
  		<composer>Mozart</composer>
          <date>1791</date>
  	</opera>
  	<opera>
  		<title>Don Giovanni</title>
  		<composer>Mozart</composer>
          <date>1787</date>
  	</opera>
  	<opera>
  		<title>Ernani</title>
  		<composer>Verdi</composer>
          <date>1843</date>
  	</opera>
  	<opera>
  		<title>Rigoletto</title>
  		<composer>Verdi</composer>
          <date>1850</date>
  	</opera>
  	<opera>
  		<title>Tosca</title>
  		<composer>Puccini</composer>
          <date>1897</date>
  	</opera>
      <composer name="Mozart">
          <fullname>Wolfgang Amadeus Mozart</fullname>
          <born>1756</born>
          <died>1791</died>
      </composer>
      <composer name="Verdi">
          <fullname>Guiseppe Verdi</fullname>
          <born>1813</born>
          <died>1901</died>
      </composer>
      <composer name="Puccini">
          <fullname>Giacomo Puccini</fullname>
          <born>1858</born>
          <died>1924</died>
      </composer>
  </programme>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk031.xml
  
  Index: mk031.xml
  ===================================================================
  <?xml version="1.0"?>
  <programme>
  	<opera>
  		<title>The Magic Flute</title>
  		<composer>Mozart</composer>
          <date>1791</date>
  	</opera>
  	<opera>
  		<title>Don Giovanni</title>
  		<composer>Mozart</composer>
          <date>1787</date>
  	</opera>
  	<opera>
  		<title>Ernani</title>
  		<composer>Verdi</composer>
          <date>1843</date>
  	</opera>
  	<opera>
  		<title>Rigoletto</title>
  		<composer>Verdi</composer>
          <date>1850</date>
  	</opera>
  	<opera>
  		<title>Tosca</title>
  		<composer>Puccini</composer>
          <date>1897</date>
  	</opera>
      <composer name="Mozart">
          <fullname>Wolfgang Amadeus Mozart</fullname>
          <born>1756</born>
          <died>1791</died>
      </composer>
      <composer name="Verdi">
          <fullname>Guiseppe Verdi</fullname>
          <born>1813</born>
          <died>1901</died>
      </composer>
      <composer name="Puccini">
          <fullname>Giacomo Puccini</fullname>
          <born>1858</born>
          <died>1924</died>
      </composer>
  </programme>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk032.xml
  
  Index: mk032.xml
  ===================================================================
  <itinerary>
  <day number="1">Arrive in Cairo</day>
  <day number="2">Visit the Pyramids at Gaza</day>
  <day number="3">Archaelogical Museum at Cairo</day>
  <day number="4">Flight to Luxor; coach to Aswan</day>
  <day number="5">Visit Temple at Philae and Aswan High Dam</day>
  <day number="6">Cruise to Edfu</day>
  <day number="7">Cruise to Luxor; visit Temple at Karnak</day>
  <day number="8">Valley of the Kings</day>
  <day number="9">Return flight from Luxor</day>
  </itinerary>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk033.xml
  
  Index: mk033.xml
  ===================================================================
  <itinerary>
  <day number="1">Arrive in Cairo</day>
  <day number="2">Visit the Pyramids at Gaza</day>
  <day number="3">Archaelogical Museum at Cairo</day>
  <day number="4">Flight to Luxor; coach to Aswan</day>
  <day number="5">Visit Temple at Philae and Aswan High Dam</day>
  <day number="6">Cruise to Edfu</day>
  <day number="7">Cruise to Luxor; visit Temple at Karnak</day>
  <day number="8">Valley of the Kings</day>
  <day number="9">Return flight from Luxor</day>
  </itinerary>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk034.xml
  
  Index: mk034.xml
  ===================================================================
  <cities>
     <city name="Paris" country="France"/>
     <city name="Roma" country="Italia"/>
     <city name="Nice" country="France"/>
     <city name="Madrid" country="Espana"/>
     <city name="Milano" country="Italia"/>
     <city name="Firenze" country="Italia"/>
     <city name="Napoli" country="Italia"/>
     <city name="Lyon" country="France"/>
     <city name="Barcelona" country="Espana"/>
  </cities>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk035.xml
  
  Index: mk035.xml
  ===================================================================
  <cities>
     <city name="Paris" country="France"/>
     <city name="Roma" country="Italia"/>
     <city name="Nice" country="France"/>
     <city name="Madrid" country="Espana"/>
     <city name="Milano" country="Italia"/>
     <city name="Firenze" country="Italia"/>
     <city name="Napoli" country="Italia"/>
     <city name="Lyon" country="France"/>
     <city name="Barcelona" country="Espana"/>
  </cities>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk036.xml
  
  Index: mk036.xml
  ===================================================================
  <booklist>
  <book category="S">
       <title>Number, the Language of Science</title>
       <author>Danzig</author>
  </book>
  <book category="FC">
       <title>The Young Visiters</title>
       <author>Daisy Ashford</author>
  </book>
  <book category="FC">
       <title>When We Were Very Young</title>
       <author>A. A. Milne</author>
  </book>
  <book category="CS">
       <title>Design Patterns</title>
       <author>Erich Gamma</author>
       <author>Richard Helm</author>
       <author>Ralph Johnson</author>
       <author>John Vlissides</author>
  </book>
  </booklist>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk037.xml
  
  Index: mk037.xml
  ===================================================================
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
  <xsl:include href="./inc/dummya.xsl"/>
  </xsl:transform>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk038.xml
  
  Index: mk038.xml
  ===================================================================
  <booklist>
  <book category="S">
       <title>Number, the Language of Science</title>
       <author>Danzig</author>
  </book>
  <book category="FC">
       <title>The Young Visiters</title>
       <author>Daisy Ashford</author>
  </book>
  <book category="FC">
       <title>When We Were Very Young</title>
       <author>A. A. Milne</author>
  </book>
  <book category="CS">
       <title>Design Patterns</title>
       <author>Erich Gamma</author>
       <author>Richard Helm</author>
       <author>Ralph Johnson</author>
       <author>John Vlissides</author>
  </book>
  </booklist>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk039.xml
  
  Index: mk039.xml
  ===================================================================
  <resorts>
     <resort>
        <name>Amsterdam</name>
        <details>A wordy description of Amsterdam</details>
        <hotel>
           <name>Grand Hotel</name>
           <stars>5</stars>
           <address> . . . </address>
        </hotel>
        <hotel>
           <name>Less Grand Hotel</name>
           <stars>2</stars>
           <address> . . . </address>
        </hotel>
     </resort>
     <resort>
        <name>Bruges</name>
        <details>An eloquent description of Bruges</details>
        <hotel>
           <name>Central Hotel</name>
           <stars>5</stars>
           <address> . . . </address>
        </hotel>
        <hotel>
           <name>Peripheral Hotel</name>
           <stars>2</stars>
           <address> . . . </address>
        </hotel>
     </resort>
  </resorts>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk040.xml
  
  Index: mk040.xml
  ===================================================================
  <booklist>
  <book category="S">
       <title>Number, the Language of Science</title>
       <author>Danzig</author>
  </book>
  <book category="FC">
       <title>The Young Visiters</title>
       <author>Daisy Ashford</author>
  </book>
  <book category="FC">
       <title>When We Were Very Young</title>
       <author>A. A. Milne</author>
  </book>
  <book category="CS">
       <title>Design Patterns</title>
       <author>Erich Gamma</author>
       <author>Richard Helm</author>
       <author>Ralph Johnson</author>
       <author>John Vlissides</author>
  </book>
  </booklist>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk041.xml
  
  Index: mk041.xml
  ===================================================================
  <issues>
  <iso-date>19991116</iso-date>
  <iso-date>19991008</iso-date>
  <iso-date>19990813</iso-date>
  <iso-date>19990709</iso-date>
  <iso-date>19990421</iso-date>
  <iso-date>19981216</iso-date>
  <iso-date>19980818</iso-date>
  </issues>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk042.xml
  
  Index: mk042.xml
  ===================================================================
  <booklist>
  <book category="S">
       <title>Number, the Language of Science</title>
       <author>Danzig</author>
  </book>
  <book category="FC">
       <title>The Young Visiters</title>
       <author>Daisy Ashford</author>
  </book>
  <book category="FC">
       <title>When We Were Very Young</title>
       <author>A. A. Milne</author>
  </book>
  <book category="CS">
       <title>Design Patterns</title>
       <author>Erich Gamma</author>
       <author>Richard Helm</author>
       <author>Ralph Johnson</author>
       <author>John Vlissides</author>
  </book>
  </booklist>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk043.xml
  
  Index: mk043.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <xsl:transform
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0"
  >
  
  <xsl:template match="/">
  <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>
      <xsl:apply-templates select="//*">
           <xsl:sort select="namespace-uri()"/>
           <xsl:sort select="local-name()"/>
      </xsl:apply-templates>
  </table></body></html>
  </xsl:template>
  
  <xsl:template match="*">
       <xsl:variable name="prefix">
          <xsl:choose>
          <xsl:when test="contains(name(), ':')">
             <xsl:value-of select="substring-before(name(),':')"/>
          </xsl:when>
          <xsl:otherwise/>
          </xsl:choose>
       </xsl:variable>
       <tr>
       <td><xsl:value-of select="name()"/></td>
       <td><xsl:value-of select="$prefix"/></td>
       <td><xsl:value-of select="local-name()"/></td>
       <td><xsl:value-of select="namespace-uri()"/></td>
       </tr>
  </xsl:template>
  
  
  </xsl:transform>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk044.xml
  
  Index: mk044.xml
  ===================================================================
  <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 author 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 author in order
  to check that she was genuine.</biog>
  </author>
  
  </authors>
   
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk045.xml
  
  Index: mk045.xml
  ===================================================================
  <shapes>
  <rectangle width="10" height="30"/>
  <square side="15"/>
  <rectangle width="3" height="80"/>
  <circle radius="10"/>
  </shapes>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk046.xml
  
  Index: mk046.xml
  ===================================================================
  <sales>
     <product>Windows 98
        <period name="Q1">82</period>
        <period name="Q2">64</period>
        <period name="Q3">58</period>
     </product>
     <product>Windows NT
        <period name="Q1">17</period>
        <period name="Q2">44</period>
        <period name="Q3">82</period>
     </product>
  </sales>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk047.xml
  
  Index: mk047.xml
  ===================================================================
  <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 author 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 author in order
  to check that she was genuine.</biog>
  </author>
  
  </authors>
   
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk048.xml
  
  Index: mk048.xml
  ===================================================================
  <results group="A">
  <match>
  <date>10-Jun-98</date>
  <team score="2">Brazil</team>
  <team score="1">Scotland</team>
  </match>
  <match>
  <date>10-Jun-98</date>
  <team score="2">Morocco</team>
  <team score="2">Norway</team>
  </match>
  <match>
  <date>16-Jun-98</date>
  <team score="1">Scotland</team>
  <team score="1">Norway</team>
  </match>
  <match>
  <date>16-Jun-98</date>
  <team score="3">Brazil</team>
  <team score="0">Morocco</team>
  </match>
  <match>
  <date>23-Jun-98</date>
  <team score="1">Brazil</team>
  <team score="2">Norway</team>
  </match>
  <match>
  <date>23-Jun-98</date>
  <team score="0">Scotland</team>
  <team score="3">Morocco</team>
  </match>
  </results>
  
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk049.xml
  
  Index: mk049.xml
  ===================================================================
  <orgchart date="28 March 2000">
  <person>
  <name>Keith Todd</name>
  <title>Chief Executive Officer</title>
  <reports>
  	<person>
     		<name>Andrew Boswell</name>
     		<title>Technical Director</title>
  		<reports>
  			<person>
  			    <name>Dave McVitie</name>
  			    <title>Chief Engineer</title>
  			</person>
  			<person>
  			    <name>John Elmore</name>
  			    <title>Director of Research</title>
  			</person>
  		</reports>			
  	</person>
  	<person>
  		<name>Alan Gibson</name>
  		<title>Operations and Finance</title>
  	</person>
  	<person>
  		<name>Fiona Colquhoun</name>
  		<title>Human Resources</title>
  	</person>
  	<person>
  		<name>John Davison</name>
  		<title>Marketing</title>
  	</person>
  	<person>
  		<name>Marie-Anne van Ingen</name>
  		<title>International</title>
  	</person>
  </reports>
  </person>
  </orgchart>       
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk050.xml
  
  Index: mk050.xml
  ===================================================================
  <booklist>
     <book>
        <title>Angela's Ashes</title>
        <author>Frank McCourt</author>
        <publisher>HarperCollins</publisher>
        <isbn>0 00 649840 X</isbn>
        <price>6.99</price>
        <sales>235</sales>
     </book>
     <book>
        <title>Sword of Honour</title>
        <author>Evelyn Waugh</author>
        <publisher>Penguin Books</publisher>
        <isbn>0 14 018967 X</isbn>
        <price>12.99</price>
        <sales>12</sales>
     </book>
  </booklist>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk051.xml
  
  Index: mk051.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1" ?>
  <SCENE>
     <TITLE>SCENE II.  Another street.</TITLE>
     <STAGEDIR>Enter OTHELLO, IAGO, and Attendants with torches</STAGEDIR>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>Though in the trade of war I have slain men,</LINE>
        <LINE>Yet do I hold it very stuff o' the conscience</LINE>
        <LINE>To do no contrived murder: I lack iniquity</LINE>
        <LINE>Sometimes to do me service: nine or ten times</LINE>
        <LINE>I had thought to have yerk'd him here under the ribs.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>'Tis better as it is.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>Nay, but he prated,</LINE>
        <LINE>And spoke such scurvy and provoking terms</LINE>
        <LINE>Against your honour</LINE>
        <LINE>That, with the little godliness I have,</LINE>
        <LINE>I did full hard forbear him. But, I pray you, sir,</LINE>
        <LINE>Are you fast married? Be assured of this,</LINE>
        <LINE>That the magnifico is much beloved,</LINE>
        <LINE>And hath in his effect a voice potential</LINE>
        <LINE>As double as the duke's: he will divorce you;</LINE>
        <LINE>Or put upon you what restraint and grievance</LINE>
        <LINE>The law, with all his might to enforce it on,</LINE>
        <LINE>Will give him cable.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Let him do his spite:</LINE>
        <LINE>My services which I have done the signiory</LINE>
        <LINE>Shall out-tongue his complaints. 'Tis yet to know,--</LINE>
        <LINE>Which, when I know that boasting is an honour,</LINE>
        <LINE>I shall promulgate--I fetch my life and being</LINE>
        <LINE>From men of royal siege, and my demerits</LINE>
        <LINE>May speak unbonneted to as proud a fortune</LINE>
        <LINE>As this that I have reach'd: for know, Iago,</LINE>
        <LINE>But that I love the gentle Desdemona,</LINE>
        <LINE>I would not my unhoused free condition</LINE>
        <LINE>Put into circumscription and confine</LINE>
        <LINE>For the sea's worth. But, look! what lights come yond?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>Those are the raised father and his friends:</LINE>
        <LINE>You were best go in.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Not I I must be found:</LINE>
        <LINE>My parts, my title and my perfect soul</LINE>
        <LINE>Shall manifest me rightly. Is it they?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>By Janus, I think no.</LINE>
     </SPEECH>
     <STAGEDIR>Enter CASSIO, and certain Officers with torches</STAGEDIR>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>The servants of the duke, and my lieutenant.</LINE>
        <LINE>The goodness of the night upon you, friends!</LINE>
        <LINE>What is the news?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>The duke does greet you, general,</LINE>
        <LINE>And he requires your haste-post-haste appearance,</LINE>
        <LINE>Even on the instant.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>What is the matter, think you?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>Something from Cyprus as I may divine:</LINE>
        <LINE>It is a business of some heat: the galleys</LINE>
        <LINE>Have sent a dozen sequent messengers</LINE>
        <LINE>This very night at one another's heels,</LINE>
        <LINE>And many of the consuls, raised and met,</LINE>
        <LINE>Are at the duke's already: you have been</LINE>
        <LINE>hotly call'd for;</LINE>
        <LINE>When, being not at your lodging to be found,</LINE>
        <LINE>The senate hath sent about three several guests</LINE>
        <LINE>To search you out.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>'Tis well I am found by you.</LINE>
        <LINE>I will but spend a word here in the house,</LINE>
        <LINE>And go with you.</LINE>
     </SPEECH>
     <STAGEDIR>Exit</STAGEDIR>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>Ancient, what makes he here?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>'Faith, he to-night hath boarded a land carack:</LINE>
        <LINE>If it prove lawful prize, he's made for ever.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>I do not understand.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>He's married.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>To who?</LINE>
     </SPEECH>
     <STAGEDIR>Re-enter OTHELLO</STAGEDIR>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>Marry, to--Come, captain, will you go?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Have with you.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>CASSIO</SPEAKER>
        <LINE>Here comes another troop to seek for you.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>It is Brabantio. General, be advised;</LINE>
        <LINE>He comes to bad intent.</LINE>
     </SPEECH>
     <STAGEDIR>Enter BRABANTIO, RODERIGO, and Officers with
  torches and weapons</STAGEDIR>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Holla! stand there!</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>RODERIGO</SPEAKER>
        <LINE>Signior, it is the Moor.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>BRABANTIO</SPEAKER>
        <LINE>Down with him, thief!</LINE>
     </SPEECH>
     <STAGEDIR>They draw on both sides</STAGEDIR>
     <SPEECH>
        <SPEAKER>IAGO</SPEAKER>
        <LINE>You, Roderigo! come, sir, I am for you.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Keep up your bright swords, for the dew will rust them.</LINE>
        <LINE>Good signior, you shall more command with years</LINE>
        <LINE>Than with your weapons.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>BRABANTIO</SPEAKER>
        <LINE>O thou foul thief, where hast thou stow'd my daughter?</LINE>
        <LINE>Damn'd as thou art, thou hast enchanted her;</LINE>
        <LINE>For I'll refer me to all things of sense,</LINE>
        <LINE>If she in chains of magic were not bound,</LINE>
        <LINE>Whether a maid so tender, fair and happy,</LINE>
        <LINE>So opposite to marriage that she shunned</LINE>
        <LINE>The wealthy curled darlings of our nation,</LINE>
        <LINE>Would ever have, to incur a general mock,</LINE>
        <LINE>Run from her guardage to the sooty bosom</LINE>
        <LINE>Of such a thing as thou, to fear, not to delight.</LINE>
        <LINE>Judge me the world, if 'tis not gross in sense</LINE>
        <LINE>That thou hast practised on her with foul charms,</LINE>
        <LINE>Abused her delicate youth with drugs or minerals</LINE>
        <LINE>That weaken motion: I'll have't disputed on;</LINE>
        <LINE>'Tis probable and palpable to thinking.</LINE>
        <LINE>I therefore apprehend and do attach thee</LINE>
        <LINE>For an abuser of the world, a practiser</LINE>
        <LINE>Of arts inhibited and out of warrant.</LINE>
        <LINE>Lay hold upon him: if he do resist,</LINE>
        <LINE>Subdue him at his peril.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>Hold your hands,</LINE>
        <LINE>Both you of my inclining, and the rest:</LINE>
        <LINE>Were it my cue to fight, I should have known it</LINE>
        <LINE>Without a prompter. Where will you that I go</LINE>
        <LINE>To answer this your charge?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>BRABANTIO</SPEAKER>
        <LINE>To prison, till fit time</LINE>
        <LINE>Of law and course of direct session</LINE>
        <LINE>Call thee to answer.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>OTHELLO</SPEAKER>
        <LINE>What if I do obey?</LINE>
        <LINE>How may the duke be therewith satisfied,</LINE>
        <LINE>Whose messengers are here about my side,</LINE>
        <LINE>Upon some present business of the state</LINE>
        <LINE>To bring me to him?</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>First Officer</SPEAKER>
        <LINE>'Tis true, most worthy signior;</LINE>
        <LINE>The duke's in council and your noble self,</LINE>
        <LINE>I am sure, is sent for.</LINE>
     </SPEECH>
     <SPEECH>
        <SPEAKER>BRABANTIO</SPEAKER>
        <LINE>How! the duke in council!</LINE>
        <LINE>In this time of the night! Bring him away:</LINE>
        <LINE>Mine's not an idle cause: the duke himself,</LINE>
        <LINE>Or any of my brothers of the state,</LINE>
        <LINE>Cannot but feel this wrong as 'twere their own;</LINE>
        <LINE>For if such actions may have passage free,</LINE>
        <LINE>Bond-slaves and pagans shall our statesmen be.</LINE>
     </SPEECH>
     <STAGEDIR>Exeunt</STAGEDIR>
  </SCENE>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk052.xml
  
  Index: mk052.xml
  ===================================================================
  <numbers>12  34.5  18.2  -35</numbers>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk053.xml
  
  Index: mk053.xml
  ===================================================================
  <booklist>
     <book>
        <title>Angela's Ashes</title>
        <author>Frank McCourt</author>
        <publisher>HarperCollins</publisher>
        <isbn>0 00 649840 X</isbn>
        <price>6.99</price>
        <sales>235</sales>
     </book>
     <book>
        <title>Sword of Honour</title>
        <author>Evelyn Waugh</author>
        <publisher>Penguin Books</publisher>
        <isbn>0 14 018967 X</isbn>
        <price>12.99</price>
        <sales>12</sales>
     </book>
  </booklist>
  
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk054.xml
  
  Index: mk054.xml
  ===================================================================
  <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
  <!DOCTYPE spec SYSTEM "spec.dtd" [
  
  <!-- Modified by Michael Kay, 12 February 2000, to remove the declaration
       of the lt entity, because is not in the form prescribed by the XML specification,
       and is rejected by Internet Explorer 5 -->
  
  <!-- LAST TOUCHED BY: Tim Bray, 8 February 1997 -->
  <!-- I think that should read 1998 - Michael Kay -->
  
  <!-- The words 'FINAL EDIT' in comments mark places where changes
  need to be made after approval of the document by the ERB, before
  publication.  -->
  
  <!ENTITY XML.version "1.0">
  <!ENTITY doc.date "10 February 1998">
  <!ENTITY iso6.doc.date "19980210">
  <!ENTITY w3c.doc.date "02-Feb-1998">
  <!ENTITY draft.day '10'>
  <!ENTITY draft.month 'February'>
  <!ENTITY draft.year '1998'>
  
  <!ENTITY WebSGML 
   'WebSGML Adaptations Annex to ISO 8879'>
  
  <!ENTITY gt     ">"> 
  <!ENTITY xmlpio "'&lt;?xml'">
  <!ENTITY pic    "'?>'">
  <!ENTITY br     "\n">
  <!ENTITY cellback '#c0d9c0'>
  <!ENTITY mdash  "--"> <!-- &#x2014, but nsgmls doesn't grok hex -->
  <!ENTITY com    "--">
  <!ENTITY como   "--">
  <!ENTITY comc   "--">
  <!ENTITY hcro   "&amp;#x">
  <!-- <!ENTITY nbsp "�"> -->
  <!-- <!ENTITY nbsp   "&#160;"> -->
  <!ENTITY magicents "<code>amp</code>,
  <code>lt</code>,
  <code>gt</code>,
  <code>apos</code>,
  <code>quot</code>">
   
  <!-- audience and distribution status:  for use at publication time -->
  <!ENTITY doc.audience "public review and discussion">
  <!ENTITY doc.distribution "may be distributed freely, as long as
  all text and legal notices remain intact">
  
  ]>
  <?xml-stylesheet href="xmlspec.xsl" type="text/xsl"?>
  <!-- for Panorama *-->
  <?VERBATIM "eg" ?>
  
  <spec>
  <header>
  <title>Extensible Markup Language (XML) 1.0</title>
  <version></version>
  <w3c-designation>REC-xml-&iso6.doc.date;</w3c-designation>
  <w3c-doctype>W3C Recommendation</w3c-doctype>
  <pubdate><day>&draft.day;</day><month>&draft.month;</month><year>&draft.year;</year></pubdate>
  
  <publoc>
  <loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;">
  http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;</loc>
  <loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml">
  http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml</loc>
  <loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html">
  http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html</loc>
  <loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf">
  http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf</loc>
  <loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps">
  http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps</loc>
  </publoc>
  <latestloc>
  <loc  href="http://www.w3.org/TR/REC-xml">
  http://www.w3.org/TR/REC-xml</loc>
  </latestloc>
  <prevlocs>
  <loc  href="http://www.w3.org/TR/PR-xml-971208">
  http://www.w3.org/TR/PR-xml-971208</loc>
  <!--
  <loc  href='http://www.w3.org/TR/WD-xml-961114'>
  http://www.w3.org/TR/WD-xml-961114</loc>
  <loc  href='http://www.w3.org/TR/WD-xml-lang-970331'>
  http://www.w3.org/TR/WD-xml-lang-970331</loc>
  <loc  href='http://www.w3.org/TR/WD-xml-lang-970630'>
  http://www.w3.org/TR/WD-xml-lang-970630</loc>
  <loc  href='http://www.w3.org/TR/WD-xml-970807'>
  http://www.w3.org/TR/WD-xml-970807</loc>
  <loc  href='http://www.w3.org/TR/WD-xml-971117'>
  http://www.w3.org/TR/WD-xml-971117</loc>-->
  </prevlocs>
  <authlist>
  <author><name>Tim Bray</name>
  <affiliation>Textuality and Netscape</affiliation>
  <email 
  href="mailto:tbray@textuality.com">tbray@textuality.com</email></author>
  <author><name>Jean Paoli</name>
  <affiliation>Microsoft</affiliation>
  <email href="mailto:jeanpa@microsoft.com">jeanpa@microsoft.com</email></author>
  <author><name>C. M. Sperberg-McQueen</name>
  <affiliation>University of Illinois at Chicago</affiliation>
  <email href="mailto:cmsmcq@uic.edu">cmsmcq@uic.edu</email></author>
  </authlist>
  <abstract>
  <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>
  </abstract>
  <status>
  <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 <loc
  href='http://www.w3.org/XML'>http://www.w3.org/XML</loc>.  A list of
  current W3C Recommendations and other technical documents can be found
  at <loc href='http://www.w3.org/TR'>http://www.w3.org/TR</loc>.
  </p>
  <p>This specification uses the term URI, which is defined by <bibref
  ref="Berners-Lee"/>, a work in progress expected to update <bibref
  ref="RFC1738"/> and <bibref ref="RFC1808"/>. 
  </p>
  <p>The list of known errors in this specification is 
  available at 
  <loc href='http://www.w3.org/XML/xml-19980210-errata'>http://www.w3.org/XML/xml-19980210-errata</loc>.</p>
  <p>Please report errors in this document to 
  <loc href='mailto:xml-editor@w3.org'>xml-editor@w3.org</loc>.
  </p>
  </status>
  
  
  <pubstmt>
  <p>Chicago, Vancouver, Mountain View, et al.:
  World-Wide Web Consortium, XML Working Group, 1996, 1997.</p>
  </pubstmt>
  <sourcedesc>
  <p>Created in electronic form.</p>
  </sourcedesc>
  <langusage>
  <language id='EN'>English</language>
  <language id='ebnf'>Extended Backus-Naur Form (formal grammar)</language>
  </langusage>
  <revisiondesc>
  <slist>
  <sitem>1997-12-03 : CMSMcQ : yet further changes</sitem>
  <sitem>1997-12-02 : TB : further changes (see TB to XML WG,
  2 December 1997)</sitem>
  <sitem>1997-12-02 : CMSMcQ : deal with as many corrections and
  comments from the proofreaders as possible:
  entify hard-coded document date in pubdate element,
  change expansion of entity WebSGML,
  update status description as per Dan Connolly (am not sure
  about refernece to Berners-Lee et al.),
  add 'The' to abstract as per WG decision,
  move Relationship to Existing Standards to back matter and
  combine with References,
  re-order back matter so normative appendices come first,
  re-tag back matter so informative appendices are tagged informdiv1,
  remove XXX XXX from list of 'normative' specs in prose,
  move some references from Other References to Normative References,
  add RFC 1738, 1808, and 2141 to Other References (they are not
  normative since we do not require the processor to enforce any 
  rules based on them),
  add reference to 'Fielding draft' (Berners-Lee et al.),
  move notation section to end of body,
  drop URIchar non-terminal and use SkipLit instead,
  lose stray reference to defunct nonterminal 'markupdecls',
  move reference to Aho et al. into appendix (Tim's right),
  add prose note saying that hash marks and fragment identifiers are
  NOT part of the URI formally speaking, and are NOT legal in 
  system identifiers (processor 'may' signal an error).
  Work through:
  Tim Bray reacting to James Clark,
  Tim Bray on his own,
  Eve Maler,
  
  NOT DONE YET:
  change binary / text to unparsed / parsed.
  handle James's suggestion about &lt; in attriubte values
  uppercase hex characters,
  namechar list,
  </sitem>
  <sitem>1997-12-01 : JB : add some column-width parameters</sitem>
  <sitem>1997-12-01 : CMSMcQ : begin round of changes to incorporate
  recent WG decisions and other corrections:
  binding sources of character encoding info (27 Aug / 3 Sept),
  correct wording of Faust quotation (restore dropped line),
  drop SDD from EncodingDecl,
  change text at version number 1.0,
  drop misleading (wrong!) sentence about ignorables and extenders,
  modify definition of PCData to make bar on msc grammatical,
  change grammar's handling of internal subset (drop non-terminal markupdecls),
  change definition of includeSect to allow conditional sections,
  add integral-declaration constraint on internal subset,
  drop misleading / dangerous sentence about relationship of
  entities with system storage objects,
  change table body tag to htbody as per EM change to DTD,
  add rule about space normalization in public identifiers,
  add description of how to generate our name-space rules from 
  Unicode character database (needs further work!).
  </sitem>
  <sitem>1997-10-08 : TB : Removed %-constructs again, new rules
  for PE appearance.</sitem>
  <sitem>1997-10-01 : TB : Case-sensitive markup; cleaned up
  element-type defs, lotsa little edits for style</sitem>
  <sitem>1997-09-25 : TB : Change to elm's new DTD, with
  substantial detail cleanup as a side-effect</sitem>
  <sitem>1997-07-24 : CMSMcQ : correct error (lost *) in definition 
  of ignoreSectContents (thanks to Makoto Murata)</sitem>
  <sitem>Allow all empty elements to have end-tags, consistent with
  SGML TC (as per JJC).</sitem>
  <sitem>1997-07-23 : CMSMcQ : pre-emptive strike on pending corrections:
  introduce the term 'empty-element tag', note that all empty elements
  may use it, and elements declared EMPTY must use it.
  Add WFC requiring encoding decl to come first in an entity.
  Redefine notations to point to PIs as well as binary entities.
  Change autodetection table by removing bytes 3 and 4 from 
  examples with Byte Order Mark.
  Add content model as a term and clarify that it applies to both
  mixed and element content.
  </sitem>
  <sitem>1997-06-30 : CMSMcQ : change date, some cosmetic changes,
  changes to productions for choice, seq, Mixed, NotationType,
  Enumeration.  Follow James Clark's suggestion and prohibit 
  conditional sections in internal subset.  TO DO:  simplify
  production for ignored sections as a result, since we don't 
  need to worry about parsers which don't expand PErefs finding
  a conditional section.</sitem>
  <sitem>1997-06-29 : TB : various edits</sitem>
  <sitem>1997-06-29 : CMSMcQ : further changes:
  Suppress old FINAL EDIT comments and some dead material.
  Revise occurrences of % in grammar to exploit Henry Thompson's pun,
  especially markupdecl and attdef.
  Remove RMD requirement relating to element content (?).
  </sitem>
  <sitem>1997-06-28 : CMSMcQ : Various changes for 1 July draft:
  Add text for draconian error handling (introduce
  the term Fatal Error).
  RE deleta est (changing wording from 
  original announcement to restrict the requirement to validating
  parsers).
  Tag definition of validating processor and link to it.
  Add colon as name character.
  Change def of %operator.
  Change standard definitions of lt, gt, amp.
  Strip leading zeros from #x00nn forms.</sitem>
  <sitem>1997-04-02 : CMSMcQ : final corrections of editorial errors
  found in last night's proofreading.  Reverse course once more on
  well-formed:   Webster's Second hyphenates it, and that's enough
  for me.</sitem>
  <sitem>1997-04-01 : CMSMcQ : corrections from JJC, EM, HT, and self</sitem>
  <sitem>1997-03-31 : Tim Bray : many changes</sitem>
  <sitem>1997-03-29 : CMSMcQ : some Henry Thompson (on entity handling),
  some Charles Goldfarb, some ERB decisions (PE handling in miscellaneous
  declarations.  Changed Ident element to accept def attribute.
  Allow normalization of Unicode characters.  move def of systemliteral
  into section on literals.</sitem>
  <sitem>1997-03-28 : CMSMcQ : make as many corrections as possible, from
  Terry Allen, Norbert Mikula, James Clark, Jon Bosak, Henry Thompson,
  Paul Grosso, and self.  Among other things:  give in on "well formed"
  (Terry is right), tentatively rename QuotedCData as AttValue
  and Literal as EntityValue to be more informative, since attribute
  values are the <emph>only</emph> place QuotedCData was used, and
  vice versa for entity text and Literal. (I'd call it Entity Text, 
  but 8879 uses that name for both internal and external entities.)</sitem>
  <sitem>1997-03-26 : CMSMcQ : resynch the two forks of this draft, reapply
  my changes dated 03-20 and 03-21.  Normalize old 'may not' to 'must not'
  except in the one case where it meant 'may or may not'.</sitem>
  <sitem>1997-03-21 : TB : massive changes on plane flight from Chicago
  to Vancouver</sitem>
  <sitem>1997-03-21 : CMSMcQ : correct as many reported errors as possible.
  </sitem>
  <sitem>1997-03-20 : CMSMcQ : correct typos listed in CMSMcQ hand copy of spec.</sitem>
  <sitem>1997-03-20 : CMSMcQ : cosmetic changes preparatory to revision for
  WWW conference April 1997:  restore some of the internal entity 
  references (e.g. to docdate, etc.), change character xA0 to &amp;nbsp;
  and define nbsp as &amp;#160;, and refill a lot of paragraphs for
  legibility.</sitem>
  <sitem>1996-11-12 : CMSMcQ : revise using Tim's edits:
  Add list type of NUMBERED and change most lists either to
  BULLETS or to NUMBERED.
  Suppress QuotedNames, Names (not used).
  Correct trivial-grammar doc type decl.
  Rename 'marked section' as 'CDATA section' passim.
  Also edits from James Clark:
  Define the set of characters from which [^abc] subtracts.
  Charref should use just [0-9] not Digit.
  Location info needs cleaner treatment:  remove?  (ERB
  question).
  One example of a PI has wrong pic.
  Clarify discussion of encoding names.
  Encoding failure should lead to unspecified results; don't
  prescribe error recovery.
  Don't require exposure of entity boundaries.
  Ignore white space in element content.
  Reserve entity names of the form u-NNNN.
  Clarify relative URLs.
  And some of my own:
  Correct productions for content model:  model cannot
  consist of a name, so "elements ::= cp" is no good.
  </sitem>
  <sitem>1996-11-11 : CMSMcQ : revise for style.
  Add new rhs to entity declaration, for parameter entities.</sitem>
  <sitem>1996-11-10 : CMSMcQ : revise for style.
  Fix / complete section on names, characters.
  Add sections on parameter entities, conditional sections.
  Still to do:  Add compatibility note on deterministic content models.
  Finish stylistic revision.</sitem>
  <sitem>1996-10-31 : TB : Add Entity Handling section</sitem>
  <sitem>1996-10-30 : TB : Clean up term &amp; termdef.  Slip in
  ERB decision re EMPTY.</sitem>
  <sitem>1996-10-28 : TB : Change DTD.  Implement some of Michael's
  suggestions.  Change comments back to //.  Introduce language for
  XML namespace reservation.  Add section on white-space handling.
  Lots more cleanup.</sitem>
  <sitem>1996-10-24 : CMSMcQ : quick tweaks, implement some ERB
  decisions.  Characters are not integers.  Comments are /* */ not //.
  Add bibliographic refs to 10646, HyTime, Unicode.
  Rename old Cdata as MsData since it's <emph>only</emph> seen
  in marked sections.  Call them attribute-value pairs not
  name-value pairs, except once.  Internal subset is optional, needs
  '?'.  Implied attributes should be signaled to the app, not
  have values supplied by processor.</sitem>
  <sitem>1996-10-16 : TB : track down &amp; excise all DSD references;
  introduce some EBNF for entity declarations.</sitem>
  <sitem>1996-10-?? : TB : consistency check, fix up scraps so
  they all parse, get formatter working, correct a few productions.</sitem>
  <sitem>1996-10-10/11 : CMSMcQ : various maintenance, stylistic, and
  organizational changes:
  Replace a few literals with xmlpio and
  pic entities, to make them consistent and ensure we can change pic
  reliably when the ERB votes.
  Drop paragraph on recognizers from notation section.
  Add match, exact match to terminology.
  Move old 2.2 XML Processors and Apps into intro.
  Mention comments, PIs, and marked sections in discussion of
  delimiter escaping.
  Streamline discussion of doctype decl syntax.
  Drop old section of 'PI syntax' for doctype decl, and add
  section on partial-DTD summary PIs to end of Logical Structures
  section.
  Revise DSD syntax section to use Tim's subset-in-a-PI
  mechanism.</sitem>
  <sitem>1996-10-10 : TB : eliminate name recognizers (and more?)</sitem>
  <sitem>1996-10-09 : CMSMcQ : revise for style, consistency through 2.3
  (Characters)</sitem>
  <sitem>1996-10-09 : CMSMcQ : re-unite everything for convenience,
  at least temporarily, and revise quickly</sitem>
  <sitem>1996-10-08 : TB : first major homogenization pass</sitem>
  <sitem>1996-10-08 : TB : turn "current" attribute on div type into 
  CDATA</sitem>
  <sitem>1996-10-02 : TB : remould into skeleton + entities</sitem>
  <sitem>1996-09-30 : CMSMcQ : add a few more sections prior to exchange
                              with Tim.</sitem>
  <sitem>1996-09-20 : CMSMcQ : finish transcribing notes.</sitem>
  <sitem>1996-09-19 : CMSMcQ : begin transcribing notes for draft.</sitem>
  <sitem>1996-09-13 : CMSMcQ : made outline from notes of 09-06,
  do some housekeeping</sitem>
  </slist>
  </revisiondesc>
  </header>
  <body> 
  <div1 id='sec-intro'>
  <head>Introduction</head>
  <p>Extensible Markup Language, abbreviated XML, describes a class of
  data objects called <termref def="dt-xml-doc">XML documents</termref> 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 <bibref ref='ISO8879'/>.
  By construction, XML documents 
  are conforming SGML documents.
  </p>
  <p>XML documents are made up of storage units called <termref
  def="dt-entity">entities</termref>, which contain either parsed
  or unparsed data.
  Parsed data is made up of <termref def="dt-character">characters</termref>,
  some 
  of which form <termref def="dt-chardata">character data</termref>, 
  and some of which form <termref def="dt-markup">markup</termref>.
  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><termdef id="dt-xml-proc" term="XML Processor">A software module
  called an <term>XML processor</term> is used to read XML documents
  and provide access to their content and structure.</termdef> <termdef
  id="dt-app" term="Application">It is assumed that an XML processor is
  doing its work on behalf of another module, called the
  <term>application</term>.</termdef> 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>
   
  <div2 id='sec-origin-goals'>
  <head>Origin and Goals</head>
  <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:<olist>
  <item><p>XML shall be straightforwardly usable over the
  Internet.</p></item>
  <item><p>XML shall support a wide variety of applications.</p></item>
  <item><p>XML shall be compatible with SGML.</p></item>
  <item><p>It shall be easy to write programs which process XML
  documents.</p></item>
  <item><p>The number of optional features in XML is to be kept to the
  absolute minimum, ideally zero.</p></item>
  <item><p>XML documents should be human-legible and reasonably
  clear.</p></item>
  <item><p>The XML design should be prepared quickly.</p></item>
  <item><p>The design of XML shall be formal and concise.</p></item>
  <item><p>XML documents shall be easy to create.</p></item>
  <item><p>Terseness in XML markup is of minimal importance.</p></item></olist>
  </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 &XML.version;
  and construct computer programs to process it.</p>
  <p>This version of the XML specification
  <!-- is for &doc.audience;.-->
  &doc.distribution;.</p>
  
  </div2>
   
  
  
   
  <div2 id='sec-terminology'>
  <head>Terminology</head>
   
  <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:
  <glist>
  <gitem>
  <label>may</label>
  <def><p><termdef id="dt-may" term="May">Conforming documents and XML
  processors are permitted to but need not behave as
  described.</termdef></p></def>
  </gitem>
  <gitem>
  <label>must</label>
  <def><p>Conforming documents and XML processors 
  are required to behave as described; otherwise they are in error.
  <!-- do NOT change this! this is what defines a violation of
  a 'must' clause as 'an error'. -MSM -->
  </p></def>
  </gitem>
  <gitem>
  <label>error</label>
  <def><p><termdef id='dt-error' term='Error'
  >A violation of the rules of this
  specification; results are
  undefined.  Conforming software may detect and report an error and may
  recover from it.</termdef></p></def>
  </gitem>
  <gitem>
  <label>fatal error</label>
  <def><p><termdef id="dt-fatal" term="Fatal Error">An error
  which a conforming <termref def="dt-xml-proc">XML processor</termref>
  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).
  </termdef></p></def>
  </gitem>
  <gitem>
  <label>at user option</label>
  <def><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></def>
  </gitem>
  <gitem>
  <label>validity constraint</label>
  <def><p>A rule which applies to all 
  <termref def="dt-valid">valid</termref> XML documents.
  Violations of validity constraints are errors; they must, at user option, 
  be reported by 
  <termref def="dt-validating">validating XML processors</termref>.</p></def>
  </gitem>
  <gitem>
  <label>well-formedness constraint</label>
  <def><p>A rule which applies to all <termref
  def="dt-wellformed">well-formed</termref> XML documents.
  Violations of well-formedness constraints are 
  <termref def="dt-fatal">fatal errors</termref>.</p></def>
  </gitem>
  
  <gitem>
  <label>match</label>
  <def><p><termdef id="dt-match" term="match">(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
  <specref ref='elementvalid'/>.
  </termdef>
  </p></def>
  </gitem>
  <gitem>
  <label>for compatibility</label>
  <def><p><termdef id="dt-compat" term="For Compatibility">A feature of
  XML included solely to ensure that XML remains compatible with SGML.
  </termdef></p></def>
  </gitem>
  <gitem>
  <label>for interoperability</label>
  <def><p><termdef id="dt-interop" term="For interoperability">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;.</termdef></p></def>
  </gitem>
  </glist>
  </p>
  </div2>
  
   
  </div1>
  <!-- &Docs; -->
   
  <div1 id='sec-documents'>
  <head>Documents</head>
   
  <p><termdef id="dt-xml-doc" term="XML Document">
  A data object is an
  <term>XML document</term> if it is
  <termref def="dt-wellformed">well-formed</termref>, as
  defined in this specification.
  A well-formed XML document may in addition be
  <termref def="dt-valid">valid</termref> if it meets certain further 
  constraints.</termdef></p>
   
  <p>Each XML document has both a logical and a physical structure.
  Physically, the document is composed of units called <termref
  def="dt-entity">entities</termref>.  An entity may <termref
  def="dt-entref">refer</termref> to other entities to cause their
  inclusion in the document. A document begins in a "root"  or <termref
  def="dt-docent">document entity</termref>.
  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 <specref ref='wf-entities'/>.
  </p>
   
  <div2 id='sec-well-formed'>
  <head>Well-Formed XML Documents</head>
   
  <p><termdef id="dt-wellformed" term="Well-Formed">
  A textual object is 
  a well-formed XML document if:</termdef>
  <olist>
  <item><p>Taken as a whole, it
  matches the production labeled <nt def='NT-document'>document</nt>.</p></item>
  <item><p>It
  meets all the well-formedness constraints given in this specification.</p>
  </item>
  <item><p>Each of the <termref def='dt-parsedent'>parsed entities</termref> 
  which is referenced directly or indirectly within the document is
  <titleref href='wf-entities'>well-formed</titleref>.</p></item>
  </olist></p>
  <p>
  <scrap lang='ebnf' id='document'>
  <head>Document</head>
  <prod id='NT-document'><lhs>document</lhs>
  <rhs><nt def='NT-prolog'>prolog</nt> 
  <nt def='NT-element'>element</nt> 
  <nt def='NT-Misc'>Misc</nt>*</rhs></prod>
  </scrap>
  </p>
  <p>Matching the <nt def="NT-document">document</nt> production 
  implies that:
  <olist>
  <item><p>It contains one or more
  <termref def="dt-element">elements</termref>.</p>
  </item>
  <!--* N.B. some readers (notably JC) find the following
  paragraph awkward and redundant.  I agree it's logically redundant:
  it *says* it is summarizing the logical implications of
  matching the grammar, and that means by definition it's
  logically redundant.  I don't think it's rhetorically
  redundant or unnecessary, though, so I'm keeping it.  It
  could however use some recasting when the editors are feeling
  stronger. -MSM *-->
  <item><p><termdef id="dt-root" term="Root Element">There is  exactly
  one element, called the <term>root</term>, or document element,  no
  part of which appears in the <termref
  def="dt-content">content</termref> of any other element.</termdef>
  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></item>
  </olist>
  </p>
  <p><termdef id="dt-parentchild" term="Parent/Child">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
  <term>parent</term> of <code>C</code>, and <code>C</code> as a
  <term>child</term> of <code>P</code>.</termdef></p></div2>
   
  <div2 id="charsets">
  <head>Characters</head>
   
  <p><termdef id="dt-text" term="Text">A parsed entity contains
  <term>text</term>, a sequence of 
  <termref def="dt-character">characters</termref>, 
  which may represent markup or character data.</termdef> 
  <termdef id="dt-character" term="Character">A <term>character</term> 
  is an atomic unit of text as specified by
  ISO/IEC 10646 <bibref ref="ISO10646"/>.
  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 <bibref ref='Unicode'/>, is discouraged.
  </termdef> 
  <scrap lang="ebnf" id="char32">
  <head>Character Range</head>
  <prodgroup pcw2="4" pcw4="17.5" pcw5="11">
  <prod id="NT-Char"><lhs>Char</lhs> 
  <rhs>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] 
  | [#x10000-#x10FFFF]</rhs> 
  <com>any Unicode character, excluding the
  surrogate blocks, FFFE, and FFFF.</com> </prod>
  </prodgroup>
  </scrap>
  </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 <specref ref='charencoding'/>.
  </p>
  <!--
  <p>Regardless of the specific encoding used, any character in the ISO/IEC
  10646 character set may be referred to by the decimal or hexadecimal
  equivalent of its 
  UCS-4 code value.
  </p>-->
  </div2>
   
  <div2 id='sec-common-syn'>
  <head>Common Syntactic Constructs</head>
   
  <p>This section defines some symbols used widely in the grammar.</p>
  <p><nt def="NT-S">S</nt> (white space) consists of one or more space (#x20)
  characters, carriage returns, line feeds, or tabs.
  
  <scrap lang="ebnf" id='white'>
  <head>White Space</head>
  <prodgroup pcw2="4" pcw4="17.5" pcw5="11">
  <prod id='NT-S'><lhs>S</lhs>
  <rhs>(#x20 | #x9 | #xD | #xA)+</rhs>
  </prod>
  </prodgroup>
  </scrap></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 <specref ref='CharClasses'/>.</p>
  <p><termdef id="dt-name" term="Name">A <term>Name</term> 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.</termdef>
  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>
  <note>
  <p>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.</p>
  </note>
  <p>An
  <nt def='NT-Nmtoken'>Nmtoken</nt> (name token) is any mixture of
  name characters.
  <scrap lang='ebnf'>
  <head>Names and Tokens</head>
  <prod id='NT-NameChar'><lhs>NameChar</lhs>
  <rhs><nt def="NT-Letter">Letter</nt> 
  | <nt def='NT-Digit'>Digit</nt> 
  | '.' | '-' | '_' | ':'
  | <nt def='NT-CombiningChar'>CombiningChar</nt> 
  | <nt def='NT-Extender'>Extender</nt></rhs>
  </prod>
  <prod id='NT-Name'><lhs>Name</lhs>
  <rhs>(<nt def='NT-Letter'>Letter</nt> | '_' | ':')
  (<nt def='NT-NameChar'>NameChar</nt>)*</rhs></prod>
  <prod id='NT-Names'><lhs>Names</lhs>
  <rhs><nt def='NT-Name'>Name</nt> 
  (<nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt>)*</rhs></prod>
  <prod id='NT-Nmtoken'><lhs>Nmtoken</lhs>
  <rhs>(<nt def='NT-NameChar'>NameChar</nt>)+</rhs></prod>
  <prod id='NT-Nmtokens'><lhs>Nmtokens</lhs>
  <rhs><nt def='NT-Nmtoken'>Nmtoken</nt> (<nt def='NT-S'>S</nt> <nt def='NT-Nmtoken'>Nmtoken</nt>)*</rhs></prod>
  </scrap>
  </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
  (<nt def='NT-EntityValue'>EntityValue</nt>),
  the values of attributes (<nt def='NT-AttValue'>AttValue</nt>), 
  and external identifiers 
  (<nt def="NT-SystemLiteral">SystemLiteral</nt>).  
  Note that a <nt def='NT-SystemLiteral'>SystemLiteral</nt>
  can be parsed without scanning for markup.
  <scrap lang='ebnf'>
  <head>Literals</head>
  <prod id='NT-EntityValue'><lhs>EntityValue</lhs>
  <rhs>'"' 
  ([^%&amp;"] 
  | <nt def='NT-PEReference'>PEReference</nt> 
  | <nt def='NT-Reference'>Reference</nt>)*
  '"' 
  </rhs>
  <rhs>|&nbsp; 
  "'" 
  ([^%&amp;'] 
  | <nt def='NT-PEReference'>PEReference</nt> 
  | <nt def='NT-Reference'>Reference</nt>)* 
  "'"</rhs>
  </prod>
  <prod id='NT-AttValue'><lhs>AttValue</lhs>
  <rhs>'"' 
  ([^&lt;&amp;"] 
  | <nt def='NT-Reference'>Reference</nt>)* 
  '"' 
  </rhs>
  <rhs>|&nbsp; 
  "'" 
  ([^&lt;&amp;'] 
  | <nt def='NT-Reference'>Reference</nt>)* 
  "'"</rhs>
  </prod>
  <prod id="NT-SystemLiteral"><lhs>SystemLiteral</lhs>
  <rhs>('"' [^"]* '"') |&nbsp;("'" [^']* "'")
  </rhs>
  </prod>
  <prod id="NT-PubidLiteral"><lhs>PubidLiteral</lhs>
  <rhs>'"' <nt def='NT-PubidChar'>PubidChar</nt>* 
  '"' 
  | "'" (<nt def='NT-PubidChar'>PubidChar</nt> - "'")* "'"</rhs>
  </prod>
  <prod id="NT-PubidChar"><lhs>PubidChar</lhs>
  <rhs>#x20 | #xD | #xA 
  |&nbsp;[a-zA-Z0-9]
  |&nbsp;[-'()+,./:=?;!*#@$_%]</rhs>
  </prod>
  </scrap>
  </p>
  
  </div2>
  
  <div2 id='syntax'>
  <head>Character Data and Markup</head>
   
  <p><termref def='dt-text'>Text</termref> consists of intermingled 
  <termref def="dt-chardata">character
  data</termref> and markup.
  <termdef id="dt-markup" term="Markup"><term>Markup</term> takes the form of
  <termref def="dt-stag">start-tags</termref>,
  <termref def="dt-etag">end-tags</termref>,
  <termref def="dt-empty">empty-element tags</termref>,
  <termref def="dt-entref">entity references</termref>,
  <termref def="dt-charref">character references</termref>,
  <termref def="dt-comment">comments</termref>,
  <termref def="dt-cdsection">CDATA section</termref> delimiters,
  <termref def="dt-doctype">document type declarations</termref>, and
  <termref def="dt-pi">processing instructions</termref>.
  </termdef>
  </p>
  <p><termdef id="dt-chardata" term="Character Data">All text that is not markup
  constitutes the <term>character data</term> of
  the document.</termdef></p>
  <p>The ampersand character (&amp;) and the left angle bracket (&lt;)
  may appear in their literal form <emph>only</emph> when used as markup
  delimiters, or within a <termref def="dt-comment">comment</termref>, a
  <termref def="dt-pi">processing instruction</termref>, 
  or a <termref def="dt-cdsection">CDATA section</termref>.  
  
  They are also legal within the <termref def='dt-litentval'>literal entity
  value</termref> of an internal entity declaration; see
  <specref ref='wf-entities'/>.
  <!-- FINAL EDIT:  restore internal entity decl or leave it out. -->
  If they are needed elsewhere,
  they must be <termref def="dt-escape">escaped</termref>
  using either <termref def='dt-charref'>numeric character references</termref>
  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, <termref def='dt-compat'>for
  compatibility</termref>, 
  be escaped using
  "<code>&amp;gt;</code>" or a character reference 
  when it appears in the string
  "<code>]]&gt;</code>"
  in content, 
  when that string is not marking the end of 
  a <termref def="dt-cdsection">CDATA section</termref>. 
  </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>]]&gt;</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>".
  <scrap lang="ebnf">
  <head>Character Data</head>
  <prod id='NT-CharData'>
  <lhs>CharData</lhs>
  <rhs>[^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;' [^&lt;&amp;]*)</rhs>
  </prod>
  </scrap>
  </p>
  </div2>
   
  <div2 id='sec-comments'>
  <head>Comments</head>
   
  <p><termdef id="dt-comment" term="Comment"><term>Comments</term> may 
  appear anywhere in a document outside other 
  <termref def='dt-markup'>markup</termref>; in addition,
  they may appear within the document type declaration
  at places allowed by the grammar.
  They are not part of the document's <termref def="dt-chardata">character
  data</termref>; an XML
  processor may, but need not, make it possible for an application to
  retrieve the text of comments.
  <termref def="dt-compat">For compatibility</termref>, the string
  "<code>--</code>" (double-hyphen) must not occur within
  comments.
  <scrap lang="ebnf">
  <head>Comments</head>
  <prod id='NT-Comment'><lhs>Comment</lhs>
  <rhs>'&lt;!--'
  ((<nt def='NT-Char'>Char</nt> - '-') 
  | ('-' (<nt def='NT-Char'>Char</nt> - '-')))* 
  '-->'</rhs>
  </prod>
  </scrap>
  </termdef></p>
  <p>An example of a comment:
  <eg>&lt;!&como; declarations for &lt;head> &amp; &lt;body> &comc;&gt;</eg>
  </p>
  </div2>
   
  <div2 id='sec-pi'>
  <head>Processing Instructions</head>
   
  <p><termdef id="dt-pi" term="Processing instruction"><term>Processing
  instructions</term> (PIs) allow documents to contain instructions
  for applications.
   
  <scrap lang="ebnf">
  <head>Processing Instructions</head>
  <prod id='NT-PI'><lhs>PI</lhs>
  <rhs>'&lt;?' <nt def='NT-PITarget'>PITarget</nt> 
  (<nt def='NT-S'>S</nt> 
  (<nt def='NT-Char'>Char</nt>* - 
  (<nt def='NT-Char'>Char</nt>* &pic; <nt def='NT-Char'>Char</nt>*)))?
  &pic;</rhs></prod>
  <prod id='NT-PITarget'><lhs>PITarget</lhs>
  <rhs><nt def='NT-Name'>Name</nt> - 
  (('X' | 'x') ('M' | 'm') ('L' | 'l'))</rhs>
  </prod>
  </scrap></termdef>
  PIs are not part of the document's <termref def="dt-chardata">character
  data</termref>, but must be passed through to the application. The
  PI begins with a target (<nt def='NT-PITarget'>PITarget</nt>) 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 <termref def='dt-notation'>Notation</termref> mechanism
  may be used for
  formal declaration of PI targets.
  </p>
  </div2>
   
  <div2 id='sec-cdata-sect'>
  <head>CDATA Sections</head>
   
  <p><termdef id="dt-cdsection" term="CDATA Section"><term>CDATA sections</term>
  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>]]&gt;</code>":
  <scrap lang="ebnf">
  <head>CDATA Sections</head>
  <prod id='NT-CDSect'><lhs>CDSect</lhs>
  <rhs><nt def='NT-CDStart'>CDStart</nt> 
  <nt def='NT-CData'>CData</nt> 
  <nt def='NT-CDEnd'>CDEnd</nt></rhs></prod>
  <prod id='NT-CDStart'><lhs>CDStart</lhs>
  <rhs>'&lt;![CDATA['</rhs>
  </prod>
  <prod id='NT-CData'><lhs>CData</lhs>
  <rhs>(<nt def='NT-Char'>Char</nt>* - 
  (<nt def='NT-Char'>Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
  </rhs>
  </prod>
  <prod id='NT-CDEnd'><lhs>CDEnd</lhs>
  <rhs>']]&gt;'</rhs>
  </prod>
  </scrap>
  
  Within a CDATA section, only the <nt def='NT-CDEnd'>CDEnd</nt> 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.</termdef>
  </p>
  
  <p>An example of a CDATA section, in which "<code>&lt;greeting></code>" and 
  "<code>&lt;/greeting></code>"
  are recognized as <termref def='dt-chardata'>character data</termref>, not
  <termref def='dt-markup'>markup</termref>:
  <eg>&lt;![CDATA[&lt;greeting>Hello, world!&lt;/greeting>]]&gt;</eg>
  </p>
  </div2>
   
  <div2 id='sec-prolog-dtd'>
  <head>Prolog and Document Type Declaration</head>
   
  <p><termdef id='dt-xmldecl' term='XML Declaration'>XML documents 
  may, and should, 
  begin with an <term>XML declaration</term> which specifies
  the version of
  XML being used.</termdef>
  For example, the following is a complete XML document, <termref
  def="dt-wellformed">well-formed</termref> but not
  <termref def="dt-valid">valid</termref>:
  <eg><![CDATA[<?xml version="1.0"?>
  <greeting>Hello, world!</greeting>
  ]]></eg>
  and so is this:
  <eg><![CDATA[<greeting>Hello, world!</greeting>
  ]]></eg>
  </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 <termref
  def="dt-doctype">document type declaration</termref>, to define
  constraints on the logical structure and to support the use of
  predefined storage units.
  
  <termdef id="dt-valid" term="Validity">An XML document is 
  <term>valid</term> if it has an associated document type
  declaration and if the document
  complies with the constraints expressed in it.</termdef></p>
  <p>The document type declaration must appear before
  the first <termref def="dt-element">element</termref> in the document.
  <scrap lang="ebnf" id='xmldoc'>
  <head>Prolog</head>
  <prodgroup pcw2="6" pcw4="17.5" pcw5="9">
  <prod id='NT-prolog'><lhs>prolog</lhs>
  <rhs><nt def='NT-XMLDecl'>XMLDecl</nt>? 
  <nt def='NT-Misc'>Misc</nt>* 
  (<nt def='NT-doctypedecl'>doctypedecl</nt> 
  <nt def='NT-Misc'>Misc</nt>*)?</rhs></prod>
  <prod id='NT-XMLDecl'><lhs>XMLDecl</lhs>
  <rhs>&xmlpio; 
  <nt def='NT-VersionInfo'>VersionInfo</nt> 
  <nt def='NT-EncodingDecl'>EncodingDecl</nt>? 
  <nt def='NT-SDDecl'>SDDecl</nt>? 
  <nt def="NT-S">S</nt>? 
  &pic;</rhs>
  </prod>
  <prod id='NT-VersionInfo'><lhs>VersionInfo</lhs>
  <rhs><nt def="NT-S">S</nt> 'version' <nt def='NT-Eq'>Eq</nt> 
  (' <nt def="NT-VersionNum">VersionNum</nt> ' 
  | " <nt def="NT-VersionNum">VersionNum</nt> ")</rhs>
  </prod>
  <prod id='NT-Eq'><lhs>Eq</lhs>
  <rhs><nt def='NT-S'>S</nt>? '=' <nt def='NT-S'>S</nt>?</rhs></prod>
  <prod id="NT-VersionNum">
  <lhs>VersionNum</lhs>
  <rhs>([a-zA-Z0-9_.:] | '-')+</rhs>
  </prod>
  <prod id='NT-Misc'><lhs>Misc</lhs>
  <rhs><nt def='NT-Comment'>Comment</nt> | <nt def='NT-PI'>PI</nt> | 
  <nt def='NT-S'>S</nt></rhs></prod>
  </prodgroup>
  </scrap></p>
  
  <p><termdef id="dt-doctype" term="Document Type Declaration">The XML
  <term>document type declaration</term> 
  contains or points to 
  <termref def='dt-markupdecl'>markup declarations</termref> 
  that provide a grammar for a
  class of documents.  
  This grammar is known as a document type definition,
  or <term>DTD</term>.  
  The document type declaration can point to an external subset (a
  special kind of 
  <termref def='dt-extent'>external entity</termref>) 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.</termdef>
  </p>
  <p><termdef id="dt-markupdecl" term="markup declaration">
  A <term>markup declaration</term> is 
  an <termref def="dt-eldecl">element type declaration</termref>, 
  an <termref def="dt-attdecl">attribute-list declaration</termref>, 
  an <termref def="dt-entdecl">entity declaration</termref>, or
  a <termref def="dt-notdecl">notation declaration</termref>.
  </termdef>
  These declarations may be contained in whole or in part
  within <termref def='dt-PE'>parameter entities</termref>,
  as described in the well-formedness and validity constraints below.
  For fuller information, see
  <specref ref="sec-physical-struct"/>.</p>
  <scrap lang="ebnf" id='dtd'>
  <head>Document Type Definition</head>
  <prodgroup pcw2="6" pcw4="17.5" pcw5="9">
  <prod id='NT-doctypedecl'><lhs>doctypedecl</lhs>
  <rhs>'&lt;!DOCTYPE' <nt def='NT-S'>S</nt> 
  <nt def='NT-Name'>Name</nt> (<nt def='NT-S'>S</nt> 
  <nt def='NT-ExternalID'>ExternalID</nt>)? 
  <nt def='NT-S'>S</nt>? ('[' 
  (<nt def='NT-markupdecl'>markupdecl</nt> 
  | <nt def='NT-PEReference'>PEReference</nt> 
  | <nt def='NT-S'>S</nt>)*
  ']' 
  <nt def='NT-S'>S</nt>?)? '>'</rhs>
  <vc def="vc-roottype"/>
  </prod>
  <prod id='NT-markupdecl'><lhs>markupdecl</lhs>
  <rhs><nt def='NT-elementdecl'>elementdecl</nt> 
  | <nt def='NT-AttlistDecl'>AttlistDecl</nt> 
  | <nt def='NT-EntityDecl'>EntityDecl</nt> 
  | <nt def='NT-NotationDecl'>NotationDecl</nt> 
  | <nt def='NT-PI'>PI</nt> 
  | <nt def='NT-Comment'>Comment</nt>
  </rhs>
  <vc def='vc-PEinMarkupDecl'/>
  <wfc def="wfc-PEinInternalSubset"/>
  </prod>
  
  </prodgroup>
  </scrap>
  
  <p>The markup declarations may be made up in whole or in part of
  the <termref def='dt-repltext'>replacement text</termref> of 
  <termref def='dt-PE'>parameter entities</termref>.
  The productions later in this specification for
  individual nonterminals (<nt def='NT-elementdecl'>elementdecl</nt>,
  <nt def='NT-AttlistDecl'>AttlistDecl</nt>, and so on) describe 
  the declarations <emph>after</emph> all the parameter entities have been 
  <termref def='dt-include'>included</termref>.</p>
  
  <vcnote id="vc-roottype">
  <head>Root Element Type</head>
  <p>
  The <nt def='NT-Name'>Name</nt> in the document type declaration must
  match the element type of the <termref def='dt-root'>root element</termref>.
  </p>
  </vcnote>
  
  <vcnote id='vc-PEinMarkupDecl'>
  <head>Proper Declaration/PE Nesting</head>
  <p>Parameter-entity 
  <termref def='dt-repltext'>replacement text</termref> must be properly nested
  with markup declarations. 
  That is to say, if either the first character
  or the last character of a markup
  declaration (<nt def='NT-markupdecl'>markupdecl</nt> above)
  is contained in the replacement text for a 
  <termref def='dt-PERef'>parameter-entity reference</termref>,
  both must be contained in the same replacement text.</p>
  </vcnote>
  <wfcnote id="wfc-PEinInternalSubset">
  <head>PEs in Internal Subset</head>
  <p>In the internal DTD subset, 
  <termref def='dt-PERef'>parameter-entity references</termref>
  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>
  </wfcnote>
  <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
  <nt def="NT-markupdecl">markupdecl</nt>, interspersed with white space
  or <termref def="dt-PERef">parameter-entity references</termref>.
  However, portions of the contents
  of the 
  external subset or of external parameter entities may conditionally be ignored
  by using 
  the <termref def="dt-cond-section">conditional section</termref>
  construct; this is not allowed in the internal subset.
  
  <scrap id="ext-Subset">
  <head>External Subset</head>
  <prodgroup pcw2="6" pcw4="17.5" pcw5="9">
  <prod id='NT-extSubset'><lhs>extSubset</lhs>
  <rhs><nt def='NT-TextDecl'>TextDecl</nt>?
  <nt def='NT-extSubsetDecl'>extSubsetDecl</nt></rhs></prod>
  <prod id='NT-extSubsetDecl'><lhs>extSubsetDecl</lhs>
  <rhs>(
  <nt def='NT-markupdecl'>markupdecl</nt> 
  | <nt def='NT-conditionalSect'>conditionalSect</nt> 
  | <nt def='NT-PEReference'>PEReference</nt> 
  | <nt def='NT-S'>S</nt>
  )*</rhs>
  </prod>
  </prodgroup>
  </scrap></p>
  <p>The external subset and external parameter entities also differ 
  from the internal subset in that in them,
  <termref def="dt-PERef">parameter-entity references</termref>
  are permitted <emph>within</emph> markup declarations,
  not only <emph>between</emph> markup declarations.</p>
  <p>An example of an XML document with a document type declaration:
  <eg><![CDATA[<?xml version="1.0"?>
  <!DOCTYPE greeting SYSTEM "hello.dtd">
  <greeting>Hello, world!</greeting>
  ]]></eg>
  The <termref def="dt-sysid">system identifier</termref> 
  "<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:
  <eg><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE greeting [
    <!ELEMENT greeting (#PCDATA)>
  ]>
  <greeting>Hello, world!</greeting>
  ]]></eg>
  If both the external and internal subsets are used, the 
  internal subset is considered to occur before the external subset.
  <!-- 'is considered to'? boo. whazzat mean? -->
  This has the effect that entity and attribute-list declarations in the
  internal subset take precedence over those in the external subset.
  </p>
  </div2>
   
  <div2 id='sec-rmd'>
  <head>Standalone Document Declaration</head>
  <p>Markup declarations can affect the content of the document,
  as passed from an <termref def="dt-xml-proc">XML processor</termref> 
  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 <termref def='dt-docent'>document entity</termref>.
  <scrap lang="ebnf" id='fulldtd'>
  <head>Standalone Document Declaration</head>
  <prodgroup pcw2="4" pcw4="19.5" pcw5="9">
  <prod id='NT-SDDecl'><lhs>SDDecl</lhs>
  <rhs>
  <nt def="NT-S">S</nt> 
  'standalone' <nt def='NT-Eq'>Eq</nt> 
  (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
  </rhs>
  <vc def='vc-check-rmd'/></prod>
  </prodgroup>
  </scrap></p>
  <p>
  In a standalone document declaration, the value "<code>yes</code>" indicates
  that there 
  are no markup declarations external to the <termref def='dt-docent'>document
  entity</termref> (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 <emph>declarations</emph>; the presence, in a
  document, of 
  references to external <emph>entities</emph>, 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>
  <vcnote id='vc-check-rmd'>
  <head>Standalone Document Declaration</head>
  <p>The standalone document declaration must have
  the value "<code>no</code>" if any external markup declarations
  contain declarations of:</p><ulist>
  <item><p>attributes with <termref def="dt-default">default</termref> values, if
  elements to which
  these attributes apply appear in the document without
  specifications of values for these attributes, or</p></item>
  <item><p>entities (other than &magicents;), 
  if <termref def="dt-entref">references</termref> to those
  entities appear in the document, or</p>
  </item>
  <item><p>attributes with values subject to
  <titleref href='AVNormalize'>normalization</titleref>, where the
  attribute appears in the document with a value which will
  change as a result of normalization, or</p>
  </item>
  <item>
  <p>element types with <termref def="dt-elemcontent">element content</termref>, 
  if white space occurs
  directly within any instance of those types.
  </p></item>
  </ulist>
  
  </vcnote>
  <p>An example XML declaration with a standalone document declaration:<eg
  >&lt;?xml version="&XML.version;" standalone='yes'?></eg></p>
  </div2>
  <div2 id='sec-white-space'>
  <head>White Space Handling</head>
  
  <p>In editing XML documents, it is often convenient to use "white space"
  (spaces, tabs, and blank lines, denoted by the nonterminal 
  <nt def='NT-S'>S</nt> 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 <termref def='dt-xml-proc'>XML processor</termref> 
  must always pass all characters in a document that are not
  markup through to the application.   A <termref def='dt-validating'>
  validating XML processor</termref> must also inform the application
  which  of these characters constitute white space appearing
  in <termref def="dt-elemcontent">element content</termref>.
  </p>
  <p>A special <termref def='dt-attr'>attribute</termref> 
  named <kw>xml:space</kw> 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 
  <termref def="dt-attdecl">declared</termref> if it is used.
  When declared, it must be given as an 
  <termref def='dt-enumerated'>enumerated type</termref> whose only
  possible values are "<code>default</code>" and "<code>preserve</code>".
  For example:<eg><![CDATA[    <!ATTLIST poem   xml:space (default|preserve) 'preserve'>]]></eg></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 <kw>xml:space</kw> attribute.
  </p>
  <p>The <termref def='dt-root'>root element</termref> 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>
  
  </div2>
  <div2 id='sec-line-ends'>
  <head>End-of-Line Handling</head>
  <p>XML <termref def='dt-parsedent'>parsed entities</termref> 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 <termref def='dt-app'>applications</termref>,
  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 <termref def='dt-xml-proc'>XML processor</termref> 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>
  </div2>
  <div2 id='sec-lang-tag'>
  <head>Language Identification</head>
  <p>In document processing, it is often useful to
  identify the natural or formal language 
  in which the content is 
  written.
  A special <termref def="dt-attr">attribute</termref> named
  <kw>xml:lang</kw> 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 
  <termref def="dt-attdecl">declared</termref> if it is used.
  The values of the attribute are language identifiers as defined
  by <bibref ref="RFC1766"/>, "Tags for the Identification of Languages":
  <scrap lang='ebnf'>
  <head>Language Identification</head>
  <prod id='NT-LanguageID'><lhs>LanguageID</lhs>
  <rhs><nt def='NT-Langcode'>Langcode</nt> 
  ('-' <nt def='NT-Subcode'>Subcode</nt>)*</rhs></prod>
  <prod id='NT-Langcode'><lhs>Langcode</lhs>
  <rhs><nt def='NT-ISO639Code'>ISO639Code</nt> | 
  <nt def='NT-IanaCode'>IanaCode</nt> | 
  <nt def='NT-UserCode'>UserCode</nt></rhs>
  </prod>
  <prod id='NT-ISO639Code'><lhs>ISO639Code</lhs>
  <rhs>([a-z] | [A-Z]) ([a-z] | [A-Z])</rhs></prod>
  <prod id='NT-IanaCode'><lhs>IanaCode</lhs>
  <rhs>('i' | 'I') '-' ([a-z] | [A-Z])+</rhs></prod>
  <prod id='NT-UserCode'><lhs>UserCode</lhs>
  <rhs>('x' | 'X') '-' ([a-z] | [A-Z])+</rhs></prod>
  <prod id='NT-Subcode'><lhs>Subcode</lhs>
  <rhs>([a-z] | [A-Z])+</rhs></prod>
  </scrap>
  The <nt def='NT-Langcode'>Langcode</nt> may be any of the following:
  <ulist>
  <item><p>a two-letter language code as defined by 
  <bibref ref="ISO639"/>, "Codes
  for the representation of names of languages"</p></item>
  <item><p>a language identifier registered with the Internet
  Assigned Numbers Authority <bibref ref='IANA'/>; these begin with the 
  prefix "<code>i-</code>" (or "<code>I-</code>")</p></item>
  <item><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></item>
  </ulist></p>
  <p>There may be any number of <nt def='NT-Subcode'>Subcode</nt> segments; if
  the first 
  subcode segment exists and the Subcode consists of two 
  letters, then it must be a country code from 
  <bibref ref="ISO3166"/>, "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 <nt def='NT-Langcode'>Langcode</nt> 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:
  <eg><![CDATA[<p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
  <p xml:lang="en-GB">What colour is it?</p>
  <p xml:lang="en-US">What color is it?</p>
  <sp who="Faust" desc='leise' xml:lang="de">
    <l>Habe nun, ach! Philosophie,</l>
    <l>Juristerei, und Medizin</l>
    <l>und leider auch Theologie</l>
    <l>durchaus studiert mit hei�em Bem�h'n.</l>
    </sp>]]></eg></p>
  <!--<p>The xml:lang value is considered to apply both to the contents of an
  element and 
  (unless otherwise via attribute default values) to the
  values of all of its attributes with free-text (CDATA) values.  -->
  <p>The intent declared with <kw>xml:lang</kw> is considered to apply to
  all attributes and content of the element where it is specified,
  unless overridden with an instance of <kw>xml:lang</kw>
  on another element within that content.</p>
  <!--
  If no
  value is specified for xml:lang on an element, and no default value is
  defined for it in the DTD, then the xml:lang attribute of any element
  takes the same value it has in the parent element, if any.  The two
  technical terms in the following example both have the same effective
  value for xml:lang:
  
    <p xml:lang="en">Here the keywords are
    <term xml:lang="en">shift</term> and
    <term>reduce</term>. ...</p>
  
  The application, not the XML processor, is responsible for this '
  inheritance' of attribute values.
  -->
  <p>A simple declaration for <kw>xml:lang</kw> might take
  the form
  <eg>xml:lang  NMTOKEN  #IMPLIED</eg>
  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:
  <eg><![CDATA[    <!ATTLIST poem   xml:lang NMTOKEN 'fr'>
      <!ATTLIST gloss  xml:lang NMTOKEN 'en'>
      <!ATTLIST note   xml:lang NMTOKEN 'en'>]]></eg>
  </p>
  
  </div2>
  </div1>
  <!-- &Elements; -->
   
  <div1 id='sec-logical-struct'>
  <head>Logical Structures</head>
   
  <p><termdef id="dt-element" term="Element">Each <termref
  def="dt-xml-doc">XML document</termref> contains one or more
  <term>elements</term>, the boundaries of which are 
  either delimited by <termref def="dt-stag">start-tags</termref> 
  and <termref def="dt-etag">end-tags</termref>, or, for <termref
  def="dt-empty">empty</termref> elements, by an <termref
  def="dt-eetag">empty-element tag</termref>. Each element has a type,
  identified by name, sometimes called its "generic
  identifier" (GI), and may have a set of
  attribute specifications.</termdef>  Each attribute specification 
  has a <termref
  def="dt-attrname">name</termref> and a <termref
  def="dt-attrval">value</termref>.
  </p>
  <scrap lang='ebnf'><head>Element</head>
  <prod id='NT-element'><lhs>element</lhs>
  <rhs><nt def='NT-EmptyElemTag'>EmptyElemTag</nt></rhs>
  <rhs>| <nt def='NT-STag'>STag</nt> <nt def='NT-content'>content</nt> 
  <nt def='NT-ETag'>ETag</nt></rhs>
  <wfc def='GIMatch'/>
  <vc def='elementvalid'/>
  </prod>
  </scrap>
  <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>
  <wfcnote id='GIMatch'>
  <head>Element Type Match</head>
  <p>
  The <nt def='NT-Name'>Name</nt> in an element's end-tag must match 
  the element type in
  the start-tag.
  </p>
  </wfcnote>
  <vcnote id='elementvalid'>
  <head>Element Valid</head>
  <p>An element is
  valid if
  there is a declaration matching 
  <nt def='NT-elementdecl'>elementdecl</nt> where the
  <nt def='NT-Name'>Name</nt> matches the element type, and
  one of the following holds:</p>
  <olist>
  <item><p>The declaration matches <kw>EMPTY</kw> and the element has no 
  <termref def='dt-content'>content</termref>.</p></item>
  <item><p>The declaration matches <nt def='NT-children'>children</nt> and
  the sequence of 
  <termref def="dt-parentchild">child elements</termref>
  belongs to the language generated by the regular expression in
  the content model, with optional white space (characters 
  matching the nonterminal <nt def='NT-S'>S</nt>) between each pair
  of child elements.</p></item>
  <item><p>The declaration matches <nt def='NT-Mixed'>Mixed</nt> and 
  the content consists of <termref def='dt-chardata'>character 
  data</termref> and <termref def='dt-parentchild'>child elements</termref>
  whose types match names in the content model.</p></item>
  <item><p>The declaration matches <kw>ANY</kw>, and the types
  of any <termref def='dt-parentchild'>child elements</termref> have
  been declared.</p></item>
  </olist>
  </vcnote>
  
  <div2 id='sec-starttags'>
  <head>Start-Tags, End-Tags, and Empty-Element Tags</head>
   
  <p><termdef id="dt-stag" term="Start-Tag">The beginning of every
  non-empty XML element is marked by a <term>start-tag</term>.
  <scrap lang='ebnf'>
  <head>Start-tag</head>
  <prodgroup pcw2="6" pcw4="15" pcw5="11.5">
  <prod id='NT-STag'><lhs>STag</lhs>
  <rhs>'&lt;' <nt def='NT-Name'>Name</nt> 
  (<nt def='NT-S'>S</nt> <nt def='NT-Attribute'>Attribute</nt>)* 
  <nt def='NT-S'>S</nt>? '>'</rhs>
  <wfc def="uniqattspec"/>
  </prod>
  <prod id='NT-Attribute'><lhs>Attribute</lhs>
  <rhs><nt def='NT-Name'>Name</nt> <nt def='NT-Eq'>Eq</nt> 
  <nt def='NT-AttValue'>AttValue</nt></rhs>
  <vc def='ValueType'/>
  <wfc def='NoExternalRefs'/>
  <wfc def='CleanAttrVals'/></prod>
  </prodgroup>
  </scrap>
  The <nt def='NT-Name'>Name</nt> in
  the start- and end-tags gives the 
  element's <term>type</term>.</termdef>
  <termdef id="dt-attr" term="Attribute">
  The <nt def='NT-Name'>Name</nt>-<nt def='NT-AttValue'>AttValue</nt> pairs are
  referred to as 
  the <term>attribute specifications</term> of the element</termdef>,
  <termdef id="dt-attrname" term="Attribute Name">with the 
  <nt def='NT-Name'>Name</nt> in each pair
  referred to as the <term>attribute name</term></termdef> and
  <termdef id="dt-attrval" term="Attribute Value">the content of the
  <nt def='NT-AttValue'>AttValue</nt> (the text between the
  <code>'</code> or <code>"</code> delimiters)
  as the <term>attribute value</term>.</termdef>
  </p>
  <wfcnote id='uniqattspec'>
  <head>Unique Att Spec</head>
  <p>
  No attribute name may appear more than once in the same start-tag
  or empty-element tag.
  </p>
  </wfcnote>
  <vcnote id='ValueType'>
  <head>Attribute Value Type</head>
  <p>
  The attribute must have been declared; the value must be of the type 
  declared for it.
  (For attribute types, see <specref ref='attdecls'/>.)
  </p>
  </vcnote>
  <wfcnote id='NoExternalRefs'>
  <head>No External Entity References</head>
  <p>
  Attribute values cannot contain direct or indirect entity references 
  to external entities.
  </p>
  </wfcnote>
  <wfcnote id='CleanAttrVals'>
  <head>No <code>&lt;</code> in Attribute Values</head>
  <p>The <termref def='dt-repltext'>replacement text</termref> 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></wfcnote>
  <p>An example of a start-tag:
  <eg>&lt;termdef id="dt-dog" term="dog"></eg></p>
  <p><termdef id="dt-etag" term="End Tag">The end of every element 
  that begins with a start-tag must
  be marked by an <term>end-tag</term>
  containing a name that echoes the element's type as given in the
  start-tag:
  <scrap lang='ebnf'>
  <head>End-tag</head>
  <prodgroup pcw2="6" pcw4="15" pcw5="11.5">
  <prod id='NT-ETag'><lhs>ETag</lhs>
  <rhs>'&lt;/' <nt def='NT-Name'>Name</nt> 
  <nt def='NT-S'>S</nt>? '>'</rhs></prod>
  </prodgroup>
  </scrap>
  </termdef></p>
  <p>An example of an end-tag:<eg>&lt;/termdef></eg></p>
  <p><termdef id="dt-content" term="Content">The 
  <termref def='dt-text'>text</termref> between the start-tag and
  end-tag is called the element's
  <term>content</term>:
  <scrap lang='ebnf'>
  <head>Content of Elements</head>
  <prodgroup pcw2="6" pcw4="15" pcw5="11.5">
  <prod id='NT-content'><lhs>content</lhs>
  <rhs>(<nt def='NT-element'>element</nt> | <nt def='NT-CharData'>CharData</nt> 
  | <nt def='NT-Reference'>Reference</nt> | <nt def='NT-CDSect'>CDSect</nt> 
  | <nt def='NT-PI'>PI</nt> | <nt def='NT-Comment'>Comment</nt>)*</rhs>
  </prod>
  </prodgroup>
  </scrap>
  </termdef></p>
  <p><termdef id="dt-empty" term="Empty">If an element is <term>empty</term>,
  it must be represented either by a start-tag immediately followed
  by an end-tag or by an empty-element tag.</termdef>
  <termdef id="dt-eetag" term="empty-element tag">An 
  <term>empty-element tag</term> takes a special form:
  <scrap lang='ebnf'>
  <head>Tags for Empty Elements</head>
  <prodgroup pcw2="6" pcw4="15" pcw5="11.5">
  <prod id='NT-EmptyElemTag'><lhs>EmptyElemTag</lhs>
  <rhs>'&lt;' <nt def='NT-Name'>Name</nt> (<nt def='NT-S'>S</nt> 
  <nt def='NT-Attribute'>Attribute</nt>)* <nt def='NT-S'>S</nt>? 
  '/&gt;'</rhs>
  <wfc def="uniqattspec"/>
  </prod>
  </prodgroup>
  </scrap>
  </termdef></p>
  <p>Empty-element tags may be used for any element which has no
  content, whether or not it is declared using the keyword
  <kw>EMPTY</kw>.
  <termref def='dt-interop'>For interoperability</termref>, the empty-element
  tag must be used, and can only be used, for elements which are
  <termref def='dt-eldecl'>declared</termref> <kw>EMPTY</kw>.</p>
  <p>Examples of empty elements:
  <eg>&lt;IMG align="left"
   src="http://www.w3.org/Icons/WWW/w3c_home" />
  &lt;br>&lt;/br>
  &lt;br/></eg></p>
  </div2>
   
  <div2 id='elemdecls'>
  <head>Element Type Declarations</head>
   
  <p>The <termref def="dt-element">element</termref> structure of an
  <termref def="dt-xml-doc">XML document</termref> may, for 
  <termref def="dt-valid">validation</termref> purposes, 
  be constrained
  using element type and attribute-list declarations.
  An element type declaration constrains the element's
  <termref def="dt-content">content</termref>.
  </p>
  
  <p>Element type declarations often constrain which element types can
  appear as <termref def="dt-parentchild">children</termref> 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><termdef id="dt-eldecl" term="Element Type declaration">An <term>element
  type declaration</term> takes the form:
  <scrap lang='ebnf'>
  <head>Element Type Declaration</head>
  <prodgroup pcw2="5.5" pcw4="18" pcw5="9">
  <prod id='NT-elementdecl'><lhs>elementdecl</lhs>
  <rhs>'&lt;!ELEMENT' <nt def='NT-S'>S</nt> 
  <nt def='NT-Name'>Name</nt> 
  <nt def='NT-S'>S</nt> 
  <nt def='NT-contentspec'>contentspec</nt>
  <nt def='NT-S'>S</nt>? '>'</rhs>
  <vc def='EDUnique'/></prod>
  <prod id='NT-contentspec'><lhs>contentspec</lhs>
  <rhs>'EMPTY' 
  | 'ANY' 
  | <nt def='NT-Mixed'>Mixed</nt> 
  | <nt def='NT-children'>children</nt>
  </rhs>
  </prod>
  </prodgroup>
  </scrap>
  where the <nt def='NT-Name'>Name</nt> gives the element type 
  being declared.</termdef>
  </p>
  
  <vcnote id='EDUnique'>
  <head>Unique Element Type Declaration</head>
  <p>
  No element type may be declared more than once.
  </p>
  </vcnote>
  
  <p>Examples of element type declarations:
  <eg>&lt;!ELEMENT br EMPTY>
  &lt;!ELEMENT p (#PCDATA|emph)* >
  &lt;!ELEMENT %name.para; %content.para; >
  &lt;!ELEMENT container ANY></eg></p>
   
  <div3 id='sec-element-content'>
  <head>Element Content</head>
   
  <p><termdef id='dt-elemcontent' term='Element content'>An element <termref
  def="dt-stag">type</termref> has
  <term>element content</term> when elements of that
  type must contain only <termref def='dt-parentchild'>child</termref> 
  elements (no character data), optionally separated by 
  white space (characters matching the nonterminal 
  <nt def='NT-S'>S</nt>).
  </termdef>
  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 (<nt def='NT-cp'>cp</nt>s), which consist of names, 
  choice lists of content particles, or
  sequence lists of content particles:
  <scrap lang='ebnf'>
  <head>Element-content Models</head>
  <prodgroup pcw2="5.5" pcw4="16" pcw5="11">
  <prod id='NT-children'><lhs>children</lhs>
  <rhs>(<nt def='NT-choice'>choice</nt> 
  | <nt def='NT-seq'>seq</nt>) 
  ('?' | '*' | '+')?</rhs></prod>
  <prod id='NT-cp'><lhs>cp</lhs>
  <rhs>(<nt def='NT-Name'>Name</nt> 
  | <nt def='NT-choice'>choice</nt> 
  | <nt def='NT-seq'>seq</nt>) 
  ('?' | '*' | '+')?</rhs></prod>
  <prod id='NT-choice'><lhs>choice</lhs>
  <rhs>'(' <nt def='NT-S'>S</nt>? cp 
  ( <nt def='NT-S'>S</nt>? '|' <nt def='NT-S'>S</nt>? <nt def='NT-cp'>cp</nt> )*
  <nt def='NT-S'>S</nt>? ')'</rhs>
  <vc def='vc-PEinGroup'/></prod>
  <prod id='NT-seq'><lhs>seq</lhs>
  <rhs>'(' <nt def='NT-S'>S</nt>? cp 
  ( <nt def='NT-S'>S</nt>? ',' <nt def='NT-S'>S</nt>? <nt def='NT-cp'>cp</nt> )*
  <nt def='NT-S'>S</nt>? ')'</rhs>
  <vc def='vc-PEinGroup'/></prod>
  
  </prodgroup>
  </scrap>
  where each <nt def='NT-Name'>Name</nt> is the type of an element which may
  appear as a <termref def="dt-parentchild">child</termref>.  
  Any content
  particle in a choice list may appear in the <termref
  def="dt-elemcontent">element content</termref> at the location where
  the choice list appears in the grammar;
  content particles occurring in a sequence list must each
  appear in the <termref def="dt-elemcontent">element content</termref> 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.  <termref
  def='dt-compat'>For compatibility</termref>, 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 <specref ref="determinism"/>.
  <!-- appendix <specref ref="determinism"/>. -->
  <!-- appendix on deterministic content models. -->
  </p>
  <vcnote id='vc-PEinGroup'>
  <head>Proper Group/PE Nesting</head>
  <p>Parameter-entity 
  <termref def='dt-repltext'>replacement text</termref> must be properly nested
  with parenthetized groups.
  That is to say, if either of the opening or closing parentheses
  in a <nt def='NT-choice'>choice</nt>, <nt def='NT-seq'>seq</nt>, or
  <nt def='NT-Mixed'>Mixed</nt> construct 
  is contained in the replacement text for a 
  <termref def='dt-PERef'>parameter entity</termref>,
  both must be contained in the same replacement text.</p>
  <p><termref def='dt-interop'>For interoperability</termref>, 
  if a parameter-entity reference appears in a 
  <nt def='NT-choice'>choice</nt>, <nt def='NT-seq'>seq</nt>, or
  <nt def='NT-Mixed'>Mixed</nt> 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>
  </vcnote>
  <p>Examples of element-content models:
  <eg>&lt;!ELEMENT spec (front, body, back?)>
  &lt;!ELEMENT div1 (head, (p | list | note)*, div2*)>
  &lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*></eg></p>
  </div3>
  
  <div3 id='sec-mixed-content'>
  <head>Mixed Content</head>
   
  <p><termdef id='dt-mixed' term='Mixed Content'>An element 
  <termref def='dt-stag'>type</termref> has 
  <term>mixed content</term> when elements of that type may contain
  character data, optionally interspersed with
  <termref def="dt-parentchild">child</termref> elements.</termdef>
  In this case, the types of the child elements
  may be constrained, but not their order or their number of occurrences:
  <scrap lang='ebnf'>
  <head>Mixed-content Declaration</head>
  <prodgroup pcw2="5.5" pcw4="16" pcw5="11">
  <prod id='NT-Mixed'><lhs>Mixed</lhs>
  <rhs>'(' <nt def='NT-S'>S</nt>? 
  '#PCDATA'
  (<nt def='NT-S'>S</nt>? 
  '|' 
  <nt def='NT-S'>S</nt>? 
  <nt def='NT-Name'>Name</nt>)* 
  <nt def='NT-S'>S</nt>? 
  ')*' </rhs>
  <rhs>| '(' <nt def='NT-S'>S</nt>? '#PCDATA' <nt def='NT-S'>S</nt>? ')'
  </rhs><vc def='vc-PEinGroup'/>
  <vc def='vc-MixedChildrenUnique'/>
  </prod>
  
  </prodgroup>
  </scrap>
  where the <nt def='NT-Name'>Name</nt>s give the types of elements
  that may appear as children.
  </p>
  <vcnote id='vc-MixedChildrenUnique'>
  <head>No Duplicate Types</head>
  <p>The same name must not appear more than once in a single mixed-content
  declaration.
  </p></vcnote>
  <p>Examples of mixed content declarations:
  <eg>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*>
  &lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >
  &lt;!ELEMENT b (#PCDATA)></eg></p>
  </div3>
  </div2>
   
  <div2 id='attdecls'>
  <head>Attribute-List Declarations</head>
   
  <p><termref def="dt-attr">Attributes</termref> are used to associate
  name-value pairs with <termref def="dt-element">elements</termref>.
  Attribute specifications may appear only within <termref
  def="dt-stag">start-tags</termref>
  and <termref def="dt-eetag">empty-element tags</termref>; 
  thus, the productions used to
  recognize them appear in <specref ref='sec-starttags'/>.  
  Attribute-list
  declarations may be used:
  <ulist>
  <item><p>To define the set of attributes pertaining to a given
  element type.</p></item>
  <item><p>To establish type constraints for these
  attributes.</p></item>
  <item><p>To provide <termref def="dt-default">default values</termref>
  for attributes.</p></item>
  </ulist>
  </p>
  <p><termdef id="dt-attdecl" term="Attribute-List Declaration">
  <term>Attribute-list declarations</term> specify the name, data type, and default
  value (if any) of each attribute associated with a given element type:
  <scrap lang='ebnf'>
  <head>Attribute-list Declaration</head>
  <prod id='NT-AttlistDecl'><lhs>AttlistDecl</lhs>
  <rhs>'&lt;!ATTLIST' <nt def='NT-S'>S</nt> 
  <nt def='NT-Name'>Name</nt> 
  <nt def='NT-AttDef'>AttDef</nt>*
  <nt def='NT-S'>S</nt>? '&gt;'</rhs>
  </prod>
  <prod id='NT-AttDef'><lhs>AttDef</lhs>
  <rhs><nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt> 
  <nt def='NT-S'>S</nt> <nt def='NT-AttType'>AttType</nt> 
  <nt def='NT-S'>S</nt> <nt def='NT-DefaultDecl'>DefaultDecl</nt></rhs>
  </prod>
  </scrap>
  The <nt def="NT-Name">Name</nt> in the
  <nt def='NT-AttlistDecl'>AttlistDecl</nt> 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 <nt def='NT-Name'>Name</nt> in the 
  <nt def='NT-AttDef'>AttDef</nt> rule is
  the name of the attribute.</termdef></p>
  <p>
  When more than one <nt def='NT-AttlistDecl'>AttlistDecl</nt> 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.  
  <termref def='dt-interop'>For interoperability,</termref> 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>
  
  <div3 id='sec-attribute-types'>
  <head>Attribute Types</head>
   
  <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:
  <scrap lang='ebnf'>
  <head>Attribute Types</head>
  <prodgroup pcw4="14" pcw5="11.5">
  <prod id='NT-AttType'><lhs>AttType</lhs>
  <rhs><nt def='NT-StringType'>StringType</nt> 
  | <nt def='NT-TokenizedType'>TokenizedType</nt> 
  | <nt def='NT-EnumeratedType'>EnumeratedType</nt>
  </rhs>
  </prod>
  <prod id='NT-StringType'><lhs>StringType</lhs>
  <rhs>'CDATA'</rhs>
  </prod>
  <prod id='NT-TokenizedType'><lhs>TokenizedType</lhs>
  <rhs>'ID'</rhs>
  <vc def='id'/>
  <vc def='one-id-per-el'/>
  <vc def='id-default'/>
  <rhs>| 'IDREF'</rhs>
  <vc def='idref'/>
  <rhs>| 'IDREFS'</rhs>
  <vc def='idref'/>
  <rhs>| 'ENTITY'</rhs>
  <vc def='entname'/>
  <rhs>| 'ENTITIES'</rhs>
  <vc def='entname'/>
  <rhs>| 'NMTOKEN'</rhs>
  <vc def='nmtok'/>
  <rhs>| 'NMTOKENS'</rhs>
  <vc def='nmtok'/></prod>
  </prodgroup>
  </scrap>
  </p>
  <vcnote id='id' >
  <head>ID</head>
  <p>
  Values of type <kw>ID</kw> must match the 
  <nt def='NT-Name'>Name</nt> 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>
  </vcnote>
  <vcnote id='one-id-per-el'>
  <head>One ID per Element Type</head>
  <p>No element type may have more than one ID attribute specified.</p>
  </vcnote>
  <vcnote id='id-default'>
  <head>ID Attribute Default</head>
  <p>An ID attribute must have a declared default of <kw>#IMPLIED</kw> or
  <kw>#REQUIRED</kw>.</p>
  </vcnote>
  <vcnote id='idref'>
  <head>IDREF</head>
  <p>
  Values of type <kw>IDREF</kw> must match
  the <nt def="NT-Name">Name</nt> production, and
  values of type <kw>IDREFS</kw> must match
  <nt def="NT-Names">Names</nt>; 
  each <nt def='NT-Name'>Name</nt> must match the value of an ID attribute on 
  some element in the XML document; i.e. <kw>IDREF</kw> values must 
  match the value of some ID attribute. 
  </p>
  </vcnote>
  <vcnote id='entname'>
  <head>Entity Name</head>
  <p>
  Values of type <kw>ENTITY</kw> 
  must match the <nt def="NT-Name">Name</nt> production,
  values of type <kw>ENTITIES</kw> must match
  <nt def="NT-Names">Names</nt>;
  each <nt def="NT-Name">Name</nt> must 
  match the
  name of an <termref def="dt-unparsed">unparsed entity</termref> declared in the
  <termref def="dt-doctype">DTD</termref>.
  </p>
  </vcnote>
  <vcnote id='nmtok'>
  <head>Name Token</head>
  <p>
  Values of type <kw>NMTOKEN</kw> must match the
  <nt def="NT-Nmtoken">Nmtoken</nt> production;
  values of type <kw>NMTOKENS</kw> must 
  match <termref def="NT-Nmtokens">Nmtokens</termref>.
  </p>
  </vcnote>
  <!-- why?
  <p>The XML processor must normalize attribute values before
  passing them to the application, as described in 
  <specref ref="AVNormalize"/>.</p>-->
  <p><termdef id='dt-enumerated' term='Enumerated Attribute
  Values'><term>Enumerated attributes</term> can take one 
  of a list of values provided in the declaration</termdef>. There are two
  kinds of enumerated types:
  <scrap lang='ebnf'>
  <head>Enumerated Attribute Types</head>
  <prod id='NT-EnumeratedType'><lhs>EnumeratedType</lhs> 
  <rhs><nt def='NT-NotationType'>NotationType</nt> 
  | <nt def='NT-Enumeration'>Enumeration</nt>
  </rhs></prod>
  <prod id='NT-NotationType'><lhs>NotationType</lhs> 
  <rhs>'NOTATION' 
  <nt def='NT-S'>S</nt> 
  '(' 
  <nt def='NT-S'>S</nt>?  
  <nt def='NT-Name'>Name</nt> 
  (<nt def='NT-S'>S</nt>? '|' <nt def='NT-S'>S</nt>?  
  <nt def='NT-Name'>Name</nt>)*
  <nt def='NT-S'>S</nt>? ')'
  </rhs>
  <vc def='notatn' /></prod>
  <prod id='NT-Enumeration'><lhs>Enumeration</lhs> 
  <rhs>'(' <nt def='NT-S'>S</nt>?
  <nt def='NT-Nmtoken'>Nmtoken</nt> 
  (<nt def='NT-S'>S</nt>? '|' 
  <nt def='NT-S'>S</nt>?  
  <nt def='NT-Nmtoken'>Nmtoken</nt>)* 
  <nt def='NT-S'>S</nt>? 
  ')'</rhs> 
  <vc def='enum'/></prod>
  </scrap>
  A <kw>NOTATION</kw> attribute identifies a 
  <termref def='dt-notation'>notation</termref>, 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>
  
  <vcnote id='notatn'>
  <head>Notation Attributes</head>
  <p>
  Values of this type must match
  one of the <titleref href='Notations'>notation</titleref> names included in
  the declaration; all notation names in the declaration must
  be declared.
  </p>
  </vcnote>
  <vcnote id='enum'>
  <head>Enumeration</head>
  <p>
  Values of this type
  must match one of the <nt def='NT-Nmtoken'>Nmtoken</nt> tokens in the
  declaration. 
  </p>
  </vcnote>
  <p><termref def='dt-interop'>For interoperability,</termref> the same
  <nt def='NT-Nmtoken'>Nmtoken</nt> should not occur more than once in the
  enumerated attribute types of a single element type.
  </p>
  </div3>
  
  <div3 id='sec-attr-defaults'>
  <head>Attribute Defaults</head>
   
  <p>An <termref def="dt-attdecl">attribute declaration</termref> 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.
  <scrap lang='ebnf'>
  <head>Attribute Defaults</head>
  <prodgroup pcw4="14" pcw5="11.5">
  <prod id='NT-DefaultDecl'><lhs>DefaultDecl</lhs>
  <rhs>'#REQUIRED' 
  |&nbsp;'#IMPLIED' </rhs>
  <rhs>| (('#FIXED' S)? <nt def='NT-AttValue'>AttValue</nt>)</rhs>
  <vc def='RequiredAttr'/>
  <vc def='defattrvalid'/>
  <wfc def="CleanAttrVals"/>
  <vc def='FixedAttr'/>
  </prod>
  </prodgroup>
  </scrap>
  
  </p>
  <p>In an attribute declaration, <kw>#REQUIRED</kw> means that the
  attribute must always be provided, <kw>#IMPLIED</kw> that no default 
  value is provided.
  <!-- not any more!!
  <kw>#IMPLIED</kw> means that if the attribute is omitted
  from an element of this type,
  the XML processor must inform the application
  that no value was specified; no constraint is placed on the behavior
  of the application. -->
  <termdef id="dt-default" term="Attribute Default">If the 
  declaration
  is neither <kw>#REQUIRED</kw> nor <kw>#IMPLIED</kw>, then the
  <nt def='NT-AttValue'>AttValue</nt> value contains the declared
  <term>default</term> value; the <kw>#FIXED</kw> 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.</termdef></p>
  <vcnote id='RequiredAttr'>
  <head>Required Attribute</head>
  <p>If the default declaration is the keyword <kw>#REQUIRED</kw>, then
  the attribute must be specified for
  all elements of the type in the attribute-list declaration.
  </p></vcnote>
  <vcnote id='defattrvalid'>
  <head>Attribute Default Legal</head>
  <p>
  The declared
  default value must meet the lexical constraints of the declared attribute type.
  </p>
  </vcnote>
  <vcnote id='FixedAttr'>
  <head>Fixed Attribute Default</head>
  <p>If an attribute has a default value declared with the 
  <kw>#FIXED</kw> keyword, instances of that attribute must
  match the default value.
  </p></vcnote>
  
  <p>Examples of attribute-list declarations:
  <eg>&lt;!ATTLIST termdef
            id      ID      #REQUIRED
            name    CDATA   #IMPLIED>
  &lt;!ATTLIST list
            type    (bullets|ordered|glossary)  "ordered">
  &lt;!ATTLIST form
            method  CDATA   #FIXED "POST"></eg></p>
  </div3>
  <div3 id='AVNormalize'>
  <head>Attribute-Value Normalization</head>
  <p>Before the value of an attribute is passed to the application
  or checked for validity, the
  XML processor must normalize it as follows:
  <ulist>
  <item><p>a character reference is processed by appending the referenced    
  character to the attribute value</p></item>
  <item><p>an entity reference is processed by recursively processing the
  replacement text of the entity</p></item>
  <item><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></item>
  <item><p>other characters are processed by appending them to the normalized
  value</p>
  </item></ulist>
  </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
  <kw>CDATA</kw>.
  </p>
  </div3>
  </div2>
  <div2 id='sec-condition-sect'>
  <head>Conditional Sections</head>
  <p><termdef id='dt-cond-section' term='conditional section'>
  <term>Conditional sections</term> are portions of the
  <termref def='dt-doctype'>document type declaration external subset</termref>
  which are 
  included in, or excluded from, the logical structure of the DTD based on
  the keyword which governs them.</termdef>
  <scrap lang='ebnf'>
  <head>Conditional Section</head>
  <prodgroup pcw2="9" pcw4="14.5">
  <prod id='NT-conditionalSect'><lhs>conditionalSect</lhs>
  <rhs><nt def='NT-includeSect'>includeSect</nt>
  | <nt def='NT-ignoreSect'>ignoreSect</nt>
  </rhs>
  </prod>
  <prod id='NT-includeSect'><lhs>includeSect</lhs>
  <rhs>'&lt;![' S? 'INCLUDE' S? '[' 
  
  <nt def="NT-extSubsetDecl">extSubsetDecl</nt>
  ']]&gt;'
  </rhs>
  </prod>
  <prod id='NT-ignoreSect'><lhs>ignoreSect</lhs>
  <rhs>'&lt;![' S? 'IGNORE' S? '[' 
  <nt def="NT-ignoreSectContents">ignoreSectContents</nt>*
  ']]&gt;'</rhs>
  </prod>
  
  <prod id='NT-ignoreSectContents'><lhs>ignoreSectContents</lhs>
  <rhs><nt def='NT-Ignore'>Ignore</nt>
  ('&lt;![' <nt def='NT-ignoreSectContents'>ignoreSectContents</nt> ']]&gt;' 
  <nt def='NT-Ignore'>Ignore</nt>)*</rhs></prod>
  <prod id='NT-Ignore'><lhs>Ignore</lhs>
  <rhs><nt def='NT-Char'>Char</nt>* - 
  (<nt def='NT-Char'>Char</nt>* ('&lt;![' | ']]&gt;') 
  <nt def='NT-Char'>Char</nt>*)
  </rhs></prod>
  
  </prodgroup>
  </scrap>
  </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 <kw>INCLUDE</kw>, then the contents of the conditional
  section are part of the DTD.
  If the keyword of the conditional
  section is <kw>IGNORE</kw>, 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 <kw>INCLUDE</kw> occurs within a larger conditional
  section with a keyword of <kw>IGNORE</kw>, 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:
  <eg>&lt;!ENTITY % draft 'INCLUDE' >
  &lt;!ENTITY % final 'IGNORE' >
   
  &lt;![%draft;[
  &lt;!ELEMENT book (comments*, title, body, supplements?)>
  ]]&gt;
  &lt;![%final;[
  &lt;!ELEMENT book (title, body, supplements?)>
  ]]&gt;
  </eg>
  </p>
  </div2>
  
  
  <!-- 
  <div2 id='sec-pass-to-app'>
  <head>XML Processor Treatment of Logical Structure</head>
  <p>When an XML processor encounters a start-tag, it must make
  at least the following information available to the application:
  <ulist>
  <item>
  <p>the element type's generic identifier</p>
  </item>
  <item>
  <p>the names of attributes known to apply to this element type
  (validating processors must make available names of all attributes
  declared for the element type; non-validating processors must
  make available at least the names of the attributes for which
  values are specified.
  </p>
  </item>
  </ulist>
  </p>
  </div2>
  --> 
  
  </div1>
  <!-- &Entities; -->
   
  <div1 id='sec-physical-struct'>
  <head>Physical Structures</head>
   
  <p><termdef id="dt-entity" term="Entity">An XML document may consist
  of one or many storage units.   These are called
  <term>entities</term>; they all have <term>content</term> and are all
  (except for the document entity, see below, and 
  the <termref def='dt-doctype'>external DTD subset</termref>) 
  identified by <term>name</term>.
  </termdef>
  Each XML document has one entity
  called the <termref def="dt-docent">document entity</termref>, which serves
  as the starting point for the <termref def="dt-xml-proc">XML
  processor</termref> and may contain the whole document.</p>
  <p>Entities may be either parsed or unparsed.
  <termdef id="dt-parsedent" term="Text Entity">A <term>parsed entity's</term>
  contents are referred to as its 
  <termref def='dt-repltext'>replacement text</termref>;
  this <termref def="dt-text">text</termref> is considered an
  integral part of the document.</termdef></p>
  
  <p><termdef id="dt-unparsed" term="Unparsed Entity">An 
  <term>unparsed entity</term> 
  is a resource whose contents may or may not be
  <termref def='dt-text'>text</termref>, and if text, may not be XML.
  Each unparsed entity
  has an associated <termref
  def="dt-notation">notation</termref>, 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.</termdef> 
  </p>
  <p>
  Parsed entities are invoked by name using entity references;
  unparsed entities by name, given in the value of <kw>ENTITY</kw>
  or <kw>ENTITIES</kw>
  attributes.</p>
  <p><termdef id='gen-entity' term='general entity'
  ><term>General entities</term>
  are entities for use within the document content.
  In this specification, general entities are sometimes referred 
  to with the unqualified term <emph>entity</emph> when this leads
  to no ambiguity.</termdef> 
  <termdef id='dt-PE' term='Parameter entity'>Parameter entities 
  are parsed entities for use within the DTD.</termdef>
  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>
  
  <div2 id='sec-references'>
  <head>Character and Entity References</head>
  <p><termdef id="dt-charref" term="Character Reference">
  A <term>character reference</term> refers to a specific character in the
  ISO/IEC 10646 character set, for example one not directly accessible from
  available input devices.
  <scrap lang='ebnf'>
  <head>Character Reference</head>
  <prod id='NT-CharRef'><lhs>CharRef</lhs>
  <rhs>'&amp;#' [0-9]+ ';' </rhs>
  <rhs>| '&hcro;' [0-9a-fA-F]+ ';'</rhs>
  <wfc def="wf-Legalchar"/>
  </prod>
  </scrap>
  <wfcnote id="wf-Legalchar">
  <head>Legal Character</head>
  <p>Characters referred to using character references must
  match the production for
  <termref def="NT-Char">Char</termref>.</p>
  </wfcnote>
  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.
  </termdef>
  </p>
  <p><termdef id="dt-entref" term="Entity Reference">An <term>entity
  reference</term> refers to the content of a named entity.</termdef>
  <termdef id='dt-GERef' term='General Entity Reference'>References to 
  parsed general entities
  use ampersand (<code>&amp;</code>) and semicolon (<code>;</code>) as
  delimiters.</termdef>
  <termdef id='dt-PERef' term='Parameter-entity reference'>
  <term>Parameter-entity references</term> use percent-sign (<code>%</code>) and
  semicolon 
  (<code>;</code>) as delimiters.</termdef>
  </p>
  <scrap lang="ebnf">
  <head>Entity Reference</head>
  <prod id='NT-Reference'><lhs>Reference</lhs>
  <rhs><nt def='NT-EntityRef'>EntityRef</nt> 
  | <nt def='NT-CharRef'>CharRef</nt></rhs></prod>
  <prod id='NT-EntityRef'><lhs>EntityRef</lhs>
  <rhs>'&amp;' <nt def='NT-Name'>Name</nt> ';'</rhs>
  <wfc def='wf-entdeclared'/>
  <vc def='vc-entdeclared'/>
  <wfc def='textent'/>
  <wfc def='norecursion'/>
  </prod>
  <prod id='NT-PEReference'><lhs>PEReference</lhs>
  <rhs>'%' <nt def='NT-Name'>Name</nt> ';'</rhs>
  <vc def='vc-entdeclared'/>
  <wfc def='norecursion'/>
  <wfc def='indtd'/>
  </prod>
  </scrap>
  
  <wfcnote id='wf-entdeclared'>
  <head>Entity Declared</head>
  <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 <nt def='NT-Name'>Name</nt> given in the entity reference must 
  <termref def="dt-match">match</termref> that in an 
  <titleref href='sec-entity-decl'>entity declaration</titleref>, except that
  well-formed documents need not declare 
  any of the following entities: &magicents;.  
  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 
  <titleref href='include-if-valid'>not obligated to</titleref> read
  and process their declarations; for such documents, the rule that
  an entity must be declared is a well-formedness constraint only
  if <titleref href='sec-rmd'>standalone='yes'</titleref>.</p>
  </wfcnote>
  <vcnote id="vc-entdeclared">
  <head>Entity Declared</head>
  <p>In a document with an external subset or external parameter
  entities with "<code>standalone='no'</code>",
  the <nt def='NT-Name'>Name</nt> given in the entity reference must <termref
  def="dt-match">match</termref> that in an 
  <titleref href='sec-entity-decl'>entity declaration</titleref>.
  For interoperability, valid documents should declare the entities 
  &magicents;, in the form
  specified in <specref ref="sec-predefined-ent"/>.
  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>
  </vcnote>
  <!-- FINAL EDIT:  is this duplication too clumsy? -->
  <wfcnote id='textent'>
  <head>Parsed Entity</head>
  <p>
  An entity reference must not contain the name of an <termref
  def="dt-unparsed">unparsed entity</termref>. Unparsed entities may be referred
  to only in <termref def="dt-attrval">attribute values</termref> declared to
  be of type <kw>ENTITY</kw> or <kw>ENTITIES</kw>.
  </p>
  </wfcnote>
  <wfcnote id='norecursion'>
  <head>No Recursion</head>
  <p>
  A parsed entity must not contain a recursive reference to itself,
  either directly or indirectly.
  </p>
  </wfcnote>
  <wfcnote id='indtd'>
  <head>In DTD</head>
  <p>
  Parameter-entity references may only appear in the 
  <termref def='dt-doctype'>DTD</termref>.
  </p>
  </wfcnote>
  <p>Examples of character and entity references:
  <eg>Type &lt;key>less-than&lt;/key> (&hcro;3C;) to save options.
  This document was prepared on &amp;docdate; and
  is classified &amp;security-level;.</eg></p>
  <p>Example of a parameter-entity reference:
  <eg><![CDATA[<!-- declare the parameter entity "ISOLat2"... -->
  <!ENTITY % ISOLat2
           SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
  <!-- ... now reference it. -->
  %ISOLat2;]]></eg></p>
  </div2>
   
  <div2 id='sec-entity-decl'>
  <head>Entity Declarations</head>
   
  <p><termdef id="dt-entdecl" term="entity declaration">
  Entities are declared thus:
  <scrap lang='ebnf'>
  <head>Entity Declaration</head>
  <prodgroup pcw2="5" pcw4="18.5">
  <prod id='NT-EntityDecl'><lhs>EntityDecl</lhs>
  <rhs><nt def="NT-GEDecl">GEDecl</nt><!--</rhs><com>General entities</com>
  <rhs>--> | <nt def="NT-PEDecl">PEDecl</nt></rhs>
  <!--<com>Parameter entities</com>-->
  </prod>
  <prod id='NT-GEDecl'><lhs>GEDecl</lhs>
  <rhs>'&lt;!ENTITY' <nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt> 
  <nt def='NT-S'>S</nt> <nt def='NT-EntityDef'>EntityDef</nt> 
  <nt def='NT-S'>S</nt>? '&gt;'</rhs>
  </prod>
  <prod id='NT-PEDecl'><lhs>PEDecl</lhs>
  <rhs>'&lt;!ENTITY' <nt def='NT-S'>S</nt> '%' <nt def='NT-S'>S</nt> 
  <nt def='NT-Name'>Name</nt> <nt def='NT-S'>S</nt> 
  <nt def='NT-PEDef'>PEDef</nt> <nt def='NT-S'>S</nt>? '&gt;'</rhs>
  <!--<com>Parameter entities</com>-->
  </prod>
  <prod id='NT-EntityDef'><lhs>EntityDef</lhs>
  <rhs><nt def='NT-EntityValue'>EntityValue</nt>
  <!--</rhs>
  <rhs>-->| (<nt def='NT-ExternalID'>ExternalID</nt> 
  <nt def='NT-NDataDecl'>NDataDecl</nt>?)</rhs>
  <!-- <nt def='NT-ExternalDef'>ExternalDef</nt></rhs> -->
  </prod>
  <!-- FINAL EDIT: what happened to WFs here? -->
  <prod id='NT-PEDef'><lhs>PEDef</lhs>
  <rhs><nt def='NT-EntityValue'>EntityValue</nt> 
  | <nt def='NT-ExternalID'>ExternalID</nt></rhs></prod>
  </prodgroup>
  </scrap>
  The <nt def='NT-Name'>Name</nt> identifies the entity in an
  <termref def="dt-entref">entity reference</termref> or, in the case of an
  unparsed entity, in the value of an <kw>ENTITY</kw> or <kw>ENTITIES</kw>
  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.</termdef>
  </p>
  
  <div3 id='sec-internal-ent'>
  <head>Internal Entities</head>
   
  <p><termdef id='dt-internent' term="Internal Entity Replacement Text">If 
  the entity definition is an 
  <nt def='NT-EntityValue'>EntityValue</nt>,  
  the defined entity is called an <term>internal entity</term>.  
  There is no separate physical
  storage object, and the content of the entity is given in the
  declaration. </termdef>
  Note that some processing of entity and character references in the
  <termref def='dt-litentval'>literal entity value</termref> may be required to
  produce the correct <termref def='dt-repltext'>replacement 
  text</termref>: see <specref ref='intern-replacement'/>.
  </p>
  <p>An internal entity is a <termref def="dt-parsedent">parsed
  entity</termref>.</p>
  <p>Example of an internal entity declaration:
  <eg>&lt;!ENTITY Pub-Status "This is a pre-release of the
   specification."></eg></p>
  </div3>
   
  <div3 id='sec-external-ent'>
  <head>External Entities</head>
   
  <p><termdef id="dt-extent" term="External Entity">If the entity is not
  internal, it is an <term>external
  entity</term>, declared as follows:
  <scrap lang='ebnf'>
  <head>External Entity Declaration</head>
  <!--
  <prod id='NT-ExternalDef'><lhs>ExternalDef</lhs>
  <rhs></prod> -->
  <prod id='NT-ExternalID'><lhs>ExternalID</lhs>
  <rhs>'SYSTEM' <nt def='NT-S'>S</nt> 
  <nt def='NT-SystemLiteral'>SystemLiteral</nt></rhs>
  <rhs>| 'PUBLIC' <nt def='NT-S'>S</nt> 
  <nt def='NT-PubidLiteral'>PubidLiteral</nt> 
  <nt def='NT-S'>S</nt> 
  <nt def='NT-SystemLiteral'>SystemLiteral</nt>
  </rhs>
  </prod>
  <prod id='NT-NDataDecl'><lhs>NDataDecl</lhs>
  <rhs><nt def='NT-S'>S</nt> 'NDATA' <nt def='NT-S'>S</nt> 
  <nt def='NT-Name'>Name</nt></rhs>
  <vc def='not-declared'/></prod>
  </scrap>
  If the <nt def='NT-NDataDecl'>NDataDecl</nt> is present, this is a
  general <termref def="dt-unparsed">unparsed
  entity</termref>; otherwise it is a parsed entity.</termdef></p>
  <vcnote id='not-declared'>
  <head>Notation Declared</head>
  <p>
  The <nt def='NT-Name'>Name</nt> must match the declared name of a
  <termref def="dt-notation">notation</termref>.
  </p>
  </vcnote>
  <p><termdef id="dt-sysid" term="System Identifier">The
  <nt def='NT-SystemLiteral'>SystemLiteral</nt> 
  is called the entity's <term>system identifier</term>. It is a URI,
  which may be used to retrieve the entity.</termdef>
  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 
  <termref def='dt-docent'>document entity</termref>, to the entity
  containing the <termref def='dt-doctype'>external DTD subset</termref>, 
  or to some other <termref def='dt-extent'>external parameter entity</termref>.
  </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><termdef id="dt-pubid" term="Public identifier">
  In addition to a system identifier, an external identifier may
  include a <term>public identifier</term>.</termdef>  
  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:
  <eg>&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 ></eg></p>
  </div3>
   
  </div2>
  
  <div2 id='TextEntities'>
  <head>Parsed Entities</head>
  <div3 id='sec-TextDecl'>
  <head>The Text Declaration</head>
  <p>External parsed entities may each begin with a <term>text
  declaration</term>. 
  <scrap lang='ebnf'>
  <head>Text Declaration</head>
  <prodgroup pcw4="12.5" pcw5="13">
  <prod id='NT-TextDecl'><lhs>TextDecl</lhs>
  <rhs>&xmlpio; 
  <nt def='NT-VersionInfo'>VersionInfo</nt>?
  <nt def='NT-EncodingDecl'>EncodingDecl</nt>
  <nt def='NT-S'>S</nt>? &pic;</rhs>
  </prod>
  </prodgroup>
  </scrap>
  </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>
  </div3>
  <div3 id='wf-entities'>
  <head>Well-Formed Parsed Entities</head>
  <p>The document entity is well-formed if it matches the production labeled
  <nt def='NT-document'>document</nt>.
  An external general 
  parsed entity is well-formed if it matches the production labeled
  <nt def='NT-extParsedEnt'>extParsedEnt</nt>.
  An external parameter
  entity is well-formed if it matches the production labeled
  <nt def='NT-extPE'>extPE</nt>.
  <scrap lang='ebnf'>
  <head>Well-Formed External Parsed Entity</head>
  <prod id='NT-extParsedEnt'><lhs>extParsedEnt</lhs>
  <rhs><nt def='NT-TextDecl'>TextDecl</nt>? 
  <nt def='NT-content'>content</nt></rhs>
  </prod>
  <prod id='NT-extPE'><lhs>extPE</lhs>
  <rhs><nt def='NT-TextDecl'>TextDecl</nt>? 
  <nt def='NT-extSubsetDecl'>extSubsetDecl</nt></rhs>
  </prod>
  </scrap>
  An internal general parsed entity is well-formed if its replacement text 
  matches the production labeled
  <nt def='NT-content'>content</nt>.
  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 
  <termref def='dt-stag'>start-tag</termref>,
  <termref def='dt-etag'>end-tag</termref>,
  <termref def="dt-empty">empty-element tag</termref>,
  <termref def='dt-element'>element</termref>, 
  <termref def='dt-comment'>comment</termref>, 
  <termref def='dt-pi'>processing instruction</termref>, 
  <termref def='dt-charref'>character
  reference</termref>, or
  <termref def='dt-entref'>entity reference</termref> 
  can begin in one entity and end in another.</p>
  </div3>
  <div3 id='charencoding'>
  <head>Character Encoding in Entities</head>
   
  <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 <titleref href='TextDecl'>text
  declaration</titleref> containing an encoding declaration:
  <scrap lang='ebnf'>
  <head>Encoding Declaration</head>
  <prod id='NT-EncodingDecl'><lhs>EncodingDecl</lhs>
  <rhs><nt def="NT-S">S</nt>
  'encoding' <nt def='NT-Eq'>Eq</nt> 
  ('"' <nt def='NT-EncName'>EncName</nt> '"' | 
  "'" <nt def='NT-EncName'>EncName</nt> "'" )
  </rhs>
  </prod>
  <prod id='NT-EncName'><lhs>EncName</lhs>
  <rhs>[A-Za-z] ([A-Za-z0-9._] | '-')*</rhs>
  <com>Encoding name contains only Latin characters</com>
  </prod>
  </scrap>
  In the <termref def='dt-docent'>document entity</termref>, the encoding
  declaration is part of the <termref def="dt-xmldecl">XML declaration</termref>.
  The <nt def="NT-EncName">EncName</nt> is the name of the encoding used.
  </p>
  <!-- FINAL EDIT:  check name of IANA and charset names -->
  <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 <emph>charset</emph>s) 
  with the Internet Assigned Numbers
  Authority <bibref ref='IANA'/>, 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 <termref def="dt-error">error</termref> 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 <termref def='dt-fatal'>fatal error</termref> when an XML processor
  encounters an entity with an encoding that it is unable to process.</p>
  <p>Examples of encoding declarations:
  <eg>&lt;?xml encoding='UTF-8'?>
  &lt;?xml encoding='EUC-JP'?></eg></p>
  </div3>
  </div2>
  <div2 id='entproc'>
  <head>XML Processor Treatment of Entities and References</head>
  <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 <termref def='dt-xml-proc'>XML processor</termref> in
  each case.  
  The labels in the leftmost column describe the recognition context:
  <glist>
  <gitem><label>Reference in Content</label>
  <def><p>as a reference
  anywhere after the <termref def='dt-stag'>start-tag</termref> and
  before the <termref def='dt-etag'>end-tag</termref> of an element; corresponds
  to the nonterminal <nt def='NT-content'>content</nt>.</p></def>
  </gitem>
  <gitem>
  <label>Reference in Attribute Value</label>
  <def><p>as a reference within either the value of an attribute in a 
  <termref def='dt-stag'>start-tag</termref>, or a default
  value in an <termref def='dt-attdecl'>attribute declaration</termref>;
  corresponds to the nonterminal
  <nt def='NT-AttValue'>AttValue</nt>.</p></def></gitem>
  <gitem>
  <label>Occurs as Attribute Value</label>
  <def><p>as a <nt def='NT-Name'>Name</nt>, not a reference, appearing either as
  the value of an 
  attribute which has been declared as type <kw>ENTITY</kw>, or as one of
  the space-separated tokens in the value of an attribute which has been
  declared as type <kw>ENTITIES</kw>.</p>
  </def></gitem>
  <gitem><label>Reference in Entity Value</label>
  <def><p>as a reference
  within a parameter or internal entity's 
  <termref def='dt-litentval'>literal entity value</termref> in
  the entity's declaration; corresponds to the nonterminal 
  <nt def='NT-EntityValue'>EntityValue</nt>.</p></def></gitem>
  <gitem><label>Reference in DTD</label>
  <def><p>as a reference within either the internal or external subsets of the 
  <termref def='dt-doctype'>DTD</termref>, but outside
  of an <nt def='NT-EntityValue'>EntityValue</nt> or
  <nt def="NT-AttValue">AttValue</nt>.</p></def>
  </gitem>
  </glist></p>
  <htable border='1' cellpadding='7' align='center'>
  <htbody>
  <tr><td bgcolor='&cellback;' rowspan='2' colspan='1'></td>
  <td bgcolor='&cellback;' align='center' valign='bottom' colspan='4'>Entity Type</td>
  <td bgcolor='&cellback;' rowspan='2' align='center'>Character</td>
  </tr>
  <tr align='center' valign='bottom'>
  <td bgcolor='&cellback;'>Parameter</td>
  <td bgcolor='&cellback;'>Internal
  General</td>
  <td bgcolor='&cellback;'>External Parsed
  General</td>
  <td bgcolor='&cellback;'>Unparsed</td>
  </tr>
  <tr align='center' valign='middle'>
  
  <td bgcolor='&cellback;' align='right'>Reference
  in Content</td>
  <td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
  <td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
  <td bgcolor='&cellback;'><titleref href='include-if-valid'>Included if validating</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
  </tr>
  <tr align='center' valign='middle'>
  <td bgcolor='&cellback;' align='right'>Reference
  in Attribute Value</td>
  <td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
  <td bgcolor='&cellback;'><titleref href='inliteral'>Included in literal</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
  </tr>
  <tr align='center' valign='middle'>
  <td bgcolor='&cellback;' align='right'>Occurs as
  Attribute Value</td>
  <td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
  <td bgcolor='&cellback;'><titleref href='not-recognized'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='not-recognized'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='notify'>Notify</titleref></td>
  <td bgcolor='&cellback;'><titleref href='not recognized'>Not recognized</titleref></td>
  </tr>
  <tr align='center' valign='middle'>
  <td bgcolor='&cellback;' align='right'>Reference
  in EntityValue</td>
  <td bgcolor='&cellback;'><titleref href='inliteral'>Included in literal</titleref></td>
  <td bgcolor='&cellback;'><titleref href='bypass'>Bypassed</titleref></td>
  <td bgcolor='&cellback;'><titleref href='bypass'>Bypassed</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
  </tr>
  <tr align='center' valign='middle'>
  <td bgcolor='&cellback;' align='right'>Reference
  in DTD</td>
  <td bgcolor='&cellback;'><titleref href='as-PE'>Included as PE</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  <td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
  </tr>
  </htbody>
  </htable>
  <div3 id='not-recognized'>
  <head>Not Recognized</head>
  <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 <nt def='NT-content'>content</nt>.
  Similarly, the names of unparsed entities are not recognized except
  when they appear in the value of an appropriately declared attribute.
  </p>
  </div3>
  <div3 id='included'>
  <head>Included</head>
  <p><termdef id="dt-include" term="Include">An entity is 
  <term>included</term> when its 
  <termref def='dt-repltext'>replacement text</termref> 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 
  <termref def='dt-chardata'>character data</termref>
  and (except for parameter entities) <termref def="dt-markup">markup</termref>,
  which must be recognized in
  the usual way, except that the replacement text of entities used to escape
  markup delimiters (the entities &magicents;) 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 <term>included</term> when the indicated
  character is processed in place of the reference itself.
  </termdef></p>
  </div3>
  <div3 id='include-if-valid'>
  <head>Included If Validating</head>
  <p>When an XML processor recognizes a reference to a parsed entity, in order
  to <termref def="dt-valid">validate</termref>
  the document, the processor must 
  <termref def="dt-include">include</termref> its
  replacement text.
  If the entity is external, and the processor is not
  attempting to validate the XML document, the
  processor <termref def="dt-may">may</termref>, 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>
  </div3>
  <div3 id='forbidden'>
  <head>Forbidden</head>
  <p>The following are forbidden, and constitute
  <termref def='dt-fatal'>fatal</termref> errors:
  <ulist>
  <item><p>the appearance of a reference to an
  <termref def='dt-unparsed'>unparsed entity</termref>.
  </p></item>
  <item><p>the appearance of any character or general-entity reference in the
  DTD except within an <nt def='NT-EntityValue'>EntityValue</nt> or 
  <nt def="NT-AttValue">AttValue</nt>.</p></item>
  <item><p>a reference to an external entity in an attribute value.</p>
  </item>
  </ulist>
  </p>
  </div3>
  <div3 id='inliteral'>
  <head>Included in Literal</head>
  <p>When an <termref def='dt-entref'>entity reference</termref> appears in an
  attribute value, or a parameter entity reference appears in a literal entity
  value, its <termref def='dt-repltext'>replacement text</termref> 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:
  <eg><![CDATA[<!ENTITY % YN '"Yes"' >
  <!ENTITY WhatHeSaid "He said &YN;" >]]></eg>
  while this is not:
  <eg>&lt;!ENTITY EndAttr "27'" >
  &lt;element attribute='a-&amp;EndAttr;></eg>
  </p></div3>
  <div3 id='notify'>
  <head>Notify</head>
  <p>When the name of an <termref def='dt-unparsed'>unparsed
  entity</termref> appears as a token in the
  value of an attribute of declared type <kw>ENTITY</kw> or <kw>ENTITIES</kw>,
  a validating processor must inform the
  application of the <termref def='dt-sysid'>system</termref> 
  and <termref def='dt-pubid'>public</termref> (if any)
  identifiers for both the entity and its associated
  <termref def="dt-notation">notation</termref>.</p>
  </div3>
  <div3 id='bypass'>
  <head>Bypassed</head>
  <p>When a general entity reference appears in the
  <nt def='NT-EntityValue'>EntityValue</nt> in an entity declaration,
  it is bypassed and left as is.</p>
  </div3>
  <div3 id='as-PE'>
  <head>Included as PE</head>
  <p>Just as with external parsed entities, parameter entities
  need only be <titleref href='include-if-valid'>included if
  validating</titleref>. 
  When a parameter-entity reference is recognized in the DTD
  and included, its 
  <termref def='dt-repltext'>replacement
  text</termref> 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>
  </div3>
  
  </div2>
  <div2 id='intern-replacement'>
  <head>Construction of Internal Entity Replacement Text</head>
  <p>In discussing the treatment
  of internal entities, it is  
  useful to distinguish two forms of the entity's value.
  <termdef id="dt-litentval" term='Literal Entity Value'>The <term>literal
  entity value</term> is the quoted string actually
  present in the entity declaration, corresponding to the
  non-terminal <nt def='NT-EntityValue'>EntityValue</nt>.</termdef>
  <termdef id='dt-repltext' term='Replacement Text'>The <term>replacement
  text</term> is the content of the entity, after
  replacement of character references and parameter-entity
  references.
  </termdef></p>
  
  <p>The literal entity value 
  as given in an internal entity declaration
  (<nt def='NT-EntityValue'>EntityValue</nt>) 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 
  <termref def='dt-include'>included</termref> as described above
  must contain the <emph>replacement text</emph> 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:
  
  <eg><![CDATA[<!ENTITY % pub    "&#xc9;ditions Gallimard" >
  <!ENTITY   rights "All rights reserved" >
  <!ENTITY   book   "La Peste: Albert Camus, 
  &#xA9; 1947 %pub;. &rights;" >]]></eg>
  then the replacement text for the entity "<code>book</code>" is:
  <eg>La Peste: Albert Camus, 
  &#169; 1947 &#201;ditions Gallimard. &amp;rights;</eg>
  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
  <specref ref='sec-entexpand'/>.
  </p>
  
  </div2>
  <div2 id='sec-predefined-ent'>
  <head>Predefined Entities</head>
  <p><termdef id="dt-escape" term="escape">Entity and character
  references can both be used to <term>escape</term> the left angle bracket,
  ampersand, and other delimiters.   A set of general entities
  (&magicents;) 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.</termdef></p>
  <p>All XML processors must recognize these entities whether they
  are declared or not.  
  <termref def='dt-interop'>For interoperability</termref>,
  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.
  <eg><![CDATA[<!ENTITY lt     "&#38;#60;"> 
  <!ENTITY gt     "&#62;"> 
  <!ENTITY amp    "&#38;#38;"> 
  <!ENTITY apos   "&#39;"> 
  <!ENTITY quot   "&#34;"> 
  ]]></eg>
  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>
  </div2>
  
  <div2 id='Notations'>
  <head>Notation Declarations</head>
   
  <p><termdef id="dt-notation" term="Notation"><term>Notations</term> identify by
  name the format of <termref def="dt-extent">unparsed
  entities</termref>, the
  format of elements which bear a notation attribute, 
  or the application to which  
  a <termref def="dt-pi">processing instruction</termref> is
  addressed.</termdef></p>
  <p><termdef id="dt-notdecl" term="Notation Declaration">
  <term>Notation declarations</term>
  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.
  <scrap lang='ebnf'>
  <head>Notation Declarations</head>
  <prod id='NT-NotationDecl'><lhs>NotationDecl</lhs>
  <rhs>'&lt;!NOTATION' <nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt> 
  <nt def='NT-S'>S</nt> 
  (<nt def='NT-ExternalID'>ExternalID</nt> | 
  <nt def='NT-PublicID'>PublicID</nt>)
  <nt def='NT-S'>S</nt>? '>'</rhs></prod>
  <prod id='NT-PublicID'><lhs>PublicID</lhs>
  <rhs>'PUBLIC' <nt def='NT-S'>S</nt> 
  <nt def='NT-PubidLiteral'>PubidLiteral</nt> 
  </rhs></prod>
  </scrap>
  </termdef></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
  <termref def="dt-sysid">system identifier</termref>,
  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>
  </div2>
  
   
  <div2 id='sec-doc-entity'>
  <head>Document Entity</head>
   
  <p><termdef id="dt-docent" term="Document Entity">The <term>document
  entity</term> serves as the root of the entity
  tree and a starting-point for an <termref def="dt-xml-proc">XML
  processor</termref>.</termdef>
  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>
  </div2>
  
  
  </div1>
  <!-- &Conformance; -->
   
  <div1 id='sec-conformance'>
  <head>Conformance</head>
   
  <div2 id='proc-types'>
  <head>Validating and Non-Validating Processors</head>
  <p>Conforming <termref def="dt-xml-proc">XML processors</termref> 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
  <termref def='dt-docent'>document entity</termref> and any 
  other <termref def='dt-parsedent'>parsed entities</termref> that 
  they read.</p>
  <p><termdef id="dt-validating" term="Validating Processor">
  <term>Validating processors</term> must report
  violations of the constraints expressed by the declarations in the
  <termref def="dt-doctype">DTD</termref>, and
  failures to fulfill the validity constraints given
  in this specification.
  </termdef>
  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 
  <termref def='dt-docent'>document entity</termref>, including
  the entire internal DTD subset, for well-formedness.
  <termdef id='dt-use-mdecl' term='Process Declarations'>
  While they are not required to check the document for validity,
  they are required to 
  <term>process</term> 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 <emph>not</emph> read; that is to 
  say, they must
  use the information in those declarations to
  <titleref href='AVNormalize'>normalize</titleref> attribute values,
  <titleref href='included'>include</titleref> the replacement text of 
  internal entities, and supply 
  <titleref href='sec-attr-defaults'>default attribute values</titleref>.
  </termdef>
  They must not <termref def='dt-use-mdecl'>process</termref>
  <termref def='dt-entdecl'>entity declarations</termref> or 
  <termref def='dt-attdecl'>attribute-list declarations</termref> 
  encountered after a reference to a parameter entity that is not
  read, since the entity may have contained overriding declarations.
  </p>
  </div2>
  <div2 id='safe-behavior'>
  <head>Using XML Processors</head>
  <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:
  <ulist>
  <item><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 
  <titleref href='wf-entdeclared'>Entity Declared</titleref>, 
  <titleref href='wf-textent'>Parsed Entity</titleref>, and
  <titleref href='wf-norecursion'>No Recursion</titleref>, as well
  as some of the cases described as
  <titleref href='forbidden'>forbidden</titleref> in 
  <specref ref='entproc'/>.</p></item>
  <item><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 
  <titleref href='AVNormalize'>normalize</titleref> attribute values,
  <titleref href='included'>include</titleref> the replacement text of 
  internal entities, or supply 
  <titleref href='sec-attr-defaults'>default attribute values</titleref>,
  where doing so depends on having read declarations in 
  external or parameter entities.</p></item>
  </ulist>
  </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>
  </div2>
  </div1>
  
  <div1 id='sec-notation'>
  <head>Notation</head>
   
  <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
  <eg>symbol ::= expression</eg></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:
  <glist>
  <gitem>
  <label><code>#xN</code></label>
  <def><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></def>
  </gitem>
  <gitem>
  <label><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></label>
  <def><p>matches any <termref def='dt-character'>character</termref> 
  with a value in the range(s) indicated (inclusive).</p></def>
  </gitem>
  <gitem>
  <label><code>[^a-z]</code>, <code>[^#xN-#xN]</code></label>
  <def><p>matches any <termref def='dt-character'>character</termref> 
  with a value <emph>outside</emph> the
  range indicated.</p></def>
  </gitem>
  <gitem>
  <label><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></label>
  <def><p>matches any <termref def='dt-character'>character</termref>
  with a value not among the characters given.</p></def>
  </gitem>
  <gitem>
  <label><code>"string"</code></label>
  <def><p>matches a literal string <termref def="dt-match">matching</termref>
  that given inside the double quotes.</p></def>
  </gitem>
  <gitem>
  <label><code>'string'</code></label>
  <def><p>matches a literal string <termref def="dt-match">matching</termref>
  that given inside the single quotes.</p></def>
  </gitem>
  </glist>
  These symbols may be combined to match more complex patterns as follows,
  where <code>A</code> and <code>B</code> represent simple expressions:
  <glist>
  <gitem>
  <label>(<code>expression</code>)</label>
  <def><p><code>expression</code> is treated as a unit 
  and may be combined as described in this list.</p></def>
  </gitem>
  <gitem>
  <label><code>A?</code></label>
  <def><p>matches <code>A</code> or nothing; optional <code>A</code>.</p></def>
  </gitem>
  <gitem>
  <label><code>A B</code></label>
  <def><p>matches <code>A</code> followed by <code>B</code>.</p></def>
  </gitem>
  <gitem>
  <label><code>A | B</code></label>
  <def><p>matches <code>A</code> or <code>B</code> but not both.</p></def>
  </gitem>
  <gitem>
  <label><code>A - B</code></label>
  <def><p>matches any string that matches <code>A</code> but does not match
  <code>B</code>.
  </p></def>
  </gitem>
  <gitem>
  <label><code>A+</code></label>
  <def><p>matches one or more occurrences of <code>A</code>.</p></def>
  </gitem>
  <gitem>
  <label><code>A*</code></label>
  <def><p>matches zero or more occurrences of <code>A</code>.</p></def>
  </gitem>
  
  </glist>
  Other notations used in the productions are:
  <glist>
  <gitem>
  <label><code>/* ... */</code></label>
  <def><p>comment.</p></def>
  </gitem>
  <gitem>
  <label><code>[ wfc: ... ]</code></label>
  <def><p>well-formedness constraint; this identifies by name a 
  constraint on 
  <termref def="dt-wellformed">well-formed</termref> documents
  associated with a production.</p></def>
  </gitem>
  <gitem>
  <label><code>[ vc: ... ]</code></label>
  <def><p>validity constraint; this identifies by name a constraint on
  <termref def="dt-valid">valid</termref> documents associated with
  a production.</p></def>
  </gitem>
  </glist>
  </p></div1>
  
  </body>
  <back>
  <!-- &SGML; -->
   
  
  <!-- &Biblio; -->
  <div1 id='sec-bibliography'>
  
  <head>References</head>
  <div2 id='sec-existing-stds'>
  <head>Normative References</head>
  
  <blist>
  <bibl id='IANA' key='IANA'>
  (Internet Assigned Numbers Authority) <emph>Official Names for 
  Character Sets</emph>,
  ed. Keld Simonsen et al.
  See <loc href='ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets'>ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</loc>.
  </bibl>
  
  <bibl id='RFC1766' key='IETF RFC 1766'>
  IETF (Internet Engineering Task Force).
  <emph>RFC 1766:  Tags for the Identification of Languages</emph>,
  ed. H. Alvestrand.
  1995.
  </bibl>
  
  <bibl id='ISO639' key='ISO 639'>
  (International Organization for Standardization).
  <emph>ISO 639:1988 (E).
  Code for the representation of names of languages.</emph>
  [Geneva]:  International Organization for
  Standardization, 1988.</bibl>
  
  <bibl id='ISO3166' key='ISO 3166'>
  (International Organization for Standardization).
  <emph>ISO 3166-1:1997 (E).
  Codes for the representation of names of countries and their subdivisions 
  &mdash; Part 1: Country codes</emph>
  [Geneva]:  International Organization for
  Standardization, 1997.</bibl>
  
  <bibl id='ISO10646' key='ISO/IEC 10646'>ISO
  (International Organization for Standardization).
  <emph>ISO/IEC 10646-1993 (E).  Information technology &mdash; Universal
  Multiple-Octet Coded Character Set (UCS) &mdash; Part 1:
  Architecture and Basic Multilingual Plane.</emph>
  [Geneva]:  International Organization for
  Standardization, 1993 (plus amendments AM 1 through AM 7).
  </bibl>
  
  <bibl id='Unicode' key='Unicode'>The Unicode Consortium.
  <emph>The Unicode Standard, Version 2.0.</emph>
  Reading, Mass.:  Addison-Wesley Developers Press, 1996.</bibl>
  
  </blist>
  
  </div2>
  
  <div2><head>Other References</head> 
  
  <blist>
  
  <bibl id='Aho' key='Aho/Ullman'>Aho, Alfred V., 
  Ravi Sethi, and Jeffrey D. Ullman.
  <emph>Compilers:  Principles, Techniques, and Tools</emph>.
  Reading:  Addison-Wesley, 1986, rpt. corr. 1988.</bibl>
  
  <bibl id="Berners-Lee" xml-link="simple" key="Berners-Lee et al.">
  Berners-Lee, T., R. Fielding, and L. Masinter.
  <emph>Uniform Resource Identifiers (URI):  Generic Syntax and
  Semantics</emph>.
  1997.
  (Work in progress; see updates to RFC1738.)</bibl>
  
  <bibl id='ABK' key='Br�ggemann-Klein'>Br�ggemann-Klein, Anne.
  <emph>Regular Expressions into Finite Automata</emph>.
  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.
  
  </bibl>
  
  <bibl id='ABKDW' key='Br�ggemann-Klein and Wood'>Br�ggemann-Klein, Anne,
  and Derick Wood.
  <emph>Deterministic Regular Languages</emph>.
  Universit�t Freiburg, Institut f�r Informatik,
  Bericht 38, Oktober 1991.
  </bibl>
  
  <bibl id='Clark' key='Clark'>James Clark.
  Comparison of SGML and XML. See
  <loc href='http://www.w3.org/TR/NOTE-sgml-xml-971215'>http://www.w3.org/TR/NOTE-sgml-xml-971215</loc>.
  </bibl>
  <bibl id="RFC1738" xml-link="simple" key="IETF RFC1738">
  IETF (Internet Engineering Task Force).
  <emph>RFC 1738:  Uniform Resource Locators (URL)</emph>, 
  ed. T. Berners-Lee, L. Masinter, M. McCahill.
  1994.
  </bibl>
  
  <bibl id="RFC1808" xml-link="simple" key="IETF RFC1808">
  IETF (Internet Engineering Task Force).
  <emph>RFC 1808:  Relative Uniform Resource Locators</emph>, 
  ed. R. Fielding.
  1995.
  </bibl>
  
  <bibl id="RFC2141" xml-link="simple" key="IETF RFC2141">
  IETF (Internet Engineering Task Force).
  <emph>RFC 2141:  URN Syntax</emph>, 
  ed. R. Moats.
  1997.
  </bibl>
  
  <bibl id='ISO8879' key='ISO 8879'>ISO
  (International Organization for Standardization).
  <emph>ISO 8879:1986(E).  Information processing &mdash; Text and Office
  Systems &mdash; Standard Generalized Markup Language (SGML).</emph>  First
  edition &mdash; 1986-10-15.  [Geneva]:  International Organization for
  Standardization, 1986.
  </bibl>
  
  
  <bibl id='ISO10744' key='ISO/IEC 10744'>ISO
  (International Organization for Standardization).
  <emph>ISO/IEC 10744-1992 (E).  Information technology &mdash;
  Hypermedia/Time-based Structuring Language (HyTime).
  </emph>
  [Geneva]:  International Organization for
  Standardization, 1992.
  <emph>Extended Facilities Annexe.</emph>
  [Geneva]:  International Organization for
  Standardization, 1996. 
  </bibl>
  
  
  
  </blist>
  </div2>
  </div1>
  <div1 id='CharClasses'>
  <head>Character Classes</head>
  <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.
  <scrap lang="ebnf" id="CHARACTERS">
  <head>Characters</head>
  <prodgroup pcw3="3" pcw4="15">
  <prod id="NT-Letter"><lhs>Letter</lhs>
  <rhs><nt def="NT-BaseChar">BaseChar</nt> 
  | <nt def="NT-Ideographic">Ideographic</nt></rhs> </prod>
  <prod id='NT-BaseChar'><lhs>BaseChar</lhs>
  <rhs>[#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]
  </rhs></prod>
  <prod id='NT-Ideographic'><lhs>Ideographic</lhs>
  <rhs>[#x4E00-#x9FA5]
  |&nbsp;#x3007
  |&nbsp;[#x3021-#x3029]
  </rhs></prod>
  <prod id='NT-CombiningChar'><lhs>CombiningChar</lhs>
  <rhs>[#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
  </rhs></prod>
  <prod id='NT-Digit'><lhs>Digit</lhs>
  <rhs>[#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]
  </rhs></prod>
  <prod id='NT-Extender'><lhs>Extender</lhs>
  <rhs>#x00B7
  |&nbsp;#x02D0
  |&nbsp;#x02D1
  |&nbsp;#x0387
  |&nbsp;#x0640
  |&nbsp;#x0E46
  |&nbsp;#x0EC6
  |&nbsp;#x3005
  |&nbsp;[#x3031-#x3035]
  |&nbsp;[#x309D-#x309E]
  |&nbsp;[#x30FC-#x30FE]
  </rhs></prod>
  
  </prodgroup>
  </scrap>
  </p>
  <p>The character classes defined here can be derived from the
  Unicode character database as follows:
  <ulist>
  <item>
  <p>Name start characters must have one of the categories Ll, Lu,
  Lo, Lt, Nl.</p>
  </item>
  <item>
  <p>Name characters other than Name-start characters 
  must have one of the categories Mc, Me, Mn, Lm, or Nd.</p>
  </item>
  <item>
  <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>
  </item>
  <item>
  <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>
  </item>
  <item>
  <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>
  </item>
  <item>
  <p>Characters #x20DD-#x20E0 are excluded (in accordance with 
  Unicode, section 5.14).</p>
  </item>
  <item>
  <p>Character #x00B7 is classified as an extender, because the
  property list so identifies it.</p>
  </item>
  <item>
  <p>Character #x0387 is added as a name character, because #x00B7
  is its canonical equivalent.</p>
  </item>
  <item>
  <p>Characters ':' and '_' are allowed as name-start characters.</p>
  </item>
  <item>
  <p>Characters '-' and '.' are allowed as name characters.</p>
  </item>
  </ulist>
  </p>
  </div1>
  <inform-div1 id="sec-xml-and-sgml">
  <head>XML and SGML</head>
   
  <p>XML is designed to be a subset of SGML, in that every
  <termref def="dt-valid">valid</termref> 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 <bibref ref='Clark'/>.
  </p>
  </inform-div1>
  <inform-div1 id="sec-entexpand">
  <head>Expansion of Entity and Character References</head>
  <p>This appendix contains some examples illustrating the
  sequence of entity- and character-reference recognition and
  expansion, as specified in <specref ref='entproc'/>.</p>
  <p>
  If the DTD contains the declaration 
  <eg><![CDATA[<!ENTITY example "<p>An ampersand (&#38;#38;) may be escaped
  numerically (&#38;#38;#38;) or with a general entity
  (&amp;amp;).</p>" >
  ]]></eg>
  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>":
  <eg><![CDATA[<p>An ampersand (&#38;) may be escaped
  numerically (&#38;#38;) or with a general entity
  (&amp;amp;).</p>
  ]]></eg>
  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):
  <eg><![CDATA[An ampersand (&) may be escaped
  numerically (&#38;) or with a general entity
  (&amp;).
  ]]></eg>
  </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.
  <eg><![CDATA[1 <?xml version='1.0'?>
  2 <!DOCTYPE test [
  3 <!ELEMENT test (#PCDATA) >
  4 <!ENTITY % xx '&#37;zz;'>
  5 <!ENTITY % zz '&#60;!ENTITY tricky "error-prone" >' >
  6 %xx;
  7 ]>
  8 <test>This sample shows a &tricky; method.</test>
  ]]></eg>
  This produces the following:
  <ulist spacing="compact">
  <item><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></item>
  <item><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></item>
  <item><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></item>
  <item><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
  <emph>This sample shows a error-prone method.</emph>
  </p></item>
  </ulist>
  </p>
  </inform-div1> 
  <inform-div1 id="determinism">
  <head>Deterministic Content Models</head>
  <p><termref def='dt-compat'>For compatibility</termref>, it is
  required
  that content models in element type declarations be deterministic.  
  </p>
  <!-- FINAL EDIT:  WebSGML allows ambiguity? -->
  <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 <bibref ref='Aho'/>.
  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�ggemann-Klein 1991 <bibref ref='ABK'/>.</p>
  </inform-div1>
  <inform-div1 id="sec-guessing">
  <head>Autodetection of Character Encodings</head>
  <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&mdash;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 <emph>must</emph>
  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>
  <ulist>
  <item>
  <p><code>00 00 00 3C</code>: UCS-4, big-endian machine (1234 order)</p>
  </item>
  <item>
  <p><code>3C 00 00 00</code>: UCS-4, little-endian machine (4321 order)</p>
  </item>
  <item>
  <p><code>00 00 3C 00</code>: UCS-4, unusual octet order (2143)</p>
  </item>
  <item>
  <p><code>00 3C 00 00</code>: UCS-4, unusual octet order (3412)</p>
  </item>
  <item>
  <p><code>FE FF</code>: UTF-16, big-endian</p>
  </item>
  <item>
  <p><code>FF FE</code>: UTF-16, little-endian</p>
  </item>
  <item>
  <p><code>00 3C 00 3F</code>: UTF-16, big-endian, no Byte Order Mark
  (and thus, strictly speaking, in error)</p>
  </item>
  <item>
  <p><code>3C 00 3F 00</code>: UTF-16, little-endian, no Byte Order Mark
  (and thus, strictly speaking, in error)</p>
  </item>
  <item>
  <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>
  </item>
  <item>
  <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>
  </item>
  <item>
  <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>
  </item>
  </ulist>
  </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.
  <ulist>
  <item><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></item>
  <item><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></item>
  <item><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></item>
  </ulist>
  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>
  
  </inform-div1>
  
  <inform-div1 id="sec-xml-wg">
  <head>W3C XML Working Group</head>
   
  <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>
   
  <orglist>
  <member><name>Jon Bosak, Sun</name><role>Chair</role></member>
  <member><name>James Clark</name><role>Technical Lead</role></member>
  <member><name>Tim Bray, Textuality and Netscape</name><role>XML Co-editor</role></member>
  <member><name>Jean Paoli, Microsoft</name><role>XML Co-editor</role></member>
  <member><name>C. M. Sperberg-McQueen, U. of Ill.</name><role>XML
  Co-editor</role></member>
  <member><name>Dan Connolly, W3C</name><role>W3C Liaison</role></member>
  <member><name>Paula Angerstein, Texcel</name></member>
  <member><name>Steve DeRose, INSO</name></member>
  <member><name>Dave Hollander, HP</name></member>
  <member><name>Eliot Kimber, ISOGEN</name></member>
  <member><name>Eve Maler, ArborText</name></member>
  <member><name>Tom Magliery, NCSA</name></member>
  <member><name>Murray Maloney, Muzmo and Grif</name></member>
  <member><name>Makoto Murata, Fuji Xerox Information Systems</name></member>
  <member><name>Joel Nava, Adobe</name></member>
  <member><name>Conleth O'Connell, Vignette</name></member>
  <member><name>Peter Sharpe, SoftQuad</name></member>
  <member><name>John Tigue, DataChannel</name></member>
  </orglist>
  
  </inform-div1>
  </back>
  </spec>
  <!-- Keep this comment at the end of the file
  Local variables:
  mode: sgml
  sgml-default-dtd-file:"~/sgml/spec.ced"
  sgml-omittag:t
  sgml-shorttag:t
  End:
  -->
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk055.xml
  
  Index: mk055.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <!-- $Id: mk055.xml,v 1.1 2001/06/20 18:54:41 amiro Exp $ -->
  <!DOCTYPE spec SYSTEM "spec.dtd" [
  <!ENTITY XML "http://www.w3.org/TR/REC-xml">
  <!ENTITY XMLNames "http://www.w3.org/TR/REC-xml-names">
  <!ENTITY year "1999">
  <!ENTITY month "November">
  <!ENTITY MM "11">
  <!ENTITY day "16">
  <!ENTITY DD "16">
  <!ENTITY YYYYMMDD "&year;&MM;&DD;">
  <!ENTITY LEV "REC">
  <!-- DTD customizations -->
  <!ELEMENT proto (arg*)>
  <!ATTLIST proto
    name NMTOKEN #REQUIRED
    return-type (number|string|boolean|node-set|object) #REQUIRED
  >
  <!ELEMENT arg EMPTY>
  <!ATTLIST arg
    type (number|string|boolean|node-set|object) #REQUIRED
    occur (opt|rep) #IMPLIED
  >
  <!ELEMENT function (#PCDATA)>
  <!ENTITY % local.illus.class "|proto">
  <!ENTITY % local.tech.class "|function">
  ]>
  <spec>
  <header>
  <title>XML Path Language (XPath)</title>
  <version>Version 1.0</version>
  <w3c-designation>&LEV;-xpath-&YYYYMMDD;</w3c-designation>
  <w3c-doctype>W3C Recommendation</w3c-doctype>
  <pubdate><day>&day;</day><month>&month;</month><year>&year;</year></pubdate>
  <publoc>
  <loc href="http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;"
            >http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;</loc>
  <loc role="available-format"
  href="http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;.xml">XML</loc>
  <loc role="available-format"
  href="http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;.html">HTML</loc>
  <!--
  <loc href="http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;.pdf"
            >http://www.w3.org/TR/&year;/&LEV;-xpath-&YYYYMMDD;.pdf</loc>
  -->
  </publoc>
  <latestloc>
  <loc href="http://www.w3.org/TR/xpath"
            >http://www.w3.org/TR/xpath</loc>
  </latestloc>
  <prevlocs>
  <loc href="http://www.w3.org/TR/1999/PR-xpath-19991008"
            >http://www.w3.org/TR/1999/PR-xpath-19991008</loc>
  <loc href="http://www.w3.org/1999/08/WD-xpath-19990813"
            >http://www.w3.org/1999/08/WD-xpath-19990813</loc>
  <loc href="http://www.w3.org/1999/07/WD-xpath-19990709"
            >http://www.w3.org/1999/07/WD-xpath-19990709</loc>
  <loc href="http://www.w3.org/TR/1999/WD-xslt-19990421"
            >http://www.w3.org/TR/1999/WD-xslt-19990421</loc>
  </prevlocs>
  <authlist>
  <author>
  <name>James Clark</name>
  <email href="mailto:jjc@jclark.com">jjc@jclark.com</email>
  </author>
  <author>
  <name>Steve DeRose</name>
  <affiliation>Inso Corp. and Brown University</affiliation>
  <email href="mailto:Steven_DeRose@Brown.edu">Steven_DeRose@Brown.edu</email>
  </author>
  </authlist>
  
  <status>
  
  <p>This document has been reviewed by W3C Members and other interested
  parties and has been endorsed by the Director as a W3C <loc
  href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</loc>. 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
  <loc href="http://www.w3.org/&year;/&MM;/&LEV;-xpath-&YYYYMMDD;-errata"
  >http://www.w3.org/&year;/&MM;/&LEV;-xpath-&YYYYMMDD;-errata</loc>.</p>
  
  <p>Comments on this specification may be sent to <loc
  href="mailto:www-xpath-comments@w3.org"
  >www-xpath-comments@w3.org</loc>; <loc
  href="http://lists.w3.org/Archives/Public/www-xpath-comments">archives</loc>
  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 <loc
  href="http://www.w3.org/Style/XSL/translations.html"
  >http://www.w3.org/Style/XSL/translations.html</loc>.</p>
  
  <p>A list of current W3C Recommendations and other technical documents
  can be found at <loc
  href="http://www.w3.org/TR">http://www.w3.org/TR</loc>.</p>
  
  <p>This specification is joint work of the XSL Working Group and the
  XML Linking Working Group and so is part of the <loc
  href="http://www.w3.org/Style/Activity">W3C Style activity</loc> and
  of the <loc href="http://www.w3.org/XML/Activity">W3C XML
  activity</loc>.</p>
  
  </status>
  
  <abstract><p>XPath is a language for addressing parts of an XML
  document, designed to be used by both XSLT and
  XPointer.</p></abstract>
  
  <langusage>
  <language id="EN">English</language>
  <language id="ebnf">EBNF</language>
  </langusage>
  <revisiondesc>
  <slist>
  <sitem>See RCS log for revision history.</sitem>
  </slist>
  </revisiondesc>
  </header>
  <body>
  
  <div1>
  <head>Introduction</head>
  
  <p>XPath is the result of an effort to provide a common syntax and
  semantics for functionality shared between XSL Transformations <bibref
  ref="XSLT"/> and XPointer <bibref ref="XPTR"/>.  The primary purpose
  of XPath is to address parts of an XML <bibref ref="XML"/> 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 <xspecref href="http://www.w3.org/TR/WD-xslt#patterns"
  >XSLT</xspecref>.</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 <termref
  def="dt-string-value">string-value</termref> for each type of node.
  Some types of nodes also have names.  XPath fully supports XML
  Namespaces <bibref ref="XMLNAMES"/>.  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 <termref
  def="dt-expanded-name">expanded-name</termref>.  The data model is
  described in detail in <specref ref="data-model"/>.</p>
  
  <p>The primary syntactic construct in XPath is the expression.  An
  expression matches the production <nt def="NT-Expr">Expr</nt>.  An
  expression is evaluated to yield an object, which has one of the
  following four basic types:</p>
  
  <slist>
  
  <sitem>node-set (an unordered collection of nodes without duplicates)</sitem>
  
  <sitem>boolean (true or false)</sitem>
  
  <sitem>number (a floating-point number)</sitem>
  
  <sitem>string (a sequence of UCS characters)</sitem>
  
  </slist>
  
  <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>
  
  <slist>
  
  <sitem>a node (<termdef id="dt-context-node" term="Context Node">the
  <term>context node</term></termdef>)</sitem>
  
  <sitem>a pair of non-zero positive integers (<termdef
  id="dt-context-position" term="Context Position">the <term>context
  position</term></termdef> and <termdef id="dt-context-size"
  term="Context Size">the <term>context size</term></termdef>)</sitem>
  
  <sitem>a set of variable bindings</sitem>
  
  <sitem>a function library</sitem>
  
  <sitem>the set of namespace declarations in scope for the
  expression</sitem>
  
  </slist>
  
  <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 <specref ref="corelib"/>).
  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 <specref
  ref="predicates"/>).  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 <nt
  def="NT-LocationPath">LocationPath</nt>.</p>
  
  <p>In the following grammar, the non-terminals <xnt
  href="&XMLNames;#NT-QName">QName</xnt> and <xnt
  href="&XMLNames;#NT-NCName">NCName</xnt> are defined in <bibref
  ref="XMLNAMES"/>, and <xnt href="&XML;#NT-S">S</xnt> is defined in
  <bibref ref="XML"/>.  The grammar uses the same EBNF notation as
  <bibref ref="XML"/> (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 <specref ref="exprlex"/>.</p>
  
  </div1>
  
  <div1 id="location-paths">
  <head>Location Paths</head>
  
  <p>Although location paths are not the most general grammatical
  construct in the language (a <nt
  def="NT-LocationPath">LocationPath</nt> is a special case of an <nt
  def="NT-Expr">Expr</nt>), 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 <specref
  ref="path-abbrev"/>).</p>
  
  <p>Here are some examples of location paths using the unabbreviated
  syntax:</p>
  
  <ulist>
  
  <item><p><code>child::para</code> selects the
  <code>para</code> element children of the context node</p></item>
  
  <item><p><code>child::*</code> selects all element
  children of the context node</p></item>
  
  <item><p><code>child::text()</code> selects all text
  node children of the context node</p></item>
  
  <item><p><code>child::node()</code> selects all the
  children of the context node, whatever their node type</p></item>
  
  <item><p><code>attribute::name</code> selects the
  <code>name</code> attribute of the context node</p></item>
  
  <item><p><code>attribute::*</code> selects all the
  attributes of the context node</p></item>
  
  <item><p><code>descendant::para</code> selects the
  <code>para</code> element descendants of the context node</p></item>
  
  <item><p><code>ancestor::div</code> selects all <code>div</code>
  ancestors of the context node</p></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><p><code>self::para</code> selects the context node if it is a
  <code>para</code> element, and otherwise selects nothing</p></item>
  
  <item><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></item>
  
  <item><p><code>child::*/child::para</code> selects
  all <code>para</code> grandchildren of the context node</p></item>
  
  <item><p><code>/</code> selects the document root (which is
  always the parent of the document element)</p></item>
  
  <item><p><code>/descendant::para</code> selects all the
  <code>para</code> elements in the same document as the context node</p></item>
  
  <item><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></item>
  
  <item><p><code>child::para[position()=1]</code> selects the first
  <code>para</code> child of the context node</p></item>
  
  <item><p><code>child::para[position()=last()]</code> selects the last
  <code>para</code> child of the context node</p></item>
  
  <item><p><code>child::para[position()=last()-1]</code> selects
  the last but one <code>para</code> child of the context node</p></item>
  
  <item><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></item>
  
  <item><p><code>following-sibling::chapter[position()=1]</code>
  selects the next <code>chapter</code> sibling of the context node</p></item>
  
  <item><p><code>preceding-sibling::chapter[position()=1]</code>
  selects the previous <code>chapter</code> sibling of the context
  node</p></item>
  
  <item><p><code>/descendant::figure[position()=42]</code> selects
  the forty-second <code>figure</code> element in the
  document</p></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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 <termref
  def="dt-string-value">string-value</termref> equal to
  <code>Introduction</code></p></item>
  
  <item><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></item>
  
  <item><p><code>child::*[self::chapter or self::appendix]</code>
  selects the <code>chapter</code> and <code>appendix</code> children of
  the context node</p></item>
  
  <item><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></item>
  
  </ulist>
  
  <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>
  
  <scrap>
  <head>Location Paths</head>
  <prodgroup pcw5="1" pcw2="10" pcw4="18">
  <prod id="NT-LocationPath">
  <lhs>LocationPath</lhs>
  <rhs><nt def="NT-RelativeLocationPath">RelativeLocationPath</nt></rhs>
  <rhs>| <nt def="NT-AbsoluteLocationPath">AbsoluteLocationPath</nt></rhs>
  </prod>
  <prod id="NT-AbsoluteLocationPath">
  <lhs>AbsoluteLocationPath</lhs>
  <rhs>'/' <nt def="NT-RelativeLocationPath">RelativeLocationPath</nt>?</rhs>
  <rhs>| <nt def="NT-AbbreviatedAbsoluteLocationPath">AbbreviatedAbsoluteLocationPath</nt></rhs>
  </prod>
  <prod id="NT-RelativeLocationPath">
  <lhs>RelativeLocationPath</lhs>
  <rhs><nt def="NT-Step">Step</nt></rhs>
  <rhs>| <nt def="NT-RelativeLocationPath">RelativeLocationPath</nt> '/' <nt def="NT-Step">Step</nt></rhs>
  <rhs>| <nt def="NT-AbbreviatedRelativeLocationPath">AbbreviatedRelativeLocationPath</nt></rhs>
  </prod>
  </prodgroup>
  </scrap>
  
  <div2>
  <head>Location Steps</head>
  
  <p>A location step has three parts:</p>
  
  <ulist>
  
  <item><p>an axis, which specifies the tree relationship between the
  nodes selected by the location step and the context node,</p></item>
  
  <item><p>a node test, which specifies the node type and <termref
  def="dt-expanded-name">expanded-name</termref> of the nodes selected
  by the location step, and</p></item>
  
  <item><p>zero or more predicates, which use arbitrary expressions to
  further refine the set of nodes selected by the location
  step.</p></item>
  
  </ulist>
  
  <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 <termref def="dt-expanded-name">expanded-name</termref> 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 <specref ref="axes"/>.  The available node tests
  are described in <specref ref="node-tests"/>.  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 <specref ref="predicates"/>.</p>
  
  <scrap>
  <head>Location Steps</head>
  <prodgroup pcw5="1" pcw2="10" pcw4="18">
  <prod id="NT-Step">
  <lhs>Step</lhs>
  <rhs><nt def="NT-AxisSpecifier">AxisSpecifier</nt>
  <nt def="NT-NodeTest">NodeTest</nt>
  <nt def="NT-Predicate">Predicate</nt>*</rhs>
  <rhs>| <nt def="NT-AbbreviatedStep">AbbreviatedStep</nt></rhs>
  </prod>
  <prod id="NT-AxisSpecifier">
  <lhs>AxisSpecifier</lhs>
  <rhs><nt def="NT-AxisName">AxisName</nt> '::'</rhs>
  <rhs>| <nt def="NT-AbbreviatedAxisSpecifier">AbbreviatedAxisSpecifier</nt>
  </rhs>
  </prod>
  </prodgroup>
  </scrap>
  
  </div2>
  
  <div2 id="axes">
  <head>Axes</head>
  
  <p>The following axes are available:</p>
  
  <ulist>
  
  <item><p>the <code>child</code> axis contains the children of the
  context node</p></item>
  
  <item><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></item>
  
  <item><p>the <code>parent</code> axis contains the <termref
  def="dt-parent">parent</termref> of the context node, if there is
  one</p></item>
  
  <item><p>the <code>ancestor</code> axis contains the ancestors of the
  context node; the ancestors of the context node consist of the
  <termref def="dt-parent">parent</termref> 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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><p>the <code>self</code> axis contains just the context node
  itself</p></item>
  
  <item><p>the <code>descendant-or-self</code> axis contains the context
  node and the descendants of the context node</p></item>
  
  <item><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></item>
  
  </ulist>
  
  <note><p>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.</p></note>
  
  <scrap>
  <head>Axes</head>
  <prod id="NT-AxisName">
  <lhs>AxisName</lhs>
  <rhs>'ancestor'</rhs>
  <rhs>| 'ancestor-or-self'</rhs>
  <rhs>| 'attribute'</rhs>
  <rhs>| 'child'</rhs>
  <rhs>| 'descendant'</rhs>
  <rhs>| 'descendant-or-self'</rhs>
  <rhs>| 'following'</rhs>
  <rhs>| 'following-sibling'</rhs>
  <rhs>| 'namespace'</rhs>
  <rhs>| 'parent'</rhs>
  <rhs>| 'preceding'</rhs>
  <rhs>| 'preceding-sibling'</rhs>
  <rhs>| 'self'</rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2 id="node-tests">
  <head>Node Tests</head>
  
  <p><termdef id="dt-principal-node-type" term="Principal Node
  Type">Every axis has a <term>principal node type</term>.  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.</termdef> Thus,</p>
  
  <slist>
  
  <sitem>For the attribute axis, the principal node type is attribute.</sitem>
  
  <sitem>For the namespace axis, the principal node type is namespace.</sitem>
  
  <sitem>For other axes, the principal node type is element.</sitem>
  
  </slist>
  
  <p>A node test that is a <xnt href="&XMLNames;#NT-QName">QName</xnt>
  is true if and only if the type of the node (see <specref ref="data-model"/>)
  is the principal node type and has
  an <termref def="dt-expanded-name">expanded-name</termref> equal to
  the <termref def="dt-expanded-name">expanded-name</termref> specified
  by the <xnt href="&XMLNames;#NT-QName">QName</xnt>.  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 <xnt href="&XMLNames;#NT-QName">QName</xnt> in the node test is
  expanded into an <termref
  def="dt-expanded-name">expanded-name</termref> 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 <xnt href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt
  href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt
  href="&XMLNames;#NT-NCName">NCName</xnt><code>:*</code>.  In this
  case, the prefix is expanded in the same way as with a <xnt
  href="&XMLNames;#NT-QName">QName</xnt>, 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 <termref
  def="dt-expanded-name">expanded-name</termref> 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 <nt def="NT-Literal">Literal</nt>; in this case, it
  is true for any processing instruction that has a name equal to the
  value of the <nt def="NT-Literal">Literal</nt>.</p>
  
  <p>A node test <code>node()</code> is true for any node of any type
  whatsoever.</p>
  
  <scrap>
  <head></head>
  <prod id="NT-NodeTest">
  <lhs>NodeTest</lhs>
  <rhs><nt def="NT-NameTest">NameTest</nt></rhs>
  <rhs>| <nt def="NT-NodeType">NodeType</nt> '(' ')'</rhs>
  <rhs>| 'processing-instruction' '(' <nt def="NT-Literal">Literal</nt> ')'</rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2 id="predicates">
  <head>Predicates</head>
  
  <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 <termref def="dt-document-order">document
  order</termref> is a forward axis.  An axis that only ever contains
  the context node or nodes that are before the context node in <termref
  def="dt-document-order">document order</termref> 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.  <termdef term="Proximity Position"
  id="dt-proximity-position">The <term>proximity position</term> 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.</termdef></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 <nt
  def="NT-PredicateExpr">PredicateExpr</nt> 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 <termref
  def="dt-proximity-position">proximity position</termref> of the node
  in the node-set with respect to the axis as the context position; if
  <nt def="NT-PredicateExpr">PredicateExpr</nt> evaluates to true for
  that node, the node is included in the new node-set; otherwise, it is
  not included.</p>
  
  <p>A <nt def="NT-PredicateExpr">PredicateExpr</nt> is evaluated by
  evaluating the <nt def="NT-Expr">Expr</nt> 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
  <function>boolean</function> function.  Thus a location path
  <code>para[3]</code> is equivalent to
  <code>para[position()=3]</code>.</p>
  
  <scrap>
  <head>Predicates</head>
  <prod id="NT-Predicate">
  <lhs>Predicate</lhs>
  <rhs>'[' <nt def="NT-PredicateExpr">PredicateExpr</nt> ']'</rhs>
  </prod>
  <prod id="NT-PredicateExpr">
  <lhs>PredicateExpr</lhs>
  <rhs><nt def="NT-Expr">Expr</nt></rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2 id="path-abbrev">
  <head>Abbreviated Syntax</head>
  
  <p>Here are some examples of location paths using abbreviated
  syntax:</p>
  
  <ulist>
  
  <item><p><code>para</code> selects the <code>para</code> element children of
  the context node</p></item>
  
  <item><p><code>*</code> selects all element children of the
  context node</p></item>
  
  <item><p><code>text()</code> selects all text node children of the
  context node</p></item>
  
  <item><p><code>@name</code> selects the <code>name</code> attribute of
  the context node</p></item>
  
  <item><p><code>@*</code> selects all the attributes of the
  context node</p></item>
  
  <item><p><code>para[1]</code> selects the first <code>para</code> child of
  the context node</p></item>
  
  <item><p><code>para[last()]</code> selects the last <code>para</code> child
  of the context node</p></item>
  
  <item><p><code>*/para</code> selects all <code>para</code> grandchildren of
  the context node</p></item>
  
  <item><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></item>
  
  <item><p><code>chapter//para</code> selects the <code>para</code> element
  descendants of the <code>chapter</code> element children of the
  context node</p></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><p><code>.</code> selects the context node</p></item>
  
  <item><p><code>.//para</code> selects the <code>para</code> element
  descendants of the context node</p></item>
  
  <item><p><code>..</code> selects the parent of the context node</p></item>
  
  <item><p><code>../@lang</code> selects the <code>lang</code> attribute
  of the parent of the context node</p></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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></item>
  
  <item><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 <termref
  def="dt-string-value">string-value</termref> equal to
  <code>Introduction</code></p></item>
  
  <item><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></item>
  
  <item><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></item>
  
  </ulist>
  
  <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>
  
  <note><p>The location path <code>//para[1]</code> does
  <emph>not</emph> 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.</p></note>
  
  <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>
  
  <eg>self::node()/descendant-or-self::node()/child::para</eg>
  
  <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>
  
  <scrap>
  <head>Abbreviations</head>
  <prodgroup pcw5="1" pcw2="15" pcw4="16">
  <prod id="NT-AbbreviatedAbsoluteLocationPath">
  <lhs>AbbreviatedAbsoluteLocationPath</lhs>
  <rhs>'//' <nt def="NT-RelativeLocationPath">RelativeLocationPath</nt></rhs>
  </prod>
  <prod id="NT-AbbreviatedRelativeLocationPath">
  <lhs>AbbreviatedRelativeLocationPath</lhs>
  <rhs><nt def="NT-RelativeLocationPath">RelativeLocationPath</nt> '//' <nt def="NT-Step">Step</nt></rhs>
  </prod>
  <prod id="NT-AbbreviatedStep">
  <lhs>AbbreviatedStep</lhs>
  <rhs>'.'</rhs>
  <rhs>| '..'</rhs>
  </prod>
  <prod id="NT-AbbreviatedAxisSpecifier">
  <lhs>AbbreviatedAxisSpecifier</lhs>
  <rhs>'@'?</rhs>
  </prod>
  </prodgroup>
  </scrap>
  
  </div2>
  
  </div1>
  
  <div1>
  <head>Expressions</head>
  
  <div2>
  <head>Basics</head>
  
  <p>A <nt def="NT-VariableReference">VariableReference</nt> 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>
  
  <scrap>
  <head></head>
  <prod id="NT-Expr">
  <lhs>Expr</lhs>
  <rhs><nt def="NT-OrExpr">OrExpr</nt></rhs>
  </prod>
  <prod id="NT-PrimaryExpr">
  <lhs>PrimaryExpr</lhs>
  <rhs><nt def="NT-VariableReference">VariableReference</nt></rhs>
  <rhs>| '(' <nt def="NT-Expr">Expr</nt> ')'</rhs>
  <rhs>| <nt def="NT-Literal">Literal</nt></rhs>
  <rhs>| <nt def="NT-Number">Number</nt></rhs>
  <rhs>| <nt def="NT-FunctionCall">FunctionCall</nt></rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2>
  <head>Function Calls</head>
  
  <p>A <nt def="NT-FunctionCall">FunctionCall</nt> expression is
  evaluated by using the <nt def="NT-FunctionName">FunctionName</nt> to
  identify a function in the expression evaluation context function
  library, evaluating each of the <nt def="NT-Argument">Argument</nt>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 <nt
  def="NT-FunctionCall">FunctionCall</nt> expression is the result
  returned by the function.</p>
  
  <p>An argument is converted to type string as if by calling the
  <function>string</function> function.  An argument is converted to
  type number as if by calling the <function>number</function> function.
  An argument is converted to type boolean as if by calling the
  <function>boolean</function> function.  An argument that is not of
  type node-set cannot be converted to a node-set.</p>
  
  <scrap>
  <head></head>
  <prod id="NT-FunctionCall">
  <lhs>FunctionCall</lhs>
  <rhs><nt def="NT-FunctionName">FunctionName</nt> '(' ( <nt def="NT-Argument">Argument</nt> ( ',' <nt def="NT-Argument">Argument</nt> )* )? ')'</rhs>
  </prod>
  <prod id="NT-Argument">
  <lhs>Argument</lhs>
  <rhs><nt def="NT-Expr">Expr</nt></rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2 id="node-sets">
  <head>Node-sets</head>
  
  <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><nt def="NT-Predicate">Predicate</nt>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 <nt def="NT-Predicate">Predicate</nt> filters the
  node-set with respect to the child axis.</p>
  
  <note><p>The meaning of a <nt def="NT-Predicate">Predicate</nt>
  depends crucially on which axis applies. For example,
  <code>preceding::foo[1]</code> returns the first <code>foo</code>
  element in <emph>reverse document order</emph>, 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 <emph>document order</emph>, because the
  axis that applies to the <code>[1]</code> predicate is the child
  axis.</p></note>
  
  <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>
  
  <scrap>
  <head></head>
  <prod id="NT-UnionExpr">
  <lhs>UnionExpr</lhs>
  <rhs><nt def="NT-PathExpr">PathExpr</nt></rhs>
  <rhs>| <nt def="NT-UnionExpr">UnionExpr</nt> '|' <nt def="NT-PathExpr">PathExpr</nt></rhs>
  </prod>
  <prod id="NT-PathExpr">
  <lhs>PathExpr</lhs>
  <rhs><nt def="NT-LocationPath">LocationPath</nt></rhs>
  <rhs>| <nt def="NT-FilterExpr">FilterExpr</nt></rhs>
  <rhs>| <nt def="NT-FilterExpr">FilterExpr</nt> '/' <nt def="NT-RelativeLocationPath">RelativeLocationPath</nt></rhs>
  <rhs>| <nt def="NT-FilterExpr">FilterExpr</nt> '//' <nt def="NT-RelativeLocationPath">RelativeLocationPath</nt></rhs>
  </prod>
  <prod id="NT-FilterExpr">
  <lhs>FilterExpr</lhs>
  <rhs><nt def="NT-PrimaryExpr">PrimaryExpr</nt></rhs>
  <rhs>| <nt def="NT-FilterExpr">FilterExpr</nt> <nt def="NT-Predicate">Predicate</nt></rhs>
  </prod>
  </scrap>
  
  </div2>
  
  <div2 id="booleans">
  <head>Booleans</head>
  
  <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
  <function>boolean</function> 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
  <function>boolean</function> 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 <nt def="NT-EqualityExpr">EqualityExpr</nt> (that is not just
  a <nt def="NT-RelationalExpr">RelationalExpr</nt>) or a <nt
  def="NT-RelationalExpr">RelationalExpr</nt> (that is not just an <nt
  def="NT-AdditiveExpr">AdditiveExpr</nt>) 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>&gt;=</code> and <code>&gt;</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>&gt;=</code> and <code>&gt;</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 <termref
  def="dt-string-value">string-value</termref>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
  <termref def="dt-string-value">string-value</termref> of that node to
  a number using the <function>number</function> 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
  <termref def="dt-string-value">string-value</termref> 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
  <function>boolean</function> 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
  <function>boolean</function> 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
  <function>number</function> function.  Otherwise, both objects to be
  compared are converted to strings as if by applying the
  <function>string</function> 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 <bibref
  ref="IEEE754"/>.  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>
  
  <note><p>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
  <emph>some</emph> node in <code>$x</code> has the string-value
  <code>foo</code>; the latter is true if and only if <emph>all</emph>
  nodes in <code>$x</code> have the string-value
  <code>foo</code>.</p></note>
  
  <p>When neither object to be compared is a node-set and the operator
  is <code>&lt;=</code>, <code>&lt;</code>, <code>&gt;=</code> or
  <code>&gt;</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>&gt;</code> comparison will
  be true if and only if the first number is greater than the second
  number.  The <code>&gt;=</code> comparison will be true if and only if
  the first number is greater than or equal to the second number.</p>
  
  <note>
  
  <p>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:</p>
  
  <eg><![CDATA[<xsl:if test="@value &lt; 10">...</xsl:if>]]></eg>
  
  </note>
  
  <scrap>
  <head></head>
  <prod id="NT-OrExpr">
  <lhs>OrExpr</lhs>
  <rhs><nt def="NT-AndExpr">AndExpr</nt></rhs>
  <rhs>| <nt def="NT-OrExpr">OrExpr</nt> 'or' <nt def="NT-AndExpr">AndExpr</nt></rhs>
  </prod>
  <prod id="NT-AndExpr">
  <lhs>AndExpr</lhs>
  <rhs><nt def="NT-EqualityExpr">EqualityExpr</nt></rhs>
  <rhs>| <nt def="NT-AndExpr">AndExpr</nt> 'and' <nt def="NT-EqualityExpr">EqualityExpr</nt></rhs>
  </prod>
  <prod id="NT-EqualityExpr">
  <lhs>EqualityExpr</lhs>
  <rhs><nt def="NT-RelationalExpr">RelationalExpr</nt></rhs>
  <rhs>| <nt def="NT-EqualityExpr">EqualityExpr</nt> '=' <nt def="NT-RelationalExpr">RelationalExpr</nt></rhs>
  <rhs>| <nt def="NT-EqualityExpr">EqualityExpr</nt> '!=' <nt def="NT-RelationalExpr">RelationalExpr</nt></rhs>
  </prod>
  <prod id="NT-RelationalExpr">
  <lhs>RelationalExpr</lhs>
  <rhs><nt def="NT-AdditiveExpr">AdditiveExpr</nt></rhs>
  <rhs>| <nt def="NT-RelationalExpr">RelationalExpr</nt> '&lt;' <nt def="NT-AdditiveExpr">AdditiveExpr</nt></rhs>
  <rhs>| <nt def="NT-RelationalExpr">RelationalExpr</nt> '>' <nt def="NT-AdditiveExpr">AdditiveExpr</nt></rhs>
  <rhs>| <nt def="NT-RelationalExpr">RelationalExpr</nt> '&lt;=' <nt def="NT-AdditiveExpr">AdditiveExpr</nt></rhs>
  <rhs>| <nt def="NT-RelationalExpr">RelationalExpr</nt> '>=' <nt def="NT-AdditiveExpr">AdditiveExpr</nt></rhs>
  </prod>
  </scrap>
  
  <note><p>The effect of the above grammar is that the order of
  precedence is (lowest precedence first):</p>
  
  <ulist>
  
  <item><p><code>or</code></p></item>
  
  <item><p><code>and</code></p></item>
  
  <item><p><code>=</code>, <code>!=</code></p></item>
  
  <item><p><code>&lt;=</code>, <code>&lt;</code>, <code>&gt;=</code>,
  <code>&gt;</code></p></item>
  
  </ulist>
  
  <p>and the operators are all left associative.</p>
  
  <p>For example, <code>3 &gt; 2 &gt; 1</code> is equivalent to <code>(3
  &gt; 2) &gt; 1</code>, which evaluates to false.</p>
  
  </note>
  
  </div2>
  
  <div2 id="numbers">
  <head>Numbers</head>
  
  <p>A number represents a floating-point number.  A number can have any
  double-precision 64-bit format IEEE 754 value <bibref ref="IEEE754"/>.
  These include a special <quote>Not-a-Number</quote> (NaN) value,
  positive and negative infinity, and positive and negative zero.  See
  <loc href="http://java.sun.com/docs/books/jls/html/4.doc.html#9208"
  >Section 4.2.3</loc> of <bibref ref="JLS"/> 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 <function>number</function> function.</p>
  
  <p>The <code>+</code> operator performs addition.</p>
  
  <p>The <code>-</code> operator performs subtraction.</p>
  
  <note><p>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 <termref
  def="dt-string-value">string-value</termref> of the first
  <code>foo</code> child element to a number and the result of
  converting the <termref def="dt-string-value">string-value</termref>
  of the first <code>bar</code> child to a number.</p></note>
   
  <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>
  
  <ulist>
  <item><p><code>5 mod 2</code> returns <code>1</code></p></item>
  <item><p><code>5 mod -2</code> returns <code>1</code></p></item>
  <item><p><code>-5 mod 2</code> returns <code>-1</code></p></item>
  <item><p><code>-5 mod -2</code> returns <code>-1</code></p></item>
  </ulist>
  
  <note><p>This is the same as the <code>%</code> operator in Java and
  ECMAScript.</p></note>
  
  <note><p>This is not the same as the IEEE 754 remainder operation, which
  returns the remainder from a rounding division.</p></note>
  
  <scrap>
  <head>Numeric Expressions</head>
  <prodgroup pcw5="1" pcw2="10" pcw4="21">
  <prod id="NT-AdditiveExpr">
  <lhs>AdditiveExpr</lhs>
  <rhs><nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt></rhs>
  <rhs>| <nt def="NT-AdditiveExpr">AdditiveExpr</nt> '+' <nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt></rhs>
  <rhs>| <nt def="NT-AdditiveExpr">AdditiveExpr</nt> '-' <nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt></rhs>
  </prod>
  <prod id="NT-MultiplicativeExpr">
  <lhs>MultiplicativeExpr</lhs>
  <rhs><nt def="NT-UnaryExpr">UnaryExpr</nt></rhs>
  <rhs>| <nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt> <nt def="NT-MultiplyOperator">MultiplyOperator</nt> <nt def="NT-UnaryExpr">UnaryExpr</nt></rhs>
  <rhs>| <nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt> 'div' <nt def="NT-UnaryExpr">UnaryExpr</nt></rhs>
  <rhs>| <nt def="NT-MultiplicativeExpr">MultiplicativeExpr</nt> 'mod' <nt def="NT-UnaryExpr">UnaryExpr</nt></rhs>
  </prod>
  <prod id="NT-UnaryExpr">  
  <lhs>UnaryExpr</lhs>
  <rhs><nt def="NT-UnionExpr">UnionExpr</nt></rhs>
  <rhs>| '-' <nt def="NT-UnaryExpr">UnaryExpr</nt></rhs>
  </prod>
  </prodgroup>
  </scrap>
  
  </div2>
  
  <div2 id="strings">
  <head>Strings</head>
  
  <p>Strings consist of a sequence of zero or more characters, where a
  character is defined as in the XML Recommendation <bibref ref="XML"/>.
  A single character in XPath thus corresponds to a single Unicode
  abstract character with a single corresponding Unicode scalar value
  (see <bibref ref="UNICODE"/>); 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>
  
  <note><p>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 <bibref
  ref="CHARMOD"/>.</p></note>
  
  </div2>
  
  <div2 id="exprlex">
  <head>Lexical Structure</head>
  
  <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: <nt
  def="NT-ExprWhitespace">ExprWhitespace</nt> may be freely added within
  patterns before or after any <nt
  def="NT-ExprToken">ExprToken</nt>.</p>
  
  <p>The following special tokenization rules must be applied in the
  order specified to disambiguate the <nt
  def="NT-ExprToken">ExprToken</nt> grammar:</p>
  
  <ulist>
  
  <item><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 <nt
  def="NT-Operator">Operator</nt>, then a <code>*</code> must be
  recognized as a <nt def="NT-MultiplyOperator">MultiplyOperator</nt>
  and an <xnt href="&XMLNames;#NT-NCName">NCName</xnt> must be
  recognized as an <nt
  def="NT-OperatorName">OperatorName</nt>.</p></item>
  
  <item><p>If the character following an <xnt
  href="&XMLNames;#NT-NCName">NCName</xnt> (possibly after intervening
  <nt def="NT-ExprWhitespace">ExprWhitespace</nt>) is <code>(</code>,
  then the token must be recognized as a <nt
  def="NT-NodeType">NodeType</nt> or a <nt
  def="NT-FunctionName">FunctionName</nt>.</p></item>
  
  <item><p>If the two characters following an <xnt
  href="&XMLNames;#NT-NCName">NCName</xnt> (possibly after intervening
  <nt def="NT-ExprWhitespace">ExprWhitespace</nt>) are <code>::</code>,
  then the token must be recognized as an <nt
  def="NT-AxisName">AxisName</nt>.</p></item>
  
  <item><p>Otherwise, the token must not be recognized as a <nt
  def="NT-MultiplyOperator">MultiplyOperator</nt>, an <nt
  def="NT-OperatorName">OperatorName</nt>, a <nt
  def="NT-NodeType">NodeType</nt>, a <nt
  def="NT-FunctionName">FunctionName</nt>, or an <nt
  def="NT-AxisName">AxisName</nt>.</p></item>
  
  </ulist>
  
  <scrap>
  <head>Expression Lexical Structure</head>
  <prodgroup pcw5="1" pcw2="8" pcw4="21">
  <prod id="NT-ExprToken">
  <lhs>ExprToken</lhs>
  <rhs>'(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'</rhs>
  <rhs>| <nt def="NT-NameTest">NameTest</nt></rhs>
  <rhs>| <nt def="NT-NodeType">NodeType</nt></rhs>
  <rhs>| <nt def="NT-Operator">Operator</nt></rhs>
  <rhs>| <nt def="NT-FunctionName">FunctionName</nt></rhs>
  <rhs>| <nt def="NT-AxisName">AxisName</nt></rhs>
  <rhs>| <nt def="NT-Literal">Literal</nt></rhs>
  <rhs>| <nt def="NT-Number">Number</nt></rhs>
  <rhs>| <nt def="NT-VariableReference">VariableReference</nt></rhs>
  </prod>
  <prod id="NT-Literal">
  <lhs>Literal</lhs>
  <rhs>'"' [^"]* '"'</rhs>
  <rhs>| "'" [^']* "'"</rhs>
  </prod>
  <prod id="NT-Number">
  <lhs>Number</lhs>
  <rhs><nt def="NT-Digits">Digits</nt> ('.' <nt def="NT-Digits">Digits</nt>?)?</rhs>
  <rhs>| '.' <nt def="NT-Digits">Digits</nt></rhs>
  </prod>
  <prod id="NT-Digits">
  <lhs>Digits</lhs>
  <rhs>[0-9]+</rhs>
  </prod>
  <prod id="NT-Operator">
  <lhs>Operator</lhs>
  <rhs><nt def="NT-OperatorName">OperatorName</nt></rhs>
  <rhs>| <nt def="NT-MultiplyOperator">MultiplyOperator</nt></rhs>
  <rhs>| '/' | '//' | '|' | '+' | '-' | '=' | '!=' | '&lt;' | '&lt;=' | '&gt;' | '&gt;='</rhs>
  </prod>
  <prod id="NT-OperatorName">
  <lhs>OperatorName</lhs>
  <rhs>'and' | 'or' | 'mod' | 'div'</rhs>
  </prod>
  <prod id="NT-MultiplyOperator">
  <lhs>MultiplyOperator</lhs>
  <rhs>'*'</rhs>
  </prod>
  <prod id="NT-FunctionName">
  <lhs>FunctionName</lhs>
  <rhs>
  <xnt href="&XMLNames;#NT-QName">QName</xnt>
  - <nt def="NT-NodeType">NodeType</nt>
  </rhs>
  </prod>
  <prod id="NT-VariableReference">
  <lhs>VariableReference</lhs>
  <rhs>'$' <xnt href="&XMLNames;#NT-QName">QName</xnt></rhs>
  </prod>
  <prod id="NT-NameTest">
  <lhs>NameTest</lhs>
  <rhs>'*'</rhs>
  <rhs>| <xnt href="&XMLNames;#NT-NCName">NCName</xnt> ':' '*'</rhs>
  <rhs>| <xnt href="&XMLNames;#NT-QName">QName</xnt></rhs>
  </prod>
  <prod id="NT-NodeType">
  <lhs>NodeType</lhs>
  <rhs>'comment'</rhs>
  <rhs>| 'text'</rhs>
  <rhs>| 'processing-instruction'</rhs>
  <rhs>| 'node'</rhs>
  </prod>
  <prod id="NT-ExprWhitespace">
  <lhs>ExprWhitespace</lhs>
  <rhs><xnt href="&XML;#NT-S">S</xnt></rhs>
  </prod>
  </prodgroup>
  </scrap>
  
  </div2>
  
  </div1>
  
  <div1 id="corelib">
  <head>Core Function Library</head>
  
  <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>
  
  <div2>
  <head>Node Set Functions</head>
  
  <proto name="last" return-type="number"></proto>
  
  <p>The <function>last</function> function returns a number equal to
  the <termref def="dt-context-size">context size</termref> from the
  expression evaluation context.</p>
  
  <proto name="position" return-type="number"></proto>
  
  <p>The <function>position</function> function returns a number equal to
  the <termref def="dt-context-position">context position</termref> from
  the expression evaluation context.</p>
  
  <proto name="count" return-type="number"><arg type="node-set"/></proto>
  
  <p>The <function>count</function> function returns the number of nodes in the
  argument node-set.</p>
  
  <proto name="id" return-type="node-set"><arg type="object"/></proto>
  
  <p>The <function>id</function> function selects elements by their
  unique ID (see <specref ref="unique-id"/>).  When the argument to
  <function>id</function> is of type node-set, then the result is the
  union of the result of applying <function>id</function> to the
  <termref def="dt-string-value">string-value</termref> of each of the
  nodes in the argument node-set.  When the argument to
  <function>id</function> is of any other type, the argument is
  converted to a string as if by a call to the
  <function>string</function> function; the string is split into a
  whitespace-separated list of tokens (whitespace is any sequence of
  characters matching the production <xnt href="&XML;#NT-S">S</xnt>);
  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>
  
  <ulist>
  <item><p><code>id("foo")</code> selects the element with unique ID
  <code>foo</code></p></item>
  <item><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></item>
  </ulist>
  
  <proto name="local-name" return-type="string"><arg occur="opt" type="node-set"/></proto>
  
  <p>The <function>local-name</function> function returns the local part
  of the <termref def="dt-expanded-name">expanded-name</termref> of the
  node in the argument node-set that is first in <termref
  def="dt-document-order">document order</termref>. If the argument
  node-set is empty or the first node has no <termref
  def="dt-expanded-name">expanded-name</termref>, 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>
  
  <proto name="namespace-uri" return-type="string"><arg occur="opt"
  type="node-set"/></proto>
  
  <p>The <function>namespace-uri</function> function returns the
  namespace URI of the <termref
  def="dt-expanded-name">expanded-name</termref> of the node in the
  argument node-set that is first in <termref
  def="dt-document-order">document order</termref>. If the argument
  node-set is empty, the first node has no <termref
  def="dt-expanded-name">expanded-name</termref>, or the namespace URI
  of the <termref def="dt-expanded-name">expanded-name</termref> 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>
  
  <note><p>The string returned by the
  <function>namespace-uri</function> function will be empty except for
  element nodes and attribute nodes.</p></note>
  
  <proto name="name" return-type="string"><arg occur="opt" type="node-set"/></proto>
  
  <p>The <function>name</function> function returns a string containing
  a <xnt href="&XMLNames;#NT-QName">QName</xnt> representing the
  <termref def="dt-expanded-name">expanded-name</termref> of the node in
  the argument node-set that is first in <termref
  def="dt-document-order">document order</termref>. The <xnt
  href="&XMLNames;#NT-QName">QName</xnt> must represent the <termref
  def="dt-expanded-name">expanded-name</termref> with respect to the
  namespace declarations in effect on the node whose <termref
  def="dt-expanded-name">expanded-name</termref> is being represented.
  Typically, this will be the <xnt
  href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt href="&XMLNames;#NT-QName">QName</xnt> used in the XML
  source. If the argument node-set is empty or the first node has no
  <termref def="dt-expanded-name">expanded-name</termref>, 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>
  
  <note><p>The string returned by the <function>name</function> function
  will be the same as the string returned by the
  <function>local-name</function> function except for element nodes and
  attribute nodes.</p></note>
  
  </div2>
  
  <div2>
  <head>String Functions</head>
  
  <proto name="string" return-type="string"><arg occur="opt" type="object"/></proto>
  
  <p>The <function>string</function> function converts an object to a string
  as follows:</p>
  
  <ulist>
  
  <item><p>A node-set is converted to a string by returning the <termref
  def="dt-string-value">string-value</termref> of the node in the
  node-set that is first in <termref def="dt-document-order">document
  order</termref>.  If the node-set is empty, an empty string is
  returned.</p></item>
  
  <item><p>A number is converted to a string as follows</p>
  
  <ulist>
  
  <item><p>NaN is converted to the string <code>NaN</code></p></item>
  
  <item><p>positive zero is converted to the string
  <code>0</code></p></item>
  
  <item><p>negative zero is converted to the string
  <code>0</code></p></item>
  
  <item><p>positive infinity is converted to the string
  <code>Infinity</code></p></item>
  
  <item><p>negative infinity is converted to the string
  <code>-Infinity</code></p></item>
  
  <item><p>if the number is an integer, the number is represented in
  decimal form as a <nt def="NT-Number">Number</nt> with no decimal
  point and no leading zeros, preceded by a minus sign (<code>-</code>)
  if the number is negative</p></item>
  
  <item><p>otherwise, the number is represented in decimal form as a <nt
  def="NT-Number">Number</nt> 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></item>
  
  </ulist>
  
  </item>
  
  <item><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></item>
  
  <item><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></item>
  
  </ulist>
  
  <p>If the argument is omitted, it defaults to a node-set with the
  context node as its only member.</p>
  
  <note><p>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 <bibref ref="XSLT"/> provide this
  functionality.</p></note>
  
  <proto name="concat" return-type="string"><arg type="string"/><arg type="string"/><arg occur="rep" type="string"/></proto>
  
  <p>The <function>concat</function> function returns the concatenation of its
  arguments.</p>
  
  <proto name="starts-with" return-type="boolean"><arg type="string"/><arg type="string"/></proto>
  
  <p>The <function>starts-with</function> function returns true if the
  first argument string starts with the second argument string, and
  otherwise returns false.</p>
  
  <proto name="contains" return-type="boolean"><arg type="string"/><arg type="string"/></proto>
  
  <p>The <function>contains</function> function returns true if the first
  argument string contains the second argument string, and otherwise
  returns false.</p>
  
  <proto name="substring-before" return-type="string"><arg type="string"/><arg type="string"/></proto>
  
  <p>The <function>substring-before</function> 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>
  
  <proto name="substring-after" return-type="string"><arg type="string"/><arg type="string"/></proto>
  
  <p>The <function>substring-after</function> 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>
  
  <proto name="substring" return-type="string">
  <arg type="string"/>
  <arg type="number"/>
  <arg type="number" occur="opt"/>
  </proto>
  
  <p>The <function>substring</function> 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 <specref
  ref="strings"/>) 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>
  
  <note><p>This differs from Java and ECMAScript, in which the
  <code>String.substring</code> method treats the position of the first
  character as 0.</p></note>
  
  <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
  <function>round</function> function. The following examples illustrate
  various unusual cases:</p>
  
  <ulist>
  
  <item><p><code>substring("12345", 1.5, 2.6)</code> returns
  <code>"234"</code></p></item>
  
  <item><p><code>substring("12345", 0, 3)</code> returns
  <code>"12"</code></p></item>
  
  <item><p><code>substring("12345", 0 div 0, 3)</code> returns
  <code>""</code></p></item>
  
  <item><p><code>substring("12345", 1, 0 div 0)</code> returns
  <code>""</code></p></item>
  
  <item><p><code>substring("12345", -42, 1 div 0)</code> returns
  <code>"12345"</code></p></item>
  
  <item><p><code>substring("12345", -1 div 0, 1 div 0)</code> returns
  <code>""</code></p></item>
  
  </ulist>
  
  <proto name="string-length" return-type="number">
  <arg type="string" occur="opt"/>
  </proto>
  
  <p>The <function>string-length</function> returns the number of
  characters in the string (see <specref ref="strings"/>).  If the
  argument is omitted, it defaults to the context node converted to a
  string, in other words the <termref
  def="dt-string-value">string-value</termref> of the context node.</p>
  
  <proto name="normalize-space" return-type="string"><arg occur="opt" type="string"/></proto>
  
  <p>The <function>normalize-space</function> 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 <xnt
  href="&XML;#NT-S">S</xnt> production in XML.  If the argument is
  omitted, it defaults to the context node converted to a string, in
  other words the <termref def="dt-string-value">string-value</termref>
  of the context node.</p>
  
  <proto name="translate" return-type="string"><arg type="string"/><arg type="string"/><arg type="string"/></proto>
  
  <p>The <function>translate</function> 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>
  
  <note><p>The <function>translate</function> function is not a sufficient
  solution for case conversion in all languages.  A future version of
  XPath may provide additional functions for case conversion.</p></note>
  
  </div2>
  
  <div2>
  <head>Boolean Functions</head>
  
  <proto name="boolean" return-type="boolean"><arg type="object"/></proto>
  
  <p>The <function>boolean</function> function converts its argument to a
  boolean as follows:</p>
  
  <ulist>
  
  <item><p>a number is true if and only if it is neither positive or
  negative zero nor NaN</p></item>
  
  <item><p>a node-set is true if and only if it is non-empty</p></item>
  
  <item><p>a string is true if and only if its length is non-zero</p></item>
  
  <item><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></item>
  
  </ulist>
  
  <proto name="not" return-type="boolean"><arg type="boolean"/></proto>
  
  <p>The <function>not</function> function returns true if its argument is
  false, and false otherwise.</p>
  
  <proto name="true" return-type="boolean"></proto>
  
  <p>The <function>true</function> function returns true.</p>
  
  <proto name="false" return-type="boolean"></proto>
  
  <p>The <function>false</function> function returns false.</p>
  
  <proto name="lang" return-type="boolean"><arg type="string"/></proto>
  
  <p>The <function>lang</function> 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 <function>lang</function> returns false. If there is such an
  attribute, then <function>lang</function> 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>
  
  <eg><![CDATA[<para xml:lang="en"/>
  <div xml:lang="en"><para/></div>
  <para xml:lang="EN"/>
  <para xml:lang="en-us"/>]]></eg>
  </div2>
  
  <div2>
  <head>Number Functions</head>
  
  <proto name="number" return-type="number"><arg occur="opt" type="object"/></proto>
  
  <p>The <function>number</function> function converts its argument to a
  number as follows:</p>
  
  <ulist>
  
  <item><p>a string that consists of optional whitespace followed by an
  optional minus sign followed by a <nt def="NT-Number">Number</nt>
  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></item>
  
  <item><p>boolean true is converted to 1; boolean false is converted to
  0</p></item>
  
  <item>
  
  <p>a node-set is first converted to a string as if by a call to the
  <function>string</function> function and then converted in the same way as a
  string argument</p>
  
  </item>
  
  <item><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></item>
  
  </ulist>
  
  <p>If the argument is omitted, it defaults to a node-set with the
  context node as its only member.</p>
  
  <note><p>The <function>number</function> 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 <function>number</function> function cannot be used
  unless the language-neutral format used by the element is consistent
  with the XPath syntax for a <nt
  def="NT-Number">Number</nt>.</p></note>
  
  <proto name="sum" return-type="number"><arg type="node-set"/></proto>
  
  <p>The <function>sum</function> function returns the sum, for each
  node in the argument node-set, of the result of converting the
  <termref def="dt-string-value">string-value</termref>s of the node to
  a number.</p>
  
  <proto name="floor" return-type="number"><arg type="number"/></proto>
  
  <p>The <function>floor</function> function returns the largest (closest to
  positive infinity) number that is not greater than the argument and
  that is an integer.</p>
  
  <proto name="ceiling" return-type="number"><arg type="number"/></proto>
  
  <p>The <function>ceiling</function> function returns the smallest (closest
  to negative infinity) number that is not less than the argument and
  that is an integer.</p>
  
  <proto name="round" return-type="number"><arg type="number"/></proto>
  
  <p>The <function>round</function> 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>
  
  <note><p>For these last two cases, the result of calling the
  <function>round</function> function is not the same as the result of
  adding 0.5 and then calling the <function>floor</function>
  function.</p></note>
  
  </div2>
  
  
  </div1>
  
  
  <div1 id="data-model">
  <head>Data Model</head>
  
  <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 <bibref
  ref="XINFO"/> is described in <specref ref="infoset"/>.</p>
  
  <p>XML documents operated on by XPath must conform to the XML
  Namespaces Recommendation <bibref ref="XMLNAMES"/>.</p>
  
  <p>The tree contains nodes.  There are seven types of node:</p>
  
  <ulist>
  
  <item><p>root nodes</p></item>
  
  <item><p>element nodes</p></item>
  
  <item><p>text nodes</p></item>
  
  <item><p>attribute nodes</p></item>
  
  <item><p>namespace nodes</p></item>
  
  <item><p>processing instruction nodes</p></item>
  
  <item><p>comment nodes</p></item>
  
  </ulist>
  
  <p><termdef term="String Value" id="dt-string-value">For every type of
  node, there is a way of determining a <term>string-value</term> 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.</termdef></p>
  
  <note><p>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 <bibref ref="DOM"/>).</p></note>
  
  <p><termdef term="Expanded Name" id="dt-expanded-name">Some types of
  node also have an <term>expanded-name</term>, 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
  <bibref ref="RFC2396"/>; 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
  <termref def="dt-expanded-name">expanded-name</termref>s of nodes in
  the data model should be absolute.</termdef> Two <termref
  def="dt-expanded-name">expanded-name</termref>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><termdef id="dt-document-order" term="Document Order">There is an
  ordering, <term>document order</term>, 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.</termdef> <termdef
  id="dt-reverse-document-order" term="Reverse Document
  Order"><term>Reverse document order</term> is the reverse of <termref
  def="dt-document-order">document order</termref>.</termdef></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.  <termdef
  id="dt-parent" term="Parent">Every node other than the root node has
  exactly one <term>parent</term>, which is either an element node or
  the root node.</termdef> A root node or an element node is the parent
  of each of its child nodes. <termdef id="dt-descendants"
  term="Descendants">The <term>descendants</term> of a node are the
  children of the node and the descendants of the children of the
  node.</termdef></p>
  
  <div2 id="root-node">
  <head>Root Node</head>
  
  <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 <termref def="dt-string-value">string-value</termref> of the
  root node is the concatenation of the <termref
  def="dt-string-value">string-value</termref>s of all text node
  <termref def="dt-descendants">descendants</termref> of the root
  node in document order.</p>
  
  <p>The root node does not have an <termref
  def="dt-expanded-name">expanded-name</termref>.</p>
  
  </div2>
  
  <div2 id="element-nodes">
  <head>Element Nodes</head>
  
  <p>There is an element node for every element in the document.  An
  element node has an <termref
  def="dt-expanded-name">expanded-name</termref> computed by expanding
  the <xnt href="&XMLNames;#NT-QName">QName</xnt> of the element
  specified in the tag in accordance with the XML Namespaces
  Recommendation <bibref ref="XMLNAMES"/>.  The namespace URI of the
  element's <termref def="dt-expanded-name">expanded-name</termref> will
  be null if the <xnt href="&XMLNames;#NT-QName">QName</xnt> has no
  prefix and there is no applicable default namespace.</p>
  
  <note><p>In the notation of Appendix A.3 of <bibref ref="XMLNAMES"/>,
  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.</p></note>
  
  <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 <termref def="dt-string-value">string-value</termref> of an
  element node is the concatenation of the <termref
  def="dt-string-value">string-value</termref>s of all text node
  <termref def="dt-descendants">descendants</termref> of the element
  node in document order.</p>
  
  <div3 id="unique-id">
  <head>Unique IDs</head>
  
  <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>
  
  <note><p>If a document does not have a DTD, then no element in the
  document will have a unique ID.</p></note>
  
  </div3>
  
  </div2>
  
  <div2 id="attribute-nodes">
  <head>Attribute Nodes</head>
  
  <p>Each element node has an associated set of attribute nodes; the
  element is the <termref def="dt-parent">parent</termref> of each of
  these attribute nodes; however, an attribute node is not a child of
  its parent element.</p>
  
  <note><p>This is different from the DOM, which does not treat the
  element bearing an attribute as the parent of the attribute (see
  <bibref ref="DOM"/>).</p></note>
  
  <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>
  
  <note><p>The <code>=</code> operator tests whether two nodes have the
  same value, <emph>not</emph> 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.</p></note>
  
  <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 <termref
  def="dt-expanded-name">expanded-name</termref> and a <termref
  def="dt-string-value">string-value</termref>.  The <termref
  def="dt-expanded-name">expanded-name</termref> is computed by
  expanding the <xnt href="&XMLNames;#NT-QName">QName</xnt> specified in
  the tag in the XML document in accordance with the XML Namespaces
  Recommendation <bibref ref="XMLNAMES"/>.  The namespace URI of the
  attribute's name will be null if the <xnt
  href="&XMLNames;#NT-QName">QName</xnt> of the attribute does not have
  a prefix.</p>
  
  <note><p>In the notation of Appendix A.3 of <bibref ref="XMLNAMES"/>,
  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.</p></note>
  
  <p>An attribute node has a <termref
  def="dt-string-value">string-value</termref>.  The <termref
  def="dt-string-value">string-value</termref> is the normalized value
  as specified by the XML Recommendation <bibref ref="XML"/>.  An
  attribute whose normalized value is a zero-length string is not
  treated specially: it results in an attribute node whose <termref
  def="dt-string-value">string-value</termref> is a zero-length
  string.</p>
  
  <note><p>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.</p></note>
  
  <p>There are no attribute nodes corresponding to attributes that
  declare namespaces (see <bibref ref="XMLNAMES"/>).</p>
  
  </div2>
  
  <div2 id="namespace-nodes">
  <head>Namespace Nodes</head>
  
  <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 <bibref ref="XMLNAMES"/>) and one for
  the default namespace if one is in scope for the element.  The element
  is the <termref def="dt-parent">parent</termref> 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>
  
  <ulist>
  
  <item><p>for every attribute on the element whose name starts with
  <code>xmlns:</code>;</p></item>
  
  <item><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></item>
  
  <item>
  
  <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>
  
  <note><p>An attribute <code>xmlns=""</code> <quote>undeclares</quote>
  the default namespace (see <bibref ref="XMLNAMES"/>).</p></note>
  
  </item>
  
  </ulist>
  
  <p>A namespace node has an <termref
  def="dt-expanded-name">expanded-name</termref>: 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 <termref def="dt-string-value">string-value</termref> 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 <termref
  def="dt-expanded-name">expanded-name</termref>.</p>
  
  </div2>
  
  
  <div2>
  <head>Processing Instruction Nodes</head>
  
  <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 <termref
  def="dt-expanded-name">expanded-name</termref>: the local part is
  the processing instruction's target; the namespace URI is null.  The
  <termref def="dt-string-value">string-value</termref> 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>?&gt;</code>.</p>
  
  <note><p>The XML declaration is not a processing instruction.
  Therefore, there is no processing instruction node corresponding to the
  XML declaration.</p></note>
  
  </div2>
  
  <div2>
  <head>Comment Nodes</head>
  
  <p>There is a comment node for every comment, except for any comment that
  occurs within the document type declaration.</p>
  
  <p>The <termref def="dt-string-value">string-value</termref> of
  comment is the content of the comment not including the opening
  <code>&lt;!--</code> or the closing <code>--&gt;</code>.</p>
  
  <p>A comment node does not have an <termref
  def="dt-expanded-name">expanded-name</termref>.</p>
  
  </div2>
  
  <div2>
  <head>Text Nodes</head>
  
  <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
  <termref def="dt-string-value">string-value</termref> 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;]]&gt;</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>]]&gt;</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>
  
  <note><p>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.</p></note>
  
  <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 <bibref
  ref="XML"/>.</p>
  
  <p>A text node does not have an <termref
  def="dt-expanded-name">expanded-name</termref>.</p>
  
  </div2>
  
  </div1>
  
  <div1>
  <head>Conformance</head>
  
  <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 <bibref ref="XPTR"/> and <bibref ref="XSLT"/>) to
  specify criteria for conformance of implementations of XPath and does
  not define any conformance criteria for independent implementations of
  XPath.</p>
  
  </div1>
  
  </body>
  
  <back>
  <div1>
  <head>References</head>
  <div2>
  <head>Normative References</head>
  
  <blist>
  
  <bibl id="IEEE754" key="IEEE 754">Institute of Electrical and
  Electronics Engineers. <emph>IEEE Standard for Binary Floating-Point
  Arithmetic</emph>. ANSI/IEEE Std 754-1985.</bibl>
  
  <bibl id="RFC2396" key="RFC2396">T. Berners-Lee, R. Fielding, and
  L. Masinter.  <emph>Uniform Resource Identifiers (URI): Generic
  Syntax</emph>. IETF RFC 2396. See <loc
  href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</loc>.</bibl>
  
  <bibl id="XML" key="XML">World Wide Web Consortium. <emph>Extensible
  Markup Language (XML) 1.0.</emph> W3C Recommendation. See <loc
  href="http://www.w3.org/TR/1998/REC-xml-19980210">http://www.w3.org/TR/1998/REC-xml-19980210</loc></bibl>
  
  <bibl id="XMLNAMES" key="XML Names">World Wide Web
  Consortium. <emph>Namespaces in XML.</emph> W3C Recommendation. See
  <loc
  href="http://www.w3.org/TR/REC-xml-names">http://www.w3.org/TR/REC-xml-names</loc></bibl>
  
  </blist>
  </div2>
  <div2>
  <head>Other References</head>
  
  <blist>
  
  <bibl id="CHARMOD" key="Character Model">World Wide Web Consortium.
  <emph>Character Model for the World Wide Web.</emph> W3C Working
  Draft. See <loc
  href="http://www.w3.org/TR/WD-charmod">http://www.w3.org/TR/WD-charmod</loc></bibl>
  
  <bibl id="DOM" key="DOM">World Wide Web Consortium.  <emph>Document
  Object Model (DOM) Level 1 Specification.</emph> W3C
  Recommendation. See <loc href="http://www.w3.org/TR/REC-DOM-Level-1"
  >http://www.w3.org/TR/REC-DOM-Level-1</loc></bibl>
  
  <bibl id="JLS" key="JLS">J. Gosling, B. Joy, and G. Steele.  <emph>The
  Java Language Specification</emph>. See <loc
  href="http://java.sun.com/docs/books/jls/index.html"
  >http://java.sun.com/docs/books/jls/index.html</loc>.</bibl>
  
  <bibl id="ISO10646" key="ISO/IEC 10646">ISO (International
  Organization for Standardization).  <emph>ISO/IEC 10646-1:1993,
  Information technology -- Universal Multiple-Octet Coded Character Set
  (UCS) -- Part 1: Architecture and Basic Multilingual Plane</emph>.
  International Standard. See <loc
  href="http://www.iso.ch/cate/d18741.html">http://www.iso.ch/cate/d18741.html</loc>.</bibl>
  
  <bibl id="TEI" key="TEI">C.M. Sperberg-McQueen, L. Burnard
  <emph>Guidelines for Electronic Text Encoding and
  Interchange</emph>. See <loc href="http://etext.virginia.edu/TEI.html"
  >http://etext.virginia.edu/TEI.html</loc>.</bibl>
  
  <bibl id="UNICODE" key="Unicode">Unicode Consortium. <emph>The Unicode
  Standard</emph>.  See <loc
  href="http://www.unicode.org/unicode/standard/standard.html"
  >http://www.unicode.org/unicode/standard/standard.html</loc>.</bibl>
  
  <bibl id="XINFO" key="XML Infoset">World Wide Web
  Consortium. <emph>XML Information Set.</emph> W3C Working Draft. See
  <loc
  href="http://www.w3.org/TR/xml-infoset">http://www.w3.org/TR/xml-infoset</loc>
  </bibl>
  
  <bibl id="XPTR" key="XPointer">World Wide Web Consortium. <emph>XML
  Pointer Language (XPointer).</emph> W3C Working Draft. See <loc
  href="http://www.w3.org/TR/WD-xptr"
  >http://www.w3.org/TR/WD-xptr</loc></bibl>
  
  <bibl id="XQL" key="XQL">J. Robie, J. Lapp, D. Schach.
  <emph>XML Query Language (XQL)</emph>. See
  <loc href="http://www.w3.org/TandS/QL/QL98/pp/xql.html"
  >http://www.w3.org/TandS/QL/QL98/pp/xql.html</loc></bibl>
  
  <bibl id="XSLT" key="XSLT">World Wide Web Consortium.  <emph>XSL
  Transformations (XSLT).</emph> W3C Recommendation.  See <loc
  href="http://www.w3.org/TR/xslt"
  >http://www.w3.org/TR/xslt</loc></bibl>
  
  </blist>
  
  </div2>
  </div1>
  
  <inform-div1 id="infoset">
  <head>XML Information Set Mapping</head>
  
  <p>The nodes in the XPath data model can be derived from the
  information items provided by the XML Information Set <bibref
  ref="XINFO"/> as follows:</p>
  
  <note><p>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 <loc
  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</loc>
  (<loc href="http://cgi.w3.org/MemberAccess/">members
  only</loc>).</p></note>
  
  <ulist>
  
  <item><p>The root node comes from the document information item.  The
  children of the root node come from the <emph
  role="infoset-property">children</emph> and <emph
  role="infoset-property">children - comments</emph>
  properties.</p></item>
  
  <item><p>An element node comes from an element information item.  The
  children of an element node come from the <emph
  role="infoset-property">children</emph> and <emph
  role="infoset-property">children - comments</emph> properties. The
  attributes of an element node come from the <emph
  role="infoset-property">attributes</emph> property.  The namespaces
  of an element node come from the <emph
  role="infoset-property">in-scope namespaces</emph> property.  The
  local part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the element node
  comes from the <emph role="infoset-property">local name</emph>
  property.  The namespace URI of the <termref
  def="dt-expanded-name">expanded-name</termref> of the element node
  comes from the <emph role="infoset-property">namespace URI</emph>
  property. The unique ID of the element node comes from the <emph
  role="infoset-property">children</emph> property of the attribute
  information item in the <emph
  role="infoset-property">attributes</emph> property that has an <emph
  role="infoset-property">attribute type</emph> property equal to
  <code>ID</code>.</p></item>
  
  <item><p>An attribute node comes from an attribute information item.
  The local part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the attribute node
  comes from the <emph role="infoset-property">local name</emph>
  property.  The namespace URI of the <termref
  def="dt-expanded-name">expanded-name</termref> of the attribute node
  comes from the <emph role="infoset-property">namespace URI</emph>
  property. The <termref def="dt-string-value">string-value</termref> of
  the node comes from concatenating the <emph
  role="infoset-property">character code</emph> property of each member
  of the <emph role="infoset-property">children</emph>
  property.</p></item>
  
  <item><p>A text node comes from a sequence of one or more consecutive
  character information items.  The <termref
  def="dt-string-value">string-value</termref> of the node comes from
  concatenating the <emph role="infoset-property">character code</emph>
  property of each of the character information items.</p></item>
  
  <item><p>A processing instruction node comes from a processing
  instruction information item.  The local part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the node comes from
  the <emph role="infoset-property">target</emph> property. (The
  namespace URI part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the node is null.)
  The <termref def="dt-string-value">string-value</termref> of the node
  comes from the <emph role="infoset-property">content</emph>
  property. There are no processing instruction nodes for processing
  instruction items that are children of document type declaration
  information item.</p></item>
  
  <item><p>A comment node comes from a comment information item.  The
  <termref def="dt-string-value">string-value</termref> of the node
  comes from the <emph role="infoset-property">content</emph> property.
  There are no comment nodes for comment information items that are
  children of document type declaration information item.</p></item>
  
  <item><p>A namespace node comes from a namespace declaration
  information item.  The local part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the node comes from
  the <emph role="infoset-property">prefix</emph> property.  (The
  namespace URI part of the <termref
  def="dt-expanded-name">expanded-name</termref> of the node is null.)
  The <termref def="dt-string-value">string-value</termref> of the node
  comes from the <emph role="infoset-property">namespace URI</emph>
  property.</p></item>
  
  </ulist>
  
  </inform-div1>
  
  </back>
  </spec>
  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk056.xml
  
  Index: mk056.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>

  <!-- $Id: mk056.xml,v 1.1 2001/06/20 18:54:41 amiro Exp $ -->

  <!DOCTYPE spec SYSTEM "spec.dtd" [

  <!ENTITY XML "http://www.w3.org/TR/REC-xml">

  <!ENTITY XMLNames "http://www.w3.org/TR/REC-xml-names">

  <!ENTITY XSLT.ns "http://www.w3.org/1999/XSL/Transform">

  <!ENTITY XSLTA.ns "http://www.w3.org/1999/XSL/TransformAlias">

  <!ENTITY XSLFO.ns "http://www.w3.org/1999/XSL/Format">

  <!ENTITY XHTML.ns "http://www.w3.org/TR/xhtml1/strict">

  <!ENTITY year "1999">

  <!ENTITY month "November">

  <!ENTITY MM "11">

  <!ENTITY day "16">

  <!ENTITY DD "16">

  <!ENTITY YYYYMMDD "&year;&MM;&DD;">

  <!ENTITY LEV "REC">

  <!ENTITY XPath "http://www.w3.org/TR/xpath">

  <!ATTLIST xfunction href CDATA "&XPath;">

  <!-- DTD customizations -->

  <!ELEMENT proto (arg*)>

  <!ATTLIST proto

    name NMTOKEN #REQUIRED

    return-type (number|string|boolean|node-set|object) #REQUIRED

  >

  <!ELEMENT arg EMPTY>

  <!ATTLIST arg

    type (number|string|boolean|node-set|object) #REQUIRED

    occur (opt|rep) #IMPLIED

  >

  <!ELEMENT function (#PCDATA)>

  <!ELEMENT xfunction (#PCDATA)>

  <!ATTLIST xfunction href CDATA #REQUIRED>

  <!ELEMENT e:element-syntax

    (e:in-category*, e:attribute*, (e:empty|e:text|e:element|e:model|e:sequence|e:choice))

  >

  <!ATTLIST e:element-syntax

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

    name NMTOKEN #REQUIRED

  >

  <!ELEMENT e:in-category EMPTY>

  <!ATTLIST

    e:in-category name NMTOKEN #REQUIRED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:attribute (e:attribute-value-template|(e:constant|e:data-type)+)>

  <!ATTLIST e:attribute

    name NMTOKEN #REQUIRED

    required (yes) #IMPLIED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:attribute-value-template (e:constant|e:data-type)+>

  <!ATTLIST e:attribute-value-template

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:constant EMPTY>

  <!ATTLIST

    e:constant value CDATA #REQUIRED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:data-type EMPTY>

  <!ATTLIST e:data-type

    name NMTOKEN #REQUIRED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:empty EMPTY>

  <!ATTLIST e:empty

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:text EMPTY>

  <!ATTLIST e:text

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:element EMPTY>

  <!ATTLIST e:element

    name NMTOKEN #REQUIRED

    repeat (zero-or-one|zero-or-more|one-or-more) #IMPLIED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:model EMPTY>

  <!ATTLIST e:model

    name NMTOKEN #REQUIRED

    repeat (zero-or-one|zero-or-more|one-or-more) #IMPLIED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:sequence (e:element|e:model|e:choice)+>

  <!ATTLIST e:sequence

    repeat (zero-or-one|zero-or-more|one-or-more) #IMPLIED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:choice (e:element|e:model|e:sequence)+>

  <!ATTLIST e:choice

    repeat (zero-or-one|zero-or-more|one-or-more) #IMPLIED

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ELEMENT e:element-syntax-summary EMPTY>

  <!ATTLIST e:element-syntax-summary 

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  <!ENTITY % local.illus.class "|proto|e:element-syntax|e:element-syntax-summary">

  <!ENTITY % local.tech.class "|function|xfunction">

  <!ENTITY % local.loc.class "|var">

  <!ELEMENT var (#PCDATA)>

  <!ATTLIST spec

    xmlns:e CDATA #FIXED "http://www.w3.org/1999/XSL/Spec/ElementSyntax"

  >

  ]>

  <spec xmlns:e="http://www.w3.org/1999/XSL/Spec/ElementSyntax">

  <header>

  <title>XSL Transformations (XSLT)</title>

  <version>Version 1.0</version>

  <w3c-designation>&LEV;-xslt-&YYYYMMDD;</w3c-designation>

  <w3c-doctype>W3C Recommendation</w3c-doctype>

  <pubdate><day>&day;</day><month>&month;</month><year>&year;</year></pubdate>

  <publoc>

  <loc href="http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;"

            >http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;</loc>

  <loc role="available-format"

  href="http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;.xml">XML</loc>

  <loc role="available-format"

  href="http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;.html">HTML</loc>

  <!--

  <loc href="http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;.pdf"

            >http://www.w3.org/TR/&year;/&LEV;-xslt-&YYYYMMDD;.pdf</loc>

  -->

  </publoc>

  <latestloc>

  <loc href="http://www.w3.org/TR/xslt"

            >http://www.w3.org/TR/xslt</loc>

  </latestloc>

  <prevlocs>

  <loc href="http://www.w3.org/TR/1999/PR-xslt-19991008"

            >http://www.w3.org/TR/1999/PR-xslt-19991008</loc>

  <loc href="http://www.w3.org/1999/08/WD-xslt-19990813"

            >http://www.w3.org/1999/08/WD-xslt-19990813</loc>

  <loc href="http://www.w3.org/1999/07/WD-xslt-19990709"

            >http://www.w3.org/1999/07/WD-xslt-19990709</loc>

  <loc href="http://www.w3.org/TR/1999/WD-xslt-19990421"

            >http://www.w3.org/TR/1999/WD-xslt-19990421</loc>

  <loc href="http://www.w3.org/TR/1998/WD-xsl-19981216"

            >http://www.w3.org/TR/1998/WD-xsl-19981216</loc>

  <loc href="http://www.w3.org/TR/1998/WD-xsl-19980818"

            >http://www.w3.org/TR/1998/WD-xsl-19980818</loc>

  </prevlocs>

  <authlist>

  <author>

  <name>James Clark</name>

  <email href="mailto:jjc@jclark.com">jjc@jclark.com</email>

  </author>

  </authlist>

  

  <status>

  

  <p>This document has been reviewed by W3C Members and other interested

  parties and has been endorsed by the Director as a W3C <loc

  href="http://www.w3.org/Consortium/Process/#RecsW3C">Recommendation</loc>. 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

  <loc href="http://www.w3.org/&year;/&MM;/&LEV;-xslt-&YYYYMMDD;-errata"

  >http://www.w3.org/&year;/&MM;/&LEV;-xslt-&YYYYMMDD;-errata</loc>.</p>

  

  <p>Comments on this specification may be sent to <loc

  href="mailto:xsl-editors@w3.org">xsl-editors@w3.org</loc>; <loc

  href="http://lists.w3.org/Archives/Public/xsl-editors">archives</loc>

  of the comments are available.  Public discussion of XSL, including

  XSL Transformations, takes place on the <loc

  href="http://www.mulberrytech.com/xsl/xsl-list/index.html">XSL-List</loc>

  mailing list.</p>

  

  <p>The English version of this specification is the only normative

  version. However, for translations of this document, see <loc

  href="http://www.w3.org/Style/XSL/translations.html"

  >http://www.w3.org/Style/XSL/translations.html</loc>.</p>

  

  <p>A list of current W3C Recommendations and other technical documents

  can be found at <loc

  href="http://www.w3.org/TR">http://www.w3.org/TR</loc>.</p>

  

  <p>This specification has been produced as part of the <loc

  href="http://www.w3.org/Style/Activity">W3C Style activity</loc>.</p>

  

  </status>

  

  <abstract>

  

  <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>

  

  </abstract>

  

  <langusage>

  <language id="EN">English</language>

  <language id="ebnf">EBNF</language>

  </langusage>

  <revisiondesc>

  <slist>

  <sitem>See RCS log for revision history.</sitem>

  </slist>

  </revisiondesc>

  </header>

  <body>

  <div1>

  <head>Introduction</head>

  

  <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 <bibref ref="XML"/> conforming to the

  Namespaces in XML Recommendation <bibref ref="XMLNAMES"/>, which may

  include both elements that are defined by XSLT and elements that are

  not defined by XSLT.  <termdef id="dt-xslt-namespace" term="XSLT

  Namespace">XSLT-defined elements are distinguished by belonging to a

  specific XML namespace (see <specref ref="xslt-namespace"/>), which is

  referred to in this specification as the <term>XSLT

  namespace</term>.</termdef> 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 <bibref ref="XMLSTYLE"/>.  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 <specref ref="import"/>).</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 <specref ref="conflict"/>.</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

  <specref ref="data-example"/>). XSLT allows a simplified syntax for

  such stylesheets (see <specref ref="result-element-stylesheet"/>).</p>

  

  <p>When a template is instantiated, it is always instantiated with

  respect to a <termdef id="dt-current-node" term="Current

  Node"><term>current node</term></termdef> and a <termdef

  id="dt-current-node-list" term="Current Node List"><term>current node

  list</term></termdef>. 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 <specref ref="rules"/> and <specref

  ref="for-each"/>); 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 <bibref

  ref="XPATH"/> for selecting elements for processing, for conditional

  processing and for generating text.</p>

  

  <p>XSLT provides two <quote>hooks</quote> 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 <specref ref="extension"/>.</p>

  

  <note><p>The XSL WG intends to define such a mechanism in a future

  version of this specification or in a separate

  specification.</p></note>

  

  <p>The element syntax summary notation used to describe the syntax of

  XSLT-defined elements is described in <specref ref="notation"/>.</p>

  

  <p>The MIME media types <code>text/xml</code> and

  <code>application/xml</code> <bibref ref="RFC2376"/> 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>

  

  </div1>

  

  <div1>

  <head>Stylesheet Structure</head>

  

  <div2 id="xslt-namespace">

  <head>XSLT Namespace</head>

  

  <p>The XSLT namespace has the URI <code>&XSLT.ns;</code>.</p>

  

  <note><p>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 <specref

  ref="stylesheet-element"/> and <specref

  ref="result-element-stylesheet"/>).</p></note>

  

  <p>XSLT processors must use the XML namespaces mechanism <bibref

  ref="XMLNAMES"/> 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 <specref

  ref="element-syntax-summary"/>.  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 <specref

  ref="extension-element"/>.</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 <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> 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>

  

  <note><p>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.</p></note>

  

  

  </div2>

  

  <div2 id="stylesheet-element">

  <head>Stylesheet Element</head>

  

  <e:element-syntax name="stylesheet">

    <e:attribute name="id">

      <e:data-type name="id"/>

    </e:attribute>

    <e:attribute name="extension-element-prefixes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:attribute name="exclude-result-prefixes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:attribute name="version" required="yes">

      <e:data-type name="number"/>

    </e:attribute>

    <e:sequence>

      <e:element repeat="zero-or-more" name="import"/>

      <e:model name="top-level-elements"/>

    </e:sequence>

  </e:element-syntax>

  

  <e:element-syntax name="transform">

    <e:attribute name="id">

      <e:data-type name="id"/>

    </e:attribute>

    <e:attribute name="extension-element-prefixes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:attribute name="exclude-result-prefixes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:attribute name="version" required="yes">

      <e:data-type name="number"/>

    </e:attribute>

    <e:sequence>

      <e:element repeat="zero-or-more" name="import"/>

      <e:model name="top-level-elements"/>

    </e:sequence>

  </e:element-syntax>

  

  <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 <specref

  ref="forwards"/>).</p>

  

  <p>The <code>xsl:stylesheet</code> element may contain the following types

  of elements:</p>

  <ulist>

  <item><p><code>xsl:import</code></p></item>

  <item><p><code>xsl:include</code></p></item>

  <item><p><code>xsl:strip-space</code></p></item>

  <item><p><code>xsl:preserve-space</code></p></item>

  <item><p><code>xsl:output</code></p></item>

  <item><p><code>xsl:key</code></p></item>

  <item><p><code>xsl:decimal-format</code></p></item>

  <item><p><code>xsl:namespace-alias</code></p></item>

  <item><p><code>xsl:attribute-set</code></p></item>

  <item><p><code>xsl:variable</code></p></item>

  <item><p><code>xsl:param</code></p></item>

  <item><p><code>xsl:template</code></p></item>

  </ulist>

  

  <p><termdef id="dt-top-level" term="Top-level">An element occurring as

  a child of an <code>xsl:stylesheet</code> element is called a

  <term>top-level</term> element.</termdef></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>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

    <xsl:import href="..."/>

  

    <xsl:include href="..."/>

  

    <xsl:strip-space elements="..."/>

    

    <xsl:preserve-space elements="..."/>

  

    <xsl:output method="..."/>

  

    <xsl:key name="..." match="..." use="..."/>

  

    <xsl:decimal-format name="..."/>

  

    <xsl:namespace-alias stylesheet-prefix="..." result-prefix="..."/>

  

    <xsl:attribute-set name="...">

      ...

    </xsl:attribute-set>

  

    <xsl:variable name="...">...</xsl:variable>

  

    <xsl:param name="...">...</xsl:param>

  

    <xsl:template match="...">

      ...

    </xsl:template>

  

    <xsl:template name="...">

      ...

    </xsl:template>

  

  </xsl:stylesheet>]]></eg>

  

  <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>

  

  <ulist>

  

  <item><p>information used by extension elements or extension functions

  (see <specref ref="extension"/>),</p></item>

  

  <item><p>information about what to do with the result tree,</p></item>

  

  <item><p>information about how to obtain the source tree,</p></item>

  

  <item><p>metadata about the stylesheet,</p></item>

  

  <item><p>structured documentation for the stylesheet.</p></item>

  

  </ulist>

  

  </div2>

  

  <div2 id="result-element-stylesheet">

  <head>Literal Result Element as Stylesheet</head>

  

  <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 <specref

  ref="literal-result-element"/>).  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>

  

  <eg>&lt;html xsl:version="1.0"

        xmlns:xsl="&XSLT.ns;"

        xmlns="&XHTML.ns;"><![CDATA[

    <head>

      <title>Expense Report Summary</title>

    </head>

    <body>

      <p>Total Amount: <xsl:value-of select="expense-report/total"/></p>

    </body>

  </html>]]></eg>

  

  <p>has the same meaning as</p>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"

                  xmlns="&XHTML.ns;"><![CDATA[

  <xsl:template match="/">

  <html>

    <head>

      <title>Expense Report Summary</title>

    </head>

    <body>

      <p>Total Amount: <xsl:value-of select="expense-report/total"/></p>

    </body>

  </html>

  </xsl:template>

  </xsl:stylesheet>]]></eg>

  

  <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 <xnt href="&XPath;#NT-Number">Number</xnt>.  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 <specref

  ref="forwards"/>).</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 <termref def="dt-top-level">top-level</termref> 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>

  

  <note><p>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.</p></note>

  

  <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>

  

  </div2>

  

  <div2 id="qname">

  <head>Qualified Names</head>

  

  <p>The name of an internal XSLT object, specifically a named template

  (see <specref ref="named-templates"/>), a mode (see <specref

  ref="modes"/>), an attribute set (see <specref

  ref="attribute-sets"/>), a key (see <specref ref="key"/>), a

  decimal-format (see <specref ref="format-number"/>), a variable or a

  parameter (see <specref ref="variables"/>) is specified as a <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  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

  <xtermref href="&XPath;#dt-expanded-name">expanded-name</xtermref>

  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

  <emph>not</emph> used for unprefixed names.</p>

  

  </div2>

  

  <div2 id="forwards">

  <head>Forwards-Compatible Processing</head>

  

  <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

  <specref ref="result-element-stylesheet"/>).  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>

  

  <ulist>

  

  <item><p>if it is a <termref def="dt-top-level">top-level</termref>

  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></item>

  

  <item><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 <specref ref="fallback"/>;</p></item>

  

  <item><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></item>

  

  </ulist>

  

  <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>

  

  <eg>&lt;xsl:stylesheet version="1.1"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

    <xsl:template match="/">

      <xsl:choose>

        <xsl:when test="system-property('xsl:version') >= 1.1">

          <xsl:exciting-new-1.1-feature/>

        </xsl:when>

        <xsl:otherwise>

          <html>

          <head>

            <title>XSLT 1.1 required</title>

          </head>

          <body>

            <p>Sorry, this stylesheet requires XSLT 1.1.</p>

          </body>

          </html>

        </xsl:otherwise>

      </xsl:choose>

    </xsl:template>

  </xsl:stylesheet>]]></eg>

  

  <note><p>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 <specref ref="message"/>) to ensure that XSLT processors

  implementing earlier versions of XSL will not silently ignore the

  top-level element. For example,</p>

  

  <eg>&lt;xsl:stylesheet version="1.5"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

  

    <xsl:important-new-1.1-declaration/>

  

    <xsl:template match="/">

      <xsl:choose>

        <xsl:when test="system-property('xsl:version') &lt; 1.1">

          <xsl:message terminate="yes">

            <xsl:text>Sorry, this stylesheet requires XSLT 1.1.</xsl:text>

          </xsl:message>

        </xsl:when>

        <xsl:otherwise>

          ...

        </xsl:otherwise>

      </xsl:choose>

    </xsl:template>

    ...

  </xsl:stylesheet>]]></eg>

  </note>

  

  <p>If an <termref def="dt-expression">expression</termref> 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>

  

  <ulist>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><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></item>

  

  </ulist>

  

  

  </div2>

  

  <div2>

  <head>Combining Stylesheets</head>

  

  <p>XSLT provides two mechanisms to combine stylesheets:</p>

  

  <slist>

  

  <sitem>an inclusion mechanism that allows stylesheets to be combined

  without changing the semantics of the stylesheets being combined,

  and</sitem>

  

  <sitem>an import mechanism that allows stylesheets to override each

  other.</sitem>

  

  </slist>

  

  <div3 id="include">

  <head>Stylesheet Inclusion</head>

  

  <e:element-syntax name="include">

    <e:in-category name="top-level-element"/>

    <e:attribute name="href" required="yes">

      <e:data-type name="uri-reference"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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

  <specref ref="base-uri"/>).</p>

  

  <p>The <code>xsl:include</code> element is only allowed as a <termref

  def="dt-top-level">top-level</termref> 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

  <specref ref="result-element-stylesheet"/>.  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>

  

  <note><p>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>.</p></note>

  

  </div3>

  

  <div3 id="import">

  <head>Stylesheet Import</head>

  

  <e:element-syntax name="import">

    <e:attribute name="href" required="yes">

      <e:data-type name="uri-reference"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <specref ref="include"/>) 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

  <specref ref="base-uri"/>).</p>

  

  <p>The <code>xsl:import</code> element is only allowed as a <termref

  def="dt-top-level">top-level</termref> 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>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

    <xsl:import href="article.xsl"/>

    <xsl:import href="bigfont.xsl"/>

    <xsl:attribute-set name="note-style">

      <xsl:attribute name="font-style">italic</xsl:attribute>

    </xsl:attribute-set>

  </xsl:stylesheet>]]></eg>

  

  <p><termdef id="dt-import-tree" term="Import Tree">The

  <code>xsl:stylesheet</code> elements encountered during processing of

  a stylesheet that contains <code>xsl:import</code> elements are

  treated as forming an <term>import tree</term>.  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.</termdef> <termdef id="dt-import-precedence" term="Import

  Precedence">An <code>xsl:stylesheet</code> element in the import tree

  is defined to have lower <term>import precedence</term> 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).</termdef> 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>

  

  <ulist>

  

  <item><p>stylesheet <var>A</var> imports stylesheets <var>B</var>

  and <var>C</var> in that order;</p></item>

  

  <item><p>stylesheet <var>B</var> imports stylesheet

  <var>D</var>;</p></item>

  

  <item><p>stylesheet <var>C</var> imports stylesheet

  <var>E</var>.</p></item>

  

  </ulist>

  

  <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>

  

  <note><p>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.</p></note>

  

  <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

  <termref def="dt-import-tree">import tree</termref> will have a

  separate <code>xsl:stylesheet</code> for each place that it is

  imported.</p>

  

  <note><p>If <code>xsl:apply-imports</code> is used (see <specref

  ref="apply-imports"/>), the behavior may be different from the

  behavior if the stylesheet had been imported only at the place with

  the highest <termref def="dt-import-precedence">import

  precedence</termref>.</p></note>

  

  </div3>

  

  </div2>

  

  <div2>

  <head>Embedding Stylesheets</head>

  

  <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>

  

  <slist>

  

  <sitem>the XSLT stylesheet may be textually embedded in a non-XML

  resource, or</sitem>

  

  <sitem>the <code>xsl:stylesheet</code> element may occur in an XML

  document other than as the document element.</sitem>

  

  </slist>

  

  <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>

  

  <note><p>In order for such an attribute to be used with the XPath

  <xfunction>id</xfunction> function, it must actually be declared in

  the DTD as being an ID.</p></note>

  

  <p>The following example shows how the <code>xml-stylesheet</code>

  processing instruction <bibref ref="XMLSTYLE"/> 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>

  

  <eg><![CDATA[<?xml-stylesheet type="text/xml" href="#style1"?>

  <!DOCTYPE doc SYSTEM "doc.dtd">

  <doc>

  <head>

  <xsl:stylesheet id="style1"

                  version="1.0"]]>

                  xmlns:xsl="&XSLT.ns;"

                  xmlns:fo="&XSLFO.ns;"><![CDATA[

  <xsl:import href="doc.xsl"/>

  <xsl:template match="id('foo')">

    <fo:block font-weight="bold"><xsl:apply-templates/></fo:block>

  </xsl:template>

  <xsl:template match="xsl:stylesheet">

    <!-- ignore -->

  </xsl:template>

  </xsl:stylesheet>

  </head>

  <body>

  <para id="foo">

  ...

  </para>

  </body>

  </doc>

  ]]></eg>

  

  <note><p>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.</p></note>

  

  </div2>

  

  </div1>

  

  <div1 id="data-model">

  <head>Data Model</head>

  

  <p>The data model used by XSLT is the same as that used by <xspecref

  href="&XPath;#data-model">XPath</xspecref> 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>

  

  <div2 id="root-node-children">

  <head>Root Node Children</head>

  

  <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

  <specref ref="output"/>), 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>

  

  </div2>

  

  <div2 id="base-uri">

  <head>Base URI</head>

  

  <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>

  

  </div2>

  

  <div2 id="unparsed-entities">

  <head>Unparsed Entities</head>

  

  <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 <bibref ref="RFC2396"/>.</p>

  

  </div2>

  

  <div2 id="strip">

  <head>Whitespace Stripping</head>

  

  <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>

  

  <ulist>

  

  <item><p>The element name of the parent of the text node is in the set

  of whitespace-preserving element names.</p></item>

  

  <item><p>The text node contains at least one non-whitespace character.

  As in XML, a whitespace character is #x20, #x9, #xD or #xA.</p></item>

  

  <item><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></item>

  

  </ulist>

  

  <p>Otherwise, the text node is stripped.</p>

  

  <p>The <code>xml:space</code> attributes are not stripped from the

  tree.</p>

  

  <note><p>This implies that if an <code>xml:space</code> attribute is

  specified on a literal result element, it will be included in the

  result.</p></note>

  

  <p>For stylesheets, the set of whitespace-preserving element names

  consists of just <code>xsl:text</code>.</p>

  

  <e:element-syntax name="strip-space">

    <e:in-category name="top-level-element"/>

    <e:attribute name="elements" required="yes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <e:element-syntax name="preserve-space">

    <e:in-category name="top-level-element"/>

    <e:attribute name="elements" required="yes">

      <e:data-type name="tokens"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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> <termref

  def="dt-top-level">top-level</termref> elements.  These elements each

  have an <code>elements</code> attribute whose value is a

  whitespace-separated list of <xnt

  href="&XPath;#NT-NameTest">NameTest</xnt>s.  Initially, the

  set of whitespace-preserving element names contains all element names.

  If an element name matches a <xnt

  href="&XPath;#NT-NameTest">NameTest</xnt> 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

  <xnt href="&XPath;#NT-NameTest">NameTest</xnt> in an

  <code>xsl:preserve-space</code> element, then it is added to the set

  of whitespace-preserving element names.  An element matches a <xnt

  href="&XPath;#NT-NameTest">NameTest</xnt> if and only if the

  <xnt href="&XPath;#NT-NameTest">NameTest</xnt> would be true

  for the element as an <xspecref href="&XPath;#node-tests">XPath node

  test</xspecref>.  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 <specref ref="conflict"/>).  Thus, the applicable match for a

  particular element name is determined as follows:</p>

  

  <ulist>

  

  <item><p>First, any match with lower <termref

  def="dt-import-precedence">import precedence</termref> than another

  match is ignored.</p></item>

  

  <item><p>Next, any match with a <xnt

  href="&XPath;#NT-NameTest">NameTest</xnt> that has a lower

  <termref def="dt-default-priority">default priority</termref> than the

  <termref def="dt-default-priority">default priority</termref> of the

  <xnt href="&XPath;#NT-NameTest">NameTest</xnt> of another

  match is ignored.</p></item>

  

  </ulist>

  

  <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>

  

  </div2>

  

  </div1>

  

  <div1>

  <head>Expressions</head>

  

  <p>XSLT uses the expression language defined by XPath <bibref

  ref="XPATH"/>.  Expressions are used in XSLT for a variety of purposes

  including:</p>

  

  <slist>

  <sitem>selecting nodes for processing;</sitem>

  <sitem>specifying conditions for different ways of processing a node;</sitem>

  <sitem>generating text to be inserted in the result tree.</sitem>

  </slist>

  

  <p><termdef id="dt-expression" term="Expression">An

  <term>expression</term> must match the XPath production <xnt

  href="&XPath;#NT-Expr">Expr</xnt>.</termdef></p>

  

  <p>Expressions occur as the value of certain attributes on

  XSLT-defined elements and within curly braces in <termref

  def="dt-attribute-value-template">attribute value

  template</termref>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>

  

  <ulist>

  

  <item><p>the context node comes from the <termref

  def="dt-current-node">current node</termref></p></item>

  

  <item><p>the context position comes from the position of the <termref

  def="dt-current-node">current node</termref> in the <termref

  def="dt-current-node-list">current node list</termref>; the first

  position is 1</p></item>

  

  <item><p>the context size comes from the size of the <termref

  def="dt-current-node-list">current node list</termref></p></item>

  

  <item><p>the variable bindings are the bindings in scope on the

  element which has the attribute in which the expression occurs (see

  <specref ref="variables"/>)</p></item>

  

  <item><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 <bibref ref="XMLNAMES"/>;

  the default

  namespace (as declared by <code>xmlns</code>) is not part of this

  set</p></item>

  

  <item><p>the function library consists of the core function library

  together with the additional functions defined in <specref

  ref="add-func"/> and extension functions as described in <specref

  ref="extension"/>; it is an error for an expression to include a call

  to any other function</p></item>

  

  </ulist>

  

  </div1>

  

  <div1 id="rules">

  <head>Template Rules</head>

  

  <div2>

  <head>Processing Model</head>

  

  <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 <termref def="dt-current-node">current

  node</termref> and with the list of source nodes as the <termref

  def="dt-current-node-list">current node list</termref>.  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>

  

  </div2>

  

  <div2 id="patterns">

  <head>Patterns</head>

  

  <p><termdef id="dt-pattern" term="Pattern">Template rules identify the

  nodes to which they apply by using a <term>pattern</term>.  As well as

  being used in template rules, patterns are used for numbering (see

  <specref ref="number"/>) and for declaring keys (see <specref

  ref="key"/>).  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.</termdef></p>

  

  <p>Here are some examples of patterns:</p>

  

  <ulist>

  

  <item><p><code>para</code> matches any <code>para</code> element</p></item>

  

  <item><p><code>*</code> matches any element</p></item>

  

  <item><p><code>chapter|appendix</code> matches any

  <code>chapter</code> element and any <code>appendix</code>

  element</p></item>

  

  <item><p><code>olist/item</code> matches any <code>item</code> element with

  an <code>olist</code> parent</p></item>

  

  <item><p><code>appendix//para</code> matches any <code>para</code> element with

  an <code>appendix</code> ancestor element</p></item>

  

  <item><p><code>/</code> matches the root node</p></item>

  

  <item><p><code>text()</code> matches any text node</p></item>

  

  <item><p><code>processing-instruction()</code> matches any processing

  instruction</p></item>

  

  <item><p><code>node()</code> matches any node other than an attribute

  node and the root node</p></item>

  

  <item><p><code>id("W11")</code> matches the element with unique ID

  <code>W11</code></p></item>

  

  <item><p><code>para[1]</code> matches any <code>para</code> element

  that is the first <code>para</code> child element of its

  parent</p></item>

  

  <item><p><code>*[position()=1 and self::para]</code> matches any

  <code>para</code> element that is the first child element of its

  parent</p></item>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><p><code>@class</code> matches any <code>class</code> attribute

  (<emph>not</emph> any element that has a <code>class</code>

  attribute)</p></item>

  

  <item><p><code>@*</code> matches any attribute</p></item>

  

  </ulist>

  

  <p>A pattern must match the grammar for <nt

  def="NT-Pattern">Pattern</nt>.  A <nt def="NT-Pattern">Pattern</nt> 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

  <xfunction>id</xfunction> or <function>key</function> function call

  with a literal argument.  Predicates in a pattern can use arbitrary

  expressions just like predicates in a location path.</p>

  

  <scrap>

  <head>Patterns</head>

  <prodgroup pcw5="1" pcw2="10">

  <prod id="NT-Pattern">

  <lhs>Pattern</lhs>

  <rhs><nt def="NT-LocationPathPattern">LocationPathPattern</nt></rhs>

  <rhs>| <nt def="NT-Pattern">Pattern</nt> '|' <nt def="NT-LocationPathPattern">LocationPathPattern</nt></rhs>

  </prod>

  <prod id="NT-LocationPathPattern">

  <lhs>LocationPathPattern</lhs>

  <rhs>'/' <nt def="NT-RelativePathPattern">RelativePathPattern</nt>?</rhs>

  <rhs>| <nt def="NT-IdKeyPattern">IdKeyPattern</nt> (('/' | '//') <nt def="NT-RelativePathPattern">RelativePathPattern</nt>)?</rhs>

  <rhs>| '//'? <nt def="NT-RelativePathPattern">RelativePathPattern</nt></rhs>

  </prod>

  <prod id="NT-IdKeyPattern">

  <lhs>IdKeyPattern</lhs>

  <rhs>'id' '(' <xnt href="&XPath;#NT-Literal">Literal</xnt> ')'</rhs>

  <rhs>| 'key' '(' <xnt href="&XPath;#NT-Literal">Literal</xnt> ',' <xnt href="&XPath;#NT-Literal">Literal</xnt> ')'</rhs>

  </prod>

  <prod id="NT-RelativePathPattern">

  <lhs>RelativePathPattern</lhs>

  <rhs><nt def="NT-StepPattern">StepPattern</nt></rhs>

  <rhs>| <nt def="NT-RelativePathPattern">RelativePathPattern</nt> '/' <nt def="NT-StepPattern">StepPattern</nt></rhs>

  <rhs>| <nt def="NT-RelativePathPattern">RelativePathPattern</nt> '//' <nt def="NT-StepPattern">StepPattern</nt></rhs>

  </prod>

  <prod id="NT-StepPattern">

  <lhs>StepPattern</lhs>

  <rhs>

  <nt def="NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</nt>

  <xnt href="&XPath;#NT-NodeTest">NodeTest</xnt>

  <xnt href="&XPath;#NT-Predicate">Predicate</xnt>*

  </rhs>

  </prod>

  <prod id="NT-ChildOrAttributeAxisSpecifier">

  <lhs>ChildOrAttributeAxisSpecifier</lhs>

  <rhs><xnt href="&XPath;#NT-AbbreviatedAxisSpecifier">AbbreviatedAxisSpecifier</xnt></rhs>

  <rhs>| ('child' | 'attribute') '::'</rhs>

  </prod>

  </prodgroup>

  </scrap>

  

  <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>

  

  <note><p>This matches even a <code>p</code> element that is the

  document element, since the document root is the parent of the

  document element.</p></note>

  

  <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 <nt def="NT-StepPattern">StepPattern</nt>s separated by

  <code>/</code> or <code>//</code> is matched from right to left.  The

  pattern only matches if the rightmost <nt

  def="NT-StepPattern">StepPattern</nt> 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 <nt

  def="NT-StepPattern">StepPattern</nt> that uses the child axis matches

  if the <xnt href="&XPath;#NT-NodeTest">NodeTest</xnt> is true for the

  node and the node is not an attribute node.  A <nt

  def="NT-StepPattern">StepPattern</nt> that uses the attribute axis

  matches if the <xnt href="&XPath;#NT-NodeTest">NodeTest</xnt> is true

  for the node and the node is an attribute node.  When <code>[]</code>

  is present, then the first <xnt

  href="&XPath;#NT-PredicateExpr">PredicateExpr</xnt> in a <nt

  def="NT-StepPattern">StepPattern</nt> is evaluated with the node being

  matched as the context node and the siblings of the context node that

  match the <xnt href="&XPath;#NT-NodeTest">NodeTest</xnt> 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 <xnt

  href="&XPath;#NT-NameTest">NameTest</xnt>.</p>

  

  <p>For example</p>

  

  <eg>appendix//ulist/item[position()=1]</eg>

  

  <p>matches a node if and only if all of the following are true:</p>

  

  <ulist>

  

  <item><p>the <xnt href="&XPath;#NT-NodeTest">NodeTest</xnt> <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></item>

  

  <item><p>evaluating the <xnt href="&XPath;#NT-PredicateExpr">PredicateExpr</xnt>

  <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></item>

  

  <item><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></item>

  

  </ulist>

  

  </div2>

  

  <div2>

  <head>Defining Template Rules</head>

  

  <e:element-syntax name="template">

    <e:in-category name="top-level-element"/>

    <e:attribute name="match">

      <e:data-type name="pattern"/>

    </e:attribute>

    <e:attribute name="name">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="priority">

      <e:data-type name="number"/>

    </e:attribute>

    <e:attribute name="mode">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:sequence>

      <e:element repeat="zero-or-more" name="param"/>

      <e:model name="template"/>

    </e:sequence>

  </e:element-syntax>

  

  <p>A template rule is specified with the <code>xsl:template</code>

  element. The <code>match</code> attribute is a <nt

  def="NT-Pattern">Pattern</nt> 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 <specref ref="named-templates"/>).

  It is an error for the value of the <code>match</code> attribute to

  contain a <xnt

  href="&XPath;#NT-VariableReference">VariableReference</xnt>. 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>

  

  <eg><![CDATA[This is an <emph>important</emph> point.]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="emph">

    <fo:inline-sequence font-weight="bold">

      <xsl:apply-templates/>

    </fo:inline-sequence>

  </xsl:template>

  ]]></eg>

  

  <note><p>Examples in this document use the <code>fo:</code> prefix for

  the namespace <code>&XSLFO.ns;</code>, which is

  the namespace of the formatting objects defined in <bibref

  ref="XSL"/>.</p></note>

  

  <p>As described next, the <code>xsl:apply-templates</code> element

  recursively processes the children of the source element.</p>

  

  </div2>

  

  <div2>

  <head>Applying Template Rules</head>

  

  <e:element-syntax name="apply-templates">

    <e:in-category name="instruction"/>

    <e:attribute name="select">

      <e:data-type name="node-set-expression"/>

    </e:attribute>

    <e:attribute name="mode">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:choice repeat="zero-or-more">

      <e:element name="sort"/>

      <e:element name="with-param"/>

    </e:choice>

  </e:element-syntax>

  

  <p>This example creates a block for a <code>chapter</code> element and

  then processes its immediate children.</p>

  

  <eg><![CDATA[<xsl:template match="chapter">

    <fo:block>

      <xsl:apply-templates/>

    </fo:block>

  </xsl:template>]]></eg>

  

  <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 <specref ref="strip"/>

  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 <xfunction>position</xfunction>

  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 <termref

  def="dt-expression">expression</termref>.  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

  <specref ref="sorting"/>).  The following example processes all of the

  <code>author</code> children of the <code>author-group</code>:</p>

  

  <eg><![CDATA[<xsl:template match="author-group">

    <fo:inline-sequence>

      <xsl:apply-templates select="author"/>

    </fo:inline-sequence>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="author-group">

    <fo:inline-sequence>

      <xsl:apply-templates select="author/given-name"/>

    </fo:inline-sequence>

  </xsl:template>]]></eg>

  

  <p>This example processes all of the <code>heading</code> descendant

  elements of the <code>book</code> element.</p>

  

  <eg><![CDATA[<xsl:template match="book">

    <fo:block>

      <xsl:apply-templates select=".//heading"/>

    </fo:block>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="employee">

    <fo:block>

      Employee <xsl:apply-templates select="name"/> belongs to group

      <xsl:apply-templates select="ancestor::department/group"/>

    </fo:block>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="product">

    <table>

      <xsl:apply-templates select="sales/domestic"/>

    </table>

    <table>

      <xsl:apply-templates select="sales/foreign"/>

    </table>

  </xsl:template>]]></eg>

  

  <note>

  

  <p>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</p>

  

  <eg><![CDATA[<doc><div><div></div></div></doc>]]></eg>

  

  <p>the rule</p>

  

  <eg><![CDATA[<xsl:template match="doc">

    <xsl:apply-templates select=".//div"/>

  </xsl:template>]]></eg>

  

  <p>will process both the outer <code>div</code> and inner <code>div</code>

  elements.</p>

  

  </note>

  

  <note><p>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,</p>

  

  <eg role="error"><![CDATA[<xsl:template match="foo">

    <xsl:apply-templates select="."/>

  </xsl:template>]]></eg>

  

  <p>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.</p></note>

  

  </div2>

  

  <div2 id="conflict">

  <head>Conflict Resolution for Template Rules</head>

  

  <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>

  

  <olist>

  

  <item><p>First, all matching template rules that have lower <termref

  def="dt-import-precedence">import precedence</termref> than the

  matching template rule or rules with the highest import precedence are

  eliminated from consideration.</p></item>

  

  <item><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 <xnt href="&XPath;#NT-Number">Number</xnt>

  with an optional leading minus sign (<code>-</code>).  <termdef

  id="dt-default-priority" term="Default Priority">The <term>default

  priority</term> is computed as follows:</termdef></p>

  

  <ulist>

  

  <item><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></item>

  

  <item><p>If the pattern has the form of a <xnt

  href="&XMLNames;#NT-QName">QName</xnt> preceded by a <nt

  def="NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</nt>

  or has the form

  <code>processing-instruction(</code><xnt href="&XPath;#NT-Literal"

  >Literal</xnt><code>)</code> preceded by a <nt

  def="NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</nt>,

  then the priority is 0.</p></item>

  

  <item><p>If the pattern has the form <xnt

  href="&XMLNames;#NT-NCName">NCName</xnt><code>:*</code> preceded by a

  <nt

  def="NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</nt>,

  then the priority is -0.25.</p></item>

  

  <item><p>Otherwise, if the pattern consists of just a <xnt

  href="&XPath;#NT-NodeTest">NodeTest</xnt> preceded by a <nt

  def="NT-ChildOrAttributeAxisSpecifier">ChildOrAttributeAxisSpecifier</nt>,

  then the priority is -0.5.</p></item>

  

  <item><p>Otherwise, the priority is 0.5.</p></item>

  

  </ulist>

  

  <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>

  

  </item>

  

  </olist>

  

  <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>

  

  </div2>

  

  <div2 id="apply-imports">

  <head>Overriding Template Rules</head>

  

  <e:element-syntax name="apply-imports">

    <e:in-category name="instruction"/>

    <e:empty/>

  </e:element-syntax>

  

  <p>A template rule that is being used to override a template rule in

  an imported stylesheet (see <specref ref="conflict"/>) can use the

  <code>xsl:apply-imports</code> element to invoke the overridden

  template rule.</p>

  

  <p><termdef id="dt-current-template-rule" term="Current Template

  Rule">At any point in the processing of a stylesheet, there is a

  <term>current template rule</term>.  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.</termdef></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>

  

  <eg><![CDATA[<xsl:template match="example">

    <pre><xsl:apply-templates/></pre>

  </xsl:template>]]></eg>

  

  <p>Another stylesheet could import <code>doc.xsl</code> and modify the

  treatment of <code>example</code> elements as follows:</p>

  

  <eg><![CDATA[<xsl:import href="doc.xsl"/>

  

  <xsl:template match="example">

    <div style="border: solid red">

       <xsl:apply-imports/>

    </div>

  </xsl:template>]]></eg>

  

  <p>The combined effect would be to transform an <code>example</code>

  into an element of the form:</p>

  

  <eg><![CDATA[<div style="border: solid red"><pre>...</pre></div>]]></eg>

  

  </div2>

  

  <div2 id="modes">

  <head>Modes</head>

  

  <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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>. 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>

  

  </div2>

  

  <div2 id="built-in-rule">

  <head>Built-in Template Rules</head>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="*|/">

    <xsl:apply-templates/>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg>&lt;xsl:template match="*|/" mode="<var>m</var>">

    &lt;xsl:apply-templates mode="<var>m</var>"/>

  &lt;/xsl:template></eg>

  

  <p>There is also a built-in template rule for text and attribute nodes

  that copies text through:</p>

  

  <eg><![CDATA[<xsl:template match="text()|@*">

    <xsl:value-of select="."/>

  </xsl:template>]]></eg>

  

  <p>The built-in template rule for processing instructions and comments

  is to do nothing.</p>

  

  <eg><![CDATA[<xsl:template match="processing-instruction()|comment()"/>]]></eg>

  

  <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 <termref

  def="dt-import-precedence">import precedence</termref> than all other

  template rules.  Thus, the author can override a built-in template

  rule by including an explicit template rule.</p>

  

  </div2>

  

  

  </div1>

  

  <div1 id="named-templates">

  <head>Named Templates</head>

  

  <e:element-syntax name="call-template">

    <e:in-category name="instruction"/>

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:element repeat="zero-or-more" name="with-param"/>

  </e:element-syntax>

  

  <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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>. 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 <termref def="dt-import-precedence">import

  precedence</termref>.</p>

  

  </div1>

  

  

  <div1>

  <head>Creating the Result Tree</head>

  

  <p>This section describes instructions that directly create nodes in

  the result tree.</p>

  

  <div2>

  <head>Creating Elements and Attributes</head>

  

  <div3 id="literal-result-element">

  <head>Literal Result Elements</head>

  

  <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 <specref

  ref="extension-element"/>) is instantiated to create an element node

  with the same <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref>.  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>&XSLT.ns;</code>), a

  namespace URI declared as an extension namespace (see <specref

  ref="extension-element"/>), 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>

  

  <note><p>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.</p></note>

  

  <p>The value of an attribute of a literal result element is

  interpreted as an <termref def="dt-attribute-value-template">attribute

  value template</termref>: it can contain expressions contained

  in curly braces (<code>{}</code>).</p>

  

  <p><termdef id="dt-literal-namespace-uri" term="Literal Namespace

  URI">A namespace URI in the stylesheet tree that is being used to

  specify a namespace URI in the result tree is called a <term>literal

  namespace URI</term>.</termdef> This applies to:</p>

  

  <ulist>

  

  <item><p>the namespace URI in the expanded-name of a literal

  result element in the stylesheet</p></item>

  

  <item><p>the namespace URI in the expanded-name of an attribute

  specified on a literal result element in the stylesheet</p></item>

  

  <item><p>the string-value of a namespace node on a literal result

  element in the stylesheet</p></item>

  

  </ulist>

  

  <e:element-syntax name="namespace-alias">

    <e:in-category name="top-level-element"/>

    <e:attribute name="stylesheet-prefix" required="yes">

      <e:data-type name="prefix"/>

      <e:constant value="#default"/>

    </e:attribute>

    <e:attribute name="result-prefix" required="yes">

      <e:data-type name="prefix"/>

      <e:constant value="#default"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <p><termdef id="dt-alias" term="Alias">A stylesheet can use the

  <code>xsl:namespace-alias</code> element to declare that one namespace

  URI is an <term>alias</term> for another namespace URI.</termdef> When

  a <termref def="dt-literal-namespace-uri">literal namespace

  URI</termref> 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 <termref

  def="dt-import-precedence">import precedence</termref> 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>

  

  <eg>&lt;xsl:stylesheet

    version="1.0"

    xmlns:xsl="&XSLT.ns;"

    xmlns:fo="&XSLFO.ns;"

    xmlns:axsl="&XSLTA.ns;"><![CDATA[

  

  <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>

  

  <xsl:template match="/">

    <axsl:stylesheet>

      <xsl:apply-templates/>

    </axsl:stylesheet>

  </xsl:template>

  

  <xsl:template match="block">

    <axsl:template match="{.}">

       <fo:block><axsl:apply-templates/></fo:block>

    </axsl:template>

  </xsl:template>

  

  </xsl:stylesheet>]]></eg>

  

  <p>will generate an XSLT stylesheet from a document of the form:</p>

  

  <eg><![CDATA[<elements>

  <block>p</block>

  <block>h1</block>

  <block>h2</block>

  <block>h3</block>

  <block>h4</block>

  </elements>]]></eg>

  

  <note><p>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.</p></note>

  

  </div3>

  

  <div3>

  <head>Creating Elements with <code>xsl:element</code></head>

  

  <e:element-syntax name="element">

    <e:in-category name="instruction"/>

    <e:attribute name="name" required="yes">

      <e:attribute-value-template>

        <e:data-type name="qname"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="namespace">

      <e:attribute-value-template>

        <e:data-type name="uri-reference"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="use-attribute-sets">

      <e:data-type name="qnames"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <p>The <code>xsl:element</code> element allows an element to be

  created with a computed name.  The <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> 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 <termref

  def="dt-attribute-value-template">attribute value template</termref>.

  It is an error if the string that results from instantiating the

  attribute value template is not a <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  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 <xnt href="&XMLNames;#NT-QName">QName</xnt> 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 <termref def="dt-attribute-value-template">attribute

  value template</termref>. 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

  <xnt href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt> 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>

  

  </div3>

  

  <div3 id="creating-attributes">

  <head>Creating Attributes with <code>xsl:attribute</code></head>

  

  <e:element-syntax name="attribute">

    <e:in-category name="instruction"/>

    <e:attribute name="name" required="yes">

      <e:attribute-value-template>

        <e:data-type name="qname"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="namespace">

      <e:attribute-value-template>

        <e:data-type name="uri-reference"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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 <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> 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 <termref

  def="dt-attribute-value-template">attribute value template</termref>.

  It is an error if the string that results from instantiating the

  attribute value template is not a <xnt

  href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt href="&XMLNames;#NT-QName">QName</xnt> is

  expanded into an expanded-name using the namespace declarations in

  effect for the <code>xsl:attribute</code> element, <emph>not</emph>

  including any default namespace declaration.</p>

  

  <p>If the <code>namespace</code> attribute is present, then it also is

  interpreted as an <termref def="dt-attribute-value-template">attribute

  value template</termref>. 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt> 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>

  

  <eg>&lt;xsl:attribute name="xmlns:xsl" namespace="whatever">&XSLT.ns;&lt;/xsl:attribute></eg>

  

  <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>

  

  <ulist>

  

  <item><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></item>

  

  <item><p>Adding an attribute to a node that is not an element;

  implementations may either signal the error or ignore the

  attribute.</p></item>

  

  <item><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></item>

  

  </ulist>

  

  <note><p>When an <code>xsl:attribute</code> contains a text node with

  a newline, then the XML output must contain a character reference.

  For example,</p>

  

  <eg><![CDATA[<xsl:attribute name="a">x

  y</xsl:attribute>]]></eg>

  

  <p>will result in the output</p>

  

  <eg><![CDATA[a="x&#xA;y"]]></eg>

  

  <p>(or with any equivalent character reference). The XML output cannot

  be</p>

  

  <eg><![CDATA[a="x

  y"]]></eg>

  

  <p>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.</p></note>

  

  </div3>

  

  <div3 id="attribute-sets">

  

  <head>Named Attribute Sets</head>

  

  <e:element-syntax name="attribute-set">

    <e:in-category name="top-level-element"/>

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="use-attribute-sets">

      <e:data-type name="qnames"/>

    </e:attribute>

    <e:element repeat="zero-or-more" name="attribute"/>

  </e:element-syntax>

  

  <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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>. 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 <specref ref="copying"/>) 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>.  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 <specref ref="variables"/>); thus,

  only variables and parameters declared by <termref

  def="dt-top-level">top-level</termref> <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>

  

  <eg><![CDATA[<xsl:template match="chapter/heading">

    <fo:block quadding="start" xsl:use-attribute-sets="title-style">

      <xsl:apply-templates/>

    </fo:block>

  </xsl:template>

  

  <xsl:attribute-set name="title-style">

    <xsl:attribute name="font-size">12pt</xsl:attribute>

    <xsl:attribute name="font-weight">bold</xsl:attribute>

  </xsl:attribute-set>]]></eg>

  

  <p>Multiple definitions of an attribute set with the same

  expanded-name are merged.  An attribute from a definition that has

  higher <termref def="dt-import-precedence">import precedence</termref>

  takes precedence over an attribute from a definition that has lower

  <termref def="dt-import-precedence">import precedence</termref>.  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 <termref def="dt-import-precedence">import

  precedence</termref> 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>

  

  </div3>

  

  </div2>

  

  <div2>

  

  <head>Creating Text</head>

  

  <p>A template can also contain text nodes.  Each text node in a

  template remaining after whitespace has been stripped as specified in

  <specref ref="strip"/> 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 <specref

  ref="disable-output-escaping"/>).</p>

  

  <e:element-syntax name="text">

    <e:in-category name="instruction"/>

    <e:attribute name="disable-output-escaping">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:text/>  

  </e:element-syntax>

  

  <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 <specref ref="strip"/>) but

  does not affect how the characters are handled by the XSLT processor

  thereafter.</p>

  

  <note><p>The <code>xml:lang</code> and <code>xml:space</code>

  attributes are not treated specially by XSLT. In particular,</p>

  

  <ulist>

  <item><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></item>

  

  <item><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></item>

  </ulist>

  </note>

  

  </div2>

  

  

  <div2>

  <head>Creating Processing Instructions</head>

  

  

  <e:element-syntax name="processing-instruction">

    <e:in-category name="instruction"/>

    <e:attribute name="name" required="yes">

      <e:attribute-value-template>

        <e:data-type name="ncname"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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 <termref def="dt-attribute-value-template">attribute

  value template</termref>.</p>

  

  <p>For example, this</p>

  

  <eg><![CDATA[<xsl:processing-instruction name="xml-stylesheet">href="book.css" type="text/css"</xsl:processing-instruction>]]></eg>

  

  <p>would create the processing instruction</p>

  

  <eg><![CDATA[<?xml-stylesheet href="book.css" type="text/css"?>]]></eg>

  

  <p>It is an error if the string that results from instantiating the

  <code>name</code> attribute is not both an <xnt

  href="&XMLNames;#NT-NCName">NCName</xnt> and a <xnt

  href="&XML;#NT-PITarget">PITarget</xnt>.  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>

  

  <note><p>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 <specref

  ref="output"/>).</p></note>

  

  <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>?&gt;</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>&gt;</code>.</p>

  

  </div2>

  

  <div2>

  <head>Creating Comments</head>

  

  <e:element-syntax name="comment">

    <e:in-category name="instruction"/>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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>

  

  <eg><![CDATA[<xsl:comment>This file is automatically generated. Do not edit!</xsl:comment>]]></eg>

  

  <p>would create the comment</p>

  

  <eg><![CDATA[<!--This file is automatically generated. Do not edit!-->]]></eg>

  

  <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>

  

  </div2>

  

  <div2 id="copying">

  <head>Copying</head>

  

  <e:element-syntax name="copy">

    <e:in-category name="instruction"/>

    <e:attribute name="use-attribute-sets">

      <e:data-type name="qnames"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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 <specref

  ref="attribute-sets"/>). 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>

  

  <eg><![CDATA[<xsl:template match="@*|node()">

    <xsl:copy>

      <xsl:apply-templates select="@*|node()"/>

    </xsl:copy>

  </xsl:template>]]></eg>

  

  <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 <specref ref="creating-attributes"/>).</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>

  

  <eg><![CDATA[<xsl:template name="apply-templates-copy-lang">

   <xsl:for-each select="@xml:lang">

     <xsl:copy/>

   </xsl:for-each>

   <xsl:apply-templates/>

  </xsl:template>]]></eg>

  

  <p>then it can simply do</p>

  

  <eg><![CDATA[<xsl:call-template name="apply-templates-copy-lang"/>]]></eg>

  

  <p>instead of</p>

  

  <eg><![CDATA[<xsl:apply-templates/>]]></eg>

  

  <p>when it wants to copy the <code>xml:lang</code> attribute.</p>

  

  </div2>

  

  <div2>

  <head>Computing Generated Text</head>

  

  <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 <termref

  def="dt-expression">expression</termref> 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>

  

  <div3 id="value-of">

  <head>Generating Text with <code>xsl:value-of</code></head>

  

  <e:element-syntax name="value-of">

    <e:in-category name="instruction"/>

    <e:attribute name="select" required="yes">

      <e:data-type name="string-expression"/>

    </e:attribute>

    <e:attribute name="disable-output-escaping">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <termref def="dt-expression">expression</termref>;

  this expression is evaluated and the resulting object is converted to

  a string as if by a call to the <xfunction>string</xfunction>

  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 <specref

  ref="copy-of"/>.</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>

  

  <eg><![CDATA[<xsl:template match="person">

    <p>

     <xsl:value-of select="@given-name"/>

     <xsl:text> </xsl:text>

     <xsl:value-of select="@family-name"/>

    </p>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="person">

    <p>

     <xsl:value-of select="given-name"/>

     <xsl:text> </xsl:text>

     <xsl:value-of select="family-name"/>

    </p>

  </xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="procedure">

    <fo:block>

      <xsl:value-of select="ancestor-or-self::*[@security][1]/@security"/>

    </fo:block>

    <xsl:apply-templates/>

  </xsl:template>]]></eg>

  

  </div3>

  

  <div3 id="attribute-value-templates">

  <head>Attribute Value Templates</head>

  

  <p><termdef id="dt-attribute-value-template" term="Attribute Value

  Template">In an attribute value that is interpreted as an

  <term>attribute value template</term>, such as an attribute of a

  literal result element, an <termref

  def="dt-expression">expression</termref> can be used by surrounding

  the expression with curly braces (<code>{}</code>)</termdef>.  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 <xfunction>string</xfunction> 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>

  

  <note><p>Not all attributes are interpreted as attribute value

  templates.  Attributes whose value is an expression or pattern,

  attributes of <termref def="dt-top-level">top-level</termref> 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.</p></note>

  

  <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>

  

  <eg><![CDATA[<xsl:variable name="image-dir">/images</xsl:variable>

  

  <xsl:template match="photograph">

  <img src="{$image-dir}/{href}" width="{size/@width}"/>

  </xsl:template>]]></eg>

  

  <p>With this source</p>

  

  <eg><![CDATA[<photograph>

    <href>headquarters.jpg</href>

    <size width="300"/>

  </photograph>]]></eg>

  

  <p>the result would be</p>

  

  <eg><![CDATA[<img src="/images/headquarters.jpg" width="300"/>]]></eg>

  

  <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 <xnt

  href="&XPath;#NT-Literal">Literal</xnt> in an expression is not

  recognized as terminating the expression.</p>

  

  <p>Curly braces are <emph>not</emph> recognized recursively inside

  expressions.  For example:</p>

  

  <eg role="error"><![CDATA[<a href="#{id({@ref})/title}">]]></eg>

  

  <p>is <emph>not</emph> allowed.  Instead, use simply:</p>

  

  <eg><![CDATA[<a href="#{id(@ref)/title}">]]></eg>

  

  </div3>

  

  </div2>

  

  <div2 id="number">

  <head>Numbering</head>

  

  <e:element-syntax name="number">

    <e:in-category name="instruction"/>

    <e:attribute name="level">

      <e:constant value="single"/>

      <e:constant value="multiple"/>

      <e:constant value="any"/>

    </e:attribute>

    <e:attribute name="count">

      <e:data-type name="pattern"/>

    </e:attribute>

    <e:attribute name="from">

      <e:data-type name="pattern"/>

    </e:attribute>

    <e:attribute name="value">

      <e:data-type name="number-expression"/>

    </e:attribute>

    <e:attribute name="format">

      <e:attribute-value-template>

        <e:data-type name="string"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="lang">

      <e:attribute-value-template>

        <e:data-type name="nmtoken"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="letter-value">

      <e:attribute-value-template>

        <e:constant value="alphabetic"/>

        <e:constant value="traditional"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="grouping-separator">

      <e:attribute-value-template>

        <e:data-type name="char"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="grouping-size">

      <e:attribute-value-template>

        <e:data-type name="number"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <termref def="dt-expression">expression</termref>.  The expression

  is evaluated and the resulting object is converted to a number as if

  by a call to the <xfunction>number</xfunction> function.  The number is

  rounded to an integer and then converted to a string using the

  attributes specified in <specref ref="convert"/>; in this

  context, the value of each of these attributes is

  interpreted as an <termref def="dt-attribute-value-template">attribute

  value template</termref>.  After conversion, the resulting string is

  inserted in the result tree. For example, the following example

  numbers a sorted list:</p>

  

  <eg><![CDATA[<xsl:template match="items">

    <xsl:for-each select="item">

      <xsl:sort select="."/>

      <p>

        <xsl:number value="position()" format="1. "/>

        <xsl:value-of select="."/>

      </p>

    </xsl:for-each>

  </xsl:template>]]></eg>

  

  <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>

  

  <ulist>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><p>The <code>from</code> attribute is a pattern that specifies

  where counting starts.</p></item>

  

  </ulist>

  

  <p>In addition, the attributes specified in <specref ref="convert"/>

  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>

  

  <ulist>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><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></item>

  

  </ulist>

  

  <p>The list of numbers is then converted into a string using the

  attributes specified in <specref ref="convert"/>; in this

  context, the value of each of these attributes is

  interpreted as an <termref def="dt-attribute-value-template">attribute

  value template</termref>.  After conversion, the resulting string is

  inserted in the result tree.</p>

  

  <p>The following would number the items in an ordered list:</p>

  

  <eg><![CDATA[<xsl:template match="ol/item">

    <fo:block>

      <xsl:number/><xsl:text>. </xsl:text><xsl:apply-templates/>

    </fo:block>

  <xsl:template>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:template match="title">

    <fo:block>

       <xsl:number level="multiple"

                   count="chapter|section|subsection"

                   format="1.1 "/>

       <xsl:apply-templates/>

    </fo:block>

  </xsl:template>

  

  <xsl:template match="appendix//title" priority="1">

    <fo:block>

       <xsl:number level="multiple"

                   count="appendix|section|subsection"

                   format="A.1 "/>

       <xsl:apply-templates/>

    </fo:block>

  </xsl:template>]]></eg>

  

  <p>The following example numbers notes sequentially within a

  chapter:</p>

  

  <eg><![CDATA[<xsl:template match="note">

    <fo:block>

       <xsl:number level="any" from="chapter" format="(1) "/>

       <xsl:apply-templates/>

    </fo:block>

  </xsl:template>]]></eg>

  

  <p>The following example would number <code>H4</code> elements in HTML

  with a three-part label:</p>

  

  <eg><![CDATA[<xsl:template match="H4">

   <fo:block>

     <xsl:number level="any" from="H1" count="H2"/>

     <xsl:text>.</xsl:text>

     <xsl:number level="any" from="H2" count="H3"/>

     <xsl:text>.</xsl:text>

     <xsl:number level="any" from="H3" count="H4"/>

     <xsl:text> </xsl:text>

     <xsl:apply-templates/>

   </fo:block>

  </xsl:template>]]></eg>

  

  <div3 id="convert">

  <head>Number to String Conversion Attributes</head>

  

  <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>

  

  <ulist>

  

  <item><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></item>

  

  <item><p>A format token <code>A</code> generates the sequence <code>A

  B C ... Z AA AB AC...</code>.</p></item>

  

  <item><p>A format token <code>a</code> generates the sequence <code>a

  b c ... z aa ab ac...</code>.</p></item>

  

  <item><p>A format token <code>i</code> generates the sequence <code>i

  ii iii iv v vi vii viii ix x ...</code>.</p></item>

  

  <item><p>A format token <code>I</code> generates the sequence <code>I

  II III IV V VI VII VIII IX X ...</code>.</p></item>

  

  <item><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></item>

  

  </ulist>

  

  <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> <bibref ref="XML"/>;

  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>

  

  <note><p>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.</p></note>

  

  <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>

  

  <note><p>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.</p></note>

  

  <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>

  

  <ulist>

  

  <item><p><code>format="&amp;#x30A2;"</code> specifies Katakana

  numbering</p></item>

  

  <item><p><code>format="&amp;#x30A4;"</code> specifies Katakana

  numbering in the <quote>iroha</quote> order</p></item>

  

  <item><p><code>format="&amp;#x0E51;"</code> specifies numbering with

  Thai digits</p></item>

  

  <item><p><code>format="&amp;#x05D0;" letter-value="traditional"</code>

  specifies <quote>traditional</quote> Hebrew numbering</p></item>

  

  <item><p><code>format="&amp;#x10D0;" letter-value="traditional"</code>

  specifies Georgian numbering</p></item>

  

  <item><p><code>format="&amp;#x03B1;" letter-value="traditional"</code>

  specifies <quote>classical</quote> Greek numbering</p></item>

  

  <item><p><code>format="&amp;#x0430;" letter-value="traditional"</code>

  specifies Old Slavic numbering</p></item>

  

  </ulist>

  

  </div3>

  </div2>

  </div1>

  

  <div1 id="for-each">

  

  <head>Repetition</head>

  

  <e:element-syntax name="for-each">

    <e:in-category name="instruction"/>

    <e:attribute name="select" required="yes">

      <e:data-type name="node-set-expression"/>

    </e:attribute>

    <e:sequence>

      <e:element repeat="zero-or-more" name="sort"/>

      <e:model name="template"/>

    </e:sequence>

  </e:element-syntax>

  

  <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 <termref

  def="dt-expression">expression</termref> 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 <termref

  def="dt-current-node">current node</termref>, and with a list of all

  of the selected nodes as the <termref

  def="dt-current-node-list">current node list</termref>.  The nodes are

  processed in document order, unless a sorting specification is present

  (see <specref ref="sorting"/>).</p>

  

  <p>For example, given an XML document with this structure</p>

  

  <eg><![CDATA[<customers>

    <customer>

      <name>...</name>

      <order>...</order>

      <order>...</order>

    </customer>

    <customer>

      <name>...</name>

      <order>...</order>

      <order>...</order>

    </customer>

  </customers>]]></eg>

  

  <p>the following would create an HTML document containing a table with

  a row for each <code>customer</code> element</p>

  

  <eg><![CDATA[<xsl:template match="/">

    <html>

      <head>

        <title>Customers</title>

      </head>

      <body>

        <table>

  	<tbody>

  	  <xsl:for-each select="customers/customer">

  	    <tr>

  	      <th>

  		<xsl:apply-templates select="name"/>

  	      </th>

  	      <xsl:for-each select="order">

  		<td>

  		  <xsl:apply-templates/>

  		</td>

  	      </xsl:for-each>

  	    </tr>

  	  </xsl:for-each>

  	</tbody>

        </table>

      </body>

    </html>

  </xsl:template>]]></eg>

  

  </div1>

  

  <div1>

  <head>Conditional Processing</head>

  

  <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>

  

  <div2>

  <head>Conditional Processing with <code>xsl:if</code></head>

  

  <e:element-syntax name="if">

    <e:in-category name="instruction"/>

    <e:attribute name="test" required="yes">

      <e:data-type name="boolean-expression"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <p>The <code>xsl:if</code> element has a <code>test</code> attribute,

  which specifies an <termref def="dt-expression">expression</termref>.

  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

  <xfunction>boolean</xfunction> 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>

  

  <eg><![CDATA[<xsl:template match="namelist/name">

    <xsl:apply-templates/>

    <xsl:if test="not(position()=last())">, </xsl:if>

  </xsl:template>]]></eg>

  

  <p>The following colors every other table row yellow:</p>

  

  <eg><![CDATA[<xsl:template match="item">

    <tr>

      <xsl:if test="position() mod 2 = 0">

         <xsl:attribute name="bgcolor">yellow</xsl:attribute>

      </xsl:if>

      <xsl:apply-templates/>

    </tr>

  </xsl:template>]]></eg>

  

  </div2>

  

  

  <div2>

  <head>Conditional Processing with <code>xsl:choose</code></head>

  

  <e:element-syntax name="choose">

    <e:in-category name="instruction"/>

    <e:sequence>

      <e:element repeat="one-or-more" name="when"/>

      <e:element repeat="zero-or-one" name="otherwise"/>

    </e:sequence>

  </e:element-syntax>

  

  <e:element-syntax name="when">

    <e:attribute name="test" required="yes">

      <e:data-type name="boolean-expression"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <e:element-syntax name="otherwise">

    <e:model name="template"/>

  </e:element-syntax>

  

  <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

  <termref def="dt-expression">expression</termref>. 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 <xfunction>boolean</xfunction> 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>

  

  <eg><![CDATA[<xsl:template match="orderedlist/listitem">

    <fo:list-item indent-start='2pi'>

      <fo:list-item-label>

        <xsl:variable name="level"

                      select="count(ancestor::orderedlist) mod 3"/>

        <xsl:choose>

          <xsl:when test='$level=1'>

            <xsl:number format="i"/>

          </xsl:when>

          <xsl:when test='$level=2'>

            <xsl:number format="a"/>

          </xsl:when>

          <xsl:otherwise>

            <xsl:number format="1"/>

          </xsl:otherwise>

        </xsl:choose>

        <xsl:text>. </xsl:text>

      </fo:list-item-label>

      <fo:list-item-body>

        <xsl:apply-templates/>

      </fo:list-item-body>

    </fo:list-item>

  </xsl:template>]]></eg>

  

  </div2>

  </div1>

  

  <div1 id="sorting">

  <head>Sorting</head>

  

  <e:element-syntax name="sort">

    <e:attribute name="select">

      <e:data-type name="string-expression"/>

    </e:attribute>

    <e:attribute name="lang">

      <e:attribute-value-template>

        <e:data-type name="nmtoken"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="data-type">

      <e:attribute-value-template>

         <e:constant value="text"/>

         <e:constant value="number"/>

         <e:data-type name="qname-but-not-ncname"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="order">

      <e:attribute-value-template>

         <e:constant value="ascending"/>

         <e:constant value="descending"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:attribute name="case-order">

      <e:attribute-value-template>

         <e:constant value="upper-first"/>

         <e:constant value="lower-first"/>

      </e:attribute-value-template>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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

  <termref def="dt-current-node-list">current node list</termref> 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 <termref def="dt-expression">expression</termref>. 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 <xfunction>string</xfunction> 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 <termref def="dt-attribute-value-template">attribute

  value templates</termref>.</p>

  

  <ulist>

  

  <item><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></item>

  

  <item><p><code>lang</code> specifies the language of the sort keys; it

  has the same range of values as <code>xml:lang</code> <bibref

  ref="XML"/>; if no <code>lang</code> value is specified, the language

  should be determined from the system environment</p></item>

  

  <item><p><code>data-type</code> specifies the data type of the

  strings; the following values are allowed:</p>

  

  <ulist>

  

  <item><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></item>

  

  <item><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

  <xfunction>number</xfunction> function; the <code>lang</code>

  attribute is ignored</p></item>

  

  <item><p>a <xnt href="&XMLNames;#NT-QName">QName</xnt> with a prefix

  is expanded into an <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> as described

  in <specref ref="qname"/>; the expanded-name identifies the data-type;

  the behavior in this case is not specified by this document</p></item>

  

  </ulist>

  

  <p>The default value is <code>text</code>.</p>

  

  <note><p>The XSL Working Group plans that future versions of XSLT will

  leverage XML Schemas to define further values for this

  attribute.</p></note>

  

  </item>

  

  <item><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></item>

  

  </ulist>

  

  <note><p>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.</p></note>

  

  <note><p>It is recommended that implementers consult <bibref

  ref="UNICODE-TR10"/> for information on internationalized

  sorting.</p></note>

  

  <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>

  

  <eg><![CDATA[<employees>

    <employee>

      <name>

        <given>James</given>

        <family>Clark</family>

      </name>

      ...

    </employee>

  </employees>

  ]]></eg>

    

  <p>Then a list of employees sorted by name could be generated

  using:</p>

  

  <eg><![CDATA[<xsl:template match="employees">

    <ul>

      <xsl:apply-templates select="employee">

        <xsl:sort select="name/family"/>

        <xsl:sort select="name/given"/>

      </xsl:apply-templates>

    </ul>

  </xsl:template>

  

  <xsl:template match="employee">

    <li>

      <xsl:value-of select="name/given"/>

      <xsl:text> </xsl:text>

      <xsl:value-of select="name/family"/>

    </li>

  </xsl:template>]]></eg>

  

  </div1>

  

  <div1 id="variables">

  <head>Variables and Parameters</head>

  

  <e:element-syntax name="variable">

    <e:in-category name="top-level-element"/>

    <e:in-category name="instruction"/>

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="select">

      <e:data-type name="expression"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <e:element-syntax name="param">

    <e:in-category name="top-level-element"/>

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="select">

      <e:data-type name="expression"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <p>A variable is a name that may be bound to a value.  The value to

  which a variable is bound (the <term>value</term> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>.</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>

  

  <div2>

  <head>Result Tree Fragments</head>

  

  <p>Variables introduce an additional data-type into the expression

  language.  <termdef id="dt-result-tree-fragment" term="Result Tree

  Fragment">This additional data type is called <term>result tree

  fragment</term>.  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.</termdef> 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

  <specref ref="copy-of"/>), 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>

  

  </div2>

  

  <div2 id="variable-values">

  <head>Values of Variables and Parameters</head>

  

  <p>A variable-binding element can specify the value of the variable in

  three alternative ways.</p>

  

  <ulist>

  

  <item><p>If the variable-binding element has a <code>select</code>

  attribute, then the value of the attribute must be an <termref

  def="dt-expression">expression</termref> and the value of the variable

  is the object that results from evaluating the expression.  In this

  case, the content must be empty.</p></item>

  

  <item>

  

  <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>

  

  </item>

  

  <item>

  

  <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>

  

  <eg><![CDATA[<xsl:variable name="x"/>]]></eg>

  

  <p>is equivalent to</p>

  

  <eg><![CDATA[<xsl:variable name="x" select="''"/>]]></eg>

  

  </item>

  

  </ulist>

  

  <note><p>When a variable is used to select nodes by position, be careful

  not to do:</p>

  

  <eg><![CDATA[<xsl:variable name="n">2</xsl:variable>

  ...

  <xsl:value-of select="item[$n]"/>]]></eg>

  

  <p>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</p>

  

  <eg><![CDATA[<xsl:variable name="n" select="2"/>

  ...

  <xsl:value-of select="item[$n]"/>]]></eg>

  

  <p>or</p>

  

  <eg><![CDATA[<xsl:variable name="n">2</xsl:variable>

  ...

  <xsl:value-of select="item[position()=$n]"/>]]></eg>

  </note>

  

  <note><p>One convenient way to specify the empty node-set as the default

  value of a parameter is:</p>

  

  <eg><![CDATA[<xsl:param name="x" select="/.."/>]]></eg>

  </note>

  

  </div2>

  

  <div2 id="copy-of">

  <head>Using Values of Variables and Parameters with

  <code>xsl:copy-of</code></head>

  

  <e:element-syntax name="copy-of">

    <e:in-category name="instruction"/>

    <e:attribute name="select" required="yes">

      <e:data-type name="expression"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <specref

  ref="value-of"/>).  The required <code>select</code> attribute

  contains an <termref def="dt-expression">expression</termref>.  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>

  

  </div2>

  

  <div2 id="top-level-variables">

  <head>Top-level Variables and Parameters</head>

  

  <p>Both <code>xsl:variable</code> and <code>xsl:param</code> are

  allowed as <termref def="dt-top-level">top-level</termref> 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 <termref

  def="dt-import-precedence">import precedence</termref>. 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>

  

  <eg><![CDATA[<xsl:variable name="para-font-size">12pt</xsl:variable>

  

  <xsl:template match="para">

   <fo:block font-size="{$para-font-size}">

     <xsl:apply-templates/>

   </fo:block>

  </xsl:template>

  ]]></eg>

  

  </div2>

  

  <div2 id="local-variables">

  <head>Variables and Parameters within Templates</head>

  

  <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><termdef id="dt-shadows" term="Shadows">A binding

  <term>shadows</term> another binding if the binding occurs at a point

  where the other binding is visible, and the bindings have the same

  name.</termdef> It is an error if a binding established by an

  <code>xsl:variable</code> or <code>xsl:param</code> element within a

  template <termref def="dt-shadows">shadows</termref> 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 <termref def="dt-shadows">shadows</termref>

  another binding established by an <code>xsl:variable</code> or

  <code>xsl:param</code> <termref def="dt-top-level">top-level</termref>

  element.  Thus, the following is an error:</p>

  

  <eg role="error"><![CDATA[<xsl:template name="foo">

  <xsl:param name="x" select="1"/>

  <xsl:variable name="x" select="2"/>

  </xsl:template>]]></eg>

  

  <p>However, the following is allowed:</p>

  

  <eg><![CDATA[<xsl:param name="x" select="1"/>

  <xsl:template name="foo">

  <xsl:variable name="x" select="2"/>

  </xsl:template>]]></eg>

  

  <note><p>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,</p>

  

  <eg><![CDATA[<xsl:variable name="x" select="'value'"/>]]></eg>

  

  <p>has similar semantics to</p>

  

  <eg>final Object x = "value";</eg>

  

  <p>XSLT does not provide an equivalent to the Java assignment operator</p>

  

  <eg>x = "value";</eg>

  

  <p>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.</p></note>

  

  </div2>

  

  <div2>

  <head>Passing Parameters to Templates</head>

  

  <e:element-syntax name="with-param">

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="select">

      <e:data-type name="expression"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>.  <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>

  

  <eg><![CDATA[<xsl:template name="numbered-block">

    <xsl:param name="format">1. </xsl:param>

    <fo:block>

      <xsl:number format="{$format}"/>

      <xsl:apply-templates/>

    </fo:block>

  </xsl:template>

  

  <xsl:template match="ol//ol/li">

    <xsl:call-template name="numbered-block">

      <xsl:with-param name="format">a. </xsl:with-param>

    </xsl:call-template>

  </xsl:template>]]></eg>

  

  </div2>

  

  </div1>

  

  <div1 id="add-func">

  <head>Additional Functions</head>

  

  <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 <termref def="dt-top-level">top-level</termref>

  elements in the stylesheet; this section also describes these

  elements.</p>

  

  <div2 id="document">

  

  <head>Multiple Source Documents</head>

  

  <proto name="document" return-type="node-set"><arg type="object"/>

  <arg type="node-set" occur="opt"/></proto>

  

  <p>The <function>document</function> function allows

  access to XML documents other than the main source document.</p>

  

  <p>When the <function>document</function> 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

  <function>document</function> function with the first argument being

  the <xtermref href="&XPath;#dt-string-value">string-value</xtermref>

  of the node, and the second argument being a node-set with the node as

  its only member. When the <function>document</function> 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 <function>document</function> function with the first

  argument being the <xtermref

  href="&XPath;#dt-string-value">string-value</xtermref> of the node,

  and with the second argument being the second argument passed to the

  <function>document</function> function.</p>

  

  <p>When the first argument to the <function>document</function>

  function is not a node-set, the first argument is converted to a

  string as if by a call to the <xfunction>string</xfunction> 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 <specref ref="data-model"/>).  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>

  

  <ulist>

  

  <item><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></item>

  

  <item><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></item>

  

  </ulist>

  

  <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>

  

  <note><p>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.</p></note>

  

  <p>The URI reference may be relative. The base URI (see <specref

  ref="base-uri"/>) 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 <function>document</function>

  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>

  

  <eg>generate-id(document("foo.xml"))=generate-id(document("foo.xml"))</eg>

  

  <p>The <function>document</function> 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 <xtermref

  href="&XPath;#dt-document-order">document order</xtermref> defined by

  XPath <bibref ref="XPATH"/>.  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>

  

  </div2>

  

  <div2 id="key">

  <head>Keys</head>

  

  <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 <xfunction>id</xfunction> function.

  However, this mechanism has a number of limitations:</p>

  

  <ulist>

  

  <item><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></item>

  

  <item><p>A document can contain only a single set of unique IDs.

  There cannot be separate independent sets of unique IDs.</p></item>

  

  <item><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></item>

  

  <item><p>An ID is constrained to be an XML name.  For example, it

  cannot contain spaces.</p></item>

  

  <item><p>An element can have at most one ID.</p></item>

  

  <item><p>At most one element can have a particular ID.</p></item>

  

  </ulist>

  

  <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>

  

  <olist>

  

  <item><p>the node which has the key</p></item>

  

  <item><p>the name of the key (an <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref>)</p></item>

  

  <item><p>the value of the key (a string)</p></item>

  

  </olist>

  

  <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>

  

  <ulist>

  

  <item><p>Keys are declared in the stylesheet using

  <code>xsl:key</code> elements.</p></item>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><p>The value of a key can be an arbitrary string; it is not

  constrained to be a name.</p></item>

  

  <item><p>There can be multiple keys in a document with the same node,

  same key name, but different key values.</p></item>

  

  <item><p>There can be multiple keys in a document with the same key

  name, same key value, but different nodes.</p></item>

  

  </ulist>

  

  <e:element-syntax name="key">

    <e:in-category name="top-level-element"/>

    <e:attribute name="name" required="yes">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="match" required="yes">

      <e:data-type name="pattern"/>

    </e:attribute>

    <e:attribute name="use" required="yes">

      <e:data-type name="expression"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>. The <code>match</code> attribute is a <nt

  def="NT-Pattern">Pattern</nt>; 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 <termref def="dt-expression">expression</termref> 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>

  

  <ulist>

  

  <item><p><var>x</var> matches the pattern specified in the

  <code>match</code> attribute of the <code>xsl:key</code> element;</p></item>

  

  <item><p>the value of the <code>name</code> attribute of the

  <code>xsl:key</code> element is equal to <var>y</var>;

  and</p></item>

  

  <item><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

  <xfunction>string</xfunction> 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></item>

  

  </ulist>

  

  <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 <termref def="dt-import-precedence">import

  precedence</termref>.</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 <xnt

  href="&XPath;#NT-VariableReference">VariableReference</xnt>.</p>

  

  <proto name="key" return-type="node-set"><arg type="string"/><arg type="object"/></proto>

  

  <p>The <function>key</function> function does for keys what the

  <xfunction>id</xfunction> function does for IDs.  The first argument

  specifies the name of the key. The value of the argument must be a

  <xnt href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as

  described in <specref ref="qname"/>. When the second argument to the

  <function>key</function> function is of type node-set, then the result

  is the union of the result of applying the <function>key</function>

  function to the string <xtermref

  href="&XPath;#dt-value">value</xtermref> of each of the nodes in the

  argument node-set.  When the second argument to

  <function>key</function> is of any other type, the argument is

  converted to a string as if by a call to the

  <xfunction>string</xfunction> 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>

  

  <eg><![CDATA[<xsl:key name="idkey" match="div" use="@id"/>]]></eg>

  

  <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>

  

  <eg><![CDATA[<!ATTLIST div id ID #IMPLIED>]]></eg>

  

  <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>

  

  <eg><![CDATA[<prototype name="key" return-type="node-set">

  <arg type="string"/>

  <arg type="object"/>

  </prototype>]]></eg>

  

  <p>and a <code>function</code> element to refer to function names</p>

  

  <eg><![CDATA[<function>key</function>]]></eg>

  

  <p>Then the stylesheet could generate hyperlinks between the

  references and definitions as follows:</p>

  

  <eg><![CDATA[<xsl:key name="func" match="prototype" use="@name"/>

  

  <xsl:template match="function">

  <b>

    <a href="#{generate-id(key('func',.))}">

      <xsl:apply-templates/>

    </a>

  </b>

  </xsl:template>

  

  <xsl:template match="prototype">

  <p><a name="{generate-id()}">

  <b>Function: </b>

  ...

  </a></p>

  </xsl:template>]]></eg>

  

  <p>The <function>key</function> 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><![CDATA[<bibref>XSLT</bibref>]]></code>, and there is a

  separate XML document <code>bib.xml</code> containing a bibliographic

  database with entries in the form:</p>

  

  <eg><![CDATA[<entry name="XSLT">...</entry>]]></eg>

  

  <p>Then the stylesheet could use the following to transform the

  <code>bibref</code> elements:</p>

  

  <eg><![CDATA[<xsl:key name="bib" match="entry" use="@name"/>

  

  <xsl:template match="bibref">

    <xsl:variable name="name" select="."/>

    <xsl:for-each select="document('bib.xml')">

      <xsl:apply-templates select="key('bib',$name)"/>

    </xsl:for-each>

  </xsl:template>]]></eg>

  

  </div2>

  

  <div2 id="format-number">

  <head>Number Formatting</head>

  

  <proto name="format-number" return-type="string"><arg type="number"/><arg type="string"/><arg occur="opt" type="string"/></proto>

  

  <p>The <function>format-number</function> 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 <loc href=

  "http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html"

  >DecimalFormat</loc> 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 <xnt href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as

  described in <specref ref="qname"/>.  It is an error if the stylesheet

  does not contain a declaration of the decimal-format with the specified

  <xtermref href="&XPath;#dt-expanded-name">expanded-name</xtermref>.</p>

  

  <note><p>Implementations are not required to use the JDK 1.1

  implementation, nor are implementations required to be implemented in

  Java.</p></note>

  

  <note><p>Stylesheets can use other facilities in XPath to control

  rounding.</p></note>

  

  <e:element-syntax name="decimal-format">

    <e:in-category name="top-level-element"/>

    

    <e:attribute name="name">

      <e:data-type name="qname"/>

    </e:attribute>

    <e:attribute name="decimal-separator">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="grouping-separator">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="infinity">

      <e:data-type name="string"/>

    </e:attribute>

    <e:attribute name="minus-sign">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="NaN">

      <e:data-type name="string"/>

    </e:attribute>

    <e:attribute name="percent">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="per-mille">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="zero-digit">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="digit">

      <e:data-type name="char"/>

    </e:attribute>

    <e:attribute name="pattern-separator">

      <e:data-type name="char"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <p>The <code>xsl:decimal-format</code> element declares a

  decimal-format, which controls the interpretation of a format pattern

  used by the <function>format-number</function> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>, which is expanded as described

  in <specref ref="qname"/>.  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 <termref def="dt-import-precedence">import

  precedence</termref>), 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 <loc href=

  "http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormatSymbols.html"

  >DecimalFormatSymbols</loc> 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>

  

  <ulist>

  

  <item><p><code>decimal-separator</code> specifies the character used

  for the decimal sign; the default value is the period character

  (<code>.</code>)</p></item>

  

  <item><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></item>

  

  <item><p><code>percent</code> specifies the character used as a

  percent sign; the default value is the percent character

  (<code>%</code>)</p></item>

  

  <item><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></item>

  

  <item><p><code>zero-digit</code> specifies the character used as the

  digit zero; the default value is the digit zero

  (<code>0</code>)</p></item>

  

  </ulist>

  

  <p>The following attributes control the interpretation of characters

  in the format pattern:</p>

  

  <ulist>

  

  <item><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></item>

  

  <item><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></item>

  

  </ulist>

  

  <p>The following attributes specify characters or strings that may

  appear in the result of formatting the number:</p>

  

  <ulist>

  

  <item><p><code>infinity</code> specifies the string used to represent

  infinity; the default value is the string

  <code>Infinity</code></p></item>

  

  <item><p><code>NaN</code> specifies the string used to represent the

  NaN value; the default value is the string <code>NaN</code></p></item>

  

  <item><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></item>

  

  </ulist>

  

  </div2>

  

  <div2 id="misc-func">

  <head>Miscellaneous Additional Functions</head>

  

  <proto name="current" return-type="node-set"></proto>

  

  <p>The <function>current</function> function returns a node-set that

  has the <termref def="dt-current-node">current node</termref> 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>

  

  <eg><![CDATA[<xsl:value-of select="current()"/>]]></eg>

  

  <p>means the same as</p>

  

  <eg><![CDATA[<xsl:value-of select="."/>]]></eg>

  

  <p>However, within square brackets the current node is usually

  different from the context node. For example,</p>

  

  <eg><![CDATA[<xsl:apply-templates select="//glossary/item[@name=current()/@ref]"/>]]></eg>

  

  <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>

  

  <eg><![CDATA[<xsl:apply-templates select="//glossary/item[@name=./@ref]"/>]]></eg>

  

  <p>which means the same as</p>

  

  <eg><![CDATA[<xsl:apply-templates select="//glossary/item[@name=@ref]"/>]]></eg>

  

  <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 <function>current</function> function in

  a <termref def="dt-pattern">pattern</termref>.</p>

  

  <proto name="unparsed-entity-uri" return-type="string"><arg type="string"/></proto>

  

  <p>The <function>unparsed-entity-uri</function> returns the URI of the

  unparsed entity with the specified name in the same document as the

  context node (see <specref ref="unparsed-entities"/>).  It returns the

  empty string if there is no such entity.</p>

  

  <proto name="generate-id" return-type="string"><arg occur="opt" type="node-set"/></proto>

  

  <p>The <function>generate-id</function> 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>

  

  <proto name="system-property" return-type="object"><arg type="string"/></proto>

  

  <p>The argument must evaluate to a string that is a <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  The <xnt

  href="&XMLNames;#NT-QName">QName</xnt> is expanded into a name using

  the namespace declarations in scope for the expression. The

  <function>system-property</function> 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>

  

  <slist>

  

  <sitem><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</sitem>

  

  <sitem><code>xsl:vendor</code>, a string identifying the vendor of the

  XSLT processor</sitem>

  

  <sitem><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.</sitem>

  

  </slist>

  

  </div2>

  

  </div1>

  

  <div1 id="message">

  <head>Messages</head>

  

  <e:element-syntax name="message">

    <e:in-category name="instruction"/>

    <e:attribute name="terminate">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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>

  

  <note><p>An XSLT processor might implement <code>xsl:message</code> by

  popping up an alert box or by writing to a log file.</p></note>

  

  <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>

  

  <eg><![CDATA[<messages>

    <message name="problem">A problem was detected.</message>

    <message name="error">An error was detected.</message>

  </messages>

  ]]></eg>

  

  <p>Then a stylesheet could use the following approach to localize

  messages:</p>

  

  <eg><![CDATA[<xsl:param name="lang" select="en"/>

  <xsl:variable name="messages"

    select="document(concat('resources/', $lang, '.xml'))/messages"/>

  

  <xsl:template name="localized-message">

    <xsl:param name="name"/>

    <xsl:message>

      <xsl:value-of select="$messages/message[@name=$name]"/>

    </xsl:message>

  </xsl:template>

  

  <xsl:template name="problem">

    <xsl:call-template name="localized-message"/>

      <xsl:with-param name="name">problem</xsl:with-param>

    </xsl:call-template>

  </xsl:template>]]></eg>

  

  </div1>

  

  <div1 id="extension">

  <head>Extensions</head>

  

  <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>

  

  <div2 id="extension-element">

  <head>Extension Elements</head>

  

  <p><termdef id="dt-extension-namespace" term="Extension Namespace">The

  element extension mechanism allows namespaces to be designated as

  <term>extension namespace</term>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.</termdef> The namespace

  determines the semantics of the instruction.</p>

  

  <note><p>Since an element that is a child of an

  <code>xsl:stylesheet</code> element is not occurring <emph>in a

  template</emph>, non-XSLT <termref

  def="dt-top-level">top-level</termref> elements are not extension

  elements as defined here, and nothing in this section applies to

  them.</p></note>

  

  <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

  <function>element-available</function> 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 <specref ref="fallback"/>.  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

  <function>element-available</function> function must return true for

  the name of the element.</p>

  

  </div2>

  

  <div2>

  <head>Extension Functions</head>

  

  <p>If a <xnt href="&XPath;#NT-FunctionName">FunctionName</xnt> in a

  <xnt href="&XPath;#NT-FunctionCall">FunctionCall</xnt> expression is

  not an <xnt href="&XMLNames;#NT-NCName">NCName</xnt> (i.e. if it

  contains a colon), then it is treated as a call to an extension

  function.  The <xnt href="&XPath;#NT-FunctionName">FunctionName</xnt>

  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

  <function>function-available</function> 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

  <function>function-available</function> 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>

  

  </div2>

  

  </div1>

  

  <div1 id="fallback">

  <head>Fallback</head>

  

  <e:element-syntax name="fallback">

    <e:in-category name="instruction"/>

    <e:model name="template"/>

  </e:element-syntax>

  

  <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>

  

  <proto name="element-available" return-type="boolean"><arg

  type="string"/></proto>

  

  <p>The argument must evaluate to a string that is a <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  The <xnt

  href="&XMLNames;#NT-QName">QName</xnt> is expanded into an <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> using the

  namespace declarations in scope for the expression. The

  <function>element-available</function> 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 <function>element-available</function> function will return

  false.</p>

  

  <proto name="function-available" return-type="boolean"><arg

  type="string"/></proto>

  

  <p>The argument must evaluate to a string that is a <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  The <xnt

  href="&XMLNames;#NT-QName">QName</xnt> is expanded into an <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> using the

  namespace declarations in scope for the expression. The

  <function>function-available</function> 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>

  

  </div1>

  

  <div1 id="output">

  <head>Output</head>

  

  <e:element-syntax name="output">

    <e:in-category name="top-level-element"/>

    <e:attribute name="method">

      <e:constant value="xml"/>

      <e:constant value="html"/>

      <e:constant value="text"/>

      <e:data-type name="qname-but-not-ncname"/>

    </e:attribute>

    <e:attribute name="version">

      <e:data-type name="nmtoken"/>

    </e:attribute>

    <e:attribute name="encoding">

      <e:data-type name="string"/>

    </e:attribute>

    <e:attribute name="omit-xml-declaration">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:attribute name="standalone">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:attribute name="doctype-public">

      <e:data-type name="string"/>

    </e:attribute>

    <e:attribute name="doctype-system">

      <e:data-type name="string"/>

    </e:attribute>

    <e:attribute name="cdata-section-elements">

      <e:data-type name="qnames"/>

    </e:attribute>

    <e:attribute name="indent">

      <e:constant value="yes"/>

      <e:constant value="no"/>

    </e:attribute>

    <e:attribute name="media-type">

      <e:data-type name="string"/>

    </e:attribute>

    <e:empty/>

  </e:element-syntax>

  

  <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 <specref

  ref="conformance"/>). 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 <termref

  def="dt-top-level">top-level</termref> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt>.  If the <xnt

  href="&XMLNames;#NT-QName">QName</xnt> 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 <xnt

  href="&XMLNames;#NT-QName">QName</xnt> has a prefix, then the <xnt

  href="&XMLNames;#NT-QName">QName</xnt> is expanded into an <xtermref

  href="&XPath;#dt-expanded-name">expanded-name</xtermref> as described

  in <specref ref="qname"/>; 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>

  

  <ulist>

  

  <item><p>the root node of the result tree has an element

  child,</p></item>

  

  <item><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></item>

  

  <item><p>any text nodes preceding the first element child of the root

  node of the result tree contain only whitespace characters,</p></item>

  

  </ulist>

  

  <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>

  

  <ulist>

  

  <item><p><code>version</code> specifies the version of the output

  method</p></item>

  

  <item><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></item>

  

  <item><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 <bibref ref="IANA"/>, <bibref

  ref="RFC2278"/> or start with <code>X-</code></p></item>

  

  <item><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></item>

  

  <item><p><code>doctype-system</code> specifies the system identifier

  to be used in the document type declaration</p></item>

  

  <item><p><code>doctype-public</code> specifies the public identifier

  to be used in the document type declaration</p></item>

  

  <item><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></item>

  

  <item><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></item>

  

  <item><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></item>

  

  </ulist>

  

  <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 <termref

  def="dt-import-precedence">import precedence</termref>. 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>

  

  <div2>

  <head>XML Output Method</head>

  

  <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>

  

  <eg><![CDATA[

  <!DOCTYPE doc [

  <!ENTITY e SYSTEM "]]><var>entity-URI</var><![CDATA[">

  ]>

  <doc>&e;</doc>]]></eg>

  

  <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 <bibref ref="XMLNAMES"/>.  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 <specref

  ref="data-model"/>, 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>

  

  <ulist>

  

  <item><p>The order of attributes in the two trees may be

  different.</p></item>

  

  <item><p>The new tree may contain namespace nodes that were not

  present in the result tree.</p>

  <note><p>An XSLT processor may need to add

  namespace declarations in the course of outputting the result tree as

  XML.</p></note>

  </item>

  

  </ulist>

  

  <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 <xnt

  href="&XML;#NT-VersionNum">VersionNum</xnt> production of the XML

  Recommendation <bibref ref="XML"/>. 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 <xnt

  href="&XML;#NT-EncName">EncName</xnt> production of the XML

  Recommendation <bibref ref="XML"/>.  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 <specref ref="strip"/> 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>

  

  <note><p>It is usually not safe to use <code>indent="yes"</code> with

  document types that include element types with mixed content.</p></note>

  

  <p>The <code>cdata-section-elements</code> attribute contains a

  whitespace-separated list of <xnt

  href="&XMLNames;#NT-QName">QName</xnt>s.  Each <xnt

  href="&XMLNames;#NT-QName">QName</xnt> is expanded into an

  expanded-name using the namespace declarations in effect on the

  <code>xsl:output</code> element in which the <xnt

  href="&XMLNames;#NT-QName">QName</xnt> occurs; if there is a default

  namespace, it is used for <xnt href="&XMLNames;#NT-QName">QName</xnt>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>

  

  <eg><![CDATA[<xsl:output cdata-section-elements="example"/>]]></eg>

  

  <p>would cause a literal result element written in the stylesheet as</p>

  

  <eg><![CDATA[<example>&lt;foo></example>]]></eg>

  

  <p>or as</p>

  

  <eg>&lt;example>&lt;![CDATA[&lt;foo>]]&gt;&lt;/example></eg>

  

  <p>to be output as</p>

  

  <eg>&lt;example>&lt;![CDATA[&lt;foo>]]&gt;&lt;/example></eg>

  

  <p>If the text node contains the sequence of characters

  <code>]]&gt;</code>, then the currently open CDATA section should be

  closed following the <code>]]</code> and a new CDATA section opened

  before the <code>&gt;</code>. For example, a literal result element

  written in the stylesheet as</p>

  

  <eg>&lt;example&gt;]]&amp;gt;&lt;/example&gt;</eg>

  

  <p>would be output as</p>

  

  <eg>&lt;example&gt;&lt;![CDATA[]]]]&gt;&lt;![CDATA[&gt;]]&gt;&lt;/example&gt;</eg>

  

  <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>

  

  </div2>

  

  <div2>

  <head>HTML Output Method</head>

  

  <p>The <code>html</code> output method outputs the result tree as

  HTML; for example,</p>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

  

  <xsl:output method="html"/>

  

  <xsl:template match="/">

    <html>

     <xsl:apply-templates/>

    </html>

  </xsl:template>

  

  ...

  

  </xsl:stylesheet>]]></eg>

  

  <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 <bibref ref="HTML"/>.</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>

  

  <eg><![CDATA[<script>if (a &lt; b) foo()</script>]]></eg>

  

  <p>or</p>

  

  <eg><![CDATA[<script><![CDATA[if (a < b) foo()]]]]><![CDATA[></script>]]></eg>

  

  <p>should be output as</p>

  

  <eg><![CDATA[<script>if (a < b) foo()</script>]]></eg>

  

  <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

  <loc

  href="http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1">Section

  B.2.1</loc> 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>&gt;</code> rather than

  <code>?&gt;</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>

  

  <eg><![CDATA[<OPTION selected="selected">]]></eg>

  

  <p>should be output as</p>

  

  <eg><![CDATA[<OPTION selected>]]></eg>

  

  <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 <loc

  href="http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.7.1.1">Section

  B.7.1</loc> of the HTML 4.0 Recommendation). For example, a start-tag

  written in the stylesheet as</p>

  

  <eg><![CDATA[<BODY bgcolor='&amp;{{randomrbg}};'>]]></eg>

  

  <p>should be output as</p>

  

  <eg><![CDATA[<BODY bgcolor='&{randomrbg};'>]]></eg>

  

  <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>

  

  <eg><![CDATA[<HEAD>

  <META http-equiv="Content-Type" content="text/html; charset=EUC-JP">

  ...]]></eg>

  

  <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>

  

  </div2>

  

  <div2>

  <head>Text Output Method</head>

  

  <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>

  

  </div2>

  

  <div2 id="disable-output-escaping">

  <head>Disabling Output Escaping</head>

  

  <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>

  

  <eg><![CDATA[<xsl:text disable-output-escaping="yes">&lt;</xsl:text>]]></eg>

  

  <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 <termref

  def="dt-result-tree-fragment">result tree fragment</termref> 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>

  

  

  </div2>

  

  </div1>

  

  <div1 id="conformance">

  <head>Conformance</head>

  

  <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>

  

  <note><p>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.</p></note>

  

  <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>

  

  </div1>

  

  <div1 id="notation">

  <head>Notation</head>

  

  <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>

  

  <ulist>

  

  <item><p>An attribute is required if and only if its name is in

  bold.</p></item>

  

  <item><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 <termref

  def="dt-attribute-value-template">attribute value template</termref>,

  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></item>

  

  <item><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; <emph>template</emph> means that any mixture of text nodes,

  literal result elements, extension elements, and XSLT elements from

  the <code>instruction</code> category is allowed;

  <emph>top-level-elements</emph> means that any mixture of XSLT

  elements from the <code>top-level-element</code> category is

  allowed.</p></item>

  

  <item><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 <emph>template</emph> or

  <emph>top-level-elements</emph>.</p></item>

  

  </ulist>

  

  </div1>

  

  </body>

  

  <back>

  <div1>

  <head>References</head>

  <div2>

  <head>Normative References</head>

  

  <blist>

  

  <bibl id="XML" key="XML">World Wide Web Consortium. <emph>Extensible

  Markup Language (XML) 1.0.</emph> W3C Recommendation. See <loc

  href="http://www.w3.org/TR/1998/REC-xml-19980210">http://www.w3.org/TR/1998/REC-xml-19980210</loc></bibl>

  

  <bibl id="XMLNAMES" key="XML Names">World Wide Web

  Consortium. <emph>Namespaces in XML.</emph> W3C Recommendation. See

  <loc

  href="http://www.w3.org/TR/REC-xml-names">http://www.w3.org/TR/REC-xml-names</loc></bibl>

  

  <bibl id="XPATH" key="XPath">World Wide Web Consortium. <emph>XML Path

  Language.</emph> W3C Recommendation. See <loc

  href="&XPath;">http://www.w3.org/TR/xpath</loc></bibl>

  

  </blist>

  </div2>

  <div2>

  <head>Other References</head>

  

  <blist>

  

  <bibl id="CSS2" key="CSS2">World Wide Web Consortium.  <emph>Cascading

  Style Sheets, level 2 (CSS2)</emph>.  W3C Recommendation.  See <loc

  href="http://www.w3.org/TR/1998/REC-CSS2-19980512"

  >http://www.w3.org/TR/1998/REC-CSS2-19980512</loc></bibl>

  

  <bibl id="DSSSL" key="DSSSL">International Organization

  for Standardization, International Electrotechnical Commission.

  <emph>ISO/IEC 10179:1996.  Document Style Semantics and Specification

  Language (DSSSL)</emph>.  International Standard.</bibl>

  

  <bibl id="HTML" key="HTML">World Wide Web Consortium. <emph>HTML 4.0

  specification</emph>. W3C Recommendation. See <loc

  href="http://www.w3.org/TR/REC-html40"

  >http://www.w3.org/TR/REC-html40</loc></bibl>

  

  <bibl id="IANA" key="IANA">Internet Assigned Numbers

  Authority. <emph>Character Sets</emph>. See <loc

  href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets"

  >ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</loc>.</bibl>

  

  <bibl id="RFC2278" key="RFC2278">N. Freed, J. Postel.  <emph>IANA

  Charset Registration Procedures</emph>.  IETF RFC 2278. See <loc

  href="http://www.ietf.org/rfc/rfc2278.txt"

  >http://www.ietf.org/rfc/rfc2278.txt</loc>.</bibl>

  

  <bibl id="RFC2376" key="RFC2376">E. Whitehead, M. Murata.  <emph>XML

  Media Types</emph>. IETF RFC 2376. See <loc

  href="http://www.ietf.org/rfc/rfc2376.txt"

  >http://www.ietf.org/rfc/rfc2376.txt</loc>.</bibl>

  

  <bibl id="RFC2396" key="RFC2396">T. Berners-Lee, R. Fielding, and

  L. Masinter.  <emph>Uniform Resource Identifiers (URI): Generic

  Syntax</emph>. IETF RFC 2396. See <loc

  href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</loc>.</bibl>

  

  <bibl id="UNICODE-TR10" key="UNICODE TR10">Unicode Consortium.

  <emph>Unicode Technical Report #10. Unicode Collation

  Algorithm</emph>.  Unicode Technical Report.  See <loc

  href="http://www.unicode.org/unicode/reports/tr10/index.html"

  >http://www.unicode.org/unicode/reports/tr10/index.html</loc>.</bibl>

  

  <bibl id="XHTML" key="XHTML">World Wide Web Consortium. <emph>XHTML

  1.0: The Extensible HyperText Markup Language.</emph> W3C Proposed

  Recommendation. See <loc href="http://www.w3.org/TR/xhtml1"

  >http://www.w3.org/TR/xhtml1</loc></bibl>

  

  <bibl id="XPTR" key="XPointer">World Wide Web

  Consortium. <emph>XML Pointer Language (XPointer).</emph> W3C Working

  Draft. See <loc href="http://www.w3.org/TR/xptr"

  >http://www.w3.org/TR/xptr</loc></bibl>

  

  <bibl id="XMLSTYLE" key="XML Stylesheet">World Wide Web

  Consortium. <emph>Associating stylesheets with XML documents.</emph>

  W3C Recommendation. See <loc

  href="http://www.w3.org/TR/xml-stylesheet"

  >http://www.w3.org/TR/xml-stylesheet</loc></bibl>

  

  <bibl id="XSL" key="XSL">World Wide Web Consortium.  <emph>Extensible

  Stylesheet Language (XSL).</emph>  W3C Working Draft.  See <loc

  href="http://www.w3.org/TR/WD-xsl"

       >http://www.w3.org/TR/WD-xsl</loc></bibl>

  

  </blist>

  

  </div2>

  </div1>

  

  <div1 id="element-syntax-summary">

  <head>Element Syntax Summary</head>

  

  <e:element-syntax-summary/>

  

  </div1>

  

  <inform-div1 id="dtd">

  <head>DTD Fragment for XSLT Stylesheets</head>

  

  <note><p>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.</p></note>

  

  <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>

  

  <eg><![CDATA[<!ENTITY % result-elements "

    | fo:inline-sequence

    | fo:block

  ">]]></eg>

  

  <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>

  

  <eg><![CDATA[<!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

  ">

  

  <!ENTITY % instructions "

    %char-instructions;

    | xsl:processing-instruction

    | xsl:comment

    | xsl:element

    | xsl:attribute

  ">

  

  <!ENTITY % char-template "

   (#PCDATA

    %char-instructions;)*

  ">

  

  <!ENTITY % template "

   (#PCDATA

    %instructions;

    %result-elements;)*

  ">

  

  <!-- Used for the type of an attribute value that is a URI reference.-->

  <!ENTITY % URI "CDATA">

  

  <!-- Used for the type of an attribute value that is a pattern.-->

  <!ENTITY % pattern "CDATA">

  

  <!-- Used for the type of an attribute value that is an

       attribute value template.-->

  <!ENTITY % avt "CDATA">

  

  <!-- Used for the type of an attribute value that is a QName; the prefix

       gets expanded by the XSLT processor. -->

  <!ENTITY % qname "NMTOKEN">

  

  <!-- Like qname but a whitespace-separated list of QNames. -->

  <!ENTITY % qnames "NMTOKENS">

  

  <!-- Used for the type of an attribute value that is an expression.-->

  <!ENTITY % expr "CDATA">

  

  <!-- Used for the type of an attribute value that consists

       of a single character.-->

  <!ENTITY % char "CDATA">

  

  <!-- Used for the type of an attribute value that is a priority. -->

  <!ENTITY % priority "NMTOKEN">

  

  <!ENTITY % space-att "xml:space (default|preserve) #IMPLIED">

  

  <!-- This may be overridden to customize the set of elements allowed

  at the top-level. -->

  

  <!ENTITY % non-xsl-top-level "">

  

  <!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;)*)

  ">

  

  <!ENTITY % top-level-atts '

    extension-element-prefixes CDATA #IMPLIED

    exclude-result-prefixes CDATA #IMPLIED

    id ID #IMPLIED

    version NMTOKEN #REQUIRED

    xmlns:xsl CDATA #FIXED "]]>&XSLT.ns;<![CDATA["

    %space-att;

  '>

  

  <!-- This entity is defined for use in the ATTLIST declaration

  for result elements. -->

  

  <!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

  '>

  

  <!ELEMENT xsl:stylesheet %top-level;>

  <!ATTLIST xsl:stylesheet %top-level-atts;>

  

  <!ELEMENT xsl:transform %top-level;>

  <!ATTLIST xsl:transform %top-level-atts;>

  

  <!ELEMENT xsl:import EMPTY>

  <!ATTLIST xsl:import href %URI; #REQUIRED>

  

  <!ELEMENT xsl:include EMPTY>

  <!ATTLIST xsl:include href %URI; #REQUIRED>

  

  <!ELEMENT xsl:strip-space EMPTY>

  <!ATTLIST xsl:strip-space elements CDATA #REQUIRED>

  

  <!ELEMENT xsl:preserve-space EMPTY>

  <!ATTLIST xsl:preserve-space elements CDATA #REQUIRED>

  

  <!ELEMENT xsl:output EMPTY>

  <!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

  >

  

  <!ELEMENT xsl:key EMPTY>

  <!ATTLIST xsl:key

    name %qname; #REQUIRED

    match %pattern; #REQUIRED

    use %expr; #REQUIRED

  >

  

  <!ELEMENT xsl:decimal-format EMPTY>

  <!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; "&#x2030;"

    zero-digit %char; "0"

    digit %char; "#"

    pattern-separator %char; ";"

  >

  

  <!ELEMENT xsl:namespace-alias EMPTY>

  <!ATTLIST xsl:namespace-alias

    stylesheet-prefix CDATA #REQUIRED

    result-prefix CDATA #REQUIRED

  >

  

  <!ELEMENT xsl:template

   (#PCDATA

    %instructions;

    %result-elements;

    | xsl:param)*

  >

  

  <!ATTLIST xsl:template

    match %pattern; #IMPLIED

    name %qname; #IMPLIED

    priority %priority; #IMPLIED

    mode %qname; #IMPLIED

    %space-att;

  >

  

  <!ELEMENT xsl:value-of EMPTY>

  <!ATTLIST xsl:value-of

    select %expr; #REQUIRED

    disable-output-escaping (yes|no) "no"

  >

  

  <!ELEMENT xsl:copy-of EMPTY>

  <!ATTLIST xsl:copy-of select %expr; #REQUIRED>

  

  <!ELEMENT xsl:number EMPTY>

  <!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

  >

  

  <!ELEMENT xsl:apply-templates (xsl:sort|xsl:with-param)*>

  <!ATTLIST xsl:apply-templates

    select %expr; "node()"

    mode %qname; #IMPLIED

  >

  

  <!ELEMENT xsl:apply-imports EMPTY>

  

  <!-- xsl:sort cannot occur after any other elements or

  any non-whitespace character -->

  

  <!ELEMENT xsl:for-each

   (#PCDATA

    %instructions;

    %result-elements;

    | xsl:sort)*

  >

  

  <!ATTLIST xsl:for-each

    select %expr; #REQUIRED

    %space-att;

  >

  

  <!ELEMENT xsl:sort EMPTY>

  <!ATTLIST xsl:sort

    select %expr; "."

    lang %avt; #IMPLIED

    data-type %avt; "text"

    order %avt; "ascending"

    case-order %avt; #IMPLIED

  >

  

  <!ELEMENT xsl:if %template;>

  <!ATTLIST xsl:if

    test %expr; #REQUIRED

    %space-att;

  >

  

  <!ELEMENT xsl:choose (xsl:when+, xsl:otherwise?)>

  <!ATTLIST xsl:choose %space-att;>

  

  <!ELEMENT xsl:when %template;>

  <!ATTLIST xsl:when

    test %expr; #REQUIRED

    %space-att;

  >

  

  <!ELEMENT xsl:otherwise %template;>

  <!ATTLIST xsl:otherwise %space-att;>

  

  <!ELEMENT xsl:attribute-set (xsl:attribute)*>

  <!ATTLIST xsl:attribute-set

    name %qname; #REQUIRED

    use-attribute-sets %qnames; #IMPLIED

  >

  

  <!ELEMENT xsl:call-template (xsl:with-param)*>

  <!ATTLIST xsl:call-template

    name %qname; #REQUIRED

  >

  

  <!ELEMENT xsl:with-param %template;>

  <!ATTLIST xsl:with-param

    name %qname; #REQUIRED

    select %expr; #IMPLIED

  >

  

  <!ELEMENT xsl:variable %template;>

  <!ATTLIST xsl:variable 

    name %qname; #REQUIRED

    select %expr; #IMPLIED

  >

  

  <!ELEMENT xsl:param %template;>

  <!ATTLIST xsl:param 

    name %qname; #REQUIRED

    select %expr; #IMPLIED

  >

  

  <!ELEMENT xsl:text (#PCDATA)>

  <!ATTLIST xsl:text

    disable-output-escaping (yes|no) "no"

  >

  

  <!ELEMENT xsl:processing-instruction %char-template;>

  <!ATTLIST xsl:processing-instruction 

    name %avt; #REQUIRED

    %space-att;

  >

  

  <!ELEMENT xsl:element %template;>

  <!ATTLIST xsl:element 

    name %avt; #REQUIRED

    namespace %avt; #IMPLIED

    use-attribute-sets %qnames; #IMPLIED

    %space-att;

  >

  

  <!ELEMENT xsl:attribute %char-template;>

  <!ATTLIST xsl:attribute 

    name %avt; #REQUIRED

    namespace %avt; #IMPLIED

    %space-att;

  >

  

  <!ELEMENT xsl:comment %char-template;>

  <!ATTLIST xsl:comment %space-att;>

  

  <!ELEMENT xsl:copy %template;>

  <!ATTLIST xsl:copy

    %space-att;

    use-attribute-sets %qnames; #IMPLIED

  >

  

  <!ELEMENT xsl:message %template;>

  <!ATTLIST xsl:message

    %space-att;

    terminate (yes|no) "no"

  >

  

  <!ELEMENT xsl:fallback %template;>

  <!ATTLIST xsl:fallback %space-att;>]]></eg>

  

  </inform-div1>

  

  <inform-div1>

  <head>Examples</head>

  

  <div2>

  <head>Document Example</head>

  

  <p>This example is a stylesheet for transforming documents that

  conform to a simple DTD into XHTML <bibref ref="XHTML"/>.  The DTD

  is:</p>

  

  <eg><![CDATA[<!ELEMENT doc (title, chapter*)>

  <!ELEMENT chapter (title, (para|note)*, section*)>

  <!ELEMENT section (title, (para|note)*)>

  <!ELEMENT title (#PCDATA|emph)*>

  <!ELEMENT para (#PCDATA|emph)*>

  <!ELEMENT note (#PCDATA|emph)*>

  <!ELEMENT emph (#PCDATA|emph)*>]]></eg>

  

  <p>The stylesheet is:</p>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"

                  xmlns="&XHTML.ns;"><![CDATA[

  

  <xsl:strip-space elements="doc chapter section"/>

  <xsl:output

     method="xml"

     indent="yes"

     encoding="iso-8859-1"

  />

  

  <xsl:template match="doc">

   <html>

     <head>

       <title>

         <xsl:value-of select="title"/>

       </title>

     </head>

     <body>

       <xsl:apply-templates/>

     </body>

   </html>

  </xsl:template>

  

  <xsl:template match="doc/title">

    <h1>

      <xsl:apply-templates/>

    </h1>

  </xsl:template>

  

  <xsl:template match="chapter/title">

    <h2>

      <xsl:apply-templates/>

    </h2>

  </xsl:template>

  

  <xsl:template match="section/title">

    <h3>

      <xsl:apply-templates/>

    </h3>

  </xsl:template>

  

  <xsl:template match="para">

    <p>

      <xsl:apply-templates/>

    </p>

  </xsl:template>

  

  <xsl:template match="note">

    <p class="note">

      <b>NOTE: </b>

      <xsl:apply-templates/>

    </p>

  </xsl:template>

  

  <xsl:template match="emph">

    <em>

      <xsl:apply-templates/>

    </em>

  </xsl:template>

  

  </xsl:stylesheet>]]></eg>

  

  <p>With the following input document</p>

  

  <eg><![CDATA[<!DOCTYPE doc SYSTEM "doc.dtd">

  <doc>

  <title>Document Title</title>

  <chapter>

  <title>Chapter Title</title>

  <section>

  <title>Section Title</title>

  <para>This is a test.</para>

  <note>This is a note.</note>

  </section>

  <section>

  <title>Another Section Title</title>

  <para>This is <emph>another</emph> test.</para>

  <note>This is another note.</note>

  </section>

  </chapter>

  </doc>]]></eg>

  

  <p>it would produce the following result</p>

  

  <eg>&lt;?xml version="1.0" encoding="iso-8859-1"?>

  &lt;html xmlns="&XHTML.ns;"><![CDATA[

  <head>

  <title>Document Title</title>

  </head>

  <body>

  <h1>Document Title</h1>

  <h2>Chapter Title</h2>

  <h3>Section Title</h3>

  <p>This is a test.</p>

  <p class="note">

  <b>NOTE: </b>This is a note.</p>

  <h3>Another Section Title</h3>

  <p>This is <em>another</em> test.</p>

  <p class="note">

  <b>NOTE: </b>This is another note.</p>

  </body>

  </html>]]></eg>

  

  </div2>

  

  <div2 id="data-example">

  <head>Data Example</head>

  

  <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>

  

  <eg><![CDATA[<sales>

  

          <division id="North">

                  <revenue>10</revenue>

                  <growth>9</growth>

                  <bonus>7</bonus>

          </division>

  

          <division id="South">

                  <revenue>4</revenue>

                  <growth>3</growth>

                  <bonus>4</bonus>

          </division>

  

          <division id="West">

                  <revenue>6</revenue>

                  <growth>-1.5</growth>

                  <bonus>2</bonus>

          </division>

  

  </sales>]]></eg>

  

  <p>The following stylesheet, which uses the simplified syntax

  described in <specref ref="result-element-stylesheet"/>, transforms

  the data into HTML:</p>

  

  <eg>&lt;html xsl:version="1.0"

        xmlns:xsl="&XSLT.ns;"<![CDATA[

        lang="en">

      <head>

  	<title>Sales Results By Division</title>

      </head>

      <body>

  	<table border="1">

  	    <tr>

  		<th>Division</th>

  		<th>Revenue</th>

  		<th>Growth</th>

  		<th>Bonus</th>

  	    </tr>

  	    <xsl:for-each select="sales/division">

  		<!-- order the result by revenue -->

  		<xsl:sort select="revenue"

  			  data-type="number"

  			  order="descending"/>

  		<tr>

  		    <td>

  			<em><xsl:value-of select="@id"/></em>

  		    </td>

  		    <td>

  			<xsl:value-of select="revenue"/>

  		    </td>

  		    <td>

  			<!-- highlight negative growth in red -->

  			<xsl:if test="growth &lt; 0">

  			     <xsl:attribute name="style">

  				 <xsl:text>color:red</xsl:text>

  			     </xsl:attribute>

  			</xsl:if>

  			<xsl:value-of select="growth"/>

  		    </td>

  		    <td>

  			<xsl:value-of select="bonus"/>

  		    </td>

  		</tr>

  	    </xsl:for-each>

  	</table>

      </body>

  </html>]]></eg>

  

  <p>The HTML output is:</p>

  

  <eg><![CDATA[<html lang="en">

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  <title>Sales Results By Division</title>

  </head>

  <body>

  <table border="1">

  <tr>

  <th>Division</th><th>Revenue</th><th>Growth</th><th>Bonus</th>

  </tr>

  <tr>

  <td><em>North</em></td><td>10</td><td>9</td><td>7</td>

  </tr>

  <tr>

  <td><em>West</em></td><td>6</td><td style="color:red">-1.5</td><td>2</td>

  </tr>

  <tr>

  <td><em>South</em></td><td>4</td><td>3</td><td>4</td>

  </tr>

  </table>

  </body>

  </html>]]></eg>

  

  <p>The following stylesheet transforms the data into SVG:</p>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"<![CDATA[

                  xmlns="http://www.w3.org/Graphics/SVG/SVG-19990812.dtd">

  

  <xsl:output method="xml" indent="yes" media-type="image/svg"/>

  

  <xsl:template match="/">

  

  <svg width = "3in" height="3in">

      <g style = "stroke: #000000"> 

          <!-- draw the axes -->

          <line x1="0" x2="150" y1="150" y2="150"/>

          <line x1="0" x2="0" y1="0" y2="150"/>

          <text x="0" y="10">Revenue</text>

          <text x="150" y="165">Division</text>

          <xsl:for-each select="sales/division">

  	    <!-- define some useful variables -->

  

  	    <!-- the bar's x position -->

  	    <xsl:variable name="pos"

  	                  select="(position()*40)-30"/>

  

  	    <!-- the bar's height -->

  	    <xsl:variable name="height"

  	                  select="revenue*10"/>

  

  	    <!-- the rectangle -->

  	    <rect x="{$pos}" y="{150-$height}"

                    width="20" height="{$height}"/>

  

  	    <!-- the text label -->

  	    <text x="{$pos}" y="165">

  	        <xsl:value-of select="@id"/>

  	    </text> 

  

  	    <!-- the bar value -->

  	    <text x="{$pos}" y="{145-$height}">

  	        <xsl:value-of select="revenue"/>

  	    </text>

          </xsl:for-each>

      </g>

  </svg>

  

  </xsl:template>

  </xsl:stylesheet>]]></eg>

  

  <p>The SVG output is:</p>

  

  <eg><![CDATA[<svg width="3in" height="3in"

       xmlns="http://www.w3.org/Graphics/SVG/svg-19990412.dtd">

      <g style="stroke: #000000">

  	<line x1="0" x2="150" y1="150" y2="150"/>

  	<line x1="0" x2="0" y1="0" y2="150"/>

  	<text x="0" y="10">Revenue</text>

  	<text x="150" y="165">Division</text>

  	<rect x="10" y="50" width="20" height="100"/>

  	<text x="10" y="165">North</text>

  	<text x="10" y="45">10</text>

  	<rect x="50" y="110" width="20" height="40"/>

  	<text x="50" y="165">South</text>

  	<text x="50" y="105">4</text>

  	<rect x="90" y="90" width="20" height="60"/>

  	<text x="90" y="165">West</text>

  	<text x="90" y="85">6</text>

      </g>

  </svg>]]></eg>

  

  <p>The following stylesheet transforms the data into VRML:</p>

  

  <eg>&lt;xsl:stylesheet version="1.0"

                  xmlns:xsl="&XSLT.ns;"><![CDATA[

  

  <!-- generate text output as mime type model/vrml, using default charset -->

  <xsl:output method="text" encoding="UTF-8" media-type="model/vrml"/>  

  

          <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" 

          } 

          

                  <xsl:for-each select="sales/division">

  bar {

          x <xsl:value-of select="revenue"/>

          y <xsl:value-of select="growth"/>

          z <xsl:value-of select="bonus"/>

          name "<xsl:value-of select="@id"/>" 

          }

                  </xsl:for-each>

          

          </xsl:template> 

   

  </xsl:stylesheet>]]></eg>

  

  <p>The VRML output is:</p>

  

  <eg><![CDATA[#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" 

          }]]></eg>

  

  </div2>

  

  </inform-div1>

  

  <inform-div1>

  <head>Acknowledgements</head>

  <p>The following have contributed to authoring this draft:</p>

  <slist>

  <sitem>Daniel Lipkin, Saba</sitem>

  <sitem>Jonathan Marsh, Microsoft</sitem>

  <sitem>Henry Thompson, University of Edinburgh</sitem>

  <sitem>Norman Walsh, Arbortext</sitem>

  <sitem>Steve Zilles, Adobe</sitem>

  </slist>

  

  <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>

  

  <orglist>

  <member>

  <name>Sharon Adler</name>

  <affiliation>IBM</affiliation>

  <role>Co-Chair</role>

  </member>

  <member>

  <name>Anders Berglund</name>

  <affiliation>IBM</affiliation>

  </member>

  <member>

  <name>Perin Blanchard</name>

  <affiliation>Novell</affiliation>

  </member>

  <member>

  <name>Scott Boag</name>

  <affiliation>Lotus</affiliation> 

  </member>

  <member>

  <name>Larry Cable</name>

  <affiliation>Sun</affiliation>

  </member>

  <member>

  <name>Jeff Caruso</name>

  <affiliation>Bitstream</affiliation>

  </member>

  <member>

  <name>James Clark</name>

  </member>

  <member>

  <name>Peter Danielsen</name>

  <affiliation>Bell Labs</affiliation>

  </member>

  <member>

  <name>Don Day</name>

  <affiliation>IBM</affiliation>

  </member>

  <member>

  <name>Stephen Deach</name>

  <affiliation>Adobe</affiliation>

  </member>

  <member>

  <name>Dwayne Dicks</name>

  <affiliation>SoftQuad</affiliation>

  </member>

  <member>

  <name>Andrew Greene</name>

  <affiliation>Bitstream</affiliation>

  </member>

  <member>

  <name>Paul Grosso</name>

  <affiliation>Arbortext</affiliation>

  </member>

  <member>

  <name>Eduardo Gutentag</name>

  <affiliation>Sun</affiliation>

  </member>

  <member>

  <name>Juliane Harbarth</name>

  <affiliation>Software AG</affiliation>

  </member>

  <member>

  <name>Mickey Kimchi</name>

  <affiliation>Enigma</affiliation>

  </member>

  <member>

  <name>Chris Lilley</name>

  <affiliation>W3C</affiliation>

  </member>

  <member>

  <name>Chris Maden</name>

  <affiliation>Exemplary Technologies</affiliation>

  </member>

  <member>

  <name>Jonathan Marsh</name>

  <affiliation>Microsoft</affiliation>

  </member>

  <member>

  <name>Alex Milowski</name> 

  <affiliation>Lexica</affiliation>

  </member>

  <member>

  <name>Steve Muench</name>

  <affiliation>Oracle</affiliation>

  </member>

  <member>

  <name>Scott Parnell</name>

  <affiliation>Xerox</affiliation>

  </member>

  <member>

  <name>Vincent Quint</name>

  <affiliation>W3C</affiliation>

  </member>

  <member>

  <name>Dan Rapp</name>

  <affiliation>Novell</affiliation>

  </member>

  <member>

  <name>Gregg Reynolds</name>

  <affiliation>Datalogics</affiliation>

  </member>

  <member>

  <name>Jonathan Robie</name>

  <affiliation>Software AG</affiliation>

  </member>

  <member>

  <name>Mark Scardina</name>

  <affiliation>Oracle</affiliation>

  </member>

  <member>

  <name>Henry Thompson</name>

  <affiliation>University of Edinburgh</affiliation>

  </member>

  <member>

  <name>Philip Wadler</name>

  <affiliation>Bell Labs</affiliation>

  </member>

  <member>

  <name>Norman Walsh</name>

  <affiliation>Arbortext</affiliation>

  </member>

  <member>

  <name>Sanjiva Weerawarana</name>

  <affiliation>IBM</affiliation>

  </member>

  <member>

  <name>Steve Zilles</name>

  <affiliation>Adobe</affiliation>

  <role>Co-Chair</role>

  </member>

  </orglist>

  

  </inform-div1>

  

  <inform-div1>

  <head>Changes from Proposed Recommendation</head>

  

  <p>The following are the changes since the Proposed Recommendation:</p>

  

  <ulist>

  

  <item><p>The <code>xsl:version</code> attribute is required on a

  literal result element used as a stylesheet (see <specref

  ref="result-element-stylesheet"/>).</p></item>

  

  <item><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 <specref ref="sorting"/>).</p></item>

  

  </ulist>

  

  </inform-div1>

  

  <inform-div1>

  <head>Features under Consideration for Future Versions of XSLT</head>

  

  <p>The following features are under consideration for versions of XSLT

  after XSLT 1.0:</p>

  

  <ulist>

  

  <item><p>a conditional expression;</p></item>

  

  <item><p>support for XML Schema datatypes and archetypes;</p></item>

  

  <item><p>support for something like style rules in the original XSL

  submission;</p></item>

  

  <item><p>an attribute to control the default namespace for names

  occurring in XSLT attributes;</p></item>

  

  <item><p>support for entity references;</p></item>

  

  <item><p>support for DTDs in the data model;</p></item>

  

  <item><p>support for notations in the data model;</p></item>

  

  <item><p>a way to get back from an element to the elements that

  reference it (e.g. by IDREF attributes);</p></item>

  

  <item><p>an easier way to get an ID or key in another document;</p></item>

  

  <item><p>support for regular expressions for matching against any or

  all of text nodes, attribute values, attribute names, element type

  names;</p></item>

  

  <item><p>case-insensitive comparisons;</p></item>

  

  <item><p>normalization of strings before comparison, for example for

  compatibility characters;</p></item>

  

  <item><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></item>

  

  <item><p>multiple result documents;</p></item>

  

  <item><p>defaulting the <code>select</code> attribute on

  <code>xsl:value-of</code> to the current node;</p></item>

  

  <item><p>an attribute on <code>xsl:attribute</code> to control how the

  attribute value is normalized;</p></item>

  

  <item><p>additional attributes on <code>xsl:sort</code> to provide

  further control over sorting, such as relative order of

  scripts;</p></item>

  

  <item><p>a way to put the text of a resource identified by a URI into

  the result tree;</p></item>

  

  <item><p>allow unions in steps (e.g. <code>foo/(bar|baz)</code>);</p></item>

  

  <item><p>allow for result tree fragments all operations that are

  allowed for node-sets;</p></item>

  

  <item><p>a way to group together consecutive nodes having duplicate

  subelements or attributes;</p></item>

  

  <item><p>features to make handling of the HTML <code>style</code>

  attribute more convenient.</p></item>

  

  </ulist>

  

  </inform-div1>

  

  </back>

  </spec>

  
  
  
  1.1                  xml-xalan/test/tests/contrib/xsltc/mk/mk062.xml
  
  Index: mk062.xml
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE BOOKLIST SYSTEM "./inc/books.dtd">
  <BOOKLIST>
  <BOOKS>
  	<ITEM CAT="S">
      	<TITLE>Number, the Language of Science</TITLE>
      	<AUTHOR>Danzig</AUTHOR>
      	<PRICE>5.95</PRICE>
      	<QUANTITY>3</QUANTITY>
  	</ITEM>
  	<ITEM CAT="F">
  		<TITLE>Tales of Grandpa Cat</TITLE>
  		<PUBLISHER>Associated Press</PUBLISHER>
  		<AUTHOR>Wardlaw, Lee</AUTHOR>
  		<PRICE>6.58</PRICE>
  		<QUANTITY>5</QUANTITY>
  	</ITEM>
  	<ITEM CAT="S">
  		<TITLE>Language &amp; the Science of Number</TITLE>
  		<AUTHOR>Danzig</AUTHOR>
  		<PRICE>8.95</PRICE>
  		<QUANTITY>5</QUANTITY>
  	</ITEM>
  	<ITEM CAT="S">
  		<TITLE>Evolution of Complexity in Animal Culture</TITLE>
  		<AUTHOR>Bonner</AUTHOR>
  		<PRICE>5.95</PRICE>
  		<QUANTITY>2</QUANTITY>
  	</ITEM>
  	<ITEM CAT="X">
  		<TITLE>Patterns of Crime in Animal Culture</TITLE>
  		<AUTHOR>Bonner</AUTHOR>
  		<PRICE>15.95</PRICE>
  		<QUANTITY>0</QUANTITY>
  	</ITEM>
  
  	<ITEM CAT="F" TAX="7.5">
  		<TITLE>When We Were Very Young</TITLE>
  		<AUTHOR>Milne, A. A.</AUTHOR>
  		<PRICE>12.50</PRICE>
  		<QUANTITY>1</QUANTITY>
  	</ITEM>
  	<ITEM CAT="C">
  		<TITLE>Learn Java Now</TITLE>
  		<AUTHOR>Stephen R. Davis</AUTHOR>
  		<PUBLISHER>Microsoft Corporation</PUBLISHER>
  		<PRICE>9.95</PRICE>
  		<QUANTITY>12</QUANTITY>
  	</ITEM>
  	<ITEM CAT="U" TAX="12.5">
  		<TITLE>Design Patterns</TITLE>
  		<AUTHOR>Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides</AUTHOR>
  		<PUBLISHER>Addison Wesley</PUBLISHER>
  		<PRICE>49.95</PRICE>
  		<QUANTITY>2</QUANTITY>
  	</ITEM>
  	<?testpi1 here is a message ?>
  	<?testpi2 here is a message ?>
  </BOOKS>
  <CATEGORIES DESC="Miscellaneous categories">
  A list of categories
  	<CATEGORY CODE="S" DESC="Science"/>
  	<CATEGORY CODE="I" DESC="Science" NOTE="Limited Stock"/>
  	<CATEGORY CODE="C" DESC="Computing"/>
  	<CATEGORY CODE="X" DESC="Crime"/>
  	<CATEGORY CODE="F" DESC="Fiction"/>
  </CATEGORIES>
  </BOOKLIST>
  
  
  

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