1: <?xml version="1.0" encoding='UTF-8' ?>
2:
3: <xsl:stylesheet version="1.0"
4: xmlns:xs="http://www.w3.org/2001/XMLSchema"
5: xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6: exclude-result-prefixes="xs">
7:
8: <xsl:output method="html" indent="yes"
9: doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
10:
11: <xsl:param name="titre"/>
12: <xsl:param name="jaxe-uri-xsl"/>
13: <xsl:variable name="uri-xsl"><xsl:call-template name="rep-uri"><xsl:with-param name="chemin" select="$jaxe-uri-xsl"/></xsl:call-template></xsl:variable>
14: <xsl:variable name="langue">
15: <xsl:choose>
16: <xsl:when test="/xs:schema/@xml:lang"><xsl:value-of select="translate(/xs:schema/@xml:lang, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:when>
17: <xsl:otherwise>fr</xsl:otherwise>
18: </xsl:choose>
19: </xsl:variable>
20: <xsl:variable name="messages" select="document(concat($uri-xsl, '/XMLSchema_messages_', $langue, '.xml'))/messages"/>
21:
22: <xsl:template match="xs:schema">
23: <html>
24: <head>
25: <title><xsl:value-of select="$titre"/></title>
26: <style type="text/css">
27: body { color: #000000; background: #FFFFFF }
28: .documentation { font-family: monospace; color: #005500; white-space: pre-line; margin-bottom: 1em }
29: .grandlien { font-size: 120%; font-weight: bold }
30: .nomtitre { color: #550000 }
31: .nomattribut { color: #000055; font-weight: bold }
32: .indentation { margin-left: 2em; margin-top: 1em; margin-bottom: 1em }
33: ul { margin-top: 0.5em }
34: </style>
35: </head>
36: <body>
37: <div align="center">
38: <h1><xsl:value-of select="$titre"/></h1>
39: </div>
40: <br/>
41: <span class="grandlien">
42: <a href="#index"><xsl:value-of select="$messages/message[@label='Aller à l index']"/></a><br/>
43: </span>
44: <hr/>
45: <xsl:apply-templates/>
46: <br/>
47: <a name="index"/>
48: <h3><xsl:value-of select="$messages/message[@label='Index']"/></h3>
49: <xsl:for-each select="//*[local-name()!='attribute' and @name!='']">
50: <xsl:sort select="@name"/>
51: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
52: <xsl:variable name="total" select="count(//*[@name=current()/@name])"/>
53: <a href="#{@name}_{$numero}"><xsl:value-of select="@name"/></a>
54: <xsl:if test="$total > 1 and ancestor::*[@name!=''][1]">
55: (<xsl:value-of select="$messages/message[@label='sous']"/><xsl:text> </xsl:text>
56: <xsl:value-of select="ancestor::*[@name!=''][1]/@name"/>)
57: </xsl:if>
58: <br/>
59: </xsl:for-each>
60: </body>
61: </html>
62: </xsl:template>
63:
64: <xsl:template match="xs:element">
65: <xsl:choose>
66: <xsl:when test="@ref">
67: <xsl:variable name="localref">
68: <xsl:choose>
69: <xsl:when test="contains(@ref,':')">
70: <xsl:value-of select="substring-after(@ref,':')"/>
71: </xsl:when>
72: <xsl:otherwise>
73: <xsl:value-of select="@ref"/>
74: </xsl:otherwise>
75: </xsl:choose>
76: </xsl:variable>
77: <xsl:variable name="numero">
78: <xsl:for-each select="/xs:schema/xs:element[@name=$localref][1]">
79: <xsl:value-of select="count(preceding::*[@name=current()/@name])"/>
80: </xsl:for-each>
81: </xsl:variable>
82: <a href="#{$localref}_{$numero}"><xsl:value-of select="@ref"/></a>
83: <br/>
84: </xsl:when>
85: <xsl:otherwise>
86: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
87: <a name="{@name}_{$numero}"/>
88: <h3><xsl:value-of select="$messages/message[@label='Elément']"/><xsl:text> </xsl:text>
89: <span class="nomtitre"><xsl:value-of select="@name"/></span></h3>
90: <xsl:if test="@type">
91: <xsl:value-of select="$messages/message[@label='type:']"/><xsl:text> </xsl:text>
92: <xsl:call-template name="nomtype">
93: <xsl:with-param name="type" select="@type"/>
94: </xsl:call-template>
95: <br/>
96: </xsl:if>
97: <xsl:apply-templates/>
98: <br/>
99: <xsl:if test="parent::xs:schema">
100: <xsl:for-each select="//xs:element[.//xs:element[@ref=current()/@name or substring-after(@ref,':')=current()/@name]] | //xs:group[.//xs:element[@ref=current()/@name or substring-after(@ref,':')=current()/@name]]">
101: <xsl:if test="position() = 1">
102: <xsl:value-of select="$messages/message[@label='Parents:']"/><xsl:text> </xsl:text>
103: </xsl:if>
104: <xsl:if test="position() != 1">, </xsl:if>
105: <xsl:variable name="numero2" select="count(preceding::*[@name=current()/@name])"/>
106: <a href="#{@name}_{$numero2}"><xsl:value-of select="@name"/></a>
107: </xsl:for-each>
108: <br/>
109: </xsl:if>
110: <xsl:if test="not(ancestor::xs:choice or ancestor::xs:sequence)">
111: <hr/>
112: </xsl:if>
113: </xsl:otherwise>
114: </xsl:choose>
115: </xsl:template>
116:
117: <xsl:template match="xs:group">
118: <xsl:choose>
119: <xsl:when test="@ref">
120: <xsl:variable name="localref">
121: <xsl:choose>
122: <xsl:when test="contains(@ref,':')">
123: <xsl:value-of select="substring-after(@ref,':')"/>
124: </xsl:when>
125: <xsl:otherwise>
126: <xsl:value-of select="@ref"/>
127: </xsl:otherwise>
128: </xsl:choose>
129: </xsl:variable>
130: <xsl:variable name="numero">
131: <xsl:for-each select="/xs:schema/xs:group[@name=$localref][1]">
132: <xsl:value-of select="count(preceding::*[@name=current()/@name])"/>
133: </xsl:for-each>
134: </xsl:variable>
135: <a href="#{$localref}_{$numero}"><xsl:value-of select="@ref"/></a>
136: <br/>
137: </xsl:when>
138: <xsl:otherwise>
139: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
140: <a name="{@name}_{$numero}"/>
141: <h3><xsl:value-of select="$messages/message[@label='Groupe']"/><xsl:text> </xsl:text>
142: <span class="nomtitre"><xsl:value-of select="@name"/></span></h3>
143: <xsl:apply-templates/>
144: <br/>
145: <xsl:for-each select="//xs:element[.//xs:group[@ref=current()/@name or substring-after(@ref,':')=current()/@name]] | //xs:group[.//xs:group[@ref=current()/@name or substring-after(@ref,':')=current()/@name]]">
146: <xsl:if test="position() = 1">
147: <xsl:value-of select="$messages/message[@label='Parents:']"/><xsl:text> </xsl:text>
148: </xsl:if>
149: <xsl:if test="position() != 1">, </xsl:if>
150: <xsl:variable name="numero2" select="count(preceding::*[@name=current()/@name])"/>
151: <a href="#{@name}_{$numero2}"><xsl:value-of select="@name"/></a>
152: </xsl:for-each>
153: <br/>
154: <hr/>
155: </xsl:otherwise>
156: </xsl:choose>
157: </xsl:template>
158:
159: <xsl:template match="xs:documentation">
160: <div class="documentation"><xsl:choose>
161: <xsl:when test="starts-with(., ' ')">
162: <xsl:value-of select="substring-after(., ' ')"/>
163: </xsl:when>
164: <xsl:otherwise>
165: <xsl:value-of select="."/>
166: </xsl:otherwise>
167: </xsl:choose></div>
168: <xsl:if test="parent::xs:annotation/parent::xs:schema">
169: <hr/>
170: </xsl:if>
171: </xsl:template>
172:
173: <xsl:template match="xs:choice">
174: <xsl:value-of select="$messages/message[@label='Choix parmi:']"/>
175: <ul>
176: <xsl:for-each select="*">
177: <li><xsl:apply-templates select="."/></li>
178: </xsl:for-each>
179: </ul>
180: </xsl:template>
181:
182: <xsl:template match="xs:sequence">
183: <xsl:value-of select="$messages/message[@label='Séquence parmi:']"/>
184: <ul>
185: <xsl:for-each select="*">
186: <li><xsl:apply-templates select="."/></li>
187: </xsl:for-each>
188: </ul>
189: </xsl:template>
190:
191: <xsl:template match="xs:complexType">
192: <!--Type complexe-->
193: <xsl:if test="@name">
194: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
195: <a name="{@name}_{$numero}"/>
196: <h3><xsl:value-of select="$messages/message[@label='Type complexe']"/><xsl:text> </xsl:text>
197: <span class="nomtitre"><xsl:value-of select="@name"/></span></h3>
198: </xsl:if>
199: <xsl:if test="@ref">
200: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
201: <a href="{@ref}_{$numero}"><xsl:value-of select="@ref"/></a><br/>
202: </xsl:if>
203: <xsl:if test="@mixed='true'">
204: <xsl:value-of select="$messages/message[@label='Peut contenir du texte']"/><br/>
205: </xsl:if>
206: <div class="indentation">
207: <xsl:apply-templates/>
208: </div>
209: <xsl:if test="@name">
210: <hr/>
211: </xsl:if>
212: </xsl:template>
213:
214: <xsl:template match="xs:attribute">
215: <xsl:value-of select="$messages/message[@label='Attribut']"/><xsl:text> </xsl:text>
216: <span class="nomattribut"><xsl:value-of select="@name"/></span>:
217: <div class="indentation">
218: <xsl:choose>
219: <xsl:when test="@use='required'">
220: <xsl:value-of select="$messages/message[@label='obligatoire']"/><br/>
221: </xsl:when>
222: <xsl:otherwise>
223: <xsl:value-of select="$messages/message[@label='facultatif']"/><br/>
224: </xsl:otherwise>
225: </xsl:choose>
226: <xsl:if test="@type">
227: <xsl:value-of select="$messages/message[@label='type:']"/><xsl:text> </xsl:text>
228: <xsl:call-template name="nomtype">
229: <xsl:with-param name="type" select="@type"/>
230: </xsl:call-template>
231: <br/>
232: </xsl:if>
233: <xsl:apply-templates/>
234: </div>
235: </xsl:template>
236:
237: <xsl:template match="xs:simpleType">
238: <xsl:choose>
239: <xsl:when test="@name!=''">
240: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
241: <a name="{@name}_{$numero}"/>
242: <h3><xsl:value-of select="$messages/message[@label='Type simple']"/><xsl:text> </xsl:text>
243: <span class="nomtitre"><xsl:value-of select="@name"/></span></h3>
244: <xsl:apply-templates/>
245: <hr/>
246: </xsl:when>
247: <xsl:otherwise>
248: <xsl:apply-templates/>
249: </xsl:otherwise>
250: </xsl:choose>
251: </xsl:template>
252:
253: <xsl:template match="xs:restriction">
254: <xsl:value-of select="$messages/message[@label='Restriction des valeurs']"/>
255: <xsl:if test="@base!=''">
256: <xsl:text> </xsl:text>
257: <xsl:value-of select="$messages/message[@label='basée sur']"/>
258: <xsl:text> </xsl:text>
259: <xsl:value-of select="@base"/>
260: </xsl:if>
261: <xsl:if test="*">
262: <ul>
263: <xsl:apply-templates/>
264: </ul>
265: </xsl:if>
266: </xsl:template>
267:
268: <xsl:template match="xs:union">
269: <xsl:value-of select="$messages/message[@label='Union des types']"/>
270: <ul>
271: <xsl:if test="@memberTypes!=''">
272: <xsl:call-template name="union-members">
273: <xsl:with-param name="types" select="@memberTypes"/>
274: </xsl:call-template>
275: </xsl:if>
276: <xsl:for-each select="xs:simpleType">
277: <li><xsl:apply-templates select="."/></li>
278: </xsl:for-each>
279: </ul>
280: </xsl:template>
281:
282: <xsl:template match="xs:enumeration">
283: <li><tt><xsl:value-of select="@value"/></tt></li>
284: </xsl:template>
285:
286: <xsl:template match="xs:pattern">
287: <li><tt><xsl:value-of select="@value"/></tt></li>
288: </xsl:template>
289:
290: <xsl:template match="xs:minInclusive">
291: <li><tt>>= <xsl:value-of select="@value"/></tt></li>
292: </xsl:template>
293:
294: <xsl:template match="xs:minExclusive">
295: <li><tt>> <xsl:value-of select="@value"/></tt></li>
296: </xsl:template>
297:
298: <xsl:template match="xs:maxInclusive">
299: <li><tt><= <xsl:value-of select="@value"/></tt></li>
300: </xsl:template>
301:
302: <xsl:template match="xs:maxExclusive">
303: <li><tt>< <xsl:value-of select="@value"/></tt></li>
304: </xsl:template>
305:
306: <xsl:template match="xs:attributeGroup">
307: <xsl:choose>
308: <xsl:when test="@ref">
309: <xsl:variable name="localref">
310: <xsl:choose>
311: <xsl:when test="contains(@ref,':')">
312: <xsl:value-of select="substring-after(@ref,':')"/>
313: </xsl:when>
314: <xsl:otherwise>
315: <xsl:value-of select="@ref"/>
316: </xsl:otherwise>
317: </xsl:choose>
318: </xsl:variable>
319: <xsl:variable name="numero">
320: <xsl:for-each select="/xs:schema/xs:attributeGroup[@name=$localref][1]">
321: <xsl:value-of select="count(preceding::*[@name=current()/@name])"/>
322: </xsl:for-each>
323: </xsl:variable>
324: <a href="#{$localref}_{$numero}"><xsl:value-of select="@ref"/></a>
325: <br/>
326: <br/>
327: </xsl:when>
328: <xsl:otherwise>
329: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
330: <a name="{@name}_{$numero}"/>
331: <h3><xsl:value-of select="$messages/message[@label='Groupe d attributs:']"/><xsl:text> </xsl:text>
332: <span class="nomtitre"><xsl:value-of select="@name"/></span></h3>
333: <xsl:apply-templates/>
334: <br/>
335: <xsl:for-each select="//xs:element[.//xs:attributeGroup[@ref=current()/@name or substring-after(@ref,':')=current()/@name]] | //xs:attributeGroup[.//xs:attributeGroup[@ref=current()/@name or substring-after(@ref,':')=current()/@name]] | //xs:complexType[.//xs:attributeGroup[@ref=current()/@name or substring-after(@ref,':')=current()/@name] and @name]">
336: <xsl:if test="position() = 1">
337: <xsl:value-of select="$messages/message[@label='Parents:']"/><xsl:text> </xsl:text>
338: </xsl:if>
339: <xsl:if test="position() != 1">, </xsl:if>
340: <xsl:variable name="numero2" select="count(preceding::*[@name=current()/@name])"/>
341: <a href="#{@name}_{$numero2}"><xsl:value-of select="@name"/></a>
342: </xsl:for-each>
343: <br/>
344: <hr/>
345: </xsl:otherwise>
346: </xsl:choose>
347: </xsl:template>
348:
349: <xsl:template match="xs:import">
350: </xsl:template>
351:
352: <xsl:template name="nomtype">
353: <xsl:param name="type"/>
354: <xsl:variable name="localType">
355: <xsl:choose>
356: <xsl:when test="contains($type,':')">
357: <xsl:value-of select="substring-after($type,':')"/>
358: </xsl:when>
359: <xsl:otherwise>
360: <xsl:value-of select="$type"/>
361: </xsl:otherwise>
362: </xsl:choose>
363: </xsl:variable>
364: <xsl:choose>
365: <xsl:when test="/xs:schema/xs:simpleType[@name=$localType]|/xs:schema/xs:complexType[@name=$localType]">
366: <xsl:for-each select="/xs:schema/xs:simpleType[@name=$localType]|/xs:schema/xs:complexType[@name=$localType]">
367: <xsl:variable name="numero" select="count(preceding::*[@name=current()/@name])"/>
368: <a href="#{@name}_{$numero}"><xsl:value-of select="@name"/></a>
369: </xsl:for-each>
370: </xsl:when>
371: <xsl:otherwise>
372: <tt><xsl:value-of select="$type"/></tt>
373: </xsl:otherwise>
374: </xsl:choose>
375: </xsl:template>
376:
377: <xsl:template name="rep-uri">
378: <!-- renvoit le chemin du répertoire d'un fichier à partir de l'URI complète, sous forme d'URI -->
379: <xsl:param name="chemin"/>
380: <!-- séparateur de chemins ( normalement / mais parfois \ avec file:// sur Windows ? ) -->
381: <xsl:variable name="sepuri"><xsl:choose>
382: <xsl:when test="contains($chemin, '\')">\</xsl:when>
383: <xsl:otherwise>/</xsl:otherwise>
384: </xsl:choose></xsl:variable>
385: <xsl:choose>
386: <xsl:when test="contains($chemin,$sepuri) and contains(substring-after($chemin,$sepuri),$sepuri)">
387: <xsl:value-of select="substring-before($chemin,$sepuri)"/><xsl:value-of select="$sepuri"/><xsl:call-template name="rep-uri"><xsl:with-param name="chemin" select="substring-after($chemin,$sepuri)"/></xsl:call-template>
388: </xsl:when>
389: <xsl:otherwise>
390: <xsl:value-of select="substring-before($chemin,$sepuri)"/>
391: </xsl:otherwise>
392: </xsl:choose>
393: </xsl:template>
394:
395: <xsl:template name="union-members">
396: <xsl:param name="types"/>
397: <xsl:variable name="nt" select="normalize-space($types)"/>
398: <xsl:if test="$nt!=''">
399: <xsl:choose>
400: <xsl:when test="contains($nt,' ')">
401: <xsl:call-template name="union-members">
402: <xsl:with-param name="types" select="substring-before($nt, ' ')"/>
403: </xsl:call-template>
404: <xsl:call-template name="union-members">
405: <xsl:with-param name="types" select="substring-after($nt, ' ')"/>
406: </xsl:call-template>
407: </xsl:when>
408: <xsl:otherwise>
409: <li>
410: <xsl:call-template name="nomtype">
411: <xsl:with-param name="type" select="$nt"/>
412: </xsl:call-template>
413: </li>
414: </xsl:otherwise>
415: </xsl:choose>
416: </xsl:if>
417: </xsl:template>
418:
419: </xsl:stylesheet>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>