Project

General

Profile

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 8178 2008-12-15 22:26:38Z 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 8178 2008-12-15 22:26:38Z 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">
69
        <xsl:text> for </xsl:text>
70
        <xsl:value-of select="title"/>
71
      </xsl:if>
72
    </xsl:attribute>
73

    
74
    <xsl:if test="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"/>
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:number count="production" level="any"/>
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="anchor"/>
127
          <xsl:apply-templates select="lhs"/>
128
        </xsl:otherwise>
129
      </xsl:choose>
130
    </td>
131
    <td valign="top" width="5%" align="center">
132
      <xsl:copy-of select="$ebnf.assignment"/>
133
    </td>
134
    <td valign="top" width="52%">
135
      <xsl:apply-templates select="rhs"/>
136
      <xsl:copy-of select="$ebnf.statement.terminator"/>
137
    </td>
138
    <td align="{$direction.align.start}" valign="top" width="30%">
139
      <xsl:choose>
140
        <xsl:when test="rhs/lineannotation|constraint">
141
          <xsl:apply-templates select="rhs/lineannotation" mode="rhslo"/>
142
          <xsl:apply-templates select="constraint"/>
143
        </xsl:when>
144
        <xsl:otherwise>
145
          <xsl:text>&#160;</xsl:text>
146
        </xsl:otherwise>
147
      </xsl:choose>
148
    </td>
149
  </tr>
150
</xsl:template>
151

    
152
<xsl:template match="productionrecap">
153
  <xsl:variable name="targets" select="key('id',@linkend)"/>
154
  <xsl:variable name="target" select="$targets[1]"/>
155

    
156
  <xsl:if test="count($targets)=0">
157
    <xsl:message>
158
      <xsl:text>Error: no ID for productionrecap linkend: </xsl:text>
159
      <xsl:value-of select="@linkend"/>
160
      <xsl:text>.</xsl:text>
161
    </xsl:message>
162
  </xsl:if>
163

    
164
  <xsl:if test="count($targets)>1">
165
    <xsl:message>
166
      <xsl:text>Warning: multiple "IDs" for productionrecap linkend: </xsl:text>
167
      <xsl:value-of select="@linkend"/>
168
      <xsl:text>.</xsl:text>
169
    </xsl:message>
170
  </xsl:if>
171

    
172
  <xsl:apply-templates select="$target">
173
    <xsl:with-param name="recap" select="true()"/>
174
  </xsl:apply-templates>
175
</xsl:template>
176

    
177
<xsl:template match="lhs">
178
  <xsl:apply-templates/>
179
</xsl:template>
180

    
181
<xsl:template match="rhs">
182
  <xsl:apply-templates/>
183
  <xsl:if test="following-sibling::rhs">
184
    <xsl:text> |</xsl:text>
185
    <br/>
186
  </xsl:if>
187
</xsl:template>
188

    
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"/>
193
    </xsl:call-template>
194
  </xsl:variable>
195

    
196
  <xsl:call-template name="check.id.unique">
197
    <xsl:with-param name="linkend" select="$linkend"/>
198
  </xsl:call-template>
199

    
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>
203
  </xsl:call-template>
204

    
205
  <!-- If you don't provide content, you can't point outside this doc. -->
206
  <xsl:choose>
207
    <xsl:when test="*|text()"><!--nop--></xsl:when>
208
    <xsl:otherwise>
209
      <xsl:if test="$linkend = ''">
210
        <xsl:message>
211
          <xsl:text>Non-terminals with no content must point to </xsl:text>
212
          <xsl:text>production elements in the current document.</xsl:text>
213
        </xsl:message>
214
        <xsl:message>
215
          <xsl:text>Invalid xpointer for empty nt: </xsl:text>
216
          <xsl:value-of select="@def"/>
217
        </xsl:message>
218
      </xsl:if>
219
    </xsl:otherwise>
220
  </xsl:choose>
221

    
222
  <xsl:variable name="href">
223
    <xsl:choose>
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"/>
229
        </xsl:call-template>
230
      </xsl:when>
231
      <xsl:otherwise>
232
        <xsl:value-of select="@def"/>
233
      </xsl:otherwise>
234
    </xsl:choose>
235
  </xsl:variable>
236

    
237
  <a href="{$href}">
238
    <xsl:choose>
239
      <xsl:when test="*|text()">
240
        <xsl:apply-templates/>
241
      </xsl:when>
242
      <xsl:otherwise>
243
        <xsl:choose>
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"/>
248
          </xsl:when>
249
          <xsl:otherwise>
250
            <xsl:text>???</xsl:text>
251
          </xsl:otherwise>
252
        </xsl:choose>
253
      </xsl:otherwise>
254
    </xsl:choose>
255
  </a>
256
</xsl:template>
257

    
258
<xsl:template match="rhs/lineannotation">
259
  <!--nop-->
260
</xsl:template>
261

    
262
<xsl:template match="rhs/lineannotation" mode="rhslo">
263
  <xsl:text>/*&#160;</xsl:text>
264
  <xsl:apply-templates/>
265
  <xsl:text>&#160;*/</xsl:text>
266
  <br/>
267
</xsl:template>
268

    
269
<xsl:template match="constraint">
270
  <xsl:call-template name="check.id.unique">
271
    <xsl:with-param name="linkend" select="@linkend"/>
272
  </xsl:call-template>
273

    
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>
277
  </xsl:call-template>
278

    
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"/>
284
    </xsl:call-template>
285
  </xsl:variable>
286

    
287
  <xsl:text>[&#160;</xsl:text>
288

    
289
  <xsl:choose>
290
    <xsl:when test="@role">
291
      <xsl:value-of select="@role"/>
292
      <xsl:text>: </xsl:text>
293
    </xsl:when>
294
    <xsl:otherwise>
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>
300
      </xsl:if>
301
    </xsl:otherwise>
302
  </xsl:choose>
303

    
304
  <a href="{$href}">
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"/>
308
  </a>
309
  <xsl:text>&#160;]</xsl:text>
310
  <xsl:if test="following-sibling::constraint">
311
    <br/>
312
  </xsl:if>
313
</xsl:template>
314

    
315
<xsl:template match="constraintdef">
316
  <div>
317
    <xsl:apply-templates select="." mode="class.attribute"/>
318
    <xsl:call-template name="anchor"/>
319
    <xsl:apply-templates/>
320
  </div>
321
</xsl:template>
322

    
323
<xsl:template match="constraintdef/title">
324
  <p><b><xsl:apply-templates/></b></p>
325
</xsl:template>
326

    
327
<!-- ==================================================================== -->
328

    
329
</xsl:stylesheet>
(13-13/39)