1 <?xml version="1.0" encoding="utf-8"?> 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:template="http://www.boddie.org.uk/ns/xmltools/template" 4 version="1.0"> 5 6 <xsl:param name="categories"/> 7 8 <xsl:template match="categories"> 9 <xsl:copy> 10 <xsl:element name="category"> 11 <xsl:variable name="category-elements" select="category"/> 12 <xsl:for-each select="$categories/category/category-enum"> 13 <xsl:variable name="category-enum" select="."/> 14 <xsl:copy> 15 <xsl:apply-templates select="@*"/> 16 <xsl:if test="$category-elements[@value = $category-enum/@value]"> 17 <xsl:attribute name="value-is-set">true</xsl:attribute> 18 </xsl:if> 19 </xsl:copy> 20 </xsl:for-each> 21 </xsl:element> 22 </xsl:copy> 23 </xsl:template> 24 25 <!-- Replicate unknown elements. --> 26 27 <xsl:template match="@*|node()"> 28 <xsl:copy> 29 <xsl:apply-templates select="@*|node()"/> 30 </xsl:copy> 31 </xsl:template> 32 33 </xsl:stylesheet>