1 | <?xml version="1.0" encoding="utf-8"?> |
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | version="1.0"> |
---|
4 | |
---|
5 | <xsl:output method="xml" indent="yes" standalone="yes"/> |
---|
6 | |
---|
7 | <xsl:strip-space elements="sequence-group or-group element element-name"/> |
---|
8 | |
---|
9 | <xsl:key name="elements" match="element" use="@name"/> |
---|
10 | <xsl:key name="attributes" match="attlist" use="@name"/> |
---|
11 | <xsl:key name="attribute-purposes" match="attpurpose" use="@name"/> |
---|
12 | |
---|
13 | <xsl:template match="dtd"> |
---|
14 | <section id="reference"> |
---|
15 | <title>Reference</title> |
---|
16 | <para> |
---|
17 | <xsl:text>Elements:</xsl:text> |
---|
18 | <itemizedlist spacing="compact"> |
---|
19 | <xsl:apply-templates select="element" mode="synopsis"> |
---|
20 | <xsl:sort select="@name"/> |
---|
21 | </xsl:apply-templates> |
---|
22 | </itemizedlist> |
---|
23 | </para> |
---|
24 | <xsl:apply-templates select="element"/> |
---|
25 | </section> |
---|
26 | </xsl:template> |
---|
27 | |
---|
28 | <!-- Element synopsis --> |
---|
29 | <xsl:template match="element" mode="synopsis"> |
---|
30 | <listitem> |
---|
31 | <simpara> |
---|
32 | <link> |
---|
33 | <xsl:attribute name="linkend"> |
---|
34 | <xsl:value-of select="concat('boostbook.dtd.',@name)"/> |
---|
35 | </xsl:attribute> |
---|
36 | <xsl:text>Element </xsl:text> |
---|
37 | <sgmltag><xsl:value-of select="@name"/></sgmltag> |
---|
38 | <xsl:text> - </xsl:text> |
---|
39 | <xsl:apply-templates select="purpose"/> |
---|
40 | </link> |
---|
41 | </simpara> |
---|
42 | </listitem> |
---|
43 | </xsl:template> |
---|
44 | |
---|
45 | <!-- Elements are transformed into DocBook refentry elements --> |
---|
46 | <xsl:template match="element"> |
---|
47 | <refentry> |
---|
48 | <xsl:attribute name="id"> |
---|
49 | <xsl:value-of select="concat('boostbook.dtd.',@name)"/> |
---|
50 | </xsl:attribute> |
---|
51 | |
---|
52 | <refmeta> |
---|
53 | <refentrytitle> |
---|
54 | BoostBook element <sgmltag><xsl:value-of select="@name"/></sgmltag> |
---|
55 | </refentrytitle> |
---|
56 | <manvolnum>9</manvolnum> |
---|
57 | </refmeta> |
---|
58 | <refnamediv> |
---|
59 | <refname><xsl:value-of select="@name"/></refname> |
---|
60 | <refpurpose><xsl:apply-templates select="purpose"/></refpurpose> |
---|
61 | </refnamediv> |
---|
62 | <refsynopsisdiv> |
---|
63 | <xsl:value-of select="@name"/><xsl:text> ::= </xsl:text> |
---|
64 | <xsl:apply-templates select="content-model-expanded"/> |
---|
65 | </refsynopsisdiv> |
---|
66 | <xsl:apply-templates select="description"/> |
---|
67 | <xsl:apply-templates select="key('attributes', @name)"/> |
---|
68 | </refentry> |
---|
69 | </xsl:template> |
---|
70 | |
---|
71 | <xsl:template match="content-model-expanded"> |
---|
72 | <xsl:apply-templates/> |
---|
73 | </xsl:template> |
---|
74 | |
---|
75 | <!-- Sequences --> |
---|
76 | <xsl:template match="sequence-group"> |
---|
77 | <xsl:param name="separator" select="''"/> |
---|
78 | |
---|
79 | <xsl:if test="preceding-sibling::*"> |
---|
80 | <xsl:value-of select="$separator"/> |
---|
81 | </xsl:if> |
---|
82 | <xsl:text>(</xsl:text> |
---|
83 | <xsl:apply-templates> |
---|
84 | <xsl:with-param name="separator" select="', '"/> |
---|
85 | </xsl:apply-templates> |
---|
86 | <xsl:text>)</xsl:text> |
---|
87 | <xsl:value-of select="@occurrence"/> |
---|
88 | </xsl:template> |
---|
89 | |
---|
90 | <!-- Alternatives --> |
---|
91 | <xsl:template match="or-group"> |
---|
92 | <xsl:param name="separator" select="''"/> |
---|
93 | |
---|
94 | <xsl:if test="preceding-sibling::*"> |
---|
95 | <xsl:value-of select="$separator"/> |
---|
96 | </xsl:if> |
---|
97 | <xsl:text>(</xsl:text> |
---|
98 | <xsl:apply-templates> |
---|
99 | <xsl:with-param name="separator" select="'| '"/> |
---|
100 | </xsl:apply-templates> |
---|
101 | <xsl:text>)</xsl:text> |
---|
102 | <xsl:value-of select="@occurrence"/> |
---|
103 | </xsl:template> |
---|
104 | |
---|
105 | <!-- Element references --> |
---|
106 | <xsl:template match="element-name"> |
---|
107 | <xsl:param name="separator" select="''"/> |
---|
108 | |
---|
109 | <xsl:if test="preceding-sibling::*"> |
---|
110 | <xsl:value-of select="$separator"/> |
---|
111 | </xsl:if> |
---|
112 | |
---|
113 | <xsl:variable name="element-node" select="key('elements', @name)"/> |
---|
114 | |
---|
115 | <xsl:choose> |
---|
116 | <xsl:when test="$element-node"> |
---|
117 | <link> |
---|
118 | <xsl:attribute name="linkend"> |
---|
119 | <xsl:value-of select="concat('boostbook.dtd.',@name)"/> |
---|
120 | </xsl:attribute> |
---|
121 | <xsl:value-of select="@name"/> |
---|
122 | </link> |
---|
123 | </xsl:when> |
---|
124 | <xsl:otherwise> |
---|
125 | <xsl:value-of select="@name"/> |
---|
126 | </xsl:otherwise> |
---|
127 | </xsl:choose> |
---|
128 | <xsl:value-of select="@occurrence"/> |
---|
129 | </xsl:template> |
---|
130 | |
---|
131 | <!-- #PCDATA --> |
---|
132 | <xsl:template match="pcdata"> |
---|
133 | <xsl:param name="separator" select="''"/> |
---|
134 | |
---|
135 | <xsl:if test="preceding-sibling::*"> |
---|
136 | <xsl:value-of select="$separator"/> |
---|
137 | </xsl:if> |
---|
138 | |
---|
139 | <xsl:text>#PCDATA</xsl:text> |
---|
140 | </xsl:template> |
---|
141 | |
---|
142 | <!-- ANY --> |
---|
143 | <xsl:template match="any"> |
---|
144 | <xsl:text>ANY</xsl:text> |
---|
145 | </xsl:template> |
---|
146 | |
---|
147 | <!-- EMPTY --> |
---|
148 | <xsl:template match="empty"> |
---|
149 | <xsl:text>EMPTY</xsl:text> |
---|
150 | </xsl:template> |
---|
151 | |
---|
152 | <!-- Just copy anything in a purpose element --> |
---|
153 | <xsl:template match="purpose"> |
---|
154 | <xsl:copy-of select="text()|*"/> |
---|
155 | </xsl:template> |
---|
156 | |
---|
157 | <!-- Just copy anything in a description element, but place it in a |
---|
158 | section. --> |
---|
159 | <xsl:template match="description"> |
---|
160 | <refsection> |
---|
161 | <title>Description</title> |
---|
162 | <xsl:copy-of select="text()|*"/> |
---|
163 | </refsection> |
---|
164 | </xsl:template> |
---|
165 | |
---|
166 | <!-- Attributes --> |
---|
167 | <xsl:template match="attlist"> |
---|
168 | <refsection> |
---|
169 | <title>Attributes</title> |
---|
170 | |
---|
171 | <informaltable> |
---|
172 | <tgroup cols="4"> |
---|
173 | <thead> |
---|
174 | <row> |
---|
175 | <entry>Name</entry> |
---|
176 | <entry>Type</entry> |
---|
177 | <entry>Value</entry> |
---|
178 | <entry>Purpose</entry> |
---|
179 | </row> |
---|
180 | </thead> |
---|
181 | <tbody> |
---|
182 | <xsl:apply-templates/> |
---|
183 | </tbody> |
---|
184 | </tgroup> |
---|
185 | </informaltable> |
---|
186 | </refsection> |
---|
187 | </xsl:template> |
---|
188 | |
---|
189 | <!-- Attribute --> |
---|
190 | <xsl:template match="attribute"> |
---|
191 | <row> |
---|
192 | <entry><xsl:value-of select="@name"/></entry> |
---|
193 | <entry><xsl:value-of select="@type"/></entry> |
---|
194 | <entry><xsl:value-of select="@value"/></entry> |
---|
195 | <entry> |
---|
196 | <xsl:choose> |
---|
197 | <xsl:when test="purpose"> |
---|
198 | <xsl:apply-templates select="purpose"/> |
---|
199 | </xsl:when> |
---|
200 | <xsl:otherwise> |
---|
201 | <xsl:apply-templates select="key('attribute-purposes', @name)"/> |
---|
202 | </xsl:otherwise> |
---|
203 | </xsl:choose> |
---|
204 | </entry> |
---|
205 | </row> |
---|
206 | </xsl:template> |
---|
207 | |
---|
208 | <!-- Eat attribute declarations --> |
---|
209 | <xsl:template match="attdecl"/> |
---|
210 | </xsl:stylesheet> |
---|