source: documentation/trunk/tutorials/processing/preprocess-tut-xml.xsl@ 25767

Last change on this file since 25767 was 25767, checked in by ak19, 12 years ago

Processing of the MajorVersion element is moved into a separate preprocessing pass, in order to ensure that NumberedItems nested in a MajorVersion element continue to have the right numbering on display.

File size: 1.1 KB
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.