<xslTutorial creator="nicmila@idoox.com">
<index keywords='id() name()'/>
<description>
The id function selects elements by their unique ID. <stylesheet id='id2'/> shows simple examples of its use. Carefully study <stylesheet id='id3'/>. Contents of title element is not displayed in [] as in DTD its attribute id is defined as CDATA, not ID. Several id's can be provided at once (<stylesheet id='id4'/>).
</description>
<dtd>
<!ELEMENT chapter ANY>
<!ATTLIST chapter id ID #REQUIRED>
<!ELEMENT title ANY>
<!ATTLIST title id CDATA #REQUIRED>
<!ELEMENT text ANY>
<!ATTLIST text value ID #REQUIRED>
</dtd>
<xmlSource id="id1">
<chapter id="intro">Introduction</chapter>
<chapter id="body">
<title id="t1">BODY</title>
<text value="text1">text text text</text>
</chapter>
<chapter id="end">THE END</chapter>
</xmlSource>
<attValues>
<value match='//*[@*]'>Matches all elements containing one or more attributes</value>
<value match='@*'>Matches all attributes</value>
</attValues>
<xslStylesheet id="id2">
<xsl:template match="/">
<P><xsl:value-of select="id('intro')"/></P>
<P><xsl:value-of select="id('body')/text"/></P>
<P><xsl:value-of select="id('text1')"/></P>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id3">
<xsl:template match="/">
<xsl:for-each select="//*[@*]">
<DIV>
<xsl:value-of select="name()"/>
<xsl:text> : </xsl:text>
<xsl:apply-templates select="@*"/>
</DIV>
</xsl:for-each>
</xsl:template>
<xsl:template match="@*">
<xsl:value-of select="name()"/>
<xsl:text> = </xsl:text>
<xsl:value-of select="."/>
<xsl:text> [ </xsl:text>
<xsl:value-of select="id(.)"/>
<xsl:text>]</xsl:text>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id4">
<xsl:template match="/">
<xsl:apply-templates select="id('intro body end')"/>
<!-- Why only intro is selected? Can anybody help?-->
<P><xsl:value-of select="id('intro body end')"/></P>
<P><xsl:value-of select="id('body end intro')"/></P>
<P><xsl:value-of select="id('in bod end')"/></P>
</xsl:template>
<xsl:template match="*">
<P style="color:red"><xsl:value-of select="."/></P>
</xsl:template>
</xslStylesheet>
</xslTutorial>