paulb@169 | 1 | <?xml version="1.0" encoding="utf-8"?> |
paulb@169 | 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
paulb@169 | 3 | xmlns:template="http://www.boddie.org.uk/ns/xmltools/template" |
paulb@169 | 4 | version="1.0"> |
paulb@169 | 5 | |
paulb@169 | 6 | <!-- Add or process comment elements inside item elements. --> |
paulb@169 | 7 | <!-- This transformation must happen after type elements have been populated. --> |
paulb@169 | 8 | |
paulb@169 | 9 | <xsl:template match="item"> |
paulb@169 | 10 | <!-- Copy the element and its contents. --> |
paulb@169 | 11 | <xsl:copy> |
paulb@169 | 12 | <xsl:apply-templates select="@*"/> |
paulb@169 | 13 | <!-- Only for certain element types... --> |
paulb@169 | 14 | <xsl:if test="type/type-enum[@value='Personal' and @value-is-set]"> |
paulb@169 | 15 | <!-- Ensure a comment element. --> |
paulb@169 | 16 | <xsl:call-template name="comment"/> |
paulb@169 | 17 | </xsl:if> |
paulb@169 | 18 | <xsl:apply-templates select="*[local-name() != 'comment']"/> |
paulb@169 | 19 | </xsl:copy> |
paulb@169 | 20 | </xsl:template> |
paulb@169 | 21 | |
paulb@169 | 22 | <!-- Investigate comment elements. --> |
paulb@169 | 23 | |
paulb@169 | 24 | <xsl:template name="comment"> |
paulb@169 | 25 | <!-- Make the element. --> |
paulb@169 | 26 | <comment> |
paulb@169 | 27 | <!-- Look for comment text. --> |
paulb@169 | 28 | <xsl:apply-templates select="comment/@*"/> |
paulb@169 | 29 | </comment> |
paulb@169 | 30 | </xsl:template> |
paulb@169 | 31 | |
paulb@169 | 32 | <!-- Replicate unknown elements. --> |
paulb@169 | 33 | |
paulb@169 | 34 | <xsl:template match="@*|*|node()"> |
paulb@169 | 35 | <xsl:copy> |
paulb@169 | 36 | <xsl:apply-templates select="@*|*|node()"/> |
paulb@169 | 37 | </xsl:copy> |
paulb@169 | 38 | </xsl:template> |
paulb@169 | 39 | |
paulb@169 | 40 | </xsl:stylesheet> |