adding all of botlist, initial add
[botlist.git] / botclient / xul / xulschema / strip_elemref.xsl
blob272ca2039a4e1c546389c52d8f08bb9192b76c33
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 This XSLT stylesheet is used to strip the XUL Elements Reference found at
4 http://www.xulplanet.com/references/elemref/refall_elemref.xml of unneeded
5 information for further processing by xulplanet2schema.xsl into a W3C Schema.
7 Please see http://mozilla.doslash.org/xulschema for more information.
8 -->
10 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
11 <!-- Root element -->
12 <xsl:template match="/elements">
13 <elements>
14 <xsl:apply-templates select="element"/>
15 <xsl:apply-templates select="events"/>
16 <xsl:apply-templates select="object[@name='XULElement']"/>
17 </elements>
18 </xsl:template>
19 <!-- ===================== <element> ============================ -->
20 <xsl:template match="element">
21 <element>
22 <xsl:copy-of select="@*|reference|child::reference/following-sibling::text()"/>
23 <xsl:apply-templates select="attr"/>
24 </element>
25 </xsl:template>
26 <!-- ============== <object name="XULElement"> ================== -->
27 <xsl:template match="object">
28 <object name="XULElement">
29 <xsl:apply-templates select="attr"/>
30 </object>
31 </xsl:template>
32 <xsl:template match="attr">
33 <xsl:choose>
34 <xsl:when test="parent::element">
35 <!-- For <element>s check if the attribute was already declared on XULElement -->
36 <xsl:variable name="name" select="@name"/>
37 <xsl:choose>
38 <xsl:when
39 test="not(//object[@name='XULElement']/attr[@name=current()/@name]) and not(//event[@name=current()/@name])">
40 <xsl:copy>
41 <xsl:copy-of select="@*"/>
42 <xsl:apply-templates/>
43 </xsl:copy>
44 </xsl:when>
45 <xsl:otherwise>
46 <xsl:comment> attribute <xsl:value-of select="@name"/> is not copied because it's duplicate </xsl:comment>
47 </xsl:otherwise>
48 </xsl:choose>
49 </xsl:when>
50 <xsl:otherwise>
51 <!-- Just copy XULElement's attributes -->
52 <xsl:copy>
53 <xsl:copy-of select="@*"/>
54 <xsl:apply-templates/>
55 </xsl:copy>
56 </xsl:otherwise>
57 </xsl:choose>
58 </xsl:template>
59 <!-- ================= Default action: copy ==================== -->
60 <xsl:template match="@*|node()">
61 <xsl:copy>
62 <xsl:apply-templates select="@*|node()"/>
63 </xsl:copy>
64 </xsl:template>
65 </xsl:stylesheet>