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"
7 <!-- ********************************************************************
8 $Id: ebnf.xsl 8178 2008-12-15 22:26:38Z bobstayton $
9 ********************************************************************
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.
15 ******************************************************************** -->
17 <doc:reference xmlns="">
19 <releaseinfo role="meta">
20 $Id: ebnf.xsl 8178 2008-12-15 22:26:38Z bobstayton $
22 <author><surname>Walsh</surname>
23 <firstname>Norman</firstname></author>
24 <copyright><year>1999</year><year>2000</year>
25 <holder>Norman Walsh</holder>
28 <title>HTML EBNF Reference</title>
31 <section><title>Introduction</title>
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>
37 <para>This reference describes the templates and parameters relevant
38 to formatting EBNF markup.</para>
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
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>
51 <!-- ==================================================================== -->
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"/>
60 <xsl:if test="$ebnf.table.border != 0">
61 <xsl:attribute name="border">1</xsl:attribute>
63 <xsl:attribute name="class">
64 <xsl:value-of select="local-name(.)"/>
66 <xsl:attribute name="summary">
67 <xsl:text>EBNF</xsl:text>
69 <xsl:text> for </xsl:text>
70 <xsl:value-of select="title"/>
76 <th align="{$direction.align.start}" valign="top">
77 <xsl:apply-templates select="." mode="class.attribute"/>
78 <xsl:apply-templates select="title"/>
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"/>
90 <xsl:attribute name="class">
91 <xsl:value-of select="local-name(.)"/>
93 <xsl:attribute name="summary">EBNF productions</xsl:attribute>
94 <xsl:apply-templates select="production|productionrecap"/>
101 <xsl:template match="productionset/title">
102 <xsl:apply-templates/>
105 <xsl:template match="production">
106 <xsl:param name="recap" select="false()"/>
108 <td align="{$direction.align.start}" valign="top" width="3%">
109 <xsl:text>[</xsl:text>
110 <xsl:number count="production" level="any"/>
111 <xsl:text>]</xsl:text>
113 <td align="{$direction.align.end}" valign="top" width="10%">
115 <xsl:when test="$recap">
117 <xsl:attribute name="href">
118 <xsl:call-template name="href.target">
119 <xsl:with-param name="object" select="."/>
122 <xsl:apply-templates select="lhs"/>
126 <xsl:call-template name="anchor"/>
127 <xsl:apply-templates select="lhs"/>
131 <td valign="top" width="5%" align="center">
132 <xsl:copy-of select="$ebnf.assignment"/>
134 <td valign="top" width="52%">
135 <xsl:apply-templates select="rhs"/>
136 <xsl:copy-of select="$ebnf.statement.terminator"/>
138 <td align="{$direction.align.start}" valign="top" width="30%">
140 <xsl:when test="rhs/lineannotation|constraint">
141 <xsl:apply-templates select="rhs/lineannotation" mode="rhslo"/>
142 <xsl:apply-templates select="constraint"/>
145 <xsl:text> </xsl:text>
152 <xsl:template match="productionrecap">
153 <xsl:variable name="targets" select="key('id',@linkend)"/>
154 <xsl:variable name="target" select="$targets[1]"/>
156 <xsl:if test="count($targets)=0">
158 <xsl:text>Error: no ID for productionrecap linkend: </xsl:text>
159 <xsl:value-of select="@linkend"/>
160 <xsl:text>.</xsl:text>
164 <xsl:if test="count($targets)>1">
166 <xsl:text>Warning: multiple "IDs" for productionrecap linkend: </xsl:text>
167 <xsl:value-of select="@linkend"/>
168 <xsl:text>.</xsl:text>
172 <xsl:apply-templates select="$target">
173 <xsl:with-param name="recap" select="true()"/>
174 </xsl:apply-templates>
177 <xsl:template match="lhs">
178 <xsl:apply-templates/>
181 <xsl:template match="rhs">
182 <xsl:apply-templates/>
183 <xsl:if test="following-sibling::rhs">
184 <xsl:text> |</xsl:text>
189 <xsl:template match="nonterminal">
190 <xsl:variable name="linkend">
191 <xsl:call-template name="xpointer.idref">
192 <xsl:with-param name="xpointer" select="@def"/>
196 <xsl:call-template name="check.id.unique">
197 <xsl:with-param name="linkend" select="$linkend"/>
200 <xsl:call-template name="check.idref.targets">
201 <xsl:with-param name="linkend" select="$linkend"/>
202 <xsl:with-param name="element-list">production</xsl:with-param>
205 <!-- If you don't provide content, you can't point outside this doc. -->
207 <xsl:when test="*|text()"><!--nop--></xsl:when>
209 <xsl:if test="$linkend = ''">
211 <xsl:text>Non-terminals with no content must point to </xsl:text>
212 <xsl:text>production elements in the current document.</xsl:text>
215 <xsl:text>Invalid xpointer for empty nt: </xsl:text>
216 <xsl:value-of select="@def"/>
222 <xsl:variable name="href">
224 <xsl:when test="$linkend != ''">
225 <xsl:variable name="targets" select="key('id',$linkend)"/>
226 <xsl:variable name="target" select="$targets[1]"/>
227 <xsl:call-template name="href.target">
228 <xsl:with-param name="object" select="$target"/>
232 <xsl:value-of select="@def"/>
239 <xsl:when test="*|text()">
240 <xsl:apply-templates/>
244 <xsl:when test="$linkend != ''">
245 <xsl:variable name="targets" select="key('id',$linkend)"/>
246 <xsl:variable name="target" select="$targets[1]"/>
247 <xsl:apply-templates select="$target/lhs"/>
250 <xsl:text>???</xsl:text>
258 <xsl:template match="rhs/lineannotation">
262 <xsl:template match="rhs/lineannotation" mode="rhslo">
263 <xsl:text>/* </xsl:text>
264 <xsl:apply-templates/>
265 <xsl:text> */</xsl:text>
269 <xsl:template match="constraint">
270 <xsl:call-template name="check.id.unique">
271 <xsl:with-param name="linkend" select="@linkend"/>
274 <xsl:call-template name="check.idref.targets">
275 <xsl:with-param name="linkend" select="@linkend"/>
276 <xsl:with-param name="element-list">constraintdef</xsl:with-param>
279 <xsl:variable name="href">
280 <xsl:variable name="targets" select="key('id',@linkend)"/>
281 <xsl:variable name="target" select="$targets[1]"/>
282 <xsl:call-template name="href.target">
283 <xsl:with-param name="object" select="$target"/>
287 <xsl:text>[ </xsl:text>
290 <xsl:when test="@role">
291 <xsl:value-of select="@role"/>
292 <xsl:text>: </xsl:text>
295 <xsl:variable name="targets" select="key('id',@linkend)"/>
296 <xsl:variable name="target" select="$targets[1]"/>
297 <xsl:if test="$target/@role">
298 <xsl:value-of select="$target/@role"/>
299 <xsl:text>: </xsl:text>
305 <xsl:variable name="targets" select="key('id',@linkend)"/>
306 <xsl:variable name="target" select="$targets[1]"/>
307 <xsl:apply-templates select="$target" mode="title.markup"/>
309 <xsl:text> ]</xsl:text>
310 <xsl:if test="following-sibling::constraint">
315 <xsl:template match="constraintdef">
317 <xsl:apply-templates select="." mode="class.attribute"/>
318 <xsl:call-template name="anchor"/>
319 <xsl:apply-templates/>
323 <xsl:template match="constraintdef/title">
324 <p><b><xsl:apply-templates/></b></p>
327 <!-- ==================================================================== -->