2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
5 exclude-result-prefixes="doc"
8 <!-- ********************************************************************
9 $Id: ebnf.xsl 6910 2007-06-28 23:23:30Z xmldoc $
10 ********************************************************************
12 This file is part of the XSL DocBook Stylesheet distribution.
13 See ../README or http://docbook.sf.net/release/xsl/current/ for
14 copyright and other information.
16 ******************************************************************** -->
18 <doc:reference xmlns="">
20 <releaseinfo role="meta">
21 $Id: ebnf.xsl 6910 2007-06-28 23:23:30Z xmldoc $
23 <author><surname>Walsh</surname>
24 <firstname>Norman</firstname></author>
25 <copyright><year>1999</year><year>2000</year><year>2001</year>
26 <holder>Norman Walsh</holder>
29 <title>HTML EBNF Reference</title>
32 <section><title>Introduction</title>
34 <para>This is technical reference documentation for the DocBook XSL
35 Stylesheets; it documents (some of) the parameters, templates, and
36 other elements of the stylesheets.</para>
38 <para>This reference describes the templates and parameters relevant
39 to formatting EBNF markup.</para>
41 <para>This is not intended to be <quote>user</quote> documentation.
42 It is provided for developers writing customization layers for the
43 stylesheets, and for anyone who's interested in <quote>how it
46 <para>Although I am trying to be thorough, this documentation is known
47 to be incomplete. Don't forget to read the source, too :-)</para>
52 <!-- ==================================================================== -->
54 <xsl:template match="productionset">
55 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
58 <xsl:when test="title">
59 <fo:block id="{$id}" xsl:use-attribute-sets="formal.object.properties">
60 <xsl:call-template name="formal.object.heading">
61 <xsl:with-param name="placement" select="'before'"/>
64 <fo:table table-layout="fixed" width="100%">
65 <fo:table-column column-number="1" column-width="3%"/>
66 <fo:table-column column-number="2" column-width="15%"/>
67 <fo:table-column column-number="3" column-width="5%"/>
68 <fo:table-column column-number="4" column-width="52%"/>
69 <fo:table-column column-number="5" column-width="25%"/>
70 <fo:table-body start-indent="0pt" end-indent="0pt">
71 <xsl:apply-templates select="production|productionrecap"/>
77 <fo:table id="{$id}" table-layout="fixed" width="100%">
78 <fo:table-column column-number="1" column-width="3%"/>
79 <fo:table-column column-number="2" column-width="15%"/>
80 <fo:table-column column-number="3" column-width="5%"/>
81 <fo:table-column column-number="4" column-width="52%"/>
82 <fo:table-column column-number="5" column-width="25%"/>
83 <fo:table-body start-indent="0pt" end-indent="0pt">
84 <xsl:apply-templates select="production|productionrecap"/>
91 <xsl:template match="productionset/title">
95 <xsl:template match="production">
96 <xsl:param name="recap" select="false()"/>
97 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
100 <fo:block text-align="start">
101 <xsl:text>[</xsl:text>
102 <xsl:number count="production" level="any"/>
103 <xsl:text>]</xsl:text>
107 <fo:block text-align="end">
109 <xsl:when test="$recap">
110 <fo:basic-link internal-destination="{$id}"
111 xsl:use-attribute-sets="xref.properties">
112 <xsl:apply-templates select="lhs"/>
116 <fo:wrapper id="{$id}">
117 <xsl:apply-templates select="lhs"/>
124 <fo:block text-align="center">
125 <xsl:copy-of select="$ebnf.assignment"/>
130 <xsl:apply-templates select="rhs"/>
131 <xsl:copy-of select="$ebnf.statement.terminator"/>
134 <fo:table-cell border-start-width="3pt">
135 <fo:block text-align="start">
137 <xsl:when test="rhs/lineannotation|constraint">
138 <xsl:apply-templates select="rhs/lineannotation" mode="rhslo"/>
139 <xsl:apply-templates select="constraint"/>
142 <xsl:text> </xsl:text>
150 <xsl:template match="productionrecap">
151 <xsl:variable name="targets" select="key('id',@linkend)"/>
152 <xsl:variable name="target" select="$targets[1]"/>
154 <xsl:if test="count($targets)=0">
156 <xsl:text>Error: no ID for productionrecap linkend: </xsl:text>
157 <xsl:value-of select="@linkend"/>
158 <xsl:text>.</xsl:text>
162 <xsl:if test="count($targets)>1">
164 <xsl:text>Warning: multiple "IDs" for productionrecap linkend: </xsl:text>
165 <xsl:value-of select="@linkend"/>
166 <xsl:text>.</xsl:text>
170 <xsl:apply-templates select="$target">
171 <xsl:with-param name="recap" select="true()"/>
172 </xsl:apply-templates>
175 <xsl:template match="lhs">
176 <xsl:apply-templates/>
179 <xsl:template match="rhs">
180 <xsl:apply-templates/>
183 <xsl:template match="nonterminal">
184 <xsl:variable name="linkend">
185 <xsl:call-template name="xpointer.idref">
186 <xsl:with-param name="xpointer" select="@def"/>
190 <xsl:call-template name="check.id.unique">
191 <xsl:with-param name="linkend" select="$linkend"/>
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>
199 <!-- If you don't provide content, you can't point outside this doc. -->
201 <xsl:when test="*|text()"><!--nop--></xsl:when>
203 <xsl:if test="$linkend = ''">
205 <xsl:text>Non-terminals with no content must point to </xsl:text>
206 <xsl:text>production elements in the current document.</xsl:text>
209 <xsl:text>Invalid xpointer for empty nt: </xsl:text>
210 <xsl:value-of select="@def"/>
216 <xsl:variable name="href">
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="object.id">
222 <xsl:with-param name="object" select="$target"/>
226 <xsl:value-of select="@def"/>
231 <fo:basic-link internal-destination="{$href}"
232 xsl:use-attribute-sets="xref.properties">
234 <xsl:when test="*|text()">
235 <xsl:apply-templates/>
239 <xsl:when test="$linkend != ''">
240 <xsl:variable name="targets" select="key('id',$linkend)"/>
241 <xsl:variable name="target" select="$targets[1]"/>
242 <xsl:apply-templates select="$target/lhs"/>
245 <xsl:text>???</xsl:text>
253 <xsl:template match="rhs/lineannotation">
257 <xsl:template match="rhs/lineannotation" mode="rhslo">
258 <xsl:text>/* </xsl:text>
259 <xsl:apply-templates/>
260 <xsl:text> */</xsl:text>
263 <xsl:template match="constraint">
264 <xsl:call-template name="check.id.unique">
265 <xsl:with-param name="linkend" select="@linkend"/>
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>
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="object.id">
277 <xsl:with-param name="object" select="$target"/>
281 <xsl:if test="preceding-sibling::constraint">
282 <fo:inline linefeed-treatment="preserve">
</fo:inline>
284 <xsl:text>[ </xsl:text>
287 <xsl:when test="@role">
288 <xsl:value-of select="@role"/>
289 <xsl:text>: </xsl:text>
292 <xsl:variable name="targets" select="key('id',@linkend)"/>
293 <xsl:variable name="target" select="$targets[1]"/>
294 <xsl:if test="$target/@role">
295 <xsl:value-of select="$target/@role"/>
296 <xsl:text>: </xsl:text>
301 <fo:basic-link internal-destination="{$href}"
302 xsl:use-attribute-sets="xref.properties">
303 <xsl:variable name="targets" select="key('id',@linkend)"/>
304 <xsl:variable name="target" select="$targets[1]"/>
305 <xsl:apply-templates select="$target" mode="title.markup"/>
307 <xsl:text> ]</xsl:text>
310 <xsl:template match="constraintdef">
311 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
312 <fo:block id="{$id}">
313 <xsl:apply-templates/>
317 <xsl:template match="constraintdef/title">
318 <fo:block font-weight="bold">
319 <xsl:apply-templates/>
323 <!-- ==================================================================== -->