Debian Codegraph @

helper/xsl_to_v74/convert39to41.xsl

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <xsl:output method="xml"
4 indent="yes" omit-xml-declaration="no" encoding="utf-8"/>
5
6 <!-- default rule -->
7 <xsl:template match="*" mode="conv39to41">
8 <xsl:copy>
9 <xsl:copy-of select="@*"/>
10 <xsl:apply-templates mode="conv39to41"/>
11 </xsl:copy>
12 </xsl:template>
13
14 <!-- version update -->
15 <para xmlns="http://docbook.org/ns/docbook">
16 Changed attribute <tag class="attribute">schemaversion</tag>
17 to <tag class="attribute">schemaversion</tag> from
18 <literal>3.9</literal> to <literal>4.1</literal>. Adding
19 <tag class="attribute">image</tag> attribute to
20 <tag class="element">type</tag> element and collecting the
21 appropriate <tag class="element">*config</tag> elements as
22 children of the <tag class="element">type</tag> element.
23 </para>
24 <xsl:template match="image" mode="conv39to41">
25 <xsl:choose>
26 <!-- nothing to do if already at 4.1 -->
27 <xsl:when test="@schemaversion > 3.9">
28 <xsl:copy-of select="."/>
29 </xsl:when>
30 <!-- otherwise apply templates -->
31 <xsl:otherwise>
32 <image schemaversion="4.1">
33 <xsl:copy-of select="@*[local-name() != 'schemaversion']"/>
34 <xsl:apply-templates mode="conv39to41"/>
35 </image>
36 </xsl:otherwise>
37 </xsl:choose>
38 </xsl:template>
39
40 <!-- toplevel processing instructions and comments -->
41 <xsl:template match="processing-instruction()|comment()" mode="conv39to41">
42 <xsl:copy>
43 <xsl:copy-of select="@*"/>
44 <xsl:apply-templates mode="conv39to41"/>
45 </xsl:copy>
46 </xsl:template>
47
48 <xsl:template match="preferences" mode="conv39to41">
49 <preferences>
50 <xsl:copy-of select="@*"/>
51 <xsl:apply-templates mode="conv39to41"/>
52 </preferences>
53 </xsl:template>
54
55 <!-- modify the type element -->
56 <xsl:template match="type" mode="conv39to41">
57 <xsl:choose>
58 <xsl:when test="text()='ec2'">
59 <type>
60 <xsl:call-template name="insertcomprops"/>
61 </type>
62 </xsl:when>
63 <xsl:when test="text()='iso'">
64 <type>
65 <xsl:call-template name="insertcomprops"/>
66 <xsl:call-template name="insertvmconfig"/>
67 <xsl:call-template name="insertxenconfig"/>
68 </type>
69 </xsl:when>
70 <xsl:when test="text()='oem'">
71 <type>
72 <xsl:call-template name="insertcomprops"/>
73 <xsl:call-template name="insertlvm"/>
74 <xsl:call-template name="insertoemconfig"/>
75 <xsl:call-template name="insertvmconfig"/>
76 <xsl:call-template name="insertxenconfig"/>
77 </type>
78 </xsl:when>
79 <xsl:when test="text()='split'">
80 <type>
81 <xsl:call-template name="insertcomprops"/>
82 <xsl:call-template name="insertoemconfig"/>
83 <xsl:call-template name="insertsplit"/>
84 <xsl:call-template name="insertvmconfig"/>
85 <xsl:call-template name="insertxenconfig"/>
86 </type>
87 </xsl:when>
88 <xsl:when test="text()='usb'">
89 <type>
90 <xsl:call-template name="insertcomprops"/>
91 <xsl:call-template name="insertlvm"/>
92 </type>
93 </xsl:when>
94 <xsl:when test="text()='vmx'">
95 <type>
96 <xsl:call-template name="insertcomprops"/>
97 <xsl:call-template name="insertlvm"/>
98 <xsl:call-template name="insertvmconfig"/>
99 <xsl:call-template name="insertxenconfig"/>
100 </type>
101 </xsl:when>
102 <xsl:when test="text()='xen'">
103 <type>
104 <xsl:call-template name="insertcomprops"/>
105 <xsl:call-template name="insertxenconfig"/>
106 </type>
107 </xsl:when>
108 <xsl:when test="text()='pxe'">
109 <type>
110 <xsl:call-template name="insertcomprops"/>
111 <xsl:call-template name="insertpxe"/>
112 </type>
113 </xsl:when>
114 <xsl:otherwise>
115 <type>
116 <xsl:call-template name="insertcomprops" />
117 <xsl:apply-templates select="*"/>
118 </type>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:template>
122
123 <!-- generic insertion of block children -->
124 <xsl:template name="insertblockchldnodes" mode="conv39to41">
125 <xsl:param name="blockname"/>
126 <xsl:for-each select="$blockname/*">
127 <xsl:copy-of select="current()"/>
128 </xsl:for-each>
129 </xsl:template>
130
131 <!-- add properties common to all type elements -->
132 <xsl:template name="insertcomprops" mode="conv39to41">
133 <xsl:attribute name="image">
134 <xsl:value-of select="current()"/>
135 </xsl:attribute>
136 <xsl:copy-of select="@*"/>
137 <xsl:if test="/image/preferences/size">
138 <xsl:copy-of select="/image/preferences/size"/>
139 </xsl:if>
140 </xsl:template>
141
142 <!-- insert the lvmvolumes block -->
143 <xsl:template name="insertlvm" mode="conv39to41">
144 <xsl:if test="/image/lvmvolumes">
145 <lvmvolumes>
146 <xsl:call-template name="insertblockchldnodes">
147 <xsl:with-param name="blockname" select="/image/lvmvolumes"/>
148 </xsl:call-template>
149 </lvmvolumes>
150 </xsl:if>
151 </xsl:template>
152
153 <!-- insert the oemconfig block -->
154 <xsl:template name="insertoemconfig" mode="conv39to41">
155 <xsl:if test="/image/oemconfig">
156 <oemconfig>
157 <xsl:call-template name="insertblockchldnodes">
158 <xsl:with-param name="blockname" select="/image/oemconfig"/>
159 </xsl:call-template>
160 </oemconfig>
161 </xsl:if>
162 </xsl:template>
163
164 <!-- insert the pxedeploy block -->
165 <xsl:template name="insertpxe" mode="conv39to41">
166 <xsl:if test="/image/pxedeploy">
167 <pxedeploy>
168 <xsl:copy-of select="/image/pxedeploy/@*"/>
169 <xsl:call-template name="insertblockchldnodes">
170 <xsl:with-param name="blockname" select="/image/pxedeploy"/>
171 </xsl:call-template>
172 </pxedeploy>
173 </xsl:if>
174 </xsl:template>
175
176 <!-- insert the split block -->
177 <xsl:template name="insertsplit" mode="conv39to41">
178 <xsl:if test="/image/split">
179 <split>
180 <xsl:call-template name="insertblockchldnodes">
181 <xsl:with-param name="blockname" select="/image/split"/>
182 </xsl:call-template>
183 </split>
184 </xsl:if>
185 </xsl:template>
186
187 <!-- Insert the vmwareconfig block -->
188 <xsl:template name="insertvmconfig" mode="conv39to41">
189 <xsl:if test="/image/vmwareconfig">
190 <vmwareconfig>
191 <xsl:copy-of select="/image/vmwareconfig/@*"/>
192 <xsl:call-template name="insertblockchldnodes">
193 <xsl:with-param name="blockname" select="/image/vmwareconfig"/>
194 </xsl:call-template>
195 </vmwareconfig>
196 </xsl:if>
197 </xsl:template>
198
199 <!-- Insert the xenconfig block -->
200 <xsl:template name="insertxenconfig" mode="conv39to41">
201 <xsl:if test="/image/xenconfig">
202 <xenconfig>
203 <xsl:copy-of select="/image/xenconfig/@*"/>
204 <xsl:call-template name="insertblockchldnodes">
205 <xsl:with-param name="blockname" select="/image/xenconfig"/>
206 </xsl:call-template>
207 </xenconfig>
208 </xsl:if>
209 </xsl:template>
210
211 <!-- Do not emmit blocks that have moved -->
212 <xsl:template match="lvmvolumes" mode="conv39to41"/>
213 <xsl:template match="oemconfig" mode="conv39to41"/>
214 <xsl:template match="pxedeploy" mode="conv39to41"/>
215 <xsl:template match="size" mode="conv39to41"/>
216 <xsl:template match="split" mode="conv39to41"/>
217 <xsl:template match="vmwareconfig" mode="conv39to41"/>
218 <xsl:template match="xenconfig" mode="conv39to41"/>
219
220 </xsl:stylesheet>