Line | |
---|
1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <xsl:stylesheet version="1.0"
|
---|
3 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
4 |
|
---|
5 | <!-- This xslt removes all MajorVersion elements from the input XML that do not
|
---|
6 | match with the specified gs-major-version parameter.
|
---|
7 | The output XML is therefore mostly identical. -->
|
---|
8 |
|
---|
9 | <xsl:param name="gs-major-version"/>
|
---|
10 |
|
---|
11 | <xsl:output method="xml"/>
|
---|
12 |
|
---|
13 | <!-- By default, apply-templates copies just the text nodes, not outer elements.
|
---|
14 | Need to explicitly copy outer elements across -->
|
---|
15 | <xsl:template match="*">
|
---|
16 | <xsl:copy>
|
---|
17 | <xsl:copy-of select="@*"/>
|
---|
18 | <xsl:apply-templates/>
|
---|
19 | </xsl:copy>
|
---|
20 | </xsl:template>
|
---|
21 |
|
---|
22 | <!-- All MajorVersion elements that match the specified gs-major-version parameter need
|
---|
23 | to be copied across. The apply-templates call will match on the template definition
|
---|
24 | for * above and copy the subelements of matching MajorVersion elements across. -->
|
---|
25 | <xsl:template match="MajorVersion">
|
---|
26 | <xsl:if test="$gs-major-version=@number">
|
---|
27 | <xsl:apply-templates/>
|
---|
28 | </xsl:if>
|
---|
29 | </xsl:template>
|
---|
30 |
|
---|
31 | </xsl:stylesheet>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.