dokumentation fertig
[cxml-rng.git] / doc / cleanup.xsl
blob0c21516352108a3065da173a03f99a4832622ff4
1 <!--
2 The first stylesheet to be used, this file cleans up the structure
3 of the Lisp-generated XML file by extracting elements from all
4 docstrings into their parent elements, so that only the textual
5 description remains in the <documentation-string>.
7 Example (input):
9 <class-definition name="foo">
10 <cpl>...</cpl>
12 <documentation-string>
13 The foo class.
14 <see-slot id="foo">See also the foo function.</see-slot>
15 Beware bugs.
16 </documentation-string>
17 </class-definition>
19 Output:
21 <class-definition name="foo">
22 <cpl>...</cpl>
24 <see-also>
25 <slot>
26 <see id="foo">See also the foo function.</see>
27 </slot>
28 </see-also>
30 <documentation-string>
31 The foo class.
32 Beware bugs.
33 </documentation-string>
34 </class-definition>
36 -->
38 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
39 <xsl:output method="xml" indent="yes"/>
41 <xsl:template match="@*|node()">
42 <xsl:copy>
43 <xsl:apply-templates select="@*|node()"/>
44 </xsl:copy>
45 </xsl:template>
47 <xsl:template match="see"/>
48 <xsl:template match="see-slot"/>
49 <xsl:template match="see-constructor"/>
50 <xsl:template match="arg"/>
51 <xsl:template match="return"/>
52 <xsl:template match="implementation-note"/>
53 <xsl:template match="section"/>
55 <xsl:template mode="extract" match="@*|node()">
56 <xsl:copy>
57 <xsl:apply-templates select="@*|node()"/>
58 </xsl:copy>
59 </xsl:template>
61 <xsl:template mode="extract" match="see-slot">
62 <see>
63 <xsl:apply-templates select="@*"/>
64 <xsl:apply-templates/>
65 </see>
66 </xsl:template>
68 <xsl:template mode="extract" match="see-constructor">
69 <see>
70 <xsl:apply-templates select="@*"/>
71 <xsl:apply-templates/>
72 </see>
73 </xsl:template>
75 <xsl:template mode="auto-see" match="class|fun|variable">
76 <see>
77 <xsl:apply-templates select="@*"/>
78 <xsl:apply-templates>
79 <xsl:sort select="@name" data-type="text" order="ascending"/>
80 </xsl:apply-templates>
81 </see>
82 </xsl:template>
84 <xsl:template match="class-definition
85 |function-definition
86 |variable-definition">
87 <xsl:if test="not(.//unexport)">
88 <xsl:copy>
89 <xsl:apply-templates select="@*|node()"/>
90 </xsl:copy>
91 </xsl:if>
92 </xsl:template>
94 <xsl:template match="documentation-string">
95 <xsl:if test=".//arg">
96 <arguments>
97 <xsl:apply-templates mode="extract" select=".//arg"/>
98 </arguments>
99 </xsl:if>
101 <xsl:if test=".//section">
102 <sections>
103 <xsl:apply-templates mode="extract" select=".//section"/>
104 </sections>
105 </xsl:if>
107 <xsl:if test=".//see or .//see-slot or .//see-constructor
108 or .//class or .//fun or .//variable">
109 <see-also>
110 <xsl:if test=".//class or .//fun or .//variable">
111 <auto>
112 <xsl:apply-templates mode="auto-see"
113 select=".//class|.//fun|.//variable"/>
114 </auto>
115 </xsl:if>
117 <xsl:if test=".//see">
118 <other>
119 <xsl:apply-templates mode="extract" select=".//see"/>
120 </other>
121 </xsl:if>
123 <xsl:if test=".//see-slot">
124 <slot>
125 <xsl:apply-templates mode="extract" select=".//see-slot"/>
126 </slot>
127 </xsl:if>
129 <xsl:if test=".//see-constructor">
130 <constructor>
131 <xsl:apply-templates mode="extract" select=".//see-constructor"/>
132 </constructor>
133 </xsl:if>
134 </see-also>
135 </xsl:if>
137 <xsl:apply-templates mode="extract" select=".//implementation-note"/>
138 <xsl:apply-templates mode="extract" select=".//return"/>
140 <documentation-string>
141 <xsl:apply-templates/>
142 </documentation-string>
143 </xsl:template>
144 </xsl:stylesheet>