1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
2 | <!-- Edited by XMLSpy® --> |
---|
3 | <xsl:stylesheet version="1.0" |
---|
4 | xmlns:xs="http://www.w3.org/2001/XMLSchema" |
---|
5 | xmlns:a="uri:w3id.org:cmip6.dreq.framework:a" |
---|
6 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
7 | xmlns:xd="http://www.pnp-software.com/XSLTdoc"> |
---|
8 | <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/> |
---|
9 | <xsl:strip-space elements="*"/> |
---|
10 | |
---|
11 | <xd:doc mode="main"> |
---|
12 | <xd:short>Mode main generates the declaration of the main document element</xd:short> |
---|
13 | <xd:detail></xd:detail> |
---|
14 | </xd:doc> |
---|
15 | <xd:doc mode="header"> |
---|
16 | <xd:short>Mode header generates type declarations</xd:short> |
---|
17 | <xd:detail>Detail for header mode</xd:detail> |
---|
18 | </xd:doc> |
---|
19 | <xd:doc mode="#default"> |
---|
20 | <xd:short>Default mode is used for general bits and pieces</xd:short> |
---|
21 | <xd:detail>Detail for default mode</xd:detail> |
---|
22 | </xd:doc> |
---|
23 | <xd:doc> |
---|
24 | <xd:short>The root template element ....</xd:short> |
---|
25 | <xd:detail> |
---|
26 | And here comes a <b>more detailed</b> |
---|
27 | description showed only in the detailed view of the documentation. |
---|
28 | </xd:detail> |
---|
29 | </xd:doc> |
---|
30 | |
---|
31 | <xsl:template match="a:defDoc"> |
---|
32 | <xs:schema targetNamespace="uri:w3id.org:cmip6.dreq.dreq:a" xmlns="uri:w3id.org:cmip6.dreq.dreq:a" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"><xsl:text>
</xsl:text> |
---|
33 | |
---|
34 | <!-- generic type definitions --> |
---|
35 | <xs:annotation> |
---|
36 | <xs:appinfo>W3Schools Note</xs:appinfo> |
---|
37 | <xs:documentation xml:lang="en"> |
---|
38 | Some specialised string types |
---|
39 | </xs:documentation> |
---|
40 | </xs:annotation><xsl:text>
</xsl:text> |
---|
41 | |
---|
42 | <xs:simpleType name="st__attLabel_def"> |
---|
43 | <xs:restriction base="xs:string"> |
---|
44 | <xs:pattern value="([a-zA-Z0-9-])+"/></xs:restriction> |
---|
45 | </xs:simpleType><xsl:text>
</xsl:text> |
---|
46 | |
---|
47 | <xs:simpleType name="st__attLabel_und"> |
---|
48 | <xs:restriction base="xs:string"> |
---|
49 | <xs:pattern value="([a-zA-Z0-9_])+"/></xs:restriction> |
---|
50 | </xs:simpleType><xsl:text>
</xsl:text> |
---|
51 | |
---|
52 | <xs:simpleType name="st__attLabel_int"> |
---|
53 | <xs:restriction base="xs:integer"/> |
---|
54 | </xs:simpleType><xsl:text>
</xsl:text> |
---|
55 | |
---|
56 | <xs:simpleType name="st__attLabel_an"> |
---|
57 | <xs:restriction base="xs:string"> |
---|
58 | <xs:pattern value="([a-zA-Z0-9])+"/></xs:restriction> |
---|
59 | </xs:simpleType><xsl:text>
</xsl:text> |
---|
60 | <xs:complexType name="ct__info" mixed="true"> |
---|
61 | <xs:attribute name="srcType" type="xs:string"/> |
---|
62 | <xs:attribute name="srcRef" type="xs:string"/> |
---|
63 | </xs:complexType> |
---|
64 | |
---|
65 | <!-- create simple and complex type definitions --> |
---|
66 | <xsl:apply-templates mode="header"/> |
---|
67 | |
---|
68 | <!-- main content produced by this section --> |
---|
69 | <xs:annotation> |
---|
70 | <xs:appinfo>W3Schools Note</xs:appinfo> |
---|
71 | <xs:documentation xml:lang="en"> |
---|
72 | This schema is automatically generated by xsltproc. |
---|
73 | </xs:documentation> |
---|
74 | </xs:annotation><xsl:text>
</xsl:text> |
---|
75 | |
---|
76 | <xs:element name="main"> |
---|
77 | <xs:complexType> |
---|
78 | <xs:all><xsl:text>
</xsl:text> |
---|
79 | <xsl:apply-templates mode="main"/> |
---|
80 | </xs:all> |
---|
81 | </xs:complexType><xsl:text>
</xsl:text> |
---|
82 | <xs:unique name="uniqueIdentifierConstraint"> |
---|
83 | <xs:annotation> |
---|
84 | <xs:appinfo>W3Schools Note</xs:appinfo> |
---|
85 | <xs:documentation xml:lang="en"> |
---|
86 | The uniqueIdentifierConstraint imposes the condition that the uuid attribute on "item" elements should have a unique value. |
---|
87 | </xs:documentation> |
---|
88 | </xs:annotation><xsl:text>
</xsl:text> |
---|
89 | <xs:selector xpath=".//item"/> |
---|
90 | <xs:field xpath="@uuid"/> |
---|
91 | </xs:unique><xsl:text>
</xsl:text> |
---|
92 | </xs:element><xsl:text>
</xsl:text> |
---|
93 | |
---|
94 | </xs:schema> |
---|
95 | </xsl:template> |
---|
96 | |
---|
97 | <!-- TEMPLATE: definition of vocab elements --> |
---|
98 | <xd:doc> |
---|
99 | <xd:short>The vocab[main] template is applied once for each vocabulary list.</xd:short> |
---|
100 | <xd:detail> |
---|
101 | There is a section with mode="main" to generate the xs:element declarations, |
---|
102 | and a separate section to generate the associcated complexType declarations. |
---|
103 | </xd:detail> |
---|
104 | </xd:doc> |
---|
105 | <xsl:template match="a:table" mode="main"> |
---|
106 | <xsl:comment>[applying elem main]</xsl:comment><xsl:text>
</xsl:text> |
---|
107 | <xs:element> |
---|
108 | <xsl:attribute name="name"><xsl:value-of select="@label"/></xsl:attribute> |
---|
109 | <xsl:attribute name="type">ct__<xsl:value-of select="@label"/></xsl:attribute> |
---|
110 | </xs:element><xsl:text>
</xsl:text> |
---|
111 | </xsl:template> |
---|
112 | |
---|
113 | <!-- TEMPLATE: definition of vocab type declarations --> |
---|
114 | <xd:doc> |
---|
115 | <xd:short>The vocab[header] template: complexType declarations </xd:short> |
---|
116 | <xd:detail> |
---|
117 | The header mode generates type declarations. |
---|
118 | </xd:detail> |
---|
119 | </xd:doc> |
---|
120 | <xsl:template match="a:table" mode="header"> |
---|
121 | <xsl:comment>Auto-generated vocabulary complexType declarations/></xsl:comment><xsl:text>
</xsl:text> |
---|
122 | <xs:annotation> |
---|
123 | <xs:appinfo>W3Schools Note</xs:appinfo> |
---|
124 | <xs:documentation xml:lang="en"> |
---|
125 | <xsl:value-of select="@label"/>: Complex Type declaration |
---|
126 | </xs:documentation> |
---|
127 | </xs:annotation><xsl:text>
</xsl:text> |
---|
128 | <xs:complexType> |
---|
129 | <xsl:attribute name="name">ct__<xsl:value-of select="@label"/></xsl:attribute><xsl:text>
</xsl:text> |
---|
130 | <xs:sequence> |
---|
131 | <!-- removed in favour of placing information in an optional index section --> |
---|
132 | <!-- <xs:element name="info" type="ct__info"/> --> |
---|
133 | <xs:element name="item" maxOccurs="8000"> |
---|
134 | <xsl:attribute name="type">ct__<xsl:value-of select="@label"/>_vocabItem</xsl:attribute> |
---|
135 | </xs:element> |
---|
136 | </xs:sequence><xsl:text>
</xsl:text> |
---|
137 | <xs:attribute name="label" type="xs:string"> |
---|
138 | <xsl:attribute name="fixed"><xsl:value-of select="@label"/></xsl:attribute> |
---|
139 | </xs:attribute><xsl:text>
</xsl:text> |
---|
140 | <xs:attribute name="title" type="xs:string"> |
---|
141 | <xsl:attribute name="fixed"><xsl:value-of select="@title"/></xsl:attribute> |
---|
142 | </xs:attribute><xsl:text>
</xsl:text> |
---|
143 | <xs:attribute name="id" type="xs:string"> |
---|
144 | <xsl:attribute name="fixed"><xsl:value-of select="@id"/></xsl:attribute> |
---|
145 | </xs:attribute><xsl:text>
</xsl:text> |
---|
146 | <xs:attribute name="class" fixed="vocab"/><xsl:text>
</xsl:text> |
---|
147 | </xs:complexType><xsl:text>
</xsl:text> |
---|
148 | |
---|
149 | <!-- type declaration for item element --> |
---|
150 | <xs:annotation> |
---|
151 | <xs:appinfo>Attribute annotation</xs:appinfo> |
---|
152 | <xs:documentation xml:lang="en"> |
---|
153 | <xsl:apply-templates mode="annotate-attr"/> |
---|
154 | </xs:documentation> |
---|
155 | </xs:annotation><xsl:text>
</xsl:text> |
---|
156 | |
---|
157 | <xs:complexType> |
---|
158 | <xsl:attribute name="name">ct__<xsl:value-of select="@label"/>_vocabItem</xsl:attribute><xsl:text>
</xsl:text> |
---|
159 | <xs:attribute name="id" type="xs:string"/><xsl:text>
</xsl:text> |
---|
160 | <xs:attribute name="label"> |
---|
161 | <xsl:attribute name="type">st__attLabel_<xsl:value-of select="@itemLabelMode"/></xsl:attribute> |
---|
162 | </xs:attribute><xsl:text>
</xsl:text> |
---|
163 | <xs:attribute name="title" type="xs:string"/> |
---|
164 | <!-- apply templates to pick up list of attributes of each item --> |
---|
165 | <xsl:apply-templates mode="attr"/> |
---|
166 | <xsl:text>
</xsl:text> |
---|
167 | </xs:complexType> |
---|
168 | </xsl:template> |
---|
169 | |
---|
170 | <xd:doc> |
---|
171 | <xd:short>rowAttribute: specifications of list item attributes</xd:short> |
---|
172 | <xd:detail> |
---|
173 | The rowAttribute template constructs the specifications of attributes in list items. |
---|
174 | </xd:detail> |
---|
175 | </xd:doc> |
---|
176 | <xsl:template match="a:rowAttribute" mode="attr"> |
---|
177 | <xsl:if test="@label!='label' and @label != 'title'"> |
---|
178 | <xs:attribute name="id" type="xs:string"> |
---|
179 | <xsl:attribute name="name"><xsl:value-of select="@label"/></xsl:attribute> |
---|
180 | <xsl:choose> |
---|
181 | <xsl:when test="@type"> |
---|
182 | <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute> |
---|
183 | </xsl:when> |
---|
184 | </xsl:choose> |
---|
185 | </xs:attribute><xsl:text>
</xsl:text> |
---|
186 | </xsl:if> |
---|
187 | </xsl:template> |
---|
188 | |
---|
189 | <xsl:template match="a:rowAttribute" mode="annotate-attr"> |
---|
190 | <xsl:value-of select="@label"/>; |
---|
191 | <xsl:choose> |
---|
192 | <xsl:when test="@type"> |
---|
193 | <xsl:value-of select="@type"/> |
---|
194 | </xsl:when> |
---|
195 | </xsl:choose> |
---|
196 | <xsl:choose> |
---|
197 | <xsl:when test="@title"> |
---|
198 | <xsl:value-of select="@title"/> |
---|
199 | </xsl:when> |
---|
200 | </xsl:choose> |
---|
201 | </xsl:template> |
---|
202 | |
---|
203 | </xsl:stylesheet> |
---|