Debian Codegraph @

ru/stylesheets/dbv5.xsl

raw symbols SCIP
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:set="http://exslt.org/sets"
4 xmlns:rng="http://relaxng.org/ns/structure/1.0"
5 xmlns:s="http://www.ascc.net/xml/schematron"
6 exclude-result-prefixes="rng set s"
7 version="1.0">
8
9 <xsl:strip-space elements="rng:*"/>
10
11 <xsl:variable name="db5doc" select="document('build/lib/db5doc.xml',.)/rng:grammar"/>
12
13 <xsl:key name="defs" match="rng:define" use="@name"/>
14 <xsl:key name="elemdefs" match="rng:define[rng:element]" use="rng:element/@name"/>
15
16 <xsl:template name="rng-element">
17 <xsl:param name="element" select="'nop'"/>
18 <xsl:choose>
19 <xsl:when test="$element = '*'">
20 <xsl:apply-templates/>
21 </xsl:when>
22 <xsl:otherwise>
23 <xsl:apply-templates select="$db5doc//rng:define[rng:element[@name=$element]]"/>
24 </xsl:otherwise>
25 </xsl:choose>
26 </xsl:template>
27
28 <xsl:template match="rng:start">
29 <div class="start">
30 <h1>
31 <a name="start"/>
32 <xsl:text>Start</xsl:text>
33 </h1>
34
35 <ul>
36 <xsl:apply-templates/>
37 </ul>
38 </div>
39 </xsl:template>
40
41 <xsl:template match="rng:define[rng:element]" priority="2">
42 <div class="define">
43 <xsl:apply-templates/>
44 </div>
45 </xsl:template>
46
47 <xsl:template match="rng:define">
48 <div class="define">
49 <xsl:value-of select="@name"/>
50
51 <ul>
52 <xsl:apply-templates/>
53 </ul>
54 </div>
55 </xsl:template>
56
57 <xsl:template match="rng:text">
58 <li><em>text</em></li>
59 </xsl:template>
60
61 <xsl:template match="rng:notAllowed">
62 <!-- nop -->
63 </xsl:template>
64
65 <xsl:template match="rng:empty">
66 <li><em>EMPTY</em></li>
67 </xsl:template>
68
69 <xsl:template match="rng:element">
70 <xsl:variable name="xdefs" select="key('elemdefs', @name)"/>
71
72 <div class="element">
73 <xsl:value-of select="@name"/>
74 <xsl:if test="count($xdefs) &gt; 1">
75 <xsl:text> (</xsl:text>
76 <xsl:value-of select="../@name"/>
77 <xsl:text>)</xsl:text>
78 </xsl:if>
79 <xsl:text> ::=</xsl:text>
80
81 <ul>
82 <xsl:choose>
83 <xsl:when test="rng:content-model">
84 <xsl:apply-templates select="rng:content-model/*"/>
85 </xsl:when>
86 <xsl:otherwise>
87 <xsl:apply-templates/>
88 </xsl:otherwise>
89 </xsl:choose>
90 </ul>
91
92 <xsl:apply-templates select="rng:attributes"/>
93 <xsl:apply-templates select="rng:rules"/>
94 </div>
95 </xsl:template>
96
97 <xsl:template match="rng:attributes">
98 <xsl:variable name="cmnAttr"
99 select="rng:optional[rng:ref[@name='id.attribute']]
100 |rng:optional[rng:ref[@name='xml.lang.attribute']]
101 |rng:optional[rng:ref[@name='xml.base.attribute']]
102 |rng:optional[rng:ref[@name='remap.attribute']]
103 |rng:optional[rng:ref[@name='xreflabel.attribute']]
104 |rng:optional[rng:ref[@name='revisionflag.attribute']]
105 |rng:optional[rng:ref[@name='arch.attribute']]
106 |rng:optional[rng:ref[@name='condition.attribute']]
107 |rng:optional[rng:ref[@name='conformance.attribute']]
108 |rng:optional[rng:ref[@name='os.attribute']]
109 |rng:optional[rng:ref[@name='revision.attribute']]
110 |rng:optional[rng:ref[@name='security.attribute']]
111 |rng:optional[rng:ref[@name='userlevel.attribute']]
112 |rng:optional[rng:ref[@name='vendor.attribute']]
113 |rng:optional[rng:ref[@name='role.attribute']]"/>
114
115 <xsl:variable name="cmnAttrIdReq"
116 select="rng:ref[@name='id.attribute']
117 |rng:optional[rng:ref[@name='xml.lang.attribute']]
118 |rng:optional[rng:ref[@name='xml.base.attribute']]
119 |rng:optional[rng:ref[@name='remap.attribute']]
120 |rng:optional[rng:ref[@name='xreflabel.attribute']]
121 |rng:optional[rng:ref[@name='revisionflag.attribute']]
122 |rng:optional[rng:ref[@name='arch.attribute']]
123 |rng:optional[rng:ref[@name='condition.attribute']]
124 |rng:optional[rng:ref[@name='conformance.attribute']]
125 |rng:optional[rng:ref[@name='os.attribute']]
126 |rng:optional[rng:ref[@name='revision.attribute']]
127 |rng:optional[rng:ref[@name='security.attribute']]
128 |rng:optional[rng:ref[@name='userlevel.attribute']]
129 |rng:optional[rng:ref[@name='vendor.attribute']]
130 |rng:optional[rng:ref[@name='role.attribute']]"/>
131
132 <xsl:variable name="cmnAttrEither" select="$cmnAttr|$cmnAttrIdReq"/>
133
134 <xsl:variable name="cmnLinkAttr"
135 select="rng:optional[rng:choice[rng:ref[@name='linkend.attribute']
136 and rng:ref[@name='href.attribute']]]"/>
137
138 <xsl:variable name="otherAttr"
139 select="set:difference(*,$cmnAttr|$cmnAttrIdReq|$cmnLinkAttr)"/>
140
141 <h4>Experimental DocBook V5 RELAX NG Attributes</h4>
142
143 <xsl:choose>
144 <xsl:when test="count($cmnAttr) = 15 and $cmnLinkAttr">
145 <p>Common attributes and common linking attributes.</p>
146 </xsl:when>
147 <xsl:when test="count($cmnAttrIdReq) = 15 and $cmnLinkAttr">
148 <p>Common attributes (ID required) and common linking atttributes.</p>
149 </xsl:when>
150 <xsl:when test="count($cmnAttr) = 15">
151 <p>Common attributes.</p>
152 </xsl:when>
153 <xsl:when test="count($cmnAttrIdReq) = 15">
154 <p>Common attributes (ID required).</p>
155 </xsl:when>
156 <xsl:when test="$cmnLinkAttr">
157 <p>Common linking attributes.</p>
158 </xsl:when>
159 </xsl:choose>
160
161 <xsl:if test="count($cmnAttrEither) != 15 or count($otherAttr) &gt; 0">
162 <p>
163 <xsl:choose>
164 <xsl:when test="count($cmnAttr) = 15
165 or count($cmnAttrIdReq) = 15
166 or $cmnLinkAttr">
167 <em>Additional attributes:</em>
168 </xsl:when>
169 <xsl:otherwise>
170 <em>Attributes:</em>
171 </xsl:otherwise>
172 </xsl:choose>
173 <xsl:text> (Required attributes, if any, are </xsl:text>
174 <b>bold</b>
175 <xsl:text>)</xsl:text>
176 </p>
177
178 <ul>
179 <xsl:choose>
180 <xsl:when test="count($cmnAttrEither) = 15">
181 <xsl:apply-templates select="$otherAttr" mode="attributes"/>
182 </xsl:when>
183 <xsl:otherwise>
184 <xsl:apply-templates mode="attributes"/>
185 </xsl:otherwise>
186 </xsl:choose>
187 </ul>
188 </xsl:if>
189 </xsl:template>
190
191 <xsl:template match="rng:optional" mode="attributes">
192 <xsl:apply-templates mode="attributes"/>
193 </xsl:template>
194
195 <xsl:template match="rng:choice" mode="attributes">
196 <li>
197 <xsl:choose>
198 <xsl:when test="ancestor::rng:optional">
199 <em>At most one of:</em>
200 </xsl:when>
201 <xsl:otherwise>
202 <em>Exactly one of:</em>
203 </xsl:otherwise>
204 </xsl:choose>
205 <ul>
206 <xsl:apply-templates mode="attributes"/>
207 </ul>
208 </li>
209 </xsl:template>
210
211 <xsl:template match="rng:interleave" mode="attributes">
212 <li>
213 <xsl:choose>
214 <xsl:when test="ancestor::rng:optional">
215 <em>All or none of:</em>
216 </xsl:when>
217 <xsl:otherwise>
218 <em>All of:</em>
219 </xsl:otherwise>
220 </xsl:choose>
221 <ul>
222 <xsl:apply-templates mode="attributes"/>
223 </ul>
224 </li>
225 </xsl:template>
226
227 <xsl:template match="rng:ref" mode="attributes">
228 <xsl:variable name="attrs" select="key('defs', @name)/rng:attribute"/>
229
230 <xsl:choose>
231 <xsl:when test="count($attrs) &gt; 1">
232 <li>
233 <xsl:choose>
234 <xsl:when test="ancestor::rng:optional">
235 <em>At most one of:</em>
236 </xsl:when>
237 <xsl:otherwise>
238 <em><b>Each of:</b></em>
239 </xsl:otherwise>
240 </xsl:choose>
241 <ul>
242 <xsl:apply-templates select="$attrs" mode="attributes">
243 <xsl:with-param name="optional" select="ancestor::rng:optional"/>
244 <xsl:with-param name="choice" select="ancestor::rng:choice"/>
245 </xsl:apply-templates>
246 </ul>
247 </li>
248 </xsl:when>
249 <xsl:otherwise>
250 <xsl:apply-templates select="$attrs" mode="attributes">
251 <xsl:with-param name="optional" select="ancestor::rng:optional"/>
252 <xsl:with-param name="choice" select="ancestor::rng:choice"/>
253 </xsl:apply-templates>
254 </xsl:otherwise>
255 </xsl:choose>
256 </xsl:template>
257
258 <xsl:template match="rng:attribute" mode="attributes">
259 <xsl:param name="optional" select="ancestor::rng:optional"/>
260 <xsl:param name="choice" select="ancestor::rng:choice"/>
261
262 <li>
263 <xsl:choose>
264 <xsl:when test="$optional">
265 <xsl:value-of select="@name"/>
266 </xsl:when>
267 <xsl:otherwise>
268 <b>
269 <xsl:value-of select="@name"/>
270 </b>
271 </xsl:otherwise>
272 </xsl:choose>
273
274 <xsl:choose>
275 <xsl:when test="rng:choice|rng:value">
276 <xsl:text> (enumeration)</xsl:text>
277 <ul>
278 <xsl:for-each select="rng:choice/rng:value|rng:value">
279 <li>
280 <xsl:text>“</xsl:text>
281 <xsl:value-of select="."/>
282 <xsl:text>”</xsl:text>
283 </li>
284 </xsl:for-each>
285 </ul>
286 </xsl:when>
287 <xsl:when test="rng:data">
288 <xsl:text> (</xsl:text>
289 <xsl:value-of select="rng:data/@type"/>
290 <xsl:text>)</xsl:text>
291 </xsl:when>
292 </xsl:choose>
293 </li>
294 </xsl:template>
295
296 <xsl:template match="rng:rules">
297 <h4>Experimental DocBook V5 RELAX NG Additional Rules</h4>
298
299 <ul>
300 <xsl:for-each select=".//s:assert">
301 <li>
302 <xsl:value-of select="."/>
303 </li>
304 </xsl:for-each>
305 </ul>
306 </xsl:template>
307
308 <xsl:template match="rng:value">
309 <xsl:if test="position() &gt; 1"> | </xsl:if>
310 <span class="{local-name()}">
311 <xsl:text>“</xsl:text>
312 <xsl:apply-templates/>
313 <xsl:text>”</xsl:text>
314 </span>
315 </xsl:template>
316
317 <xsl:template match="rng:ref">
318 <xsl:variable name="elemName" select="(key('defs', @name)/rng:element)[1]/@name"/>
319 <xsl:variable name="xdefs" select="key('elemdefs', $elemName)"/>
320
321 <li>
322 <xsl:choose>
323 <xsl:when test="$elemName">
324 <tt>
325 <a href="{$elemName}.html">
326 <xsl:value-of select="key('defs', @name)/rng:element/@name"/>
327 </a>
328 </tt>
329 <xsl:if test="parent::rng:optional">?</xsl:if>
330 </xsl:when>
331 <xsl:otherwise>
332 <xsl:value-of select="@name"/>
333 <xsl:if test="parent::rng:optional">?</xsl:if>
334 </xsl:otherwise>
335 </xsl:choose>
336
337 <xsl:if test="count($xdefs) &gt; 1">
338 <xsl:text> (</xsl:text>
339 <xsl:value-of select="@name"/>
340 <xsl:text>)</xsl:text>
341 </xsl:if>
342 </li>
343 </xsl:template>
344
345 <xsl:template match="rng:optional">
346 <xsl:apply-templates/>
347 </xsl:template>
348
349 <xsl:template match="rng:zeroOrMore">
350 <li><xsl:text>Zero or more of:</xsl:text></li>
351 <ul class="{local-name()}">
352 <xsl:apply-templates>
353 <xsl:sort select="key('defs',@name)/rng:element/@name"/>
354 <xsl:sort select="@name"/>
355 </xsl:apply-templates>
356 </ul>
357 </xsl:template>
358
359 <xsl:template match="rng:oneOrMore">
360 <li>
361 <xsl:choose>
362 <xsl:when test="parent::rng:optional">
363 <xsl:text>Optional one or more of:</xsl:text>
364 </xsl:when>
365 <xsl:otherwise>
366 <xsl:text>One or more of:</xsl:text>
367 </xsl:otherwise>
368 </xsl:choose>
369 </li>
370 <ul class="{local-name()}">
371 <xsl:apply-templates>
372 <xsl:sort select="key('defs',@name)/rng:element/@name"/>
373 <xsl:sort select="@name"/>
374 </xsl:apply-templates>
375 </ul>
376 </xsl:template>
377
378 <xsl:template match="rng:group">
379 <li>
380 <xsl:choose>
381 <xsl:when test="parent::rng:optional">
382 <xsl:text>Optional sequence of:</xsl:text>
383 </xsl:when>
384 <xsl:otherwise>
385 <xsl:text>Sequence of:</xsl:text>
386 </xsl:otherwise>
387 </xsl:choose>
388 </li>
389 <ul class="{local-name()}">
390 <xsl:apply-templates/>
391 </ul>
392 </xsl:template>
393
394 <xsl:template match="rng:interleave">
395 <li>
396 <xsl:choose>
397 <xsl:when test="parent::rng:optional">
398 <xsl:text>Optional interleave of:</xsl:text>
399 </xsl:when>
400 <xsl:otherwise>
401 <xsl:text>Interleave of:</xsl:text>
402 </xsl:otherwise>
403 </xsl:choose>
404 </li>
405 <ul class="{local-name()}">
406 <xsl:apply-templates/>
407 </ul>
408 </xsl:template>
409
410 <xsl:template match="rng:choice">
411 <li>
412 <xsl:choose>
413 <xsl:when test="parent::rng:optional">
414 <xsl:text>Optionally one of: </xsl:text>
415 </xsl:when>
416 <xsl:otherwise>
417 <xsl:text>One of: </xsl:text>
418 </xsl:otherwise>
419 </xsl:choose>
420 </li>
421 <ul class="{local-name()}">
422 <xsl:apply-templates>
423 <xsl:sort select="key('defs',@name)/rng:element/@name"/>
424 <xsl:sort select="@name"/>
425 </xsl:apply-templates>
426 </ul>
427 </xsl:template>
428
429 </xsl:stylesheet>