adding all of botlist, initial add
[botlist.git] / botclient / xul / xulschema / xulstructure.xsl
blob14a35a3ef703e3412dc14cc21e7dcef740b9d8fd
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This XSLT stylesheet is used to transform structure information in
4 xulstructure.xml into a W3C Schema definitions. Please see
5 http://mozilla.doslash.org/xulschema for more information.
6 -->
8 <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
10 <!-- -->
11 <xsl:template match="/elements">
12 <xs:schema xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
13 targetNamespace="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
14 <xsl:apply-templates/>
15 </xs:schema>
16 </xsl:template>
17 <!-- -->
18 <xsl:template match="type">
19 <xsl:apply-templates>
20 <xsl:with-param name="type" select="concat(@name,'ElementType')"/>
21 </xsl:apply-templates>
22 </xsl:template>
23 <!-- -->
24 <xsl:template match="element[@name]">
25 <xsl:param name="type"/>
26 <xs:complexType name="{@name}ElementType">
27 <xs:complexContent>
28 <xs:extension base="xul:{$type}">
29 <xsl:apply-templates/>
30 </xs:extension>
31 </xs:complexContent>
32 </xs:complexType>
33 </xsl:template>
34 <xsl:template match="group[@name]">
35 <xs:group name="{@name}ElementGroup">
36 <xsl:apply-templates/>
37 </xs:group>
38 </xsl:template>
39 <!-- ElementType definitions -->
40 <xsl:template match="definetype">
41 <xs:complexType name="{@name}ElementType">
42 <xsl:choose>
43 <xsl:when test="@derive">
44 <xs:complexContent>
45 <xs:extension base="xul:{@derive}ElementType">
46 <xsl:apply-templates/>
47 </xs:extension>
48 </xs:complexContent>
49 </xsl:when>
50 <xsl:otherwise>
51 <xsl:apply-templates/>
52 </xsl:otherwise>
53 </xsl:choose>
54 </xs:complexType>
55 </xsl:template>
56 <xsl:template match="defineelement">
57 <xs:element name="{@name}"/>
58 </xsl:template>
59 <!-- -->
60 <xsl:template match="element[@ref]">
61 <xs:element ref="xul:{@ref}">
62 <xsl:copy-of select="@minOccurs|@maxOccurs"/>
63 </xs:element>
64 </xsl:template>
65 <xsl:template match="group[@ref]">
66 <xs:group ref="xul:{@ref}ElementGroup">
67 <xsl:copy-of select="@minOccurs|@maxOccurs"/>
68 </xs:group>
69 </xsl:template>
70 <xsl:template match="attributeGroup[@ref]">
71 <xs:attributeGroup ref="xul:{@ref}AttributeGroup"/>
72 </xsl:template>
73 <!-- rng -> schema -->
74 <xsl:template match="zeroOrMore">
75 <xs:choice minOccurs="0" maxOccurs="unbounded">
76 <xsl:apply-templates/>
77 </xs:choice>
78 </xsl:template>
79 <xsl:template match="oneOrMore">
80 <xs:choice maxOccurs="unbounded">
81 <xsl:apply-templates/>
82 </xs:choice>
83 </xsl:template>
84 <!-- -->
85 <xsl:template match="choice">
86 <xs:choice>
87 <xsl:copy-of select="@minOccurs|@maxOccurs"/>
88 <xsl:apply-templates/>
89 </xs:choice>
90 </xsl:template>
91 <xsl:template match="sequence">
92 <xs:sequence>
93 <xsl:copy-of select="@minOccurs|@maxOccurs"/>
94 <xsl:apply-templates/>
95 </xs:sequence>
96 </xsl:template>
97 <xsl:template match="all">
98 <xs:all>
99 <xsl:apply-templates/>
100 </xs:all>
101 </xsl:template>
102 <xsl:template match="any">
103 <xs:any>
104 <xsl:copy-of select="@*"/>
105 </xs:any>
106 </xsl:template>
107 <xsl:template match="optional">
108 <xs:sequence minOccurs="0" maxOccurs="1">
109 <xsl:apply-templates/>
110 </xs:sequence>
111 </xsl:template>
112 </xsl:stylesheet>