1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:output method="xml" indent="yes" />
<xsl:key name="category" match="catalog/*" use="@category" />
<xsl:template match="catalog">
<catalog catalog-id="photo-catalog">
<xsl:apply-templates select="header[1]" />
<xsl:if test=". != ''">
<xsl:apply-templates select="*[generate-id(.)=generate-id(key('category',@category)[1])]"/>
</xsl:if>
</catalog>
</xsl:template>
<xsl:template match="book">
<book category="{@category}">
<xsl:if test=". != ''">
<xsl:copy-of select="key('category', @category)" />
</xsl:if>
</book>
</xsl:template>
</xsl:stylesheet> |
Partager