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 <!-- Add or process comment elements inside item elements. --> 7 <!-- This transformation must happen after type elements have been populated. --> 8 9 <xsl:template match="item"> 10 <!-- Copy the element and its contents. --> 11 <xsl:copy> 12 <xsl:apply-templates select="@*"/> 13 <!-- Only for certain element types... --> 14 <xsl:if test="type/type-enum[@value='Personal' and @value-is-set]"> 15 <!-- Ensure a comment element. --> 16 <xsl:call-template name="comment"/> 17 </xsl:if> 18 <xsl:apply-templates select="*[local-name() != 'comment']"/> 19 </xsl:copy> 20 </xsl:template> 21 22 <!-- Investigate comment elements. --> 23 24 <xsl:template name="comment"> 25 <!-- Make the element. --> 26 <comment> 27 <!-- Look for comment text. --> 28 <xsl:apply-templates select="comment/@*"/> 29 </comment> 30 </xsl:template> 31 32 <!-- Replicate unknown elements. --> 33 34 <xsl:template match="@*|*|node()"> 35 <xsl:copy> 36 <xsl:apply-templates select="@*|*|node()"/> 37 </xsl:copy> 38 </xsl:template> 39 40 </xsl:stylesheet>