A sequence of several values can be passed to a key() function. The resulting sequence is a union of all hits returned by individual keys in the second argument to the key() function.
|
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="bbb" use="@y"/> <xsl:template match="/aaa"> <xsl:apply-templates select="key('kkk',ccc/ddd)"/> </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> <bbb y="c">Z</bbb> <ccc> <ddd>a</ddd> <ddd>c</ddd> </ccc> </aaa> |
Output
<bbb y="a">X</bbb> <bbb y="c">Z</bbb> |
| Previous chapter: | Namespaces |
| Next chapter: | Recursions |
| Previous page: | The same node matched by several keys |
| Next page: | Optional third argument of key function |