-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathnormalize-idl.xslt
98 lines (85 loc) · 3.58 KB
/
normalize-idl.xslt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" doctype-public="-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" doctype-system="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"/>
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="tp:docstring p li ul ol"/>
<!-- start from the root node, sorting interfaces by name. -->
<xsl:template match="/node">
<xsl:copy>
<xsl:apply-templates select="@*">
<xsl:sort select="name()"/>
</xsl:apply-templates>
<xsl:apply-templates select="tp:enum">
<xsl:sort select="@name"/>
</xsl:apply-templates>
<xsl:apply-templates select="./interface">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<!-- Preserve everything in comments, attributes, etc -->
<xsl:template match="@*|comment()|processing-instruction()">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Organize the contents of interface definitions. -->
<xsl:template match="/node/interface">
<xsl:comment>~~~~~~~~~~~~~~~~~~~~~~
~~~~ DBus Interface ~~~~
~~~~~~~~~~~~~~~~~~~~~~~</xsl:comment>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<!-- Maintain enumeration definitions, but sort them by name -->
<xsl:apply-templates select="tp:enum">
<xsl:sort select="@name"/>
</xsl:apply-templates>
<!-- Copy any defined documentation -->
<xsl:apply-templates select="tp:docstring"/>
<!-- Copy all methods, if there are any, and sort them by name -->
<xsl:if test="method">
<xsl:comment>~~~~~~~~~~~~~~~~~~~~~~
~~~~ DBus Methods ~~~~
~~~~~~~~~~~~~~~~~~~~~~~</xsl:comment>
<xsl:apply-templates select="method">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:if>
<!-- Copy all signals, if there are any, and sort them by name -->
<xsl:if test="signal">
<xsl:comment>~~~~~~~~~~~~~~~~~~~~~~
~~~~ DBus Signals ~~~~
~~~~~~~~~~~~~~~~~~~~~~~</xsl:comment>
<xsl:apply-templates select="signal">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:if>
<!-- Copy all properties, if there are any, and sort them by name -->
<xsl:if test="property">
<xsl:comment>~~~~~~~~~~~~~~~~~~~~~~
~~~~ DBus Properties ~~~~
~~~~~~~~~~~~~~~~~~~~~~~</xsl:comment>
<xsl:apply-templates select="property">
<xsl:sort select="@name"/>
</xsl:apply-templates>
</xsl:if>
</xsl:copy>
</xsl:template>
<!-- Maintain all subnodes of methods. Order of <arg> elements DOES matter, so never reorder them. -->
<xsl:template match="/node/interface/method">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Maintain all subnodes of signals. Order of <arg> elements DOES matter, so never reorder them. -->
<xsl:template match="/node/interface/signal">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Maintain all subnodes of properties. -->
<xsl:template match="/node/interface/property">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Maintain all documentation as-is. May change when auto-generating documentation based on that tool's requirements. -->
<xsl:template match="tp:docstring">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Maintain all enum documentation and values as-is. -->
<xsl:template match="tp:enum">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>