summaryrefslogtreecommitdiff
path: root/sandbox/paultremblay/python_interface/docutilsToFo/valid/main.rng
blob: a1db914e1a6151efb3d13f2e9c00b0dca6c14ec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<?xml version="1.0" encoding="UTF-8"?>
<!--
  =========================================================
                                                           
  (c) 2004, RenderX                                        
                                                           
  Author: Alexander Peshkov <peshkov@renderx.com>          
                                                           
  Permission is granted to use this document, copy and     
  modify free of charge, provided that every derived work  
  bear a reference to the present document.                
                                                           
  This document contains a computer program written in     
  XSL Transformations Language. It is published with no    
  warranty of any kind about its usability, as a mere      
  example of XSL technology. RenderX shall not be          
  considered liable for any damage or loss of data caused  
  by use of this program.                                  
                                                           
  =========================================================
-->
<grammar xmlns:rx="http://www.renderx.com/XSL/Extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns="http://relaxng.org/ns/structure/1.0">
  <include href="elements.rng"/>
  <start>
    <ref name="root"/>
  </start>
  <!--
    ****************************************************************************************
    Element structure for top-level elements
    ****************************************************************************************
    ===============================================================
    Root element. Contains everything, generates nothing. It has an
    id, a FO namespace prefix declaration, and other namespace
    declarations if used.
    ===============================================================
  -->
  <define name="root">
    <element name="fo:root">
      <ref name="root.attlist"/>
      <ref name="root.content"/>
    </element>
  </define>
  <define name="root.content">
    <optional>
      <ref name="meta-info"/>
    </optional>
    <ref name="layout-master-set"/>
    <optional>
      <ref name="declarations"/>
    </optional>
    <optional>
      <ref name="outline"/>
    </optional>
    <oneOrMore>
      <ref name="page-sequence"/>
    </oneOrMore>
  </define>
  <!--
    ===============================================================
    Document meta information - RenderX extension
    ===============================================================
  -->
  <define name="meta-info">
    <element name="rx:meta-info">
      <ref name="meta-info.attlist"/>
      <ref name="meta-info.content"/>
    </element>
  </define>
  <define name="meta-info.content">
    <oneOrMore>
      <ref name="meta-field"/>
    </oneOrMore>
  </define>
  <define name="meta-field">
    <element name="rx:meta-field">
      <ref name="meta-field.attlist"/>
      <empty/>
    </element>
  </define>
  <!--
    ===============================================================
    Color profile declarations
    ===============================================================
  -->
  <define name="declarations">
    <element name="fo:declarations">
      <ref name="declarations.attlist"/>
      <ref name="declarations.content"/>
    </element>
  </define>
  <define name="declarations.content">
    <oneOrMore>
      <ref name="color-profile"/>
    </oneOrMore>
  </define>
  <define name="color-profile">
    <element name="fo:color-profile">
      <ref name="color-profile.attlist"/>
      <empty/>
    </element>
  </define>
  <!--
    ===============================================================
    Bookmarks - RenderX extension
    ===============================================================
  -->
  <define name="outline">
    <element name="rx:outline">
      <ref name="outline.attlist"/>
      <ref name="outline.content"/>
    </element>
  </define>
  <define name="outline.content">
    <oneOrMore>
      <ref name="bookmark"/>
    </oneOrMore>
  </define>
  <define name="bookmark">
    <element name="rx:bookmark">
      <ref name="bookmark.attlist"/>
      <ref name="bookmark.content"/>
    </element>
  </define>
  <define name="bookmark.content">
    <ref name="bookmark-label"/>
    <zeroOrMore>
      <ref name="bookmark"/>
    </zeroOrMore>
  </define>
  <define name="bookmark-label">
    <element name="rx:bookmark-label">
      <ref name="bookmark-label.attlist"/>
      <ref name="bookmark-label.content"/>
    </element>
  </define>
  <define name="bookmark-label.content">
    <text/>
  </define>
  <!--
    ===============================================================
    Layout-master-set. Contains a set of page-masters.
    Content model made more strict than in the spec, to enforce
    that a page-sequence-master be always accompanied by at least
    one simple-page-master.
    ===============================================================
  -->
  <define name="layout-master-set">
    <element name="fo:layout-master-set">
      <ref name="layout-master-set.attlist"/>
      <ref name="layout-master-set.content"/>
    </element>
  </define>
  <define name="layout-master-set.content">
    <interleave>
      <zeroOrMore>
        <ref name="page-sequence-master"/>
      </zeroOrMore>
      <oneOrMore>
        <ref name="simple-page-master"/>
      </oneOrMore>
    </interleave>
  </define>
  <!--
    ===============================================================
    Page sequence master
    ===============================================================
  -->
  <define name="page-sequence-master">
    <element name="fo:page-sequence-master">
      <ref name="page-sequence-master.attlist"/>
      <ref name="page-sequence-master.content"/>
    </element>
  </define>
  <define name="page-sequence-master.content">
    <oneOrMore>
      <choice>
        <ref name="single-page-master-reference"/>
        <ref name="repeatable-page-master-reference"/>
        <ref name="repeatable-page-master-alternatives"/>
      </choice>
    </oneOrMore>
  </define>
  <!--
    ===============================================================
    Sequence specifiers are predefined sequences of page masters
    that are used by page sequence master to construct a desired
    page collection.
    ===============================================================
  -->
  <define name="single-page-master-reference">
    <element name="fo:single-page-master-reference">
      <ref name="single-page-master-reference.attlist"/>
      <empty/>
    </element>
  </define>
  <define name="repeatable-page-master-reference">
    <element name="fo:repeatable-page-master-reference">
      <ref name="repeatable-page-master-reference.attlist"/>
      <empty/>
    </element>
  </define>
  <define name="repeatable-page-master-alternatives">
    <element name="fo:repeatable-page-master-alternatives">
      <ref name="repeatable-page-master-alternatives.attlist"/>
      <ref name="repeatable-page-master-alternatives.content"/>
    </element>
  </define>
  <define name="repeatable-page-master-alternatives.content">
    <oneOrMore>
      <ref name="conditional-page-master-reference"/>
    </oneOrMore>
  </define>
  <define name="conditional-page-master-reference">
    <element name="fo:conditional-page-master-reference">
      <ref name="conditional-page-master-reference.attlist"/>
      <empty/>
    </element>
  </define>
  <!--
    ===============================================================
    Simple page master defines a page layout. It does not
    explicitly generate any content.
    ===============================================================
  -->
  <define name="simple-page-master">
    <element name="fo:simple-page-master">
      <ref name="simple-page-master.attlist"/>
      <ref name="simple-page-master.content"/>
    </element>
  </define>
  <define name="simple-page-master.content">
    <ref name="region-body"/>
    <optional>
      <ref name="region-before"/>
    </optional>
    <optional>
      <ref name="region-after"/>
    </optional>
    <optional>
      <ref name="region-start"/>
    </optional>
    <optional>
      <ref name="region-end"/>
    </optional>
  </define>
  <!--
    ===============================================================
    Regions. The page instance is divided into subareas, whose
    properties are described by the five region-* elements. These
    elements by themselves do not generate any content.
    ===============================================================
  -->
  <!--
    ===============================================================
    Body region: middle of the page.
    ===============================================================
  -->
  <define name="region-body">
    <element name="fo:region-body">
      <ref name="region-body.attlist"/>
      <empty/>
    </element>
  </define>
  <!--
    ===============================================================
    Side regions: page edges.
    ===============================================================
  -->
  <define name="region-before">
    <element name="fo:region-before">
      <ref name="region-before.attlist"/>
      <empty/>
    </element>
  </define>
  <define name="region-after">
    <element name="fo:region-after">
      <ref name="region-after.attlist"/>
      <empty/>
    </element>
  </define>
  <define name="region-start">
    <element name="fo:region-start">
      <ref name="region-start.attlist"/>
      <empty/>
    </element>
  </define>
  <define name="region-end">
    <element name="fo:region-end">
      <ref name="region-end.attlist"/>
      <empty/>
    </element>
  </define>
  <!--
    ===============================================================
    Page sequence defines the order of choosing page masters to
    accomodate all the contents generated by its fo:flow and
    fo:static-content children, and the way of numbering them.
    ===============================================================
  -->
  <define name="page-sequence">
    <element name="fo:page-sequence">
      <ref name="page-sequence.attlist"/>
      <ref name="page-sequence.content"/>
    </element>
  </define>
  <define name="page-sequence.content">
    <optional>
      <ref name="title"/>
    </optional>
    <zeroOrMore>
      <ref name="static-content"/>
    </zeroOrMore>
    <ref name="flow"/>
  </define>
  <!--
    ===============================================================
    Title. May not contain out-of-lines.
    ===============================================================
    MEMO: Spec states:
    XSL> Additionally, an fo:title is not permitted to have as a descendant an fo:block-container
    XSL> that generates an absolutely positioned area.
    We prohibit block-level descendants except for those descendats of fo:inline-container.
    This content model shared by fo:leader and fo:inline child of an fo:footnote.
  -->
  <define name="title">
    <element name="fo:title">
      <ref name="title.attlist"/>
      <ref name="title.content"/>
    </element>
  </define>
  <define name="title.content">
    <zeroOrMore>
      <ref name="inlines-inline"/>
    </zeroOrMore>
  </define>
  <!--
    ===============================================================
    Flows. They are just sequences of blocks. 'flow-name' feature
    defines linkage of the flow to a region in the page master.
    ===============================================================
    ===============================================================
    An extension element, rx:flow-section, has been added in order
    to overcome limitations on multicolumn layout imposed by XSL FO
    ===============================================================
    NOTE: We use tricks with nested grammar in order control marker/retrieve-marker 
    and outlines  appearance inside fo:static-content and fo:flow
    MEMO: We forcedly prohibit side-floats as descendants of ablsoutely positioned
    block-containers. This problem appears due to the 'half-outline' behavior of
    an absolute-container - it cannot contain outlines except for side-float and it cannot
    be nested into any other outlines.
    NOTE: 'Folint' prohibits use of side-floats in static-content that is against the spec.
  -->
  <define name="static-content">
    <element name="fo:static-content">
      <ref name="static-content.attlist"/>
      <ref name="static-content.content"/>
    </element>
  </define>
  <define name="static-content.content">
    <grammar>
      <start>
        <oneOrMore>
          <ref name="blocks"/>
        </oneOrMore>
      </start>
      <include href="elements.rng">
        <define name="retrieve-marker">
          <ref name="retrieve-marker-real"/>
        </define>
        <define name="absolute-container">
          <ref name="absolute-container-real"/>
        </define>
        <define name="absolute-container.content">
          <parentRef name="absolute-container.content"/>
        </define>
        <define name="side-float">
          <ref name="side-float-real"/>
        </define>
        <define name="float.content">
          <parentRef name="float.content"/>
        </define>
        <define name="leader.content">
          <parentRef name="leader.content"/>
        </define>
      </include>
    </grammar>
  </define>
  <define name="flow">
    <element name="fo:flow">
      <ref name="flow.attlist"/>
      <ref name="flow.content"/>
    </element>
  </define>
  <define name="flow.content">
    <grammar>
      <start>
        <zeroOrMore>
          <ref name="marker"/>
        </zeroOrMore>
        <oneOrMore>
          <choice>
            <ref name="blocks"/>
            <ref name="flow-section"/>
          </choice>
        </oneOrMore>
      </start>
      <include href="elements.rng">
        <define name="absolute-container">
          <ref name="absolute-container-real"/>
        </define>
        <!--
          MEMO: We have two options here:
          * use parent content model which is too strict (side-floats descendants not allowed);
          * use current content model which is too loose (all outline descendants are allowed).
          We prefer stricter mode.
        -->
        <define name="absolute-container.content">
          <parentRef name="absolute-container.content"/>
        </define>
        <define name="marker">
          <ref name="marker-real"/>
        </define>
        <define name="marker.content">
          <parentRef name="marker.content"/>
        </define>
        <define name="side-float">
          <ref name="side-float-real"/>
        </define>
        <define name="before-float">
          <ref name="before-float-real"/>
        </define>
        <define name="float.content">
          <parentRef name="float.content"/>
        </define>
        <define name="footnote">
          <ref name="footnote-real"/>
        </define>
        <define name="footnote.content">
          <parentRef name="footnote.content"/>
        </define>
        <!-- NOTE: fo:leader can't have outlines and marker descendants -->
        <define name="leader.content">
          <parentRef name="leader.content"/>
        </define>
      </include>
      <!-- Extension element. Acts like a top-level block with multiple columns. -->
      <define name="flow-section">
        <element name="rx:flow-section">
          <ref name="flow-section.attlist"/>
          <ref name="flow-section.content"/>
        </element>
      </define>
      <define name="flow-section.content">
        <oneOrMore>
          <ref name="blocks"/>
        </oneOrMore>
      </define>
    </grammar>
  </define>
</grammar>
<!--
  MEMO: Spec prohibits use of fo:leader as a descendant of itself.
  We find this constraint somewhat abusive so we do not enforce it.
  'Folint' also does not controll this constraint
  However following trick can be used to prevent fo:leader to appear as it's own child.
  (to make it work we have to set leader.content to be notAllowed and move
  actual content into leader.content-real in elements.rnc)
  leader.content |= grammar {
  start = leader.content-real
   include "elements.rnc" {
     leader = notAllowed 
   }
  }
-->