Debian Codegraph @

docbook-xsl-ns/xhtml/ebnf.xsl

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