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