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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
|
<?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="properties.rng"/>
<!--
****************************************************************************************
Common content models used by content-bearing elements
****************************************************************************************
-->
<define name="very-basic-inlines">
<choice>
<ref name="character"/>
<ref name="external-graphic"/>
<ref name="instream-foreign-object"/>
<ref name="inline-container"/>
<ref name="leader"/>
<ref name="page-number"/>
<ref name="page-number-citation"/>
<ref name="multi-toggle"/>
<!-- MEMO: To be strict, we have to control that this element is a descendant of an fo:multi-case. -->
<ref name="page-index"/>
<ref name="begin-index-range"/>
<ref name="end-index-range"/>
</choice>
</define>
<!-- NOTE: An absolute-container can be treated both as block and as outline. -->
<define name="basic-blocks">
<choice>
<ref name="block"/>
<ref name="block-container"/>
<ref name="table-and-caption"/>
<ref name="table"/>
<ref name="list-block"/>
</choice>
</define>
<!-- NOTE: Unlike other out-of-lines fo:footnote can be used only in the context where inlines are permitted -->
<define name="out-of-lines-block">
<choice>
<ref name="before-float"/>
<ref name="side-float"/>
<ref name="absolute-container"/>
</choice>
</define>
<define name="out-of-lines">
<choice>
<ref name="footnote"/>
<ref name="out-of-lines-block"/>
</choice>
</define>
<!--
As a compromise for intricated inline content model prescribed by XSL FO spec
we define two types of inline content:
first as restrictive as required by spec for descendants of an fo:leader or of an fo:inline
child of an fo:footnote (and for some other cases where we believe it is reasonable),
it permits inline level elements only, except for descendants of fo:inline-container;
second as loose as prescribed by spec for the general cases
-->
<define name="basic-inlines-inline">
<choice>
<ref name="very-basic-inlines"/>
<ref name="basic-link-inline"/>
<ref name="inline-inline"/>
<ref name="bidi-override-inline"/>
</choice>
</define>
<define name="basic-inlines">
<choice>
<ref name="very-basic-inlines"/>
<ref name="basic-link"/>
<ref name="inline"/>
<ref name="bidi-override"/>
</choice>
</define>
<!--
We have three content models for wrappers:
first one allows inline content only (based on basic-inlines-inline described above);
second one requires block-level elements to be at the top of it;
third one is for mixed content (general case);
-->
<define name="wrappers-inline">
<choice>
<ref name="multi-switch-inline"/>
<ref name="multi-properties-inline"/>
<ref name="wrapper-inline"/>
<ref name="retrieve-marker"/>
</choice>
</define>
<define name="wrappers-block">
<choice>
<ref name="multi-switch-block"/>
<ref name="multi-properties-block"/>
<ref name="wrapper-block"/>
<ref name="retrieve-marker"/>
</choice>
</define>
<define name="wrappers">
<choice>
<ref name="multi-switch"/>
<ref name="multi-properties"/>
<ref name="wrapper"/>
<ref name="retrieve-marker"/>
</choice>
</define>
<!--
We have two extended content models for inlines:
first one is stricter, with inline elements only (exception for fo:inline-container descendants)
and with no outlines (actually they are bared in main.rnc anyway);
second one is loose, with all possible inlines and outlines.
In general those content models corresponds very well with two possible contexts:
block context and inline context
-->
<define name="inlines-inline">
<choice>
<text/>
<ref name="basic-inlines-inline"/>
<ref name="wrappers-inline"/>
</choice>
</define>
<define name="inlines">
<choice>
<text/>
<ref name="basic-inlines"/>
<ref name="out-of-lines"/>
<ref name="wrappers"/>
</choice>
</define>
<!-- Content model for blocks including block-level outlines -->
<define name="blocks">
<choice>
<ref name="basic-blocks"/>
<ref name="wrappers-block"/>
<ref name="out-of-lines-block"/>
</choice>
</define>
<!-- Mixed content model - broadest one -->
<define name="mix">
<choice>
<ref name="inlines"/>
<ref name="basic-blocks"/>
</choice>
</define>
<!--
****************************************************************************************
Element structure for content-bearing elements
****************************************************************************************
===============================================================
Block is the base element for all content areas.
===============================================================
-->
<define name="block">
<element name="fo:block">
<ref name="block.attlist"/>
<ref name="block.content"/>
</element>
</define>
<define name="block.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<choice>
<ref name="initial-property-set"/>
<ref name="mix"/>
</choice>
</zeroOrMore>
</define>
<!--
===============================================================
Block container
===============================================================
MEMO: We are forced to create separate element 'absolute-container' in order
to satisfy XSL FO spec requirements. Note that this is the *only* place where
properties really interfer with element-level structure (well, actually fo:float is the second place).
A separate fo:absolute-container is clearly necessary.
Absolutely possitioned block-container cannot contain markers and and outlines.
It's behaviour is quite similar to the outline elements such as float.
'Folint' do not control absolutely positioned container restriction
(due to expressions that can result in absolute position)
'Folint' also permits empty block-containers, that is against the spec.
Spec defines fo:block-container content as (%block;)+
-->
<define name="absolute-container">
<notAllowed/>
</define>
<define name="absolute-container-real">
<element name="fo:block-container">
<ref name="absolute-container.attlist"/>
<ref name="absolute-container.content"/>
</element>
</define>
<define name="absolute-container.content">
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<define name="block-container">
<element name="fo:block-container">
<ref name="block-container.attlist"/>
<ref name="block-container.content"/>
</element>
</define>
<define name="block-container.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
****************************************************************************************
Inline elements
****************************************************************************************
===============================================================
Unicode bidi-override
===============================================================
MEMO: According to spec this element CAN have block level children except for the cases listed below:
XSL> An fo:bidi-override that is a descendant of an fo:leader or of an fo:inline child
XSL> of an fo:footnote may not have block-level children, unless it has a nearer ancestor
XSL> that is an fo:inline-container.
NOTE: This is contradictory to the description of fo:leader element (6.6.9. fo:leader) that
prohibits (some) block-level elements/outlines to be fo:leader descendants
no matter if they wrapped in any fo:inline-containers and fo:bidi-override.
We have two models:
first (restrictive) used by descendants of an fo:title, fo:leader or of an fo:inline child of an fo:footnote;
second (loose) as prescribed by spec for the general cases
'Folint' believes that no block level elements should be allowed in this element in either way.
-->
<define name="bidi-override-inline">
<element name="fo:bidi-override">
<ref name="bidi-override.attlist"/>
<ref name="bidi-override-inline.content"/>
</element>
</define>
<define name="bidi-override-inline.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<define name="bidi-override">
<element name="fo:bidi-override">
<ref name="bidi-override.attlist"/>
<ref name="bidi-override.content"/>
</element>
</define>
<define name="bidi-override.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
===============================================================
Single character
===============================================================
-->
<define name="character">
<element name="fo:character">
<ref name="character.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
Initial property set specifies properties for one or more lines
===============================================================
-->
<define name="initial-property-set">
<element name="fo:initial-property-set">
<ref name="initial-property-set.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
External graphic
===============================================================
-->
<define name="external-graphic">
<element name="fo:external-graphic">
<ref name="external-graphic.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
In-stream graphic
===============================================================
-->
<define name="instream-foreign-object">
<element name="fo:instream-foreign-object">
<ref name="instream-foreign-object.attlist"/>
<ref name="any"/>
</element>
</define>
<!--
===============================================================
Inline
===============================================================
MEMO: This element used by content model that consists of inlines only
with exception for descendants of inline-container
-->
<define name="inline-inline">
<element name="fo:inline">
<ref name="inline.attlist"/>
<ref name="inline-inline.content"/>
</element>
</define>
<define name="inline-inline.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<define name="inline">
<element name="fo:inline">
<ref name="inline.attlist"/>
<ref name="inline.content"/>
</element>
</define>
<define name="inline.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
XSL> An fo:inline that is a child of an fo:footnote may not have block-level children.
XSL> An fo:inline that is a descendant of an fo:leader or of the fo:inline child of
XSL> an fo:footnote may not have block-level children, unless it has a nearer
XSL> ancestor that is an fo:inline-container.
NOTE: This definition is contradictory to the one of the fo:leader since latter prohibits
fo:inline-container as a descendant. But it's the definition of fo:leader that should be fixed
since content model described above is the only sane content model in the inline context.
It should be the same for fo:bidi-override. However definition must be adjasted
in order to mention fo:title since this element is a typical inline.
'Folint' believes that block elements are allowed here and thoroughly tests for
all those tricky exceptions. This behavior seems to be quite inconsisten with the
one regarding fo:bidi-override treatment.
-->
<!--
===============================================================
Inline container
===============================================================
-->
<define name="inline-container">
<element name="fo:inline-container">
<ref name="inline-container.attlist"/>
<ref name="inline-container.content"/>
</element>
</define>
<define name="inline-container.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="blocks"/>
</zeroOrMore>
</define>
<!--
===============================================================
Leader
===============================================================
-->
<define name="leader">
<element name="fo:leader">
<ref name="leader.attlist"/>
<ref name="leader.content"/>
</element>
</define>
<define name="leader.content">
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<!--
MEMO: Following two lines used together with tricky redefinition in main.rnc
in order to prevent fo:leader nesting.
leader.content = notAllowed
leader.content-real = inlines-inline*
-->
<!--
MEMO: We use inline content model here which is consistent with
such elements as fo:inline child of fo:footnote. It allows blocks/outlines, but only as a
descendant of inline-container. XSL FO spec is quite uneven at this point (and should be fixed).
According to spec, this element can contain inline level elements and text, but
XSL> The content must not contain an fo:leader, fo:inline-container, fo:block-container,
XSL> fo:float, fo:footnote, or fo:marker either as a direct child or as a descendant.
NOTE: XSL FO spec DO NOT prohibit blocks or tables as descendants of fo:leader!
NOTE: fo:leader constraints are contradictory to those of fo:inline since section "6.6.7. fo:inline"
states implicitly that there could be an fo:inline-container that is a descendent of fo:leader.
'Folint' respects these constraints partially: it prohibits fo:block-container as a descendant,
but permits fo:marker, fo:leader, fo:inline-container, fo:float, fo:footnote.
It also prohibits use of fo:block as descendant.
-->
<!--
===============================================================
Page Number
===============================================================
-->
<define name="page-number">
<element name="fo:page-number">
<ref name="page-number.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
Page number citation
===============================================================
-->
<define name="page-number-citation">
<element name="fo:page-number-citation">
<ref name="page-number-citation.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
Atomic elements for index ranges markup
===============================================================
-->
<define name="begin-index-range">
<element name="rx:begin-index-range">
<ref name="begin-index-range.attlist"/>
<empty/>
</element>
</define>
<define name="end-index-range">
<element name="rx:end-index-range">
<ref name="end-index-range.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
Page number list - index entry
===============================================================
-->
<define name="page-index">
<element name="rx:page-index">
<ref name="page-index.attlist"/>
<ref name="page-index.content"/>
</element>
</define>
<!--
MEMO: Currently page-index must contain at least one rx:index-item element,
empty content is allowed for backward compatibility.
-->
<define name="page-index.content">
<zeroOrMore>
<ref name="index-item"/>
</zeroOrMore>
</define>
<define name="index-item">
<element name="rx:index-item">
<ref name="index-item.attlist"/>
<empty/>
</element>
</define>
<!--
****************************************************************************************
Formatting objects for tables.
****************************************************************************************
-->
<!--
===============================================================
Table & Caption is a wrapper to all the stuff pertinent to a
given table. It generates a block consisting of two subblocks:
one for the caption, another one for the table itself. The
placement of these two blocks is controlled by the
'caption-side' property: if caption-side="before"|"after" (or
their absolute orientation equivalents), the two blocks are
drawn one after another; if it is "start"|"end", then the
caption is displayed on the correspondent side of the table.
In this case, the relative alignment of the two blocks is given
by the 'relative-align'/'display-align' property.
===============================================================
-->
<define name="table-and-caption">
<element name="fo:table-and-caption">
<ref name="table-and-caption.attlist"/>
<ref name="table-and-caption.content"/>
</element>
</define>
<define name="table-and-caption.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<optional>
<ref name="table-caption"/>
</optional>
<ref name="table"/>
</define>
<!--
===============================================================
Table caption is an area container.
===============================================================
-->
<define name="table-caption">
<element name="fo:table-caption">
<ref name="table-caption.attlist"/>
<ref name="table-caption.content"/>
</element>
</define>
<define name="table-caption.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
===============================================================
fo:table is the basic element for all tables. All the contents
placed inside it is distributed over a single rectangular grid
of rows and columns.
===============================================================
-->
<define name="table">
<element name="fo:table">
<ref name="table.attlist"/>
<ref name="table.content"/>
</element>
</define>
<define name="table.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="table-column"/>
</zeroOrMore>
<optional>
<ref name="table-header"/>
</optional>
<optional>
<ref name="table-footer"/>
</optional>
<oneOrMore>
<ref name="table-body"/>
</oneOrMore>
</define>
<!--
===============================================================
Table column specifies common properties to ascribe to all
cells in a column *or a group of columns*. Note that, if both
'number-columns-repeated' and 'number-columns-spanned' exceed
1, the column counter is increased by 'number-columns-spanned'.
it means that you only set properties for columns:
'column-number'
'column-number' + 'number-columns-spanned'
'column-number' + 2 * 'number-columns-spanned'
and so on, leaving default properties for intermediate columns.
===============================================================
-->
<define name="table-column">
<element name="fo:table-column">
<ref name="table-column.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
Table header, table footer, and table body are wrappers for
groups of rows. They contain either one or more fo:table-rows,
or one or more fo:table-cells; in the latter case, row breaks
are specified in the cells by 'starts-row'/'ends-row'.
All these elements are identical both in the content structure
and in the attributes.
===============================================================
-->
<define name="row-group">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<choice>
<oneOrMore>
<ref name="table-row"/>
</oneOrMore>
<oneOrMore>
<ref name="table-cell"/>
</oneOrMore>
</choice>
</define>
<define name="table-header">
<element name="fo:table-header">
<ref name="table-header.attlist"/>
<ref name="table-header.content"/>
</element>
</define>
<define name="table-header.content">
<ref name="row-group"/>
</define>
<define name="table-footer">
<element name="fo:table-footer">
<ref name="table-footer.attlist"/>
<ref name="table-footer.content"/>
</element>
</define>
<define name="table-footer.content">
<ref name="row-group"/>
</define>
<define name="table-body">
<element name="fo:table-body">
<ref name="table-body.attlist"/>
<ref name="table-body.content"/>
</element>
</define>
<define name="table-body.content">
<ref name="row-group"/>
</define>
<!--
===============================================================
Table row.
===============================================================
-->
<define name="table-row">
<element name="fo:table-row">
<ref name="table-row.attlist"/>
<ref name="table-row.content"/>
</element>
</define>
<define name="table-row.content">
<oneOrMore>
<ref name="table-cell"/>
</oneOrMore>
</define>
<!--
MEMO: We are more strict here, so this note is about 'Folint':
'Folint' permits empty fo:table-row, that is against the spec.
XSL FO spec defines fo:table-row content as (table-cell+)
-->
<!--
===============================================================
Table cell.
===============================================================
-->
<define name="table-cell">
<element name="fo:table-cell">
<ref name="table-cell.attlist"/>
<ref name="table-cell.content"/>
</element>
</define>
<define name="table-cell.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
MEMO: We are more strict here, so this note is about 'Folint':
'Folint' permits empty table-cells that is against the spec. Spec defines fo:table-cell
content as (%block;)+
Note that 'Folint' is quite consistent regarding this matter - it simillary allows empty
block-containers and table-rows
-->
<!--
****************************************************************************************
Formatting objects for lists.
****************************************************************************************
===============================================================
List block is a block, with some extra features to control the
disposition of list items.
===============================================================
-->
<define name="list-block">
<element name="fo:list-block">
<ref name="list-block.attlist"/>
<ref name="list-block.content"/>
</element>
</define>
<define name="list-block.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="list-item"/>
</oneOrMore>
</define>
<!--
===============================================================
List item is a coupling of item label and item body.
===============================================================
-->
<define name="list-item">
<element name="fo:list-item">
<ref name="list-item.attlist"/>
<ref name="list-item.content"/>
</element>
</define>
<define name="list-item.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<ref name="list-item-label"/>
<ref name="list-item-body"/>
</define>
<!--
===============================================================
List item label and list item body
===============================================================
-->
<define name="list-item-label">
<element name="fo:list-item-label">
<ref name="list-item-label.attlist"/>
<ref name="list-item-label.content"/>
</element>
</define>
<define name="list-item-label.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<define name="list-item-body">
<element name="fo:list-item-body">
<ref name="list-item-body.attlist"/>
<ref name="list-item-body.content"/>
</element>
</define>
<define name="list-item-body.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
MEMO: We are more strict here, so this note is about 'Folint':
'Folint' permits empty fo:list-item-label/body, that is clearly the spec.
Spec defines fo:list-item-label/body content as (%block;)+
-->
<!--
****************************************************************************************
Out-of-lines.
****************************************************************************************
===============================================================
Floats and footnotes resemble containers. Accordingly, we treat
them as block sequences.
===============================================================
MEMO: We do not allows absolutely positioned container as an outline descendant.
'Folint' is loose here - it do not check this condition.
MEMO: We are forced to create two types of floats: side-floats and before-floats
because they have different restrictions (side-floats can appear in static content,
before-floats can't bear 'clear' property)
NOTE: 'Folint' does not allows any floats inside absolutely positioned containers too.
-->
<define name="side-float">
<notAllowed/>
</define>
<define name="side-float-real">
<element name="fo:float">
<ref name="side-float.attlist"/>
<ref name="float.content"/>
</element>
</define>
<define name="before-float">
<notAllowed/>
</define>
<define name="before-float-real">
<element name="fo:float">
<ref name="before-float.attlist"/>
<ref name="float.content"/>
</element>
</define>
<define name="float.content">
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
XSL> It is an error if the fo:footnote occurs as a descendant of a flow that is not assigned
XSL> to a region-body, or of an fo:block-container that generates absolutely positioned areas.
-->
<define name="footnote">
<notAllowed/>
</define>
<define name="footnote-real">
<element name="fo:footnote">
<ref name="footnote.attlist"/>
<ref name="footnote.content"/>
</element>
</define>
<!--
XSL> An fo:inline that is a child of an fo:footnote may not have block-level children.
XSL> An fo:inline that is a descendant of an fo:leader or of the fo:inline child of
XSL> an fo:footnote may not have block-level children, unless it has a nearer
XSL> ancestor that is an fo:inline-container.
We do check here that first inline have no block-level children/descendants unlless
they are wrapped into an inline-container.
'Folint' does the same.
-->
<define name="footnote.content">
<ref name="inline-inline"/>
<ref name="footnote-body"/>
</define>
<define name="footnote-body">
<element name="fo:footnote-body">
<ref name="footnote-body.attlist"/>
<ref name="footnote-body.content"/>
</element>
</define>
<define name="footnote-body.content">
<oneOrMore>
<ref name="blocks"/>
</oneOrMore>
</define>
<!--
===============================================================
Simple link. From the formatting point of view, it's nothing
but a regular inline sequence.
===============================================================
This elment is for separate 'inline' content model
-->
<define name="basic-link-inline">
<element name="fo:basic-link">
<ref name="basic-link.attlist"/>
<ref name="basic-link-inline.content"/>
</element>
</define>
<define name="basic-link-inline.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<define name="basic-link">
<element name="fo:basic-link">
<ref name="basic-link.attlist"/>
<ref name="basic-link.content"/>
</element>
</define>
<define name="basic-link.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
****************************************************************************************
Wrappers and Markers.
****************************************************************************************
===============================================================
Wrapper. This may be useful but it seriously complicates validation of
content models for blocks and inlines.
===============================================================
There are 3 different kind of wrappers for different contexts
-->
<define name="wrapper-inline">
<element name="fo:wrapper">
<ref name="wrapper.attlist"/>
<ref name="wrapper-inline.content"/>
</element>
</define>
<define name="wrapper-inline.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<define name="wrapper-block">
<element name="fo:wrapper">
<ref name="wrapper.attlist"/>
<ref name="wrapper-block.content"/>
</element>
</define>
<define name="wrapper-block.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="blocks"/>
</zeroOrMore>
</define>
<define name="wrapper">
<element name="fo:wrapper">
<ref name="wrapper.attlist"/>
<ref name="wrapper.content"/>
</element>
</define>
<define name="wrapper.content">
<zeroOrMore>
<ref name="marker"/>
</zeroOrMore>
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
===============================================================
Marker.
===============================================================
-->
<define name="marker">
<notAllowed/>
</define>
<define name="marker-real">
<element name="fo:marker">
<ref name="marker.attlist"/>
<ref name="marker.content"/>
</element>
</define>
<define name="marker.content">
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
===============================================================
Marker retrieval.
We are more strict here making retrieve-class-name attribute a mandatory,
but marker with no retrieve-class-name is meaningless.
===============================================================
-->
<define name="retrieve-marker">
<notAllowed/>
</define>
<define name="retrieve-marker-real">
<element name="fo:retrieve-marker">
<ref name="retrieve-marker.attlist"/>
<empty/>
</element>
</define>
<!--
****************************************************************************************
Multistate stuff.
All those elements are practically unused and XSL content model invloved is
intricated. Therefor validation is not absolutely strict here.
****************************************************************************************
===============================================================
Switch. This is a pure logical operator; no formatting may be
conveyed through it.
===============================================================
Thera are 3 different kind of multi-switch (because there are 3 kinds of multi-case)
-->
<define name="multi-switch-inline">
<element name="fo:multi-switch">
<ref name="multi-switch.attlist"/>
<ref name="multi-switch-inline.content"/>
</element>
</define>
<define name="multi-switch-inline.content">
<oneOrMore>
<ref name="multi-case-inline"/>
</oneOrMore>
</define>
<define name="multi-switch-block">
<element name="fo:multi-switch">
<ref name="multi-switch.attlist"/>
<ref name="multi-switch-block.content"/>
</element>
</define>
<define name="multi-switch-block.content">
<oneOrMore>
<ref name="multi-case-block"/>
</oneOrMore>
</define>
<define name="multi-switch">
<element name="fo:multi-switch">
<ref name="multi-switch.attlist"/>
<ref name="multi-switch.content"/>
</element>
</define>
<define name="multi-switch.content">
<oneOrMore>
<ref name="multi-case"/>
</oneOrMore>
</define>
<!--
===============================================================
Single case. Block-level formatting may be conveyed.
===============================================================
Thera are 3 different kind of multi-case (similar to fo:wrapper)
-->
<define name="multi-case-inline">
<element name="fo:multi-case">
<ref name="multi-case.attlist"/>
<ref name="multi-case-inline.content"/>
</element>
</define>
<define name="multi-case-inline.content">
<zeroOrMore>
<ref name="inlines-inline"/>
</zeroOrMore>
</define>
<define name="multi-case-block">
<element name="fo:multi-case">
<ref name="multi-case.attlist"/>
<ref name="multi-case-block.content"/>
</element>
</define>
<define name="multi-case-block.content">
<zeroOrMore>
<ref name="blocks"/>
</zeroOrMore>
</define>
<define name="multi-case">
<element name="fo:multi-case">
<ref name="multi-case.attlist"/>
<ref name="multi-case.content"/>
</element>
</define>
<define name="multi-case.content">
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
===============================================================
Toggle. This is a typical inline.
===============================================================
MEMO: This element is only permitted as a descendant of an fo:multi-case.
-->
<define name="multi-toggle">
<element name="fo:multi-toggle">
<ref name="multi-toggle.attlist"/>
<ref name="multi-toggle.content"/>
</element>
</define>
<define name="multi-toggle.content">
<zeroOrMore>
<ref name="mix"/>
</zeroOrMore>
</define>
<!--
===============================================================
Multi-properties.
===============================================================
Thera are 3 different kind of multi-properties (similar to fo:wrapper)
-->
<define name="multi-properties-inline">
<element name="fo:multi-properties">
<ref name="multi-properties.attlist"/>
<ref name="multi-properties-inline.content"/>
</element>
</define>
<define name="multi-properties-inline.content">
<oneOrMore>
<ref name="multi-property-set"/>
</oneOrMore>
<ref name="wrapper-inline"/>
</define>
<define name="multi-properties-block">
<element name="fo:multi-properties">
<ref name="multi-properties.attlist"/>
<ref name="multi-properties-block.content"/>
</element>
</define>
<define name="multi-properties-block.content">
<oneOrMore>
<ref name="multi-property-set"/>
</oneOrMore>
<ref name="wrapper-block"/>
</define>
<define name="multi-properties">
<element name="fo:multi-properties">
<ref name="multi-properties.attlist"/>
<ref name="multi-properties.content"/>
</element>
</define>
<define name="multi-properties.content">
<oneOrMore>
<ref name="multi-property-set"/>
</oneOrMore>
<ref name="wrapper"/>
</define>
<!--
===============================================================
Multi property set.
===============================================================
-->
<define name="multi-property-set">
<element name="fo:multi-property-set">
<ref name="multi-property-set.attlist"/>
<empty/>
</element>
</define>
<!--
===============================================================
"Match anything" definition, used by fo:instream-foreign-object
===============================================================
MEMO: Should we exclude elements which belongs to fo: namespace?
-->
<define name="any">
<zeroOrMore>
<choice>
<element>
<anyName/>
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
<ref name="any"/>
</element>
<text/>
</choice>
</zeroOrMore>
</define>
</grammar>
|