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@175 | 13 | <!-- Ensure an options element. --> |
paulb@175 | 14 | <xsl:call-template name="options"/> |
paulb@175 | 15 | <xsl:apply-templates select="*[local-name() != 'options']"/> |
paulb@169 | 16 | </xsl:copy> |
paulb@169 | 17 | </xsl:template> |
paulb@169 | 18 | |
paulb@175 | 19 | <!-- Investigate options elements. --> |
paulb@169 | 20 | |
paulb@175 | 21 | <xsl:template name="options"> |
paulb@169 | 22 | <!-- Make the element. --> |
paulb@175 | 23 | <options> |
paulb@175 | 24 | <!-- Only for certain element types... --> |
paulb@175 | 25 | <xsl:if test="type/type-enum[@value='Personal' and @value-is-set]"> |
paulb@175 | 26 | <!-- Add comments. --> |
paulb@175 | 27 | <comment> |
paulb@175 | 28 | <xsl:apply-templates select="options/comment/@value"/> |
paulb@175 | 29 | </comment> |
paulb@175 | 30 | </xsl:if> |
paulb@175 | 31 | </options> |
paulb@169 | 32 | </xsl:template> |
paulb@169 | 33 | |
paulb@169 | 34 | <!-- Replicate unknown elements. --> |
paulb@169 | 35 | |
paulb@169 | 36 | <xsl:template match="@*|*|node()"> |
paulb@169 | 37 | <xsl:copy> |
paulb@169 | 38 | <xsl:apply-templates select="@*|*|node()"/> |
paulb@169 | 39 | </xsl:copy> |
paulb@169 | 40 | </xsl:template> |
paulb@169 | 41 | |
paulb@169 | 42 | </xsl:stylesheet> |