paulb@137 | 1 | <?xml version="1.0" encoding="utf-8"?> |
paulb@137 | 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
paulb@137 | 3 | version="1.0"> |
paulb@137 | 4 | |
paulb@137 | 5 | <xsl:param name="types"/> |
paulb@137 | 6 | |
paulb@137 | 7 | <!-- Add or process type elements inside item elements. --> |
paulb@137 | 8 | |
paulb@137 | 9 | <xsl:template match="item"> |
paulb@137 | 10 | <!-- Copy the element and its contents. --> |
paulb@137 | 11 | <xsl:copy> |
paulb@137 | 12 | <xsl:apply-templates select="@*"/> |
paulb@137 | 13 | <!-- Look for a type element. --> |
paulb@160 | 14 | <xsl:call-template name="type"/> |
paulb@137 | 15 | <xsl:apply-templates select="*[local-name() != 'type']"/> |
paulb@137 | 16 | </xsl:copy> |
paulb@137 | 17 | </xsl:template> |
paulb@137 | 18 | |
paulb@137 | 19 | <!-- Investigate type elements. --> |
paulb@137 | 20 | |
paulb@137 | 21 | <xsl:template name="type"> |
paulb@137 | 22 | <!-- Make the element. --> |
paulb@137 | 23 | <type> |
paulb@160 | 24 | <xsl:apply-templates select="type/@*"/> |
paulb@137 | 25 | <xsl:call-template name="type-enum"/> |
paulb@137 | 26 | </type> |
paulb@137 | 27 | </xsl:template> |
paulb@137 | 28 | |
paulb@137 | 29 | <!-- Add to type elements the range of acceptable values. --> |
paulb@137 | 30 | |
paulb@137 | 31 | <xsl:template name="type-enum"> |
paulb@137 | 32 | <!-- Find all values in the range and add them. --> |
paulb@137 | 33 | <xsl:for-each select="$types/types/type-enum"> |
paulb@137 | 34 | <xsl:copy> |
paulb@137 | 35 | <xsl:apply-templates select="@*"/> |
paulb@137 | 36 | </xsl:copy> |
paulb@137 | 37 | </xsl:for-each> |
paulb@137 | 38 | </xsl:template> |
paulb@137 | 39 | |
paulb@137 | 40 | <!-- Replicate unknown elements. --> |
paulb@137 | 41 | |
paulb@137 | 42 | <xsl:template match="@*|*|node()"> |
paulb@137 | 43 | <xsl:copy> |
paulb@137 | 44 | <xsl:apply-templates select="@*|*|node()"/> |
paulb@137 | 45 | </xsl:copy> |
paulb@137 | 46 | </xsl:template> |
paulb@137 | 47 | |
paulb@137 | 48 | </xsl:stylesheet> |