stylesheets erklaert
[cxml-rng.git] / doc / cleanup.xsl
blobe644814e1effc501d66183e9288088cdfbac335c
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 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>
19 Output:
21 <class 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>
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 match="documentation-string">
76 <xsl:if test=".//arg">
77 <arguments>
78 <xsl:apply-templates mode="extract" select=".//arg"/>
79 </arguments>
80 </xsl:if>
82 <xsl:if test=".//section">
83 <sections>
84 <xsl:apply-templates mode="extract" select=".//section"/>
85 </sections>
86 </xsl:if>
88 <xsl:if test=".//see or .//see-slot or .//see-constructor">
89 <see-also>
90 <xsl:if test=".//see">
91 <other>
92 <xsl:apply-templates mode="extract" select=".//see"/>
93 </other>
94 </xsl:if>
96 <xsl:if test=".//see-slot">
97 <slot>
98 <xsl:apply-templates mode="extract" select=".//see-slot"/>
99 </slot>
100 </xsl:if>
102 <xsl:if test=".//see-constructor">
103 <constructor>
104 <xsl:apply-templates mode="extract" select=".//see-constructor"/>
105 </constructor>
106 </xsl:if>
107 </see-also>
108 </xsl:if>
110 <xsl:apply-templates mode="extract" select=".//implementation-note"/>
111 <xsl:apply-templates mode="extract" select=".//return"/>
113 <documentation-string>
114 <xsl:apply-templates/>
115 </documentation-string>
116 </xsl:template>
117 </xsl:stylesheet>