OLD | NEW |
| (Empty) |
1 <?xml version='1.0'?> | |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" | |
4 exclude-result-prefixes="doc" | |
5 version='1.0'> | |
6 | |
7 <!-- ******************************************************************** | |
8 $Id: ebnf.xsl 9664 2012-11-07 20:02:17Z bobstayton $ | |
9 ******************************************************************** | |
10 | |
11 This file is part of the XSL DocBook Stylesheet distribution. | |
12 See ../README or http://docbook.sf.net/release/xsl/current/ for | |
13 copyright and other information. | |
14 | |
15 ******************************************************************** --> | |
16 | |
17 <doc:reference xmlns=""> | |
18 <referenceinfo> | |
19 <releaseinfo role="meta"> | |
20 $Id: ebnf.xsl 9664 2012-11-07 20:02:17Z bobstayton $ | |
21 </releaseinfo> | |
22 <author><surname>Walsh</surname> | |
23 <firstname>Norman</firstname></author> | |
24 <copyright><year>1999</year><year>2000</year> | |
25 <holder>Norman Walsh</holder> | |
26 </copyright> | |
27 </referenceinfo> | |
28 <title>HTML EBNF Reference</title> | |
29 | |
30 <partintro> | |
31 <section><title>Introduction</title> | |
32 | |
33 <para>This is technical reference documentation for the DocBook XSL | |
34 Stylesheets; it documents (some of) the parameters, templates, and | |
35 other elements of the stylesheets.</para> | |
36 | |
37 <para>This reference describes the templates and parameters relevant | |
38 to formatting EBNF markup.</para> | |
39 | |
40 <para>This is not intended to be <quote>user</quote> documentation. | |
41 It is provided for developers writing customization layers for the | |
42 stylesheets, and for anyone who's interested in <quote>how it | |
43 works</quote>.</para> | |
44 | |
45 <para>Although I am trying to be thorough, this documentation is known | |
46 to be incomplete. Don't forget to read the source, too :-)</para> | |
47 </section> | |
48 </partintro> | |
49 </doc:reference> | |
50 | |
51 <!-- ==================================================================== --> | |
52 | |
53 <xsl:template match="productionset"> | |
54 <table width="100%" cellpadding="5"> | |
55 <xsl:if test="$ebnf.table.bgcolor != ''"> | |
56 <xsl:attribute name="bgcolor"> | |
57 <xsl:value-of select="$ebnf.table.bgcolor"/> | |
58 </xsl:attribute> | |
59 </xsl:if> | |
60 <xsl:if test="$ebnf.table.border != 0"> | |
61 <xsl:attribute name="border">1</xsl:attribute> | |
62 </xsl:if> | |
63 <xsl:attribute name="class"> | |
64 <xsl:value-of select="local-name(.)"/> | |
65 </xsl:attribute> | |
66 <xsl:attribute name="summary"> | |
67 <xsl:text>EBNF</xsl:text> | |
68 <xsl:if test="title|info/title"> | |
69 <xsl:text> for </xsl:text> | |
70 <xsl:value-of select="title|info/title[1]"/> | |
71 </xsl:if> | |
72 </xsl:attribute> | |
73 | |
74 <xsl:if test="title|info/title"> | |
75 <tr> | |
76 <th align="{$direction.align.start}" valign="top"> | |
77 <xsl:apply-templates select="." mode="class.attribute"/> | |
78 <xsl:apply-templates select="title|info/title[1]"/> | |
79 </th> | |
80 </tr> | |
81 </xsl:if> | |
82 <tr> | |
83 <td> | |
84 <table border="0" width="99%" cellpadding="0"> | |
85 <xsl:if test="$ebnf.table.bgcolor != ''"> | |
86 <xsl:attribute name="bgcolor"> | |
87 <xsl:value-of select="$ebnf.table.bgcolor"/> | |
88 </xsl:attribute> | |
89 </xsl:if> | |
90 <xsl:attribute name="class"> | |
91 <xsl:value-of select="local-name(.)"/> | |
92 </xsl:attribute> | |
93 <xsl:attribute name="summary">EBNF productions</xsl:attribute> | |
94 <xsl:apply-templates select="production|productionrecap"/> | |
95 </table> | |
96 </td> | |
97 </tr> | |
98 </table> | |
99 </xsl:template> | |
100 | |
101 <xsl:template match="productionset/title"> | |
102 <xsl:apply-templates/> | |
103 </xsl:template> | |
104 | |
105 <xsl:template match="production"> | |
106 <xsl:param name="recap" select="false()"/> | |
107 <tr> | |
108 <td align="{$direction.align.start}" valign="top" width="3%"> | |
109 <xsl:text>[</xsl:text> | |
110 <xsl:apply-templates select="." mode="label.markup"/> | |
111 <xsl:text>]</xsl:text> | |
112 </td> | |
113 <td align="{$direction.align.end}" valign="top" width="10%"> | |
114 <xsl:choose> | |
115 <xsl:when test="$recap"> | |
116 <a> | |
117 <xsl:attribute name="href"> | |
118 <xsl:call-template name="href.target"> | |
119 <xsl:with-param name="object" select="."/> | |
120 </xsl:call-template> | |
121 </xsl:attribute> | |
122 <xsl:apply-templates select="lhs"/> | |
123 </a> | |
124 </xsl:when> | |
125 <xsl:otherwise> | |
126 <xsl:call-template name="id.attribute"/> | |
127 <xsl:call-template name="anchor"/> | |
128 <xsl:apply-templates select="lhs"/> | |
129 </xsl:otherwise> | |
130 </xsl:choose> | |
131 </td> | |
132 <td valign="top" width="5%" align="center"> | |
133 <xsl:copy-of select="$ebnf.assignment"/> | |
134 </td> | |
135 <td valign="top" width="52%"> | |
136 <xsl:apply-templates select="rhs"/> | |
137 <xsl:copy-of select="$ebnf.statement.terminator"/> | |
138 </td> | |
139 <td align="{$direction.align.start}" valign="top" width="30%"> | |
140 <xsl:choose> | |
141 <xsl:when test="rhs/lineannotation|constraint"> | |
142 <xsl:apply-templates select="rhs/lineannotation" mode="rhslo"/> | |
143 <xsl:apply-templates select="constraint"/> | |
144 </xsl:when> | |
145 <xsl:otherwise> | |
146 <xsl:text> </xsl:text> | |
147 </xsl:otherwise> | |
148 </xsl:choose> | |
149 </td> | |
150 </tr> | |
151 </xsl:template> | |
152 | |
153 <xsl:template match="productionrecap"> | |
154 <xsl:variable name="targets" select="key('id',@linkend)"/> | |
155 <xsl:variable name="target" select="$targets[1]"/> | |
156 | |
157 <xsl:if test="count($targets)=0"> | |
158 <xsl:message> | |
159 <xsl:text>Error: no ID for productionrecap linkend: </xsl:text> | |
160 <xsl:value-of select="@linkend"/> | |
161 <xsl:text>.</xsl:text> | |
162 </xsl:message> | |
163 </xsl:if> | |
164 | |
165 <xsl:if test="count($targets)>1"> | |
166 <xsl:message> | |
167 <xsl:text>Warning: multiple "IDs" for productionrecap linkend: </xsl:text> | |
168 <xsl:value-of select="@linkend"/> | |
169 <xsl:text>.</xsl:text> | |
170 </xsl:message> | |
171 </xsl:if> | |
172 | |
173 <xsl:apply-templates select="$target"> | |
174 <xsl:with-param name="recap" select="true()"/> | |
175 </xsl:apply-templates> | |
176 </xsl:template> | |
177 | |
178 <xsl:template match="lhs"> | |
179 <xsl:apply-templates/> | |
180 </xsl:template> | |
181 | |
182 <xsl:template match="rhs"> | |
183 <xsl:apply-templates/> | |
184 <xsl:if test="following-sibling::rhs"> | |
185 <xsl:text> |</xsl:text> | |
186 <br/> | |
187 </xsl:if> | |
188 </xsl:template> | |
189 | |
190 <xsl:template match="nonterminal"> | |
191 <xsl:variable name="linkend"> | |
192 <xsl:call-template name="xpointer.idref"> | |
193 <xsl:with-param name="xpointer" select="@def"/> | |
194 </xsl:call-template> | |
195 </xsl:variable> | |
196 | |
197 <xsl:call-template name="check.id.unique"> | |
198 <xsl:with-param name="linkend" select="$linkend"/> | |
199 </xsl:call-template> | |
200 | |
201 <xsl:call-template name="check.idref.targets"> | |
202 <xsl:with-param name="linkend" select="$linkend"/> | |
203 <xsl:with-param name="element-list">production</xsl:with-param> | |
204 </xsl:call-template> | |
205 | |
206 <!-- If you don't provide content, you can't point outside this doc. --> | |
207 <xsl:choose> | |
208 <xsl:when test="*|text()"><!--nop--></xsl:when> | |
209 <xsl:otherwise> | |
210 <xsl:if test="$linkend = ''"> | |
211 <xsl:message> | |
212 <xsl:text>Non-terminals with no content must point to </xsl:text> | |
213 <xsl:text>production elements in the current document.</xsl:text> | |
214 </xsl:message> | |
215 <xsl:message> | |
216 <xsl:text>Invalid xpointer for empty nt: </xsl:text> | |
217 <xsl:value-of select="@def"/> | |
218 </xsl:message> | |
219 </xsl:if> | |
220 </xsl:otherwise> | |
221 </xsl:choose> | |
222 | |
223 <xsl:variable name="href"> | |
224 <xsl:choose> | |
225 <xsl:when test="$linkend != ''"> | |
226 <xsl:variable name="targets" select="key('id',$linkend)"/> | |
227 <xsl:variable name="target" select="$targets[1]"/> | |
228 <xsl:call-template name="href.target"> | |
229 <xsl:with-param name="object" select="$target"/> | |
230 </xsl:call-template> | |
231 </xsl:when> | |
232 <xsl:otherwise> | |
233 <xsl:value-of select="@def"/> | |
234 </xsl:otherwise> | |
235 </xsl:choose> | |
236 </xsl:variable> | |
237 | |
238 <a href="{$href}"> | |
239 <xsl:choose> | |
240 <xsl:when test="*|text()"> | |
241 <xsl:apply-templates/> | |
242 </xsl:when> | |
243 <xsl:otherwise> | |
244 <xsl:choose> | |
245 <xsl:when test="$linkend != ''"> | |
246 <xsl:variable name="targets" select="key('id',$linkend)"/> | |
247 <xsl:variable name="target" select="$targets[1]"/> | |
248 <xsl:apply-templates select="$target/lhs"/> | |
249 </xsl:when> | |
250 <xsl:otherwise> | |
251 <xsl:text>???</xsl:text> | |
252 </xsl:otherwise> | |
253 </xsl:choose> | |
254 </xsl:otherwise> | |
255 </xsl:choose> | |
256 </a> | |
257 </xsl:template> | |
258 | |
259 <xsl:template match="rhs/lineannotation"> | |
260 <!--nop--> | |
261 </xsl:template> | |
262 | |
263 <xsl:template match="rhs/lineannotation" mode="rhslo"> | |
264 <xsl:text>/* </xsl:text> | |
265 <xsl:apply-templates/> | |
266 <xsl:text> */</xsl:text> | |
267 <br/> | |
268 </xsl:template> | |
269 | |
270 <xsl:template match="constraint"> | |
271 <xsl:call-template name="check.id.unique"> | |
272 <xsl:with-param name="linkend" select="@linkend"/> | |
273 </xsl:call-template> | |
274 | |
275 <xsl:call-template name="check.idref.targets"> | |
276 <xsl:with-param name="linkend" select="@linkend"/> | |
277 <xsl:with-param name="element-list">constraintdef</xsl:with-param> | |
278 </xsl:call-template> | |
279 | |
280 <xsl:variable name="href"> | |
281 <xsl:variable name="targets" select="key('id',@linkend)"/> | |
282 <xsl:variable name="target" select="$targets[1]"/> | |
283 <xsl:call-template name="href.target"> | |
284 <xsl:with-param name="object" select="$target"/> | |
285 </xsl:call-template> | |
286 </xsl:variable> | |
287 | |
288 <xsl:text>[ </xsl:text> | |
289 | |
290 <xsl:choose> | |
291 <xsl:when test="@role"> | |
292 <xsl:value-of select="@role"/> | |
293 <xsl:text>: </xsl:text> | |
294 </xsl:when> | |
295 <xsl:otherwise> | |
296 <xsl:variable name="targets" select="key('id',@linkend)"/> | |
297 <xsl:variable name="target" select="$targets[1]"/> | |
298 <xsl:if test="$target/@role"> | |
299 <xsl:value-of select="$target/@role"/> | |
300 <xsl:text>: </xsl:text> | |
301 </xsl:if> | |
302 </xsl:otherwise> | |
303 </xsl:choose> | |
304 | |
305 <a href="{$href}"> | |
306 <xsl:variable name="targets" select="key('id',@linkend)"/> | |
307 <xsl:variable name="target" select="$targets[1]"/> | |
308 <xsl:apply-templates select="$target" mode="title.markup"/> | |
309 </a> | |
310 <xsl:text> ]</xsl:text> | |
311 <xsl:if test="following-sibling::constraint"> | |
312 <br/> | |
313 </xsl:if> | |
314 </xsl:template> | |
315 | |
316 <xsl:template match="constraintdef"> | |
317 <div> | |
318 <xsl:apply-templates select="." mode="class.attribute"/> | |
319 <xsl:call-template name="id.attribute"/> | |
320 <xsl:call-template name="anchor"/> | |
321 <xsl:apply-templates/> | |
322 </div> | |
323 </xsl:template> | |
324 | |
325 <xsl:template match="constraintdef/title"> | |
326 <p><b><xsl:apply-templates/></b></p> | |
327 </xsl:template> | |
328 | |
329 <!-- ==================================================================== --> | |
330 | |
331 </xsl:stylesheet> | |
OLD | NEW |