Debian Codegraph @

docbook-xsl-ns/fo/ebnf.xsl

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