Several xsl:keys may match the same node in the source document.
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:key name="kkk" match="*" use="@y"/> <xsl:key name="jjj" match="vvv" use="."/> <xsl:template match="/aaa"> <ggg> <xsl:apply-templates select="key('kkk','b')"/> </ggg> <hhh> <xsl:apply-templates select="key('jjj','Z')"/> </hhh> </xsl:template> <xsl:template match="*"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb y="a">X</bbb> <bbb y="b">Y</bbb> <vvv y="b">Z</vvv> </aaa> |
Output
<ggg> <bbb y="b">Y</bbb> <vvv y="b">Z</vvv> </ggg> <hhh> <vvv y="b">Z</vvv> </hhh> |
| Previous chapter: | Namespaces |
| Next chapter: | Recursions |
| Previous page: | Several keys elements of the same name |
| Next page: | Sequence of several values as the second argument of key function |