adding all of botlist, initial add
[botlist.git] / botclient / xul / xulschema / xulplanet2schema.xsl
blobcd4d3b7f43509c08e269ddbe2a2b7152a0b3bd55
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This is an XSLT stylesheet converting the stripped down (by strip_elemref.xsl)
4 XUL Elements Reference to a W3C Schema.
6 Please see http://mozilla.doslash.org/xulschema for more information.
7 -->
9 <!-- attrs with type=xs:int should be manually processed -->
10 <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
11 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
13 <!-- ==================================================== -->
14 <!-- Common XUL events. Cannot generate in stylesheet itself due to XSLT limitations -->
15 <xsl:param name="output"/>
16 <xsl:variable name="ignore_attr"
17 select="' grippyhidden onblur onbroadcast onchange onclick onclose oncommand oncommandupdate oncontextmenu ondblclick ondragdrop ondragenter ondragexit ondraggesture ondragover onfocus oninput onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseout onmouseover onmouseup onoverflow onoverflowchanged onpopuphidden onpopuphiding onpopupshowing onpopupshown onselect onunderflow onunload '"/>
18 <xsl:variable name="ignore_elts"
19 select="' textbox (Firefox Auto Complete) textbox (Mozilla Auto Complete) grippy toolbargrippy '"/>
20 <!-- ==================================================== -->
21 <xsl:template match="/">
22 <!-- XXX legal disclaimer - waiting for an answer from Neil -->
23 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
24 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
25 targetNamespace="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26 <xsl:comment>======================================================================</xsl:comment>
27 <xsl:comment>===== DO NOT EDIT! THIS IS A GENERATED FILE ==========================</xsl:comment>
28 <xsl:comment>======================================================================</xsl:comment>
29 <xsl:comment> Generated from the XUL Planet's Elements Reference.
30 See http://mozilla.doslash.org/xulschema for more info </xsl:comment>
31 <xsl:comment>======================================================================</xsl:comment>
32 <!--==== Common XUL attributes and events ===================================-->
33 <xsl:if test="$output='common' or $output=''">
34 <xsl:comment> This file defines common XUL attributes and events </xsl:comment>
35 <xsl:comment>
36 ...but let's declare a few simple types first:
37 </xsl:comment>
38 <xsl:comment> boolType is used instead of xs:boolean to make XML editors show true/false dropdown </xsl:comment>
39 <xs:simpleType name="boolType">
40 <xs:restriction base="xs:string">
41 <xs:enumeration value="true"/>
42 <xs:enumeration value="false"/>
43 </xs:restriction>
44 </xs:simpleType>
45 <xsl:comment> scriptType is for inline script code, that often occurs in on* attributes </xsl:comment>
46 <xs:simpleType name="scriptType">
47 <xs:restriction base="xs:string"/>
48 </xs:simpleType>
49 <xsl:comment>
50 Common (i.e. not specific to a few) XUL attributes. These are all sticked into XULElement attributes
51 on XulPlanet.com, we are more restrictive about this. While certain combinations allowed by the schema
52 may not make sense, it's still better than allowing all of XULElement attributes on all XUL elements.
54 There are a few groups of attributes declared below.
55 IdAttributeGroup (used solely for overlayElementType)
56 CommonAttributeGroup (also includes IdAttributeGroup)
57 XULAttributeGroup = CommonAttributeGroup + OverlayAttributeGroup + RDFAttributeGroup
58 BoxAttributeGroup
59 ContainerAttributeGroup
60 EventHandlerAttributeGroup
61 The last three don't include any attributeGroups, so generally a XUL element includes one to four
62 of the following attribute groups: XULAttributeGroup, BoxAttributeGroup, ContainerAttributeGroup.
63 </xsl:comment>
64 <xsl:variable name="e" select="//object[@name='XULElement']/attr"/>
65 <xsl:comment>
66 Attributes that make sense for *all* XUL elements - that is, to info elements too
67 </xsl:comment>
68 <xs:attributeGroup name="IdAttributeGroup">
69 <xsl:apply-templates select="$e[@name='id']"/>
70 <xsl:apply-templates select="$e[@name='class']"/>
71 </xs:attributeGroup>
72 <xs:attributeGroup name="CommonAttributeGroup">
73 <xs:attributeGroup ref="xul:IdAttributeGroup"/>
74 <xsl:apply-templates select="$e[@name='observes']"/>
75 <xsl:apply-templates select="$e[@name='ordinal']"/>
76 <xsl:apply-templates select="$e[@name='persist']"/>
77 </xs:attributeGroup>
78 <xsl:comment>
79 And these make sense for any element in an overlay
80 </xsl:comment>
81 <xs:attributeGroup name="OverlayAttributeGroup">
82 <xsl:apply-templates select="$e[@name='insertafter']"/>
83 <xsl:apply-templates select="$e[@name='insertbefore']"/>
84 <xsl:apply-templates select="$e[@name='position']"/>
85 <xsl:apply-templates select="$e[@name='removeelement']"/>
86 </xs:attributeGroup>
87 <xsl:comment>
88 Attributes used with XUL templates (xxx TBD)
89 </xsl:comment>
90 <xs:attributeGroup name="RDFAttributeGroup">
91 <xsl:apply-templates select="$e[@name='allownegativeassertions']"/>
92 <xsl:apply-templates select="$e[@name='coalesceduplicatearcs']"/>
93 <xsl:apply-templates select="$e[@name='container']"/>
94 <xsl:apply-templates select="$e[@name='containment']"/>
95 <xsl:apply-templates select="$e[@name='datasources']"/>
96 <xsl:apply-templates select="$e[@name='empty']"/>
97 <xsl:apply-templates select="$e[@name='flags']"/>
98 <xsl:apply-templates select="$e[@name='ref']"/>
99 <xsl:apply-templates select="$e[@name='sortDirection']"/>
100 <xsl:apply-templates select="$e[@name='sortResource']"/>
101 <xsl:apply-templates select="$e[@name='sortResource2']"/>
102 <xsl:apply-templates select="$e[@name='template']"/>
103 <xsl:apply-templates select="$e[@name='uri']"/>
104 </xs:attributeGroup>
105 <xsl:comment>
106 This group combines all of the above. These attributes apply to almost all XUL elements
107 </xsl:comment>
108 <xs:attributeGroup name="XULAttributeGroup">
109 <!-- xxx bad name -->
110 <xs:attributeGroup ref="xul:CommonAttributeGroup"/>
111 <xs:attributeGroup ref="xul:OverlayAttributeGroup"/>
112 <!-- don't include rdf attributes - at least for now xs:attributeGroup ref="xul:RDFAttributeGroup"/-->
113 </xs:attributeGroup>
114 <xsl:comment>
115 These make sense for any visible element
116 </xsl:comment>
117 <xs:attributeGroup name="BoxAttributeGroup">
118 <xsl:apply-templates select="$e[@name='collapsed']"/>
119 <xsl:apply-templates select="$e[@name='hidden']"/>
120 <xsl:apply-templates select="$e[@name='flex']"/>
121 <xsl:apply-templates select="$e[@name='context']"/>
122 <xsl:apply-templates select="$e[@name='contextmenu']"/>
123 <xsl:apply-templates select="$e[@name='menu']"/>
124 <xsl:apply-templates select="$e[@name='popup']"/>
125 <xsl:apply-templates select="$e[@name='tooltip']"/>
126 <xsl:apply-templates select="$e[@name='tooltiptext']"/>
127 <xsl:apply-templates select="$e[@name='debug']"/>
128 <xsl:apply-templates select="$e[@name='statustext']"/>
129 <xsl:apply-templates select="$e[@name='style']"/>
130 <xsl:apply-templates select="$e[@name='wait-cursor']"/>
131 <!-- xxx Some/most/all of these only apply to elements in stack -->
132 <xsl:apply-templates select="$e[@name='top']"/>
133 <xsl:apply-templates select="$e[@name='left']"/>
134 <xsl:apply-templates select="$e[@name='height']"/>
135 <xsl:apply-templates select="$e[@name='maxheight']"/>
136 <xsl:apply-templates select="$e[@name='maxwidth']"/>
137 <xsl:apply-templates select="$e[@name='minheight']"/>
138 <xsl:apply-templates select="$e[@name='minwidth']"/>
139 <xsl:apply-templates select="$e[@name='width']"/>
140 </xs:attributeGroup>
141 <xsl:comment>
142 These Attributes affect the children of the element, therefore
143 they only apply to container elements
144 </xsl:comment>
145 <xs:attributeGroup name="ContainerAttributeGroup">
146 <xsl:apply-templates select="$e[@name='align']"/>
147 <xsl:apply-templates select="$e[@name='allowevents']"/>
148 <xsl:apply-templates select="$e[@name='dir']"/>
149 <xsl:apply-templates select="$e[@name='equalsize']"/>
150 <xsl:apply-templates select="$e[@name='mousethrough']"/>
151 <xsl:apply-templates select="$e[@name='orient']"/>
152 <xsl:apply-templates select="$e[@name='pack']"/>
153 </xs:attributeGroup>
154 <xsl:comment>
155 Common XUL events
156 </xsl:comment>
157 <xs:attributeGroup name="EventHandlerAttributeGroup">
158 <xsl:apply-templates select="//events/event"/>
159 </xs:attributeGroup>
160 </xsl:if>
161 <!--==== XUL elements ========================================================-->
162 <xsl:if test="$output='elements' or $output=''">
163 <xsl:comment> This file contains the list of XUL elements with descriptions </xsl:comment>
164 <xsl:if test="$output='elements'">
165 <xs:include schemaLocation="xulcommon.xsd"/>
166 </xsl:if>
167 <xsl:apply-templates
168 select="//element[not(boolean(@lang='xbl') or substring-before(@name,':')='rdf')]"/>
169 </xsl:if>
170 </xs:schema>
171 </xsl:template>
172 <!-- ==================================================== -->
173 <xsl:template match="element">
174 <!-- xxx autocomplete -->
175 <xsl:if test="not(contains($ignore_elts,concat(' ',@name,' '))) or @name='textbox'">
176 <xsl:variable name="name" select="@name"/>
177 <xs:element name="{@name}">
178 <xs:annotation>
179 <xs:documentation>
180 <xsl:value-of select="child::reference/following-sibling::text()"/>
181 </xs:documentation>
182 </xs:annotation>
183 <xs:complexType>
184 <xs:complexContent>
185 <xs:extension base="xul:{$name}ElementType">
186 <xsl:apply-templates select="attr"/>
187 </xs:extension>
188 </xs:complexContent>
189 </xs:complexType>
190 </xs:element>
191 </xsl:if>
192 </xsl:template>
193 <!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -->
194 <xsl:template name="annotateAttrs">
195 <xs:annotation>
196 <xs:documentation>
197 <xsl:value-of select="child::text()"/>
198 </xs:documentation>
199 </xs:annotation>
200 </xsl:template>
201 <xsl:template match="attr">
202 <!-- Note: this throws away elaborate explanations of some events -->
203 <xsl:if test="not(contains($ignore_attr,concat(' ',@name,' ')))">
204 <xs:attribute>
205 <xsl:attribute name="name">
206 <xsl:value-of select="@name"/>
207 </xsl:attribute>
208 <!-- set up type -->
209 <xsl:choose>
210 <xsl:when test="@type='boolean'">
211 <xsl:if test="count(value)=0">
212 <xsl:attribute name="type">xul:boolType</xsl:attribute>
213 <xsl:call-template name="annotateAttrs"/>
214 </xsl:if>
215 </xsl:when>
216 <xsl:when test="@type='integer'">
217 <xsl:attribute name="type">xs:int</xsl:attribute>
218 <xsl:call-template name="annotateAttrs"/>
219 </xsl:when>
220 <xsl:when test="@type='string' and count(value)=0">
221 <!-- note, that if count(value)>0, it's a enum/list instead -->
222 <xsl:attribute name="type">xs:string</xsl:attribute>
223 <xsl:call-template name="annotateAttrs"/>
224 </xsl:when>
225 <xsl:otherwise>
226 <xs:annotation>
227 <xs:documentation>
228 <xsl:if test="@type and @type!='string'">(<xsl:value-of select="@type"/>)</xsl:if>
229 <xsl:value-of select="child::text()"/>
230 </xs:documentation>
231 </xs:annotation>
232 </xsl:otherwise>
233 </xsl:choose>
234 <xsl:if test="count(value)>0">
235 <xs:simpleType>
236 <xsl:choose>
237 <xsl:when test="@name='flags'">
238 <xs:list>
239 <xs:simpleType>
240 <xs:restriction base="xs:string">
241 <xsl:apply-templates select="value"/>
242 </xs:restriction>
243 </xs:simpleType>
244 </xs:list>
245 </xsl:when>
246 <xsl:when test="@name='buttons'">
247 <!-- bah! We cannot do anything useful here :(
248 XML Schema only supports space-separated lists, and Mozilla wants us to use commas.
250 <xs:restriction base="xs:string">
251 <xsl:apply-templates select="value"/>
252 </xs:restriction>
253 </xsl:when>
254 <xsl:otherwise>
255 <xs:restriction base="xs:string">
256 <xsl:apply-templates select="value"/>
257 </xs:restriction>
258 </xsl:otherwise>
259 </xsl:choose>
260 </xs:simpleType>
261 </xsl:if>
262 </xs:attribute>
263 </xsl:if>
264 </xsl:template>
265 <!-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -->
266 <xsl:template match="value">
267 <xsl:choose>
268 <xsl:when test="not(contains(child::text(),'(Deprecated)'))">
269 <xs:enumeration>
270 <xsl:attribute name="value">
271 <xsl:value-of select="@name"/>
272 </xsl:attribute>
273 <xs:annotation>
274 <xs:documentation>
275 <xsl:if test="@default='true'">(default)</xsl:if>
276 <xsl:value-of select="child::text()"/>
277 </xs:documentation>
278 </xs:annotation>
279 </xs:enumeration>
280 </xsl:when>
281 <xsl:otherwise>
282 <xsl:comment>deprecated attribute value <xsl:value-of select="@name"/> omitted</xsl:comment>
283 </xsl:otherwise>
284 </xsl:choose>
285 </xsl:template>
286 <!-- ==================================================== -->
287 <!-- actually, not all events apply to all elements -->
288 <xsl:template match="event">
289 <xsl:if test="starts-with(@name,'on')">
290 <xs:attribute type="xul:scriptType">
291 <xsl:attribute name="name">
292 <xsl:value-of select="@name"/>
293 </xsl:attribute>
294 <xs:annotation>
295 <xs:documentation>
296 <xsl:value-of select="text()"/>
297 </xs:documentation>
298 </xs:annotation>
299 </xs:attribute>
300 </xsl:if>
301 </xsl:template>
302 <xsl:template match="object[@name='XULElement']">
303 <xsl:apply-templates select="attr"/>
304 </xsl:template>
305 </xsl:stylesheet>