Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / folint.xsl @ 187

History | View | Annotate | Download (148.5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- ===================================================================
3

    
4
This stylesheet is meant as a replacement to a DTD for XSL Formatting
5
objects. It checks structural validity of an XSL FO document, issuing
6
messages at inconsistencies found. As compared to DTD, stylesheet
7
validation offers the following advantages:
8

    
9
1. More flexibility in controlling the document structure. For example,
10
the stylesheet can control the following aspects of the document
11
structure that a DTD cannot handle:
12

    
13
  - check for block-level content through intermediate fo:wrapper elements;
14
  - exclude contents of fo:instream-foreign-object from validation;
15
  - check mutual exclusion of @internal-destination and @external-destination;
16
  - check fo:marker/fo:initial-property-set position in a mixed content model;
17
  - check that fo:marker is a descendant of fo:flow;
18
  - check that a footnote may not contain other footnotes or floats;
19
  - etc.
20

    
21
2. Improved readability of validation error messages. Frequent errors can get
22
a separate message that explains the problem and eventually offers a hint
23
to fix it. (In many respects, this is still a TODO :-)).
24

    
25
3. Namespace awareness. The namespace prefix need not be fixed anymore
26
(as it was the case with DTD validation).
27

    
28
4. Smart handling of attribute values - "partial" validation. This stylesheet
29
catches misprints in predefined attribute values but passes expressions through.
30

    
31
*************************************************************************
32

    
33
IMPLEMENTATION NOTES
34

    
35
1. Stylesheet structure and techniques.
36

    
37
The structure of this stylesheet is trivial: we apply templates to each elements
38
and attributes, and issue an error message each time there is something suspicious
39
about the document structure. There is a dozen of named templates that assist us
40
in performing common tasks.
41

    
42
1.1. Validating element names and content models
43

    
44
Each element described in XSL 1.0 has a matching template, and all
45
incorrectly named or missplaced elements are catched by a default rule
46
(redefined to complain about invalid elements). Inside each template,
47
there is a number of checks for obligatory attributes and content model.
48
The document-node template checks namespace correctness and presence
49
of fo:root as the top node.
50

    
51
1.2. Validating attribute occurrency
52

    
53
By design of XSL, almost every property may be in principle specified
54
anywhere. Attribute occurrence can be reliably limited only in the
55
following places:
56

    
57
  - fo:layout-master-set and its descendants;
58
  - terminal inline elements - fo:character, fo:page-number,
59
    fo:page-number-citation, fo:initial-property-set;
60
  - graphics - fo:external-graphics, fo:instream-foreign-object.
61

    
62
I used the following approach to achieve this: the default rule
63
for @* complains about incorrect attribute. However, the priority
64
for this default rule differs across the element tree:
65

    
66
 * -2 for fo:root, fo:page-sequence and all descendants
67
   of fo:page-sequence;
68

    
69
 *  2 for fo:simple-page-master and its descendants;
70

    
71
 *  4 for fo:layout-master-set and its descendants other than
72
      fo:simple-master/fo:region-*.
73

    
74
For each correct attribute, the stylesheet contains an enabling template.
75
Attributes that can occur only inside fo:page-sequence get enabling
76
templates with default priority; attributes permitted on region
77
descriptors get priority="3"; attributes of other fo:layout-master-set
78
children will have priority="5".
79

    
80
To limit attribute occurrence on atomic inlines and graphics, there are
81
two disabling named templates defined. They are added inside enabling
82
templates.
83

    
84
1.3. Validating attribute values.
85

    
86
Validation of attribute values is hard in XSL FO because of expressions:
87
even properties with a closed list of possible values can be specified
88
as expressions. This stylesheet validates attributes "partially":
89

    
90
 - attributes that can get only fixed values are validated only if their value
91
   does not contain a pair of parentheses (because any expression inside them
92
   should inevitably contain a function call);
93

    
94
 - attributes that can get numeric values are validated if their value
95
   does not contain any of the following:
96

    
97
     * parentheses;
98
     * math operators;
99
     * digits.
100

    
101
This gives a reliable method of catching mistyped values of attributes.
102

    
103
There are three cases where additional processing is necessary:
104

    
105
  A. Validation of URIs. Attributes that may get URI values are checked
106
     to be of the form 'url(...)'.
107

    
108
  B. Validation of 'content-type' attribute. It is checked to start
109
     with either 'content-type:' or 'namespace:'.
110

    
111
  C. Validation of 'text-align' attribute. This attribute may have an
112
     arbitrary string as its value; therefore, its correct validation
113
     is impossible - a mistype in any of the fixed values turns it
114
     into a 'string'. Because 'string' alignment is rare, and fixed
115
     values for text-align are ubiquitous, I felt necessary to introduce
116
     some heuristics to distinguish between table-alignment strings
117
     and mistyped predefined tokens. The heuristics is as follows:
118
     if a value contains only alphabetic characters, it's a keyword 
119
     and should match one of the predefined tokens. Otherwise, it's 
120
     a string and should not be spellchecked.
121

    
122
     (Frankly speaking, a 'string' value of "left" cannot be distinguished
123
     from a token 'left'. The property is really poorly designed.)
124

    
125
2. This stylesheet also contains checks for some RenderX extensions to XSL FO.
126
They are placed into a separate namespace, and should not interfere
127
with the correct validation of conformant XSL FO documents.
128

    
129
==================================================================== --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
130
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
131
                xmlns:rx="http://www.renderx.com/XSL/Extensions"
132
                version="1.0"
133
                exclude-result-prefixes="fo rx">
134

    
135
   <xsl:output method="xml" omit-xml-declaration="yes"/>
136

    
137
   <!-- Strictness level. Currently used levels: 0 (loose), 1 (normal), 2 (pedantic) -->
138
<xsl:param name="strictness">1</xsl:param>
139

    
140
   <!-- =================================== -->
141
<!-- Match topmost node - must be <root> -->
142

    
143
<xsl:template match="/">
144
      <xsl:if test="not(fo:root)">
145
         <xsl:call-template name="print-error">
146
            <xsl:with-param name="msg">
147
               <xsl:choose>
148
                  <xsl:when test="local-name(*[1]) = 'root'">
149
                     <xsl:text>Incorrect namespace at top element - should be 'http://www.w3.org/1999/XSL/Format'</xsl:text>
150
                  </xsl:when>
151
                  <xsl:otherwise>
152
                     <xsl:text>Incorrect top element - should be 'root'</xsl:text>
153
                  </xsl:otherwise>
154
               </xsl:choose>
155
            </xsl:with-param>
156
         </xsl:call-template>
157
      </xsl:if>
158

    
159
      <xsl:apply-templates select="fo:root"/>
160
   </xsl:template>
161

    
162

    
163
   <!-- =================================== -->
164
<!-- Root                                -->
165

    
166
<xsl:template match="fo:root">
167
      <xsl:if test="@*[.='inherit']">
168
         <xsl:call-template name="print-warning">
169
            <xsl:with-param name="msg">Attributes with value of 'inherit' are meaningless on '<xsl:value-of select="name()"/>'.</xsl:with-param>
170
         </xsl:call-template>
171
      </xsl:if>
172

    
173
      <xsl:apply-templates select="@*"/>
174
      <xsl:call-template name="no-text"/>
175

    
176
      <xsl:apply-templates select="*[not(self::rx:meta-info                                   or self::fo:layout-master-set                                   or self::fo:declarations                                   or self::rx:outline                                   or self::fo:page-sequence)]"
177
                           mode="report-intrusive-elements"/>
178

    
179
      <xsl:if test="not(fo:layout-master-set)">
180
         <xsl:call-template name="print-error">
181
            <xsl:with-param name="msg">Element 'layout-master-set' is required as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
182
         </xsl:call-template>
183
      </xsl:if>
184

    
185
      <xsl:if test="count(fo:layout-master-set) &gt; 1">
186
         <xsl:call-template name="print-error">
187
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:layout-master-set[1])"/>' element as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
188
         </xsl:call-template>
189
      </xsl:if>
190

    
191
      <xsl:if test="count(fo:declarations) &gt; 1">
192
         <xsl:call-template name="print-error">
193
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:declarations[1])"/>' element as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
194
         </xsl:call-template>
195
      </xsl:if>
196

    
197
      <xsl:if test="not(fo:page-sequence)">
198
         <xsl:call-template name="print-error">
199
            <xsl:with-param name="msg">There should be at least one 'page-sequence' element as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
200
         </xsl:call-template>
201
      </xsl:if>
202

    
203
      <xsl:if test="fo:layout-master-set[preceding-sibling::fo:declarations]">
204
         <xsl:call-template name="print-warning">
205
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:layout-master-set[1])"/>' shall precede '<xsl:value-of select="name(fo:declarations[1])"/>'. </xsl:with-param>
206
         </xsl:call-template>
207
      </xsl:if>
208

    
209
      <xsl:if test="fo:declarations[preceding-sibling::fo:page-sequence]">
210
         <xsl:call-template name="print-error">
211
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:declarations[1])"/>' shall be placed before the first '<xsl:value-of select="name(fo:page-sequence[1])"/>' element. </xsl:with-param>
212
         </xsl:call-template>
213
      </xsl:if>
214

    
215
      <xsl:if test="fo:layout-master-set[preceding-sibling::fo:page-sequence]">
216
         <xsl:call-template name="print-error">
217
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:layout-master-set[1])"/>' shall be placed before the first '<xsl:value-of select="name(fo:page-sequence[1])"/>' element. </xsl:with-param>
218
         </xsl:call-template>
219
      </xsl:if>
220

    
221
      <!-- Tests of RenderX extension elements -->
222
  <xsl:if test="count(rx:meta-info) &gt; 1">
223
         <xsl:call-template name="print-error">
224
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(rx:meta-info[1])"/>' element as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
225
         </xsl:call-template>
226
      </xsl:if>
227

    
228
      <xsl:if test="count(rx:outline) &gt; 1">
229
         <xsl:call-template name="print-error">
230
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(rx:outline[1])"/>' element as a child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
231
         </xsl:call-template>
232
      </xsl:if>
233

    
234
      <xsl:if test="rx:meta-info[preceding-sibling::*]">
235
         <xsl:call-template name="print-warning">
236
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(rx:meta-info[1])"/>' should be the first child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
237
         </xsl:call-template>
238
      </xsl:if>
239

    
240
      <xsl:if test="rx:outline[preceding-sibling::fo:page-sequence]">
241
         <xsl:call-template name="print-error">
242
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(rx:outline[1])"/>' shall be placed before the first '<xsl:value-of select="name(fo:page-sequence[1])"/>' element. </xsl:with-param>
243
         </xsl:call-template>
244
      </xsl:if>
245

    
246
      <xsl:apply-templates select="*"/>
247

    
248
   </xsl:template>
249

    
250

    
251
   <!-- =================================== -->
252
<!-- Layout-master-set                   -->
253

    
254
<xsl:template match="fo:layout-master-set">
255
      <xsl:apply-templates select="@*"/>
256
      <xsl:call-template name="no-text"/>
257

    
258
      <xsl:apply-templates select="*[not(self::fo:simple-page-master                                   or self::fo:page-sequence-master)]"
259
                           mode="report-intrusive-elements">
260
         <xsl:with-param name="reason">Only 'simple-page-master' and 'page-sequence-master' elements are permitted in this context.</xsl:with-param>
261
      </xsl:apply-templates>
262

    
263
      <xsl:if test="not(fo:simple-page-master)">
264
         <xsl:call-template name="print-error">
265
            <xsl:with-param name="msg">There should be at least one 'simple-page-master' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
266
         </xsl:call-template>
267
      </xsl:if>
268

    
269
      <xsl:apply-templates select="*"/>
270
   </xsl:template>
271

    
272

    
273
   <!-- =================================== -->
274
<!-- Simple-page-master                  -->
275

    
276
<xsl:template match="fo:simple-page-master">
277
      <xsl:apply-templates select="@*"/>
278
      <xsl:call-template name="no-text"/>
279

    
280
      <xsl:apply-templates select="*[not(self::fo:region-body                                   or self::fo:region-before                                   or self::fo:region-after                                   or self::fo:region-start                                   or self::fo:region-end)]"
281
                           mode="report-intrusive-elements">
282
         <xsl:with-param name="reason">Only region descriptors are permitted in this context.</xsl:with-param>
283
      </xsl:apply-templates>
284

    
285
      <xsl:if test="not(@master-name)">
286
         <xsl:call-template name="print-error">
287
            <xsl:with-param name="msg">Attribute 'master-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
288
         </xsl:call-template>
289
      </xsl:if>
290

    
291
      <xsl:variable name="master-name" select="@master-name"/>
292
      <xsl:if test="ancestor::fo:layout-master-set             and (following-sibling::*[@master-name = $master-name]               or preceding-sibling::*[@master-name = $master-name])">
293
         <xsl:call-template name="print-error">
294
            <xsl:with-param name="msg">
295
        Duplicate identifier: master-name="<xsl:value-of select="$master-name"/>".
296
        Property 'master-name' should be unique within '<xsl:value-of select="name(ancestor::fo:layout-master-set[1])"/>'.
297
      </xsl:with-param>
298
         </xsl:call-template>
299
      </xsl:if>
300

    
301
      <xsl:if test="not(fo:region-body)">
302
         <xsl:call-template name="print-error">
303
            <xsl:with-param name="msg">Element 'region-body' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
304
         </xsl:call-template>
305
      </xsl:if>
306

    
307
      <xsl:if test="count(fo:region-body) &gt; 1">
308
         <xsl:call-template name="print-error">
309
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:region-body[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
310
         </xsl:call-template>
311
      </xsl:if>
312

    
313
      <xsl:if test="count(fo:region-before) &gt; 1">
314
         <xsl:call-template name="print-error">
315
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:region-before[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
316
         </xsl:call-template>
317
      </xsl:if>
318

    
319
      <xsl:if test="count(fo:region-after) &gt; 1">
320
         <xsl:call-template name="print-error">
321
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:region-after[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
322
         </xsl:call-template>
323
      </xsl:if>
324

    
325
      <xsl:if test="count(fo:region-start) &gt; 1">
326
         <xsl:call-template name="print-error">
327
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:region-start[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
328
         </xsl:call-template>
329
      </xsl:if>
330

    
331
      <xsl:if test="count(fo:region-end) &gt; 1">
332
         <xsl:call-template name="print-error">
333
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:region-end[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
334
         </xsl:call-template>
335
      </xsl:if>
336

    
337
      <!-- I didn't want to control the ordering of regions; -->
338
  <!-- but they convinced me...                          -->
339

    
340
  <xsl:if test="$strictness &gt; 0">
341
         <xsl:if test="fo:region-body/preceding-sibling::*[self::fo:region-before                                                    or self::fo:region-after                                                    or self::fo:region-start                                                    or self::fo:region-end]                or fo:region-before/preceding-sibling::*[self::fo:region-after                                                    or self::fo:region-start                                                    or self::fo:region-end]                or fo:region-after/preceding-sibling::*[self::fo:region-start                                                    or self::fo:region-end]                or fo:region-start/preceding-sibling::fo:region-end">
342
            <xsl:call-template name="print-warning">
343
               <xsl:with-param name="msg">Incorrect order of region descriptors inside '<xsl:value-of select="name()"/>'. Regions shall be ordered according to the following content model: fo:region-body, fo:region-before?, fo:region-after?, fo:region-start?, fo:region-end?</xsl:with-param>
344
            </xsl:call-template>
345
         </xsl:if>
346
      </xsl:if>
347

    
348
      <xsl:apply-templates select="*"/>
349
   </xsl:template>
350

    
351
   <!-- =================================== -->
352
<!-- Regions                             -->
353

    
354
<xsl:template match="fo:region-body                    | fo:region-before                    | fo:region-after                    | fo:region-start                    | fo:region-end">
355
      <xsl:apply-templates select="@*"/>
356
      <xsl:call-template name="empty-element"/>
357
      <xsl:if test="not(@extent) and not (self::fo:region-body)">
358
         <xsl:call-template name="print-error">
359
            <xsl:with-param name="msg">Attribute 'extent' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
360
         </xsl:call-template>
361
      </xsl:if>
362

    
363
      <xsl:variable name="region-name">
364
         <xsl:choose>
365
            <xsl:when test="@region-name">
366
               <xsl:value-of select="@region-name"/>
367
            </xsl:when>
368
            <xsl:otherwise>
369
               <xsl:value-of select="concat('xsl-', local-name())"/>
370
            </xsl:otherwise>
371
         </xsl:choose>
372
      </xsl:variable>
373

    
374
      <xsl:if test="ancestor::fo:simple-page-master              and (preceding-sibling::*[@region-name = $region-name]                or following-sibling::*[@region-name = $region-name])">
375
         <xsl:call-template name="print-error">
376
            <xsl:with-param name="msg">
377
        Duplicate identifier: region-name="<xsl:value-of select="$region-name"/>".
378
        Property 'region-name' shall be unique within '<xsl:value-of select="name(ancestor::fo:simple-page-master[1])"/>'.
379
      </xsl:with-param>
380
         </xsl:call-template>
381
      </xsl:if>
382
  
383
      <xsl:if test="$strictness &gt; 1">
384
         <xsl:if test="@*[starts-with(local-name(), 'padding')]                     [normalize-space(.) != '0'                   and normalize-space(.) != '0pt'                  and normalize-space(.) != '0px'                  and normalize-space(.) != '0mm'                  and normalize-space(.) != '0em'                  and normalize-space(.) != '0cm'                  and normalize-space(.) != '0pc'                  and normalize-space(.) != '0in']">
385
            <xsl:call-template name="print-warning">
386
               <xsl:with-param name="msg">
387
          Padding on '<xsl:value-of select="name()"/>' is a RenderX extension.
388
        </xsl:with-param>
389
            </xsl:call-template>
390
         </xsl:if>
391

    
392
         <xsl:if test="@*[starts-with(local-name(), 'border')]">
393
            <xsl:call-template name="print-warning">
394
               <xsl:with-param name="msg">
395
          Border on '<xsl:value-of select="name()"/>' is a RenderX extension.
396
       </xsl:with-param>
397
            </xsl:call-template>
398
         </xsl:if>
399
      </xsl:if>
400

    
401
   </xsl:template>
402

    
403

    
404
   <!-- =================================== -->
405
<!-- Page-sequence-master                -->
406

    
407
<xsl:template match="fo:page-sequence-master">
408
      <xsl:apply-templates select="@*"/>
409
      <xsl:call-template name="no-text"/>
410

    
411
      <xsl:if test="not(@master-name)">
412
         <xsl:call-template name="print-error">
413
            <xsl:with-param name="msg">Attribute 'master-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
414
         </xsl:call-template>
415
      </xsl:if>
416

    
417
      <xsl:variable name="master-name" select="@master-name"/>
418
      <xsl:if test="ancestor::fo:layout-master-set             and (following-sibling::*[@master-name = $master-name]               or preceding-sibling::*[@master-name = $master-name])">
419
         <xsl:call-template name="print-error">
420
            <xsl:with-param name="msg">
421
        Duplicate identifier: master-name="<xsl:value-of select="$master-name"/>".
422
        Property 'master-name' should be unique within '<xsl:value-of select="name(ancestor::fo:layout-master-set[1])"/>'.
423
      </xsl:with-param>
424
         </xsl:call-template>
425
      </xsl:if>
426

    
427
      <xsl:apply-templates select="*[not(self::fo:single-page-master-reference                                   or self::fo:repeatable-page-master-reference                                   or self::fo:repeatable-page-master-alternatives)]"
428
                           mode="report-intrusive-elements">
429
         <xsl:with-param name="reason">Only page sequence specifiers are permitted in this context.</xsl:with-param>
430
      </xsl:apply-templates>
431

    
432
      <xsl:if test="not (fo:single-page-master-reference                   or fo:repeatable-page-master-reference                   or fo:repeatable-page-master-alternatives)">
433
         <xsl:call-template name="print-error">
434
            <xsl:with-param name="msg">At least one page sequence specifier is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
435
         </xsl:call-template>
436
      </xsl:if>
437

    
438
      <xsl:apply-templates select="*"/>
439
   </xsl:template>
440

    
441

    
442
   <!-- =================================== -->
443
<!-- Page master references              -->
444

    
445
<xsl:template match="fo:single-page-master-reference                    | fo:repeatable-page-master-reference                    | fo:conditional-page-master-reference">
446
      <xsl:apply-templates select="@*"/>
447
      <xsl:call-template name="empty-element"/>
448
      <xsl:if test="not(@master-reference)">
449
         <xsl:call-template name="print-error">
450
            <xsl:with-param name="msg">Attribute 'master-reference' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
451
         </xsl:call-template>
452
      </xsl:if>
453
   </xsl:template>
454

    
455

    
456
   <!-- =================================== -->
457
<!-- Repeatable-page-master-alternatives -->
458

    
459
<xsl:template match="fo:repeatable-page-master-alternatives">
460
      <xsl:apply-templates select="@*"/>
461
      <xsl:call-template name="no-text"/>
462

    
463
      <xsl:apply-templates select="*[not(self::fo:conditional-page-master-reference)]"
464
                           mode="report-intrusive-elements">
465
         <xsl:with-param name="reason">Only 'conditional-page-master-reference' elements are permitted in this context.</xsl:with-param>
466
      </xsl:apply-templates>
467

    
468
      <xsl:if test="not(fo:conditional-page-master-reference)">
469
         <xsl:call-template name="print-error">
470
            <xsl:with-param name="msg">At least one 'conditional-page-master-reference' element should be present inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
471
         </xsl:call-template>
472
      </xsl:if>
473

    
474
      <xsl:apply-templates select="*"/>
475
   </xsl:template>
476

    
477
   <!-- =================================== -->
478
<!-- Rx:meta-info                        -->
479

    
480
<xsl:template match="rx:meta-info">
481
      <xsl:apply-templates select="@*"/>
482
      <xsl:call-template name="no-text"/>
483

    
484
      <xsl:apply-templates select="*[not(self::rx:meta-field)]" mode="report-intrusive-elements">
485
         <xsl:with-param name="reason">Only 'meta-field' elements are permitted in this context.</xsl:with-param>
486
      </xsl:apply-templates>
487

    
488
      <xsl:if test="not (rx:meta-field)">
489
         <xsl:call-template name="print-error">
490
            <xsl:with-param name="msg">At least one 'meta-field' element should be present inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
491
         </xsl:call-template>
492
      </xsl:if>
493

    
494
      <xsl:apply-templates select="*"/>
495
   </xsl:template>
496

    
497

    
498
   <!-- =================================== -->
499
<!-- Rx:meta-field                       -->
500

    
501
<xsl:template match="rx:meta-field">
502
      <xsl:apply-templates select="@*"/>
503
      <xsl:call-template name="empty-element"/>
504
      <xsl:if test="not(@name)">
505
         <xsl:call-template name="print-error">
506
            <xsl:with-param name="msg">Attribute 'name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
507
         </xsl:call-template>
508
      </xsl:if>
509
      <xsl:if test="not(@value)">
510
         <xsl:call-template name="print-error">
511
            <xsl:with-param name="msg">Attribute 'value' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
512
         </xsl:call-template>
513
      </xsl:if>
514
   </xsl:template>
515

    
516
   <!-- =================================== -->
517
<!-- Rx:page-device                      -->
518

    
519
<xsl:template match="rx:page-device" mode="report-intrusive-elements">
520
      <xsl:call-template name="print-error">
521
         <xsl:with-param name="msg">Element 'page-device' is obsolete;  use &lt;?xep-postscript-* ?&gt; processing instructions instead.</xsl:with-param>
522
      </xsl:call-template>
523
   </xsl:template>
524

    
525

    
526
   <!-- =================================== -->
527
<!-- Declarations                        -->
528

    
529
<xsl:template match="fo:declarations">
530
      <xsl:apply-templates select="@*"/>
531
      <xsl:call-template name="no-text"/>
532

    
533
      <xsl:apply-templates select="*[not(self::fo:color-profile)]" mode="report-intrusive-elements">
534
         <xsl:with-param name="reason">Only 'color-profile' elements are permitted in this context.</xsl:with-param>
535
      </xsl:apply-templates>
536

    
537
      <xsl:apply-templates select="*"/>
538
   </xsl:template>
539

    
540

    
541
   <!-- =================================== -->
542
<!-- Color-profile                       -->
543

    
544
<xsl:template match="fo:color-profile">
545
      <xsl:apply-templates select="@*"/>
546
      <xsl:call-template name="empty-element"/>
547
      <xsl:if test="not(@color-profile-name)">
548
         <xsl:call-template name="print-error">
549
            <xsl:with-param name="msg">Attribute 'color-profile-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
550
         </xsl:call-template>
551
      </xsl:if>
552
      <xsl:if test="not(@src)">
553
         <xsl:call-template name="print-error">
554
            <xsl:with-param name="msg">Attribute 'src' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
555
         </xsl:call-template>
556
      </xsl:if>
557
   </xsl:template>
558

    
559

    
560
   <!-- =================================== -->
561
<!-- Rx:outline                        -->
562

    
563
<xsl:template match="rx:outline">
564
      <xsl:apply-templates select="@*"/>
565
      <xsl:call-template name="no-text"/>
566

    
567
      <xsl:apply-templates select="*[not(self::rx:bookmark)]" mode="report-intrusive-elements">
568
         <xsl:with-param name="reason">Only 'bookmark' elements are permitted in this context.</xsl:with-param>
569
      </xsl:apply-templates>
570

    
571
      <xsl:if test="not (rx:bookmark)">
572
         <xsl:call-template name="print-error">
573
            <xsl:with-param name="msg">At least one 'bookmark' element should be present inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
574
         </xsl:call-template>
575
      </xsl:if>
576

    
577
      <xsl:apply-templates select="*"/>
578
   </xsl:template>
579

    
580

    
581
   <!-- =================================== -->
582
<!-- Rx:bookmark                         -->
583

    
584
<xsl:template match="rx:bookmark">
585
      <xsl:apply-templates select="@*"/>
586
      <xsl:call-template name="no-text"/>
587

    
588
      <xsl:if test="not(@internal-destination or @external-destination)">
589
         <xsl:call-template name="print-error">
590
            <xsl:with-param name="msg">Either 'internal-destination' or 'external-destination' attribute must be present on '<xsl:value-of select="name()"/>'. </xsl:with-param>
591
         </xsl:call-template>
592
      </xsl:if>
593

    
594
      <xsl:if test="@internal-destination and @external-destination">
595
         <xsl:call-template name="print-error">
596
            <xsl:with-param name="msg">Only one of 'internal-destination' or 'external-destination' attributes can be present on '<xsl:value-of select="name()"/>'. </xsl:with-param>
597
         </xsl:call-template>
598
      </xsl:if>
599

    
600
      <xsl:apply-templates select="*[not(self::rx:bookmark                                   or self::rx:bookmark-label)]"
601
                           mode="report-intrusive-elements">
602
         <xsl:with-param name="reason">Only 'bookmark-label' and/or nested 'boormark' elements are permitted in this context.</xsl:with-param>
603
      </xsl:apply-templates>
604

    
605
      <xsl:if test="not (rx:bookmark-label)">
606
         <xsl:call-template name="print-error">
607
            <xsl:with-param name="msg">Element 'bookmark-label' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
608
         </xsl:call-template>
609
      </xsl:if>
610

    
611
      <xsl:if test="count (rx:bookmark-label) &gt; 1">
612
         <xsl:call-template name="print-error">
613
            <xsl:with-param name="msg">There should be exactly one '<xsl:value-of select="name(rx:bookmark-label[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
614
         </xsl:call-template>
615
      </xsl:if>
616

    
617
      <xsl:if test="rx:bookmark-label[preceding-sibling::*]">
618
         <xsl:call-template name="print-error">
619
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(rx:bookmark-label[1])"/>' should be the first child of '<xsl:value-of select="name()"/>'. </xsl:with-param>
620
         </xsl:call-template>
621
      </xsl:if>
622

    
623
      <xsl:apply-templates select="*"/>
624
   </xsl:template>
625

    
626

    
627
   <!-- =================================== -->
628
<!-- Rx:bookmark-label                   -->
629

    
630
<xsl:template match="rx:bookmark-label">
631
      <xsl:apply-templates select="@*"/>
632

    
633
      <xsl:apply-templates select="*" mode="report-intrusive-elements">
634
         <xsl:with-param name="reason">Only plain text is permitted in this context.</xsl:with-param>
635
      </xsl:apply-templates>
636
   </xsl:template>
637

    
638

    
639
   <!-- =================================== -->
640
<!-- Page-sequence                       -->
641

    
642
<xsl:template match="fo:page-sequence">
643
      <xsl:apply-templates select="@*"/>
644
      <xsl:call-template name="no-text"/>
645

    
646
      <xsl:if test="not(@master-reference)">
647
         <xsl:call-template name="print-error">
648
            <xsl:with-param name="msg">Attribute 'master-reference' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
649
         </xsl:call-template>
650
      </xsl:if>
651

    
652
      <xsl:apply-templates select="*[not(self::fo:title                                   or self::fo:static-content                                   or self::fo:flow)]"
653
                           mode="report-intrusive-elements">
654
         <xsl:with-param name="reason">Only 'flow', 'static-content', and 'title' elements are permitted in this context.</xsl:with-param>
655
      </xsl:apply-templates>
656

    
657
      <xsl:if test="not(fo:flow)">
658
         <xsl:call-template name="print-error">
659
            <xsl:with-param name="msg">Element 'flow' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
660
         </xsl:call-template>
661
      </xsl:if>
662

    
663
      <xsl:if test="count(fo:flow) &gt; 1">
664
         <xsl:call-template name="print-error">
665
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:flow[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
666
         </xsl:call-template>
667
      </xsl:if>
668

    
669
      <xsl:if test="count(fo:title) &gt; 1">
670
         <xsl:call-template name="print-error">
671
            <xsl:with-param name="msg">There can be at most one '<xsl:value-of select="name(fo:title[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
672
         </xsl:call-template>
673
      </xsl:if>
674

    
675
      <xsl:if test="fo:title[preceding-sibling::*]">
676
         <xsl:call-template name="print-error">
677
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:title[1])"/>' should be the first child of its parent '<xsl:value-of select="name()"/>'. </xsl:with-param>
678
         </xsl:call-template>
679
      </xsl:if>
680

    
681
      <xsl:if test="fo:flow[following-sibling::*]">
682
         <xsl:call-template name="print-error">
683
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:flow[1])"/>' should be the last child of its parent '<xsl:value-of select="name()"/>'. </xsl:with-param>
684
         </xsl:call-template>
685
      </xsl:if>
686

    
687
      <xsl:apply-templates select="*"/>
688
   </xsl:template>
689

    
690

    
691
   <!-- =================================== -->
692
<!-- Title                               -->
693

    
694
<xsl:template match="fo:title">
695
      <xsl:apply-templates select="@*"/>
696
      <xsl:call-template name="inline-level"/>
697
      <xsl:apply-templates select="*"/>
698
   </xsl:template>
699

    
700

    
701
   <!-- =================================== -->
702
<!-- Flow and static-content             -->
703

    
704
<xsl:template match="fo:flow | fo:static-content">
705
      <xsl:apply-templates select="@*"/>
706
      <xsl:call-template name="block-level"/>
707

    
708
      <xsl:if test="not(@flow-name)">
709
         <xsl:call-template name="print-error">
710
            <xsl:with-param name="msg">Attribute 'flow-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
711
         </xsl:call-template>
712
      </xsl:if>
713

    
714
      <xsl:variable name="flow-name" select="@flow-name"/>
715
      <xsl:if test="ancestor::fo:page-sequence             and (following-sibling::*[self::fo:flow or self::fo:static-content][@flow-name = $flow-name]               or preceding-sibling::*[self::fo:flow or self::fo:static-content][@flow-name = $flow-name])">
716
         <xsl:call-template name="print-error">
717
            <xsl:with-param name="msg">
718
        Duplicate identifier: flow-name="<xsl:value-of select="$flow-name"/>".
719
        Property 'flow-name' should be unique within '<xsl:value-of select="name(ancestor::fo:page-sequence[1])"/>'.
720
      </xsl:with-param>
721
         </xsl:call-template>
722
      </xsl:if>
723

    
724
      <xsl:apply-templates select="*"/>
725
   </xsl:template>
726

    
727

    
728
   <!-- =================================== -->
729
<!-- Rx:flow-section                     -->
730

    
731
<xsl:template match="rx:flow-section">
732
      <xsl:apply-templates select="@*"/>
733
      <xsl:call-template name="block-level"/>
734

    
735
      <xsl:if test="not(parent::fo:flow)">
736
         <xsl:call-template name="print-error">
737
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' must be a direct descendant of 'flow'. </xsl:with-param>
738
         </xsl:call-template>
739
      </xsl:if>
740

    
741
      <xsl:apply-templates select="*"/>
742
   </xsl:template>
743

    
744

    
745
   <!-- =================================== -->
746
<!-- Block                               -->
747

    
748
<xsl:template match="fo:block">
749
      <xsl:apply-templates select="@*"/>
750
      <xsl:call-template name="mixed-level"/>
751
      <xsl:apply-templates select="*"/>
752
   </xsl:template>
753

    
754

    
755
   <!-- =================================== -->
756
<!-- Containers                          -->
757

    
758
<xsl:template match="fo:block-container | fo:inline-container">
759
      <xsl:apply-templates select="@*"/>
760
      <xsl:call-template name="block-level"/>
761
      <xsl:apply-templates select="*"/>
762
   </xsl:template>
763

    
764

    
765
   <!-- =================================== -->
766
<!-- Bidi-override                       -->
767

    
768
<xsl:template match="fo:bidi-override">
769
      <xsl:apply-templates select="@*"/>
770
      <xsl:call-template name="inline-level"/>
771

    
772
      <xsl:if test="not(@direction)">
773
         <xsl:call-template name="print-warning">
774
            <xsl:with-param name="msg">Attribute 'direction' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
775
         </xsl:call-template>
776
      </xsl:if>
777

    
778
      <xsl:apply-templates select="*"/>
779
   </xsl:template>
780

    
781

    
782
   <!-- =================================== -->
783
<!-- Character                           -->
784

    
785
<xsl:template match="fo:character">
786
      <xsl:apply-templates select="@*"/>
787
      <xsl:call-template name="empty-element"/>
788

    
789
      <xsl:if test="not(@character)">
790
         <xsl:call-template name="print-error">
791
            <xsl:with-param name="msg">Attribute 'character' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
792
         </xsl:call-template>
793
      </xsl:if>
794
   </xsl:template>
795

    
796

    
797
   <!-- =================================== -->
798
<!-- Initial-property-set                -->
799

    
800
<xsl:template match="fo:initial-property-set">
801
      <xsl:apply-templates select="@*"/>
802
      <xsl:call-template name="empty-element"/>
803

    
804
      <xsl:choose>
805
         <xsl:when test="parent::fo:block">
806
            <xsl:if test="preceding-sibling::*">
807
               <xsl:call-template name="print-error">
808
                  <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be the first child of '<xsl:value-of select="name(parent::fo:block)"/>'. </xsl:with-param>
809
               </xsl:call-template>
810
            </xsl:if>
811

    
812
            <xsl:if test="preceding-sibling::text()[normalize-space() != '']">
813
               <xsl:call-template name="print-error">
814
                  <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be preceded by non-space characters in '<xsl:value-of select="name(parent::fo:block)"/>'. </xsl:with-param>
815
               </xsl:call-template>
816
            </xsl:if>
817

    
818
            <xsl:if test="preceding-sibling::fo:initial-property-set">
819
               <xsl:call-template name="print-error">
820
                  <xsl:with-param name="msg">Only one '<xsl:value-of select="name()"/>' element is permitted in 'xsl:value-of select="name(parent::fo:block)"/&gt;'. </xsl:with-param>
821
               </xsl:call-template>
822
            </xsl:if>
823
         </xsl:when>
824

    
825
         <xsl:otherwise>
826
            <xsl:call-template name="print-error">
827
               <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' can only occur inside 'block'. </xsl:with-param>
828
            </xsl:call-template>
829
         </xsl:otherwise>
830
      </xsl:choose>
831
   </xsl:template>
832

    
833

    
834
   <!-- =================================== -->
835
<!-- Line-numerator                      -->
836

    
837
<xsl:template match="rx:ruler">
838
      <xsl:apply-templates select="@*"/>
839
      <xsl:call-template name="empty-element"/>
840

    
841
      <xsl:choose>
842
         <xsl:when test="parent::fo:block-container">
843
            <xsl:if test="preceding-sibling::*">
844
               <xsl:call-template name="print-error">
845
                  <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be the first child of '<xsl:value-of select="name(parent::fo:block-container)"/>'. </xsl:with-param>
846
               </xsl:call-template>
847
            </xsl:if>
848

    
849
            <xsl:if test="preceding-sibling::text()[normalize-space() != '']">
850
               <xsl:call-template name="print-error">
851
                  <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be preceded by non-space characters in '<xsl:value-of select="name(parent::fo:block-container)"/>'. </xsl:with-param>
852
               </xsl:call-template>
853
            </xsl:if>
854

    
855
            <xsl:if test="preceding-sibling::rx:ruler">
856
               <xsl:call-template name="print-error">
857
                  <xsl:with-param name="msg">Only one '<xsl:value-of select="name()"/>' element is permitted in 'xsl:value-of select="name(parent::fo:block-container)"/&gt;'. </xsl:with-param>
858
               </xsl:call-template>
859
            </xsl:if>
860
         </xsl:when>
861

    
862
         <xsl:otherwise>
863
            <xsl:call-template name="print-error">
864
               <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' can only occur inside 'block-container'. </xsl:with-param>
865
            </xsl:call-template>
866
         </xsl:otherwise>
867
      </xsl:choose>
868
   </xsl:template>
869

    
870

    
871
   <!-- =================================== -->
872
<!-- External-graphic                    -->
873

    
874
<xsl:template match="fo:external-graphic">
875
      <xsl:apply-templates select="@*"/>
876
      <xsl:call-template name="empty-element"/>
877

    
878
      <xsl:if test="not(@src)">
879
         <xsl:call-template name="print-error">
880
            <xsl:with-param name="msg">Attribute 'src' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
881
         </xsl:call-template>
882
      </xsl:if>
883
   </xsl:template>
884

    
885

    
886
   <!-- =================================== -->
887
<!-- Instream-foreign-object             -->
888

    
889
<xsl:template match="fo:instream-foreign-object">
890
      <xsl:apply-templates select="@*"/>
891
      <!-- only the attributes are checked -->
892
</xsl:template>
893

    
894

    
895
   <!-- =================================== -->
896
<!-- Inline                              -->
897

    
898
<xsl:template match="fo:inline">
899
      <xsl:apply-templates select="@*"/>
900
      <xsl:call-template name="mixed-level"/>
901
      <xsl:apply-templates select="*"/>
902
   </xsl:template>
903

    
904

    
905
   <!-- =================================== -->
906
<!-- Leader                              -->
907

    
908
<xsl:template match="fo:leader">
909
      <xsl:apply-templates select="@*"/>
910
      <xsl:call-template name="inline-level"/>
911
      <xsl:apply-templates select="*"/>
912
   </xsl:template>
913

    
914

    
915
   <!-- =================================== -->
916
<!-- Page-number                         -->
917

    
918
<xsl:template match="fo:page-number">
919
      <xsl:apply-templates select="@*"/>
920
      <xsl:call-template name="empty-element"/>
921
   </xsl:template>
922

    
923

    
924
   <!-- =================================== -->
925
<!-- Page-number-citation                -->
926

    
927
<xsl:template match="fo:page-number-citation">
928
      <xsl:apply-templates select="@*"/>
929
      <xsl:call-template name="empty-element"/>
930

    
931
      <xsl:if test="not(@ref-id)">
932
         <xsl:call-template name="print-error">
933
            <xsl:with-param name="msg">Attribute 'ref-id' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
934
         </xsl:call-template>
935
      </xsl:if>
936
   </xsl:template>
937

    
938
   <!-- ========================================================== -->
939
<!-- Rx:page-number-citation-last (actually an XSL 1.1 element) -->
940

    
941
<xsl:template match="rx:page-number-citation-last">
942
      <xsl:apply-templates select="@*"/>
943
      <xsl:call-template name="empty-element"/>
944

    
945
      <xsl:if test="not(@ref-id)">
946
         <xsl:call-template name="print-error">
947
            <xsl:with-param name="msg">Attribute 'ref-id' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
948
         </xsl:call-template>
949
      </xsl:if>
950
   </xsl:template>
951

    
952

    
953
   <!-- =================================== -->
954
<!-- Rx:pinpoint                        -->
955

    
956
<xsl:template match="rx:pinpoint">
957
      <xsl:apply-templates select="@*"/>
958
      <xsl:call-template name="empty-element"/>
959

    
960
      <xsl:if test="not(@value)">
961
         <xsl:call-template name="print-error">
962
            <xsl:with-param name="msg">Attribute 'value' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
963
         </xsl:call-template>
964
      </xsl:if>
965
   </xsl:template>
966

    
967

    
968
   <!-- =================================== -->
969
<!-- Rx:page-index                       -->
970

    
971
<xsl:template match="rx:page-index">
972
      <xsl:apply-templates select="@*"/>
973
      <xsl:call-template name="no-text"/>
974

    
975
      <xsl:apply-templates select="*[not(self::rx:index-item)]" mode="report-intrusive-elements">
976
         <xsl:with-param name="reason">Only 'rx:index-item' elements are permitted in this context</xsl:with-param>
977
      </xsl:apply-templates>
978

    
979
      <xsl:if test="not(@ref-key) and not (rx:index-item)">
980
         <xsl:call-template name="print-error">
981
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' must have either 'ref-key' attribute, or 'rx:index-item' descendant elements.</xsl:with-param>
982
         </xsl:call-template>
983
      </xsl:if>
984
      <xsl:if test="@ref-key and rx:index-item">
985
         <xsl:call-template name="print-error">
986
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' can have either 'ref-key' attribute or '<xsl:value-of select="name(rx:index-item[1])"/>' descendant elements, but not both.</xsl:with-param>
987
         </xsl:call-template>
988
      </xsl:if>
989
      <xsl:apply-templates select="*"/>
990
   </xsl:template>
991

    
992
   <!-- =================================== -->
993
<!-- Rx:index-item                       -->
994

    
995
<xsl:template match="rx:index-item">
996
      <xsl:apply-templates select="@*"/>
997
      <xsl:call-template name="empty-element"/>
998

    
999
      <xsl:if test="not(@ref-key)">
1000
         <xsl:call-template name="print-error">
1001
            <xsl:with-param name="msg">Attribute 'ref-key' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1002
         </xsl:call-template>
1003
      </xsl:if>
1004
   </xsl:template>
1005

    
1006

    
1007
   <!-- =================================== -->
1008
<!-- Rx:begin-index-range                -->
1009

    
1010
<xsl:template match="rx:begin-index-range">
1011
      <xsl:apply-templates select="@*"/>
1012
      <xsl:call-template name="empty-element"/>
1013

    
1014
      <xsl:if test="not(@rx:key)">
1015
         <xsl:call-template name="print-error">
1016
            <xsl:with-param name="msg">Attribute 'rx:key' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1017
         </xsl:call-template>
1018
      </xsl:if>
1019
  
1020
      <xsl:choose>
1021
         <xsl:when test="not(@id)">
1022
            <xsl:call-template name="print-error">
1023
               <xsl:with-param name="msg">Attribute 'id' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1024
            </xsl:call-template>
1025
         </xsl:when>
1026
         <xsl:otherwise>
1027
            <xsl:variable name="id" select="@id"/>
1028
      
1029
            <xsl:if test="count(preceding::rx:begin-index-range[@id=$id]) = 1">
1030
	              <xsl:call-template name="print-error">
1031
	                 <xsl:with-param name="msg">Two or more '<xsl:value-of select="name()"/>' elements with id='<xsl:value-of select="@id"/>';  'id' should be unique within the document.</xsl:with-param>
1032
	              </xsl:call-template>
1033
            </xsl:if>
1034
      
1035
            <xsl:choose> 
1036
               <xsl:when test="following::rx:end-index-range[@ref-id=$id]"/>
1037
               <xsl:when test="preceding::rx:end-index-range[@ref-id=$id]"/>
1038
               <xsl:otherwise>
1039
                  <xsl:call-template name="print-error">
1040
                     <xsl:with-param name="msg">Unmatched '<xsl:value-of select="name()"/>' element with id='<xsl:value-of select="@id"/>': no correspondent 'rx:end-index-range' found. </xsl:with-param>
1041
                  </xsl:call-template>
1042
               </xsl:otherwise>
1043
            </xsl:choose> 
1044
         </xsl:otherwise>
1045
      </xsl:choose>
1046
   </xsl:template>
1047

    
1048
   <!-- =================================== -->
1049
<!-- Rx:end-index-range                  -->
1050

    
1051
<xsl:template match="rx:end-index-range">
1052
      <xsl:apply-templates select="@*"/>
1053
      <xsl:call-template name="empty-element"/>
1054

    
1055
      <xsl:choose>
1056
         <xsl:when test="not(@ref-id)">
1057
            <xsl:call-template name="print-error">
1058
               <xsl:with-param name="msg">Attribute 'ref-id' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1059
            </xsl:call-template>
1060
         </xsl:when>
1061
         <xsl:otherwise>
1062
            <xsl:variable name="refid" select="@ref-id"/>
1063

    
1064
            <xsl:if test="count(preceding::rx:end-index-range[@ref-id=$refid]) = 1">
1065
               <xsl:call-template name="print-error">
1066
                  <xsl:with-param name="msg">Two or more '<xsl:value-of select="name()"/>' elements with ref-id='<xsl:value-of select="@ref-id"/>'.</xsl:with-param>
1067
               </xsl:call-template>
1068
            </xsl:if>
1069

    
1070
            <xsl:choose> 
1071
               <xsl:when test="following::rx:begin-index-range[@id=$refid]">
1072
                  <xsl:call-template name="print-warning">
1073
                     <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' with ref-id='<xsl:value-of select="@ref-id"/>' precedes its matching '<xsl:value-of select="name(following::rx:begin-index-range[@id=$refid][1])"/>'. </xsl:with-param>
1074
                  </xsl:call-template>
1075
               </xsl:when>
1076
               <xsl:when test="preceding::rx:begin-index-range[@id=$refid]"/>
1077
               <xsl:otherwise>
1078
                  <xsl:call-template name="print-error">
1079
                     <xsl:with-param name="msg">Unmatched '<xsl:value-of select="name()"/>' element with ref-id='<xsl:value-of select="@ref-id"/>': no correspondent 'rx:begin-index-range' found. </xsl:with-param>
1080
                  </xsl:call-template>
1081
               </xsl:otherwise>
1082
            </xsl:choose> 
1083
         </xsl:otherwise>
1084
      </xsl:choose>
1085
   </xsl:template>
1086

    
1087

    
1088
   <!-- =================================== -->
1089
<!-- Table-and-caption                   -->
1090

    
1091
<xsl:template match="fo:table-and-caption">
1092
      <xsl:apply-templates select="@*"/>
1093
      <xsl:call-template name="no-text"/>
1094

    
1095
      <xsl:apply-templates select="*[not(self::fo:table-caption                                   or self::fo:table                                   or self::fo:marker)]"
1096
                           mode="report-intrusive-elements">
1097
         <xsl:with-param name="reason">Only 'table-caption' and 'table' elements are permitted in this context.</xsl:with-param>
1098
      </xsl:apply-templates>
1099

    
1100
      <xsl:if test="not(fo:table)">
1101
         <xsl:call-template name="print-error">
1102
            <xsl:with-param name="msg">Element 'table' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1103
         </xsl:call-template>
1104
      </xsl:if>
1105

    
1106
      <xsl:if test="count(fo:table) &gt; 1">
1107
         <xsl:call-template name="print-error">
1108
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:table[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1109
         </xsl:call-template>
1110
      </xsl:if>
1111

    
1112
      <xsl:if test="count(fo:table-caption) &gt; 1">
1113
         <xsl:call-template name="print-error">
1114
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:table-caption[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1115
         </xsl:call-template>
1116
      </xsl:if>
1117

    
1118
      <xsl:if test="fo:table-caption[preceding-sibling::fo:table]">
1119
         <xsl:call-template name="print-error">
1120
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:table-caption[1])"/>' must precede '<xsl:value-of select="name(fo:table[1])"/>' inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1121
         </xsl:call-template>
1122
      </xsl:if>
1123

    
1124
      <xsl:apply-templates select="*"/>
1125
   </xsl:template>
1126

    
1127

    
1128
   <!-- =================================== -->
1129
<!-- Table-caption                       -->
1130

    
1131
<xsl:template match="fo:table-caption">
1132
      <xsl:apply-templates select="@*"/>
1133
      <xsl:call-template name="block-level"/>
1134
      <xsl:apply-templates select="*"/>
1135
   </xsl:template>
1136

    
1137

    
1138
   <!-- =================================== -->
1139
<!-- Table                               -->
1140

    
1141
<xsl:template match="fo:table">
1142
      <xsl:apply-templates select="@*"/>
1143
      <xsl:call-template name="no-text"/>
1144

    
1145
      <xsl:apply-templates select="*[not(self::fo:table-column                                   or self::fo:table-header                                   or self::fo:table-footer                                   or self::fo:table-body                                   or self::fo:marker)]"
1146
                           mode="report-intrusive-elements">
1147
         <xsl:with-param name="reason">Only 'table-column' elements, row group elements, and markers are permitted in this context.</xsl:with-param>
1148
      </xsl:apply-templates>
1149

    
1150
      <xsl:if test="not(fo:table-body)">
1151
         <xsl:call-template name="print-error">
1152
            <xsl:with-param name="msg">At least one 'table-body' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1153
         </xsl:call-template>
1154
      </xsl:if>
1155

    
1156
      <xsl:if test="count(fo:table-header) &gt; 1">
1157
         <xsl:call-template name="print-error">
1158
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:table-header[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1159
         </xsl:call-template>
1160
      </xsl:if>
1161

    
1162
      <xsl:if test="count(fo:table-footer) &gt; 1">
1163
         <xsl:call-template name="print-error">
1164
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:table-footer[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1165
         </xsl:call-template>
1166
      </xsl:if>
1167

    
1168
      <xsl:if test="fo:table-column[preceding-sibling::*[not(self::fo:table-column or self::fo:marker)]]">
1169
         <xsl:call-template name="print-error">
1170
            <xsl:with-param name="msg">'<xsl:value-of select="name(fo:table-column[1])"/>' elements should be located before any other element in '<xsl:value-of select="name()"/>'. </xsl:with-param>
1171
         </xsl:call-template>
1172
      </xsl:if>
1173

    
1174
      <xsl:if test="fo:table-header[preceding-sibling::fo:table-footer]">
1175
         <xsl:call-template name="print-error">
1176
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:table-header[1])"/>' should be located before '<xsl:value-of select="name(fo:table-footer[1])"/>' in '<xsl:value-of select="name()"/>'. </xsl:with-param>
1177
         </xsl:call-template>
1178
      </xsl:if>
1179

    
1180
      <xsl:if test="fo:table-header[preceding-sibling::fo:table-body]">
1181
         <xsl:call-template name="print-error">
1182
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:table-header[1])"/>' should be located before '<xsl:value-of select="name(fo:table-body[1])"/>' in '<xsl:value-of select="name()"/>'. </xsl:with-param>
1183
         </xsl:call-template>
1184
      </xsl:if>
1185

    
1186
      <xsl:if test="fo:table-body[following-sibling::*[not(self::fo:table-body)]]">
1187
         <xsl:call-template name="print-error">
1188
            <xsl:with-param name="msg">'<xsl:value-of select="name(fo:table-body[1])"/>' elements should be located last in '<xsl:value-of select="name()"/>'. </xsl:with-param>
1189
         </xsl:call-template>
1190
      </xsl:if>
1191

    
1192
      <xsl:apply-templates select="*"/>
1193
   </xsl:template>
1194

    
1195

    
1196
   <!-- =================================== -->
1197
<!-- Row group elements                  -->
1198

    
1199
<xsl:template match="fo:table-body | fo:table-header | fo:table-footer">
1200
      <xsl:apply-templates select="@*"/>
1201
      <xsl:call-template name="no-text"/>
1202

    
1203
      <xsl:apply-templates select="*[not(self::fo:table-row                                   or self::fo:table-cell                                   or self::fo:marker)]"
1204
                           mode="report-intrusive-elements">
1205
         <xsl:with-param name="reason">Only 'table-row', 'table-cell', or 'marker' elements are permitted in this context.</xsl:with-param>
1206
      </xsl:apply-templates>
1207

    
1208
      <xsl:if test="$strictness &gt; 0">
1209
         <xsl:if test="not (*)">
1210
            <xsl:call-template name="print-error">
1211
               <xsl:with-param name="msg">Empty '<xsl:value-of select="name()"/>'. </xsl:with-param>
1212
            </xsl:call-template>
1213
         </xsl:if>
1214
      </xsl:if>
1215

    
1216
      <xsl:if test="fo:table-row and fo:table-cell">
1217
         <xsl:call-template name="print-error">
1218
            <xsl:with-param name="msg">'<xsl:value-of select="name(fo:table-row[1])"/>' and '<xsl:value-of select="name(fo:table-cell[1])"/>' elements should not be mixed inside '<xsl:value-of select="name()"/>' element. </xsl:with-param>
1219
         </xsl:call-template>
1220
      </xsl:if>
1221

    
1222
      <xsl:apply-templates select="*"/>
1223
   </xsl:template>
1224

    
1225

    
1226
   <!-- =================================== -->
1227
<!-- Table-row                           -->
1228

    
1229
<xsl:template match="fo:table-row">
1230
      <xsl:apply-templates select="@*"/>
1231
      <xsl:call-template name="no-text"/>
1232

    
1233
      <xsl:apply-templates select="*[not(self::fo:table-cell)]" mode="report-intrusive-elements">
1234
         <xsl:with-param name="reason">Only 'table-cell' elements are permitted in this context.</xsl:with-param>
1235
      </xsl:apply-templates>
1236

    
1237
      <xsl:if test="not(parent::fo:table-body or parent::fo:table-header or parent::fo:table-footer)">
1238
         <xsl:call-template name="print-error">
1239
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be wrapped in 'table-body', 'table-header', or 'table-footer'. </xsl:with-param>
1240
         </xsl:call-template>
1241
      </xsl:if>
1242

    
1243
      <xsl:apply-templates select="*"/>
1244
   </xsl:template>
1245

    
1246
   <!-- =================================== -->
1247
<!-- Table-cell                          -->
1248

    
1249
<xsl:template match="fo:table-cell">
1250
      <xsl:apply-templates select="@*"/>
1251
      <xsl:call-template name="block-level"/>
1252
      <xsl:apply-templates select="*"/>
1253
   </xsl:template>
1254

    
1255

    
1256
   <!-- =================================== -->
1257
<!-- List-block                          -->
1258

    
1259
<xsl:template match="fo:list-block">
1260
      <xsl:apply-templates select="@*"/>
1261
      <xsl:call-template name="no-text"/>
1262

    
1263
      <xsl:apply-templates select="*[not(self::fo:list-item or self::fo:marker)]"
1264
                           mode="report-intrusive-elements">
1265
         <xsl:with-param name="reason">Only 'list-item' or 'marker' elements are permitted in this context.</xsl:with-param>
1266
      </xsl:apply-templates>
1267

    
1268
      <xsl:apply-templates select="*"/>
1269
   </xsl:template>
1270

    
1271

    
1272
   <!-- =================================== -->
1273
<!-- List-item                           -->
1274

    
1275
<xsl:template match="fo:list-item">
1276
      <xsl:apply-templates select="@*"/>
1277
      <xsl:call-template name="no-text"/>
1278

    
1279
      <xsl:apply-templates select="*[not(self::fo:list-item-label                                   or self::fo:list-item-body                                   or self::fo:marker)]"
1280
                           mode="report-intrusive-elements">
1281
         <xsl:with-param name="reason">Element '<xsl:value-of select="name()"/>' shall consist of one 'list-item-label' and one 'list-item-body'.</xsl:with-param>
1282
      </xsl:apply-templates>
1283

    
1284
      <xsl:if test="not(parent::fo:list-block)">
1285
         <xsl:call-template name="print-error">
1286
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a child of 'list-block'. </xsl:with-param>
1287
         </xsl:call-template>
1288
      </xsl:if>
1289

    
1290
      <xsl:if test="not(fo:list-item-label)">
1291
         <xsl:call-template name="print-error">
1292
            <xsl:with-param name="msg">Element 'list-item-label' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1293
         </xsl:call-template>
1294
      </xsl:if>
1295

    
1296
      <xsl:if test="not(fo:list-item-body)">
1297
         <xsl:call-template name="print-error">
1298
            <xsl:with-param name="msg">Element 'list-item-body' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1299
         </xsl:call-template>
1300
      </xsl:if>
1301

    
1302
      <xsl:if test="count(fo:list-item-label) &gt; 1">
1303
         <xsl:call-template name="print-error">
1304
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:list-item-label[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1305
         </xsl:call-template>
1306
      </xsl:if>
1307

    
1308
      <xsl:if test="count(fo:list-item-body) &gt; 1">
1309
         <xsl:call-template name="print-error">
1310
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:list-item-body[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1311
         </xsl:call-template>
1312
      </xsl:if>
1313

    
1314
      <xsl:if test="fo:list-item-body[following-sibling::fo:list-item-label]">
1315
         <xsl:call-template name="print-error">
1316
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:list-item-label[1])"/>' must precede '<xsl:value-of select="name(fo:list-item-body[1])"/>' inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1317
         </xsl:call-template>
1318
      </xsl:if>
1319

    
1320
      <xsl:if test="fo:list-item-label and not (fo:list-item-label/@start-indent)                                    and not (fo:list-item-label/@margin)                                    and not (fo:list-item-label/@margin-left)                                    and not (fo:list-item-label/@margin-right)                                    and not (fo:list-item-label/@margin-top)                                    and not (fo:list-item-label/@margin-bottom)              and fo:list-item-body and not (fo:list-item-body/@start-indent)                                    and not (fo:list-item-body/@margin)                                    and not (fo:list-item-body/@margin-left)                                    and not (fo:list-item-body/@margin-right)                                    and not (fo:list-item-body/@margin-top)                                    and not (fo:list-item-body/@margin-bottom)">
1321
         <xsl:call-template name="print-warning">
1322
            <xsl:with-param name="msg">Start-indent is not specified neither on '<xsl:value-of select="name(fo:list-item-label[1])"/>' nor on '<xsl:value-of select="name(fo:list-item-body[1])"/>': list subcomponents will overlap</xsl:with-param>
1323
         </xsl:call-template>
1324
      </xsl:if>
1325

    
1326
      <xsl:if test="fo:list-item-label and not (fo:list-item-label/@end-indent)                                    and not (fo:list-item-label/@margin)                                    and not (fo:list-item-label/@margin-left)                                    and not (fo:list-item-label/@margin-right)                                    and not (fo:list-item-label/@margin-top)                                    and not (fo:list-item-label/@margin-bottom)              and fo:list-item-body and not (fo:list-item-body/@end-indent)                                    and not (fo:list-item-body/@margin)                                    and not (fo:list-item-body/@margin-left)                                    and not (fo:list-item-body/@margin-right)                                    and not (fo:list-item-body/@margin-top)                                    and not (fo:list-item-body/@margin-bottom)">
1327
         <xsl:call-template name="print-warning">
1328
            <xsl:with-param name="msg">End-indent is not specified neither on '<xsl:value-of select="name(fo:list-item-label[1])"/>' nor on '<xsl:value-of select="name(fo:list-item-body[1])"/>': list subcomponents will overlap</xsl:with-param>
1329
         </xsl:call-template>
1330
      </xsl:if>
1331

    
1332
      <xsl:apply-templates select="*"/>
1333
   </xsl:template>
1334

    
1335

    
1336
   <!-- =================================== -->
1337
<!-- List item subcomponents             -->
1338

    
1339
<xsl:template match="fo:list-item-label | fo:list-item-body">
1340
      <xsl:apply-templates select="@*"/>
1341
      <xsl:call-template name="block-level"/>
1342
      <xsl:apply-templates select="*"/>
1343
   </xsl:template>
1344

    
1345

    
1346
   <!-- =================================== -->
1347
<!-- Footnote                            -->
1348

    
1349
<xsl:template match="fo:footnote">
1350
      <xsl:apply-templates select="@*"/>
1351
      <xsl:call-template name="no-text"/>
1352
      <xsl:call-template name="out-of-line"/>
1353

    
1354
      <xsl:apply-templates select="*[not(self::fo:inline                                   or self::fo:footnote-body)]"
1355
                           mode="report-intrusive-elements">
1356
         <xsl:with-param name="reason">Element '<xsl:value-of select="name()"/>' shall consist of one 'inline' and one 'footnote-body'.</xsl:with-param>
1357
      </xsl:apply-templates>
1358

    
1359
      <xsl:if test="not(fo:inline)">
1360
         <xsl:call-template name="print-error">
1361
            <xsl:with-param name="msg">Element 'inline' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1362
         </xsl:call-template>
1363
      </xsl:if>
1364

    
1365
      <xsl:if test="not(fo:footnote-body)">
1366
         <xsl:call-template name="print-error">
1367
            <xsl:with-param name="msg">Element 'footnote-body' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1368
         </xsl:call-template>
1369
      </xsl:if>
1370

    
1371
      <xsl:if test="count(fo:inline) &gt; 1">
1372
         <xsl:call-template name="print-error">
1373
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:inline[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1374
         </xsl:call-template>
1375
      </xsl:if>
1376

    
1377
      <xsl:if test="count(fo:footnote-body) &gt; 1">
1378
         <xsl:call-template name="print-error">
1379
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:footnote-body[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1380
         </xsl:call-template>
1381
      </xsl:if>
1382

    
1383
      <xsl:if test="fo:footnote-body[following-sibling::fo:inline]">
1384
         <xsl:call-template name="print-error">
1385
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:inline[1])"/>' must precede '<xsl:value-of select="name(fo:footnote-body[1])"/>' inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1386
         </xsl:call-template>
1387
      </xsl:if>
1388

    
1389
      <xsl:for-each select="fo:inline">
1390
         <xsl:call-template name="inline-level"/>
1391
      </xsl:for-each>
1392

    
1393
      <xsl:apply-templates select="*"/>
1394
   </xsl:template>
1395

    
1396

    
1397
   <!-- =================================== -->
1398
<!-- Footnote-body                       -->
1399

    
1400
<xsl:template match="fo:footnote-body">
1401
      <xsl:apply-templates select="@*"/>
1402
      <xsl:call-template name="block-level"/>
1403
      <xsl:apply-templates select="*"/>
1404
   </xsl:template>
1405

    
1406

    
1407
   <!-- =================================== -->
1408
<!-- Float                               -->
1409

    
1410
<xsl:template match="fo:float">
1411
      <xsl:apply-templates select="@*"/>
1412
      <xsl:call-template name="block-level"/>
1413
      <xsl:call-template name="out-of-line"/>
1414
      <xsl:apply-templates select="*"/>
1415
   </xsl:template>
1416

    
1417

    
1418
   <!-- =================================== -->
1419
<!-- Wrapper                             -->
1420

    
1421
<xsl:template match="fo:wrapper">
1422
      <xsl:apply-templates select="@*"/>
1423
      <xsl:call-template name="mixed-level"/>
1424
      <xsl:apply-templates select="*"/>
1425
   </xsl:template>
1426

    
1427

    
1428
   <!-- === =============================== -->
1429
<!-- Marker                              -->
1430

    
1431
<xsl:template match="fo:marker">
1432
      <xsl:apply-templates select="@*"/>
1433
      <xsl:call-template name="mixed-level"/>
1434

    
1435
      <xsl:choose>
1436
         <xsl:when test="not(@marker-class-name)">
1437
            <xsl:call-template name="print-error">
1438
               <xsl:with-param name="msg">Attribute 'marker-class-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1439
            </xsl:call-template>
1440
         </xsl:when>
1441
         <xsl:otherwise>
1442
            <xsl:variable name="marker-class-name" select="@marker-class-name"/>
1443
            <xsl:if test="preceding-sibling::fo:marker[@marker-class-name=$marker-class-name]">
1444
               <xsl:call-template name="print-error">
1445
                  <xsl:with-param name="msg">Sibling <xsl:value-of select="name()"/> elements have the same value of 'marker-class-name' attribute ("<xsl:value-of select="@marker-class-name"/>"). </xsl:with-param>
1446
               </xsl:call-template>
1447
            </xsl:if>
1448
         </xsl:otherwise>
1449
      </xsl:choose>
1450

    
1451
      <xsl:if test="preceding-sibling::*[not(self::fo:marker)]">
1452
         <xsl:call-template name="print-error">
1453
            <xsl:with-param name="msg">'<xsl:value-of select="name()"/>' elements should be initial children of their parents. </xsl:with-param>
1454
         </xsl:call-template>
1455
      </xsl:if>
1456

    
1457
      <xsl:if test="preceding-sibling::text()[normalize-space() != '']">
1458
         <xsl:call-template name="print-error">
1459
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be preceded by non-space text nodes. </xsl:with-param>
1460
         </xsl:call-template>
1461
      </xsl:if>
1462

    
1463
      <xsl:if test="not(ancestor::fo:flow)">
1464
         <xsl:call-template name="print-error">
1465
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a descendant of 'flow'. </xsl:with-param>
1466
         </xsl:call-template>
1467
      </xsl:if>
1468

    
1469
      <xsl:if test="ancestor::fo:multi-case">
1470
         <xsl:call-template name="print-error">
1471
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be used inside '<xsl:value-of select="name(ancestor::fo:multi-case[1])"/>'. </xsl:with-param>
1472
         </xsl:call-template>
1473
      </xsl:if>
1474

    
1475
      <xsl:if test="ancestor::fo:float">
1476
         <xsl:call-template name="print-error">
1477
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be used inside '<xsl:value-of select="name(ancestor::fo:float[1])"/>'. </xsl:with-param>
1478
         </xsl:call-template>
1479
      </xsl:if>
1480

    
1481
      <xsl:if test="ancestor::fo:footnote">
1482
         <xsl:call-template name="print-error">
1483
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be used inside '<xsl:value-of select="name(ancestor::fo:footnote[1])"/>'. </xsl:with-param>
1484
         </xsl:call-template>
1485
      </xsl:if>
1486

    
1487
      <xsl:apply-templates select="*"/>
1488
   </xsl:template>
1489

    
1490
   <!-- === =============================== -->
1491
<!-- Retrieve-marker                     -->
1492

    
1493
<xsl:template match="fo:retrieve-marker">
1494
      <xsl:apply-templates select="@*"/>
1495
      <xsl:call-template name="empty-element"/>
1496

    
1497
      <xsl:if test="not(@retrieve-class-name)">
1498
         <xsl:call-template name="print-error">
1499
            <xsl:with-param name="msg">Attribute 'retrieve-class-name' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1500
         </xsl:call-template>
1501
      </xsl:if>
1502

    
1503
      <xsl:if test="not(ancestor::fo:static-content)">
1504
         <xsl:call-template name="print-error">
1505
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a descendant of 'static-content'. </xsl:with-param>
1506
         </xsl:call-template>
1507
      </xsl:if>
1508
   </xsl:template>
1509

    
1510

    
1511
   <!-- === =============================== -->
1512
<!-- Basic-link                          -->
1513

    
1514
<xsl:template match="fo:basic-link">
1515
      <xsl:apply-templates select="@*"/>
1516
      <xsl:call-template name="mixed-level"/>
1517

    
1518
      <xsl:if test="not(@internal-destination or @external-destination)">
1519
         <xsl:call-template name="print-error">
1520
            <xsl:with-param name="msg">Either 'internal-destination' or 'external-destination' attribute must be present on '<xsl:value-of select="name()"/>'. </xsl:with-param>
1521
         </xsl:call-template>
1522
      </xsl:if>
1523

    
1524
      <xsl:if test="@internal-destination and @external-destination">
1525
         <xsl:call-template name="print-error">
1526
            <xsl:with-param name="msg">Only one of 'internal-destination' or 'external-destination' attributes can be present on '<xsl:value-of select="name()"/>'. </xsl:with-param>
1527
         </xsl:call-template>
1528
      </xsl:if>
1529

    
1530
      <xsl:apply-templates select="*"/>
1531
   </xsl:template>
1532

    
1533

    
1534
   <!-- =================================== -->
1535
<!-- Multi-switch                        -->
1536

    
1537
<xsl:template match="fo:multi-switch">
1538
      <xsl:apply-templates select="@*"/>
1539
      <xsl:call-template name="no-text"/>
1540

    
1541
      <xsl:apply-templates select="*[not(self::fo:multi-case)]" mode="report-intrusive-elements">
1542
         <xsl:with-param name="reason">Only 'multi-case' elements are permitted in this context.</xsl:with-param>
1543
      </xsl:apply-templates>
1544

    
1545
      <xsl:apply-templates select="*"/>
1546
   </xsl:template>
1547

    
1548

    
1549
   <!-- =================================== -->
1550
<!-- Multi-case                          -->
1551

    
1552
<xsl:template match="fo:multi-case">
1553
      <xsl:apply-templates select="@*"/>
1554
      <xsl:call-template name="mixed-level"/>
1555
      <xsl:if test="not(parent::fo:multi-switch)">
1556
         <xsl:call-template name="print-error">
1557
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a child of 'multi-switch'. </xsl:with-param>
1558
         </xsl:call-template>
1559
      </xsl:if>
1560
      <xsl:apply-templates select="*"/>
1561
   </xsl:template>
1562

    
1563

    
1564
   <!-- ===================================== -->
1565
<!-- Multi-toggle                          -->
1566

    
1567
<xsl:template match="fo:multi-toggle">
1568
      <xsl:apply-templates select="@*"/>
1569
      <xsl:call-template name="mixed-level"/>
1570

    
1571
      <xsl:if test="not(ancestor::fo:multi-case)">
1572
         <xsl:call-template name="print-error">
1573
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' can be used only inside 'multi-case'. </xsl:with-param>
1574
         </xsl:call-template>
1575
      </xsl:if>
1576

    
1577
      <xsl:apply-templates select="*"/>
1578
   </xsl:template>
1579

    
1580

    
1581
   <!-- ===================================== -->
1582
<!-- Multi-properties                    -->
1583

    
1584
<xsl:template match="fo:multi-properties">
1585
      <xsl:apply-templates select="@*"/>
1586
      <xsl:call-template name="no-text"/>
1587

    
1588
      <xsl:apply-templates select="*[not(self::fo:multi-property-set                                   or self::fo:wrapper)]"
1589
                           mode="report-intrusive-elements">
1590
         <xsl:with-param name="reason">Element '<xsl:value-of select="name()"/>' shall consist of one or more 'multi-property-set' elements, followed by a 'wrapper'.</xsl:with-param>
1591
      </xsl:apply-templates>
1592

    
1593
      <xsl:if test="not(fo:multi-property-set)">
1594
         <xsl:call-template name="print-error">
1595
            <xsl:with-param name="msg">At least one 'multi-property-set' element should be specified in '<xsl:value-of select="name()"/>'. </xsl:with-param>
1596
         </xsl:call-template>
1597
      </xsl:if>
1598

    
1599
      <xsl:if test="not(fo:wrapper)">
1600
         <xsl:call-template name="print-error">
1601
            <xsl:with-param name="msg">Element 'wrapper' is required inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1602
         </xsl:call-template>
1603
      </xsl:if>
1604

    
1605
      <xsl:if test="count(fo:wrapper) &gt; 1">
1606
         <xsl:call-template name="print-error">
1607
            <xsl:with-param name="msg">There can be only one '<xsl:value-of select="name(fo:wrapper[1])"/>' element inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1608
         </xsl:call-template>
1609
      </xsl:if>
1610

    
1611
      <xsl:if test="fo:wrapper[following-sibling::fo:multi-property-set]">
1612
         <xsl:call-template name="print-error">
1613
            <xsl:with-param name="msg">Element '<xsl:value-of select="name(fo:wrapper[1])"/>' must be located after all '<xsl:value-of select="name(fo:multi-property-set[1])"/>' elements inside '<xsl:value-of select="name()"/>'. </xsl:with-param>
1614
         </xsl:call-template>
1615
      </xsl:if>
1616

    
1617
      <xsl:apply-templates select="*"/>
1618
   </xsl:template>
1619

    
1620

    
1621
   <!-- ===================================== -->
1622
<!-- Multi-property-set                    -->
1623

    
1624
<xsl:template match="fo:multi-property-set">
1625
      <xsl:apply-templates select="@*"/>
1626
      <xsl:call-template name="empty-element"/>
1627

    
1628
      <xsl:if test="not(@active-state)">
1629
         <xsl:call-template name="print-error">
1630
            <xsl:with-param name="msg">Attribute 'active-state' is required for '<xsl:value-of select="name()"/>'. </xsl:with-param>
1631
         </xsl:call-template>
1632
      </xsl:if>
1633

    
1634
      <xsl:if test="not(parent::fo:multi-properties)">
1635
         <xsl:call-template name="print-error">
1636
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a child of 'multi-properties'. </xsl:with-param>
1637
         </xsl:call-template>
1638
      </xsl:if>
1639

    
1640
   </xsl:template>
1641

    
1642

    
1643
   <!-- =================================== -->
1644
<!-- Common structure-checking templates -->
1645

    
1646
<!-- Check for block-level elements         -->
1647

    
1648
<xsl:template name="block-level">
1649
      <xsl:call-template name="no-text">
1650
         <xsl:with-param name="reason">Only block-level elements are permitted in this context.</xsl:with-param>
1651
      </xsl:call-template>
1652

    
1653
      <xsl:apply-templates select="*[not(self::fo:block                                   or self::fo:block-container                                   or self::fo:list-block                                   or self::fo:table                                   or self::fo:table-and-caption                                   or self::fo:float                                   or self::fo:wrapper                                   or self::fo:marker                                   or self::fo:retrieve-marker                                   or self::fo:multi-switch                                   or self::fo:multi-properties                                   or self::rx:ruler                                   or self::rx:begin-index-range                                   or self::rx:end-index-range                                   or self::rx:flow-section)]"
1654
                           mode="report-intrusive-elements-block">
1655
         <xsl:with-param name="reason">Only block-level elements are permitted in this context.</xsl:with-param>
1656
      </xsl:apply-templates>
1657
      <xsl:for-each select="fo:wrapper | fo:multi-switch/fo:multi-case | fo:multi-properties">
1658
         <xsl:call-template name="block-level"/>
1659
      </xsl:for-each>
1660
   </xsl:template>
1661

    
1662

    
1663
   <!-- Check for inline-level elements         -->
1664

    
1665
<xsl:template name="inline-level">
1666
      <xsl:apply-templates select="*[not(self::fo:bidi-override                                   or self::fo:character                                   or self::fo:external-graphic                                   or self::fo:instream-foreign-object                                   or self::fo:inline                                   or self::fo:inline-container                                   or self::fo:leader                                   or self::fo:page-number                                   or self::fo:page-number-citation                                   or self::fo:basic-link                                   or self::fo:multi-toggle                                   or self::fo:footnote                                   or self::fo:float                                   or self::fo:wrapper                                   or self::fo:marker                                   or self::fo:retrieve-marker                                   or self::fo:multi-switch                                   or self::fo:multi-properties                                  or self::rx:page-index                                   or self::rx:page-number-citation-last                                   or self::rx:page-index                                   or self::rx:begin-index-range                                   or self::rx:end-index-range                                   or self::rx:pinpoint)]"
1667
                           mode="report-intrusive-elements-inline">
1668
         <xsl:with-param name="reason">Only inline-level elements are permitted in this context.</xsl:with-param>
1669
      </xsl:apply-templates>
1670
      <xsl:for-each select="fo:wrapper | fo:multi-switch/fo:multi-case | fo:multi-properties | fo:multi-toggle | fo:inline | fo:basic-link | fo:bidi-override">
1671
         <xsl:call-template name="inline-level"/>
1672
      </xsl:for-each>
1673
   </xsl:template>
1674

    
1675

    
1676
   <!-- Check for mixed-level elements         -->
1677

    
1678
<xsl:template name="mixed-level">
1679
      <xsl:apply-templates select="*[not(self::fo:block                                   or self::fo:block-container                                   or self::fo:list-block                                   or self::fo:table                                   or self::fo:table-and-caption                                   or self::fo:bidi-override                                   or self::fo:character                                   or self::fo:external-graphic                                   or self::fo:initial-property-set                                   or self::fo:instream-foreign-object                                   or self::fo:inline                                   or self::fo:inline-container                                   or self::fo:leader                                   or self::fo:page-number                                   or self::fo:page-number-citation                                   or self::fo:basic-link                                   or self::fo:multi-toggle                                   or self::fo:footnote                                   or self::fo:float                                   or self::fo:wrapper                                   or self::fo:marker                                   or self::fo:retrieve-marker                                   or self::fo:multi-switch                                   or self::fo:multi-properties                                   or self::rx:page-number-citation-last                                   or self::rx:page-index                                   or self::rx:begin-index-range                                   or self::rx:end-index-range                                   or self::rx:pinpoint)]"
1680
                           mode="report-intrusive-elements-block">
1681
         <xsl:with-param name="reason">Only block-level or inline-level elements are permitted in this context.</xsl:with-param>
1682
      </xsl:apply-templates>
1683
      <xsl:for-each select="fo:wrapper | fo:multi-switch/fo:multi-case | fo:multi-properties">
1684
         <xsl:call-template name="mixed-level"/>
1685
      </xsl:for-each>
1686
   </xsl:template>
1687

    
1688

    
1689
   <!-- Check constraints applicable to out-of-line elements  -->
1690

    
1691
<xsl:template name="out-of-line">
1692
      <xsl:if test="not(ancestor::fo:flow)">
1693
         <xsl:call-template name="print-error">
1694
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' should be a descendant of 'flow'. </xsl:with-param>
1695
         </xsl:call-template>
1696
      </xsl:if>
1697

    
1698
      <xsl:if test="ancestor::fo:float">
1699
         <xsl:call-template name="print-error">
1700
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be a descendant of '<xsl:value-of select="name(ancestor::fo:float[1])"/>'. </xsl:with-param>
1701
         </xsl:call-template>
1702
      </xsl:if>
1703

    
1704
      <xsl:if test="ancestor::fo:footnote-body">
1705
         <xsl:call-template name="print-error">
1706
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be a descendant of '<xsl:value-of select="name(ancestor::fo:footnote-body[1])"/>'. </xsl:with-param>
1707
         </xsl:call-template>
1708
      </xsl:if>
1709

    
1710
      <xsl:if test="ancestor::fo:marker">
1711
         <xsl:call-template name="print-error">
1712
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be a descendant of '<xsl:value-of select="name(ancestor::fo:marker[1])"/>'. </xsl:with-param>
1713
         </xsl:call-template>
1714
      </xsl:if>
1715

    
1716
      <xsl:if test="ancestor::*[@position='absolute' or @absolute-position='absolute'                          or @position='fixed' or @absolute-position='fixed']">
1717
         <xsl:call-template name="print-error">
1718
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' cannot be a descendant of an absolutely positioned
1719
      '<xsl:value-of select="name(ancestor::*[@position='absolute' or @absolute-position='absolute'                                            or @position='fixed' or @absolute-position='fixed'][1])"/>'. </xsl:with-param>
1720
         </xsl:call-template>
1721
      </xsl:if>
1722
   </xsl:template>
1723

    
1724
   <!-- =================================== -->
1725
<!-- Auxiliary templates                 -->
1726

    
1727

    
1728
<!-- Check for non-blank #PCDATA -->
1729

    
1730
<xsl:template name="no-text">
1731
      <xsl:param name="reason" select="''"/>
1732

    
1733
      <xsl:if test="text()[normalize-space(.) != '']">
1734
         <xsl:call-template name="print-error">
1735
            <xsl:with-param name="msg">
1736
        Element '<xsl:value-of select="name()"/>' cannot have
1737
	non-empty text descendants here. <xsl:value-of select="text()[normalize-space(.) != '']"/>
1738
               <xsl:if test="$reason != ''">
1739
                  <xsl:value-of select="$reason"/>
1740
               </xsl:if>
1741
            </xsl:with-param>
1742
         </xsl:call-template>
1743
      </xsl:if>
1744
   </xsl:template>
1745

    
1746

    
1747
   <!-- Check for element being EMPTY -->
1748

    
1749
<xsl:template name="empty-element">
1750
      <xsl:if test="* | text()">
1751
         <xsl:call-template name="print-error">
1752
            <xsl:with-param name="msg">Element '<xsl:value-of select="name()"/>' must be empty. </xsl:with-param>
1753
         </xsl:call-template>
1754
      </xsl:if>
1755
   </xsl:template>
1756

    
1757

    
1758

    
1759
   <!-- Report an element that may not be present in a given point -->
1760

    
1761
<xsl:template match="*" mode="report-intrusive-elements" priority="-1">
1762
      <xsl:param name="reason" select="''"/>
1763
      <xsl:variable name="uri" select="namespace-uri()"/>
1764

    
1765
      <xsl:choose>
1766
         <xsl:when test="$uri='http://www.w3.org/1999/XSL/Format'                  or $uri='http://www.renderx.com/XSL/Extensions'">
1767
            <xsl:call-template name="print-error">
1768
               <xsl:with-param name="msg">
1769
           Element '<xsl:value-of select="name()"/>' cannot be a child of '<xsl:value-of select="name(..)"/>'.
1770
           <xsl:if test="$reason != ''">
1771
                     <xsl:value-of select="$reason"/>
1772
                  </xsl:if>
1773
               </xsl:with-param>
1774
            </xsl:call-template>
1775
         </xsl:when>
1776
         <xsl:when test="$uri = ''">
1777
            <xsl:call-template name="print-error">
1778
               <xsl:with-param name="msg">
1779
          Element '<xsl:value-of select="name()"/>' belonging to the anonymous namespace cannot occur in an XSL-FO document outside 'instream-foreign-object' elements.
1780
        </xsl:with-param>
1781
            </xsl:call-template>
1782
         </xsl:when>
1783
         <xsl:when test="$uri = 'http://www.w3.org/2000/svg'">
1784
            <xsl:if test="$strictness &gt; 0">
1785
               <xsl:call-template name="print-warning">
1786
                  <xsl:with-param name="msg">
1787
            SVG element '<xsl:value-of select="name()"/>' is located outside 'instream-foreign-object' element.
1788
          </xsl:with-param>
1789
               </xsl:call-template>
1790
            </xsl:if>
1791
         </xsl:when>
1792
         <xsl:otherwise>
1793
            <xsl:if test="$strictness &gt; 1">
1794
               <xsl:call-template name="print-warning">
1795
                  <xsl:with-param name="msg">
1796
             Element '<xsl:value-of select="name()"/>' belongs to an unknown namespace <xsl:value-of select="$uri"/>
1797
                  </xsl:with-param>
1798
               </xsl:call-template>
1799
            </xsl:if>
1800
         </xsl:otherwise>
1801
      </xsl:choose>
1802
   </xsl:template>
1803

    
1804
   <xsl:template match="*" mode="report-intrusive-elements-block" priority="-1">
1805
      <xsl:param name="reason"/>
1806

    
1807
      <xsl:apply-templates select="." mode="report-intrusive-elements">
1808
         <xsl:with-param name="reason" select="$reason"/>
1809
      </xsl:apply-templates>
1810
   </xsl:template>
1811

    
1812
   <xsl:template match="*" mode="report-intrusive-elements-inline" priority="-1">
1813
      <xsl:param name="reason"/>
1814

    
1815
      <xsl:apply-templates select="." mode="report-intrusive-elements">
1816
         <xsl:with-param name="reason" select="$reason"/>
1817
      </xsl:apply-templates>
1818
   </xsl:template>
1819

    
1820

    
1821
   <!-- Special case: report an invalid element contained in a wrapper -->
1822

    
1823
<xsl:template match="fo:wrapper/*                    | fo:multi-properties/*                    | fo:multi-case/*"
1824
                 mode="report-intrusive-elements-block">
1825
      <xsl:param name="reason" select="''"/>
1826

    
1827
      <xsl:call-template name="print-error">
1828
         <xsl:with-param name="msg">
1829
      Element '<xsl:value-of select="name()"/>' cannot be a descendant of '<xsl:value-of select="name(ancestor::*[not(self::fo:wrapper or self::fo:multi-switch or self::fo:multi-case or self::fo:multi-properties)][1])"/>' through wrapper elements.
1830
      <xsl:if test="$reason != ''">
1831
               <xsl:value-of select="$reason"/>
1832
            </xsl:if>
1833
         </xsl:with-param>
1834
      </xsl:call-template>
1835
   </xsl:template>
1836

    
1837
   <xsl:template match="fo:wrapper/*                    | fo:inline/*                    | fo:basic-link/*                    | fo:bidi-override/*                    | fo:multi-toggle/*                    | fo:multi-properties/*                    | fo:multi-case/*"
1838
                 mode="report-intrusive-elements-inline">
1839
      <xsl:param name="reason" select="''"/>
1840

    
1841
      <xsl:call-template name="print-error">
1842
         <xsl:with-param name="msg">
1843
      Element '<xsl:value-of select="name()"/>' cannot be a descendant of '<xsl:value-of select="name(ancestor::*[not(self::fo:wrapper or self::fo:multi-switch or self::fo:multi-case or self::fo:multi-toggle or self::fo:multi-properties or self::fo:inline)][1])"/>' through wrapper or inline elements.
1844
      <xsl:if test="$reason != ''">
1845
               <xsl:value-of select="$reason"/>
1846
            </xsl:if>
1847
         </xsl:with-param>
1848
      </xsl:call-template>
1849
   </xsl:template>
1850

    
1851

    
1852
   <!-- Default rules -->
1853

    
1854
<xsl:template match="*" priority="-1"/>
1855
   <xsl:template match="text()"/>
1856

    
1857

    
1858
   <!-- ##################################################################### -->
1859
<!-- Processing of attributes.                                             -->
1860
<!-- ##################################################################### -->
1861

    
1862
<!-- Report any attribute not covered by enabling templates -->
1863

    
1864
<xsl:template match="@*" priority="-2">
1865
      <xsl:call-template name="complain-attribute"/>
1866
   </xsl:template>
1867

    
1868
   <!-- Report any attribute in fo:layout-master-set etc. as invalid.         -->
1869
<!-- This is overridden by a rule with higher priority for those (few)     -->
1870
<!-- properties that actually may occur in these special positions         -->
1871

    
1872
<xsl:template match="@*[not (parent::fo:root)                     and not (ancestor::fo:page-sequence)                     and not (parent::*/parent::fo:simple-page-master)]"
1873
                 priority="4">
1874
      <xsl:call-template name="complain-attribute"/>
1875
   </xsl:template>
1876

    
1877
   <xsl:template match="fo:simple-page-master/*/@*" priority="2">
1878
      <xsl:call-template name="complain-attribute"/>
1879
   </xsl:template>
1880

    
1881
   <xsl:template name="complain-attribute">
1882
      <xsl:variable name="uri" select="namespace-uri()"/>
1883

    
1884
      <xsl:choose>
1885
    <!-- Ignore attributes from XML namespace - xml:space, xml:base, etc. -->
1886
    <xsl:when test="$uri='http://www.w3.org/XML/1998/namespace'"/> 
1887
         <xsl:when test="$uri=''                  or $uri='http://www.w3.org/1999/XSL/Format'                  or $uri='http://www.renderx.com/XSL/Extensions'">
1888
            <xsl:call-template name="print-error">
1889
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot occur at element '<xsl:value-of select="name(..)"/>'. </xsl:with-param>
1890
            </xsl:call-template>
1891
         </xsl:when>
1892
         <xsl:otherwise>
1893
            <xsl:if test="$strictness &gt; 1">
1894
               <xsl:call-template name="print-warning">
1895
                  <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' at element '<xsl:value-of select="name(..)"/>' belongs to an unknown namespace <xsl:value-of select="$uri"/> 
1896
                  </xsl:with-param>
1897
               </xsl:call-template>
1898
            </xsl:if>
1899
         </xsl:otherwise>
1900
      </xsl:choose>
1901
   </xsl:template>
1902

    
1903
   <xsl:template name="disable-on-atomic-inlines">
1904
      <xsl:if test="parent::fo:character              or parent::fo:page-number              or parent::fo:page-number-citation              or parent::rx:page-number-citation-last              or parent::fo:initial-property-set">
1905
         <xsl:call-template name="complain-attribute"/>
1906
      </xsl:if>
1907
   </xsl:template>
1908

    
1909

    
1910
   <xsl:template name="disable-on-graphics">
1911
      <xsl:if test="parent::fo:external-graphic              or parent::fo:instream-foreign-object">
1912
         <xsl:call-template name="complain-attribute"/>
1913
      </xsl:if>
1914
   </xsl:template>
1915

    
1916
   <!-- Report a value not in a list. Expressions (recognized by the presence -->
1917
<!-- of parentheses or operators) are excluded from validation.            -->
1918

    
1919
<xsl:template name="enumerated-values">
1920
      <xsl:param name="valuelist"/>
1921
      <xsl:variable name="value" select="normalize-space(.)"/>
1922
      <xsl:choose>
1923
         <xsl:when test="contains($valuelist, concat(' ', $value, ' '))"/>
1924
         <xsl:when test="contains($value, '(') and contains ($value, ')')"/>
1925
         <xsl:otherwise>
1926
            <xsl:call-template name="print-error">
1927
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot have a value of "<xsl:value-of select="$value"/>". </xsl:with-param>
1928
            </xsl:call-template>
1929
         </xsl:otherwise>
1930
      </xsl:choose>
1931
   </xsl:template>
1932

    
1933
   <!-- Report a value that is not a valid number or length. Skips validation -->
1934
<!-- of attributes containing digits, parentheses, and math operators.     -->
1935

    
1936
<xsl:template name="quantitative-values">
1937
      <xsl:param name="valuelist"/>
1938
      <xsl:variable name="value" select="normalize-space(.)"/>
1939
      <xsl:choose>
1940
         <xsl:when test="contains($valuelist, concat(' ', $value, ' '))"/>
1941
         <xsl:when test="contains($value, '(') and contains ($value, ')')"/>
1942
         <xsl:when test="contains($value, '0')"/>
1943
         <xsl:when test="contains($value, '1')"/>
1944
         <xsl:when test="contains($value, '2')"/>
1945
         <xsl:when test="contains($value, '3')"/>
1946
         <xsl:when test="contains($value, '4')"/>
1947
         <xsl:when test="contains($value, '5')"/>
1948
         <xsl:when test="contains($value, '6')"/>
1949
         <xsl:when test="contains($value, '7')"/>
1950
         <xsl:when test="contains($value, '8')"/>
1951
         <xsl:when test="contains($value, '9')"/>
1952
         <xsl:when test="contains($value, '+')"/>
1953
         <xsl:when test="contains($value, ' - ')"/>
1954
         <xsl:when test="contains($value, '*')"/>
1955
         <xsl:when test="contains($value, ' div ')"/>
1956
         <xsl:when test="contains($value, ' mod ')"/>
1957
         <xsl:otherwise>
1958
            <xsl:call-template name="print-error">
1959
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot have a value of "<xsl:value-of select="$value"/>". </xsl:with-param>
1960
            </xsl:call-template>
1961
         </xsl:otherwise>
1962
      </xsl:choose>
1963
   </xsl:template>
1964

    
1965
   <!-- Check if a value is valid as a URL specifier -->
1966
<xsl:template name="check-url">
1967
      <xsl:variable name="val" select="normalize-space()"/>
1968
      <xsl:choose>
1969
         <xsl:when test="$val = 'inherit'"/>
1970
         <xsl:when test="starts-with($val, 'url(')                 and substring ($val, string-length($val)) = ')'"/>
1971
         <xsl:otherwise>
1972
            <xsl:call-template name="print-warning">
1973
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot have a value of "<xsl:value-of select="."/>": should be either 'inherit' or a URI: <xsl:value-of select="name()"/>="url(...)".</xsl:with-param>
1974
            </xsl:call-template>
1975
         </xsl:otherwise>
1976
      </xsl:choose>
1977
   </xsl:template>
1978

    
1979
   <!-- 7.3. Accessibility properties - ubiquitous; not validated -->
1980
<xsl:template match="@source-document" priority="5">
1981
      <xsl:variable name="val" select="normalize-space()"/>
1982
      <xsl:choose>
1983
         <xsl:when test="$val = 'inherit'"/>
1984
         <xsl:when test="$val = 'none'"/>
1985
         <xsl:when test="starts-with($val, 'url(')                 and substring ($val, string-length($val)) = ')'"/>
1986
         <xsl:otherwise>
1987
            <xsl:call-template name="print-error">
1988
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot have a value of "<xsl:value-of select="."/>": should be 'inherit', 'none', or one or more URIs: source="url(...) [url(...) ...]".</xsl:with-param>
1989
            </xsl:call-template>
1990
         </xsl:otherwise>
1991
      </xsl:choose>
1992
   </xsl:template>
1993

    
1994

    
1995
   <xsl:template match="@role" priority="5"/>
1996

    
1997
   <!-- 7.4. Absolute position -->
1998
<xsl:template match="fo:block-container/@absolute-position">
1999
      <xsl:call-template name="enumerated-values">
2000
         <xsl:with-param name="valuelist"> auto absolute fixed inherit </xsl:with-param>
2001
      </xsl:call-template>
2002
   </xsl:template>
2003

    
2004
   <xsl:template match="@top | @bottom | @left | @right">
2005
      <xsl:call-template name="quantitative-values">
2006
         <xsl:with-param name="valuelist"> auto inherit </xsl:with-param>
2007
      </xsl:call-template>
2008
   </xsl:template>
2009

    
2010
   <!-- 7.5. Aural properties. May happen everywhere in the flows. Not validated. -->
2011
<xsl:template match="@azimuth"/>
2012
   <xsl:template match="@cue-after"/>
2013
   <xsl:template match="@cue-before"/>
2014

    
2015
   <xsl:template match="@elevation">
2016
      <xsl:call-template name="quantitative-values">
2017
         <xsl:with-param name="valuelist"> below level above higher lower inherit </xsl:with-param>
2018
      </xsl:call-template>
2019
   </xsl:template>
2020

    
2021
   <xsl:template match="@pause-after | @pause-before">
2022
      <xsl:call-template name="quantitative-values">
2023
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2024
      </xsl:call-template>
2025
   </xsl:template>
2026

    
2027
   <xsl:template match="@pitch">
2028
      <xsl:call-template name="quantitative-values">
2029
         <xsl:with-param name="valuelist"> x-low low medium high x-high inherit </xsl:with-param>
2030
      </xsl:call-template>
2031
   </xsl:template>
2032

    
2033
   <xsl:template match="@pitch-range">
2034
      <xsl:call-template name="quantitative-values">
2035
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2036
      </xsl:call-template>
2037
   </xsl:template>
2038

    
2039
   <xsl:template match="@play-during"/>
2040

    
2041
   <xsl:template match="@richness">
2042
      <xsl:call-template name="quantitative-values">
2043
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2044
      </xsl:call-template>
2045
   </xsl:template>
2046

    
2047
   <xsl:template match="@speak">
2048
      <xsl:call-template name="enumerated-values">
2049
         <xsl:with-param name="valuelist"> normal none spell-out inherit </xsl:with-param>
2050
      </xsl:call-template>
2051
   </xsl:template>
2052

    
2053
   <xsl:template match="@speak-header">
2054
      <xsl:call-template name="enumerated-values">
2055
         <xsl:with-param name="valuelist"> once always inherit </xsl:with-param>
2056
      </xsl:call-template>
2057
   </xsl:template>
2058

    
2059
   <xsl:template match="@speak-numeral">
2060
      <xsl:call-template name="enumerated-values">
2061
         <xsl:with-param name="valuelist"> digits continuous inherit </xsl:with-param>
2062
      </xsl:call-template>
2063
   </xsl:template>
2064

    
2065
   <xsl:template match="@speak-punctuation">
2066
      <xsl:call-template name="enumerated-values">
2067
         <xsl:with-param name="valuelist"> code none inherit </xsl:with-param>
2068
      </xsl:call-template>
2069
   </xsl:template>
2070

    
2071
   <xsl:template match="@speech-rate">
2072
      <xsl:call-template name="quantitative-values">
2073
         <xsl:with-param name="valuelist"> x-slow slow medium fast x-fast faster slower inherit </xsl:with-param>
2074
      </xsl:call-template>
2075
   </xsl:template>
2076

    
2077
   <xsl:template match="@stress">
2078
      <xsl:call-template name="quantitative-values">
2079
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2080
      </xsl:call-template>
2081
   </xsl:template>
2082

    
2083
   <xsl:template match="@voice-family"/>
2084
   <xsl:template match="@volume">
2085
      <xsl:call-template name="quantitative-values">
2086
         <xsl:with-param name="valuelist"> silent x-soft soft medium loud x-loud inherit </xsl:with-param>
2087
      </xsl:call-template>
2088
   </xsl:template>
2089

    
2090

    
2091
   <!-- 7.6. Border, padding, and background -->
2092
<xsl:template priority="3" match="@background-attachment">
2093
      <xsl:call-template name="enumerated-values">
2094
         <xsl:with-param name="valuelist"> scroll fixed inherit </xsl:with-param>
2095
      </xsl:call-template>
2096
   </xsl:template>
2097

    
2098
   <xsl:template priority="3" match="@background-color"/>
2099

    
2100
   <xsl:template priority="3" match="@background-image">
2101
      <xsl:if test=". != 'none'">
2102
         <xsl:call-template name="check-url"/>
2103
      </xsl:if>
2104
   </xsl:template>
2105

    
2106
   <xsl:template priority="3" match="@background-repeat">
2107
      <xsl:call-template name="enumerated-values">
2108
         <xsl:with-param name="valuelist"> repeat repeat-x repeat-y no-repeat inherit </xsl:with-param>
2109
      </xsl:call-template>
2110
   </xsl:template>
2111

    
2112
   <xsl:template priority="3" match="@background-position-horizontal">
2113
      <xsl:call-template name="quantitative-values">
2114
         <xsl:with-param name="valuelist"> left center right inherit </xsl:with-param>
2115
      </xsl:call-template>
2116
   </xsl:template>
2117

    
2118
   <xsl:template priority="3" match="@background-position-vertical">
2119
      <xsl:call-template name="quantitative-values">
2120
         <xsl:with-param name="valuelist"> top center bottom inherit </xsl:with-param>
2121
      </xsl:call-template>
2122
   </xsl:template>
2123

    
2124
   <xsl:template priority="3"
2125
                 match="@border-before-color                    | @border-after-color                    | @border-start-color                    | @border-end-color                    | @border-top-color                    | @border-bottom-color                    | @border-left-color                    | @border-right-color"/>
2126

    
2127
   <xsl:template priority="3"
2128
                 match="@border-before-style                    | @border-after-style                    | @border-start-style                    | @border-end-style                    | @border-top-style                    | @border-bottom-style                    | @border-left-style                    | @border-right-style">
2129
      <xsl:call-template name="enumerated-values">
2130
         <xsl:with-param name="valuelist"> none hidden dotted dashed solid double groove ridge inset outset inherit </xsl:with-param>
2131
      </xsl:call-template>
2132
   </xsl:template>
2133

    
2134
   <xsl:template priority="3"
2135
                 match="@border-before-width                    | @border-before-width.length                    | @border-after-width                    | @border-after-width.length                    | @border-start-width                    | @border-start-width.length                    | @border-end-width                    | @border-end-width.length                    | @border-top-width                    | @border-bottom-width                    | @border-left-width                    | @border-right-width">
2136
      <xsl:call-template name="quantitative-values">
2137
         <xsl:with-param name="valuelist"> thin medium thick inherit </xsl:with-param>
2138
      </xsl:call-template>
2139
   </xsl:template>
2140

    
2141
   <xsl:template match="@border-before-width.conditionality                    | @border-after-width.conditionality                    | @border-start-width.conditionality                    | @border-end-width.conditionality">
2142
      <xsl:call-template name="enumerated-values">
2143
         <xsl:with-param name="valuelist"> discard retain </xsl:with-param>
2144
      </xsl:call-template>
2145
   </xsl:template>
2146

    
2147
   <xsl:template priority="3"
2148
                 match="@padding-before                    | @padding-before.length                    | @padding-after                    | @padding-after.length                    | @padding-start                    | @padding-start.length                    | @padding-end                    | @padding-end.length                    | @padding-top                    | @padding-bottom                    | @padding-left                    | @padding-right">
2149
      <xsl:call-template name="quantitative-values">
2150
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2151
      </xsl:call-template>
2152
   </xsl:template>
2153

    
2154
   <xsl:template match="@padding-before.conditionality                    | @padding-after.conditionality                    | @padding-start.conditionality                    | @padding-end.conditionality">
2155
      <xsl:call-template name="enumerated-values">
2156
         <xsl:with-param name="valuelist"> discard retain </xsl:with-param>
2157
      </xsl:call-template>
2158
   </xsl:template>
2159

    
2160
   <!-- 7.7. Font properties  -->
2161
<xsl:template match="@font-family">
2162
      <xsl:call-template name="disable-on-graphics"/>
2163
   </xsl:template>
2164

    
2165
   <xsl:template match="@font-selection-strategy">
2166
      <xsl:call-template name="disable-on-graphics"/>
2167
      <xsl:call-template name="enumerated-values">
2168
         <xsl:with-param name="valuelist"> auto character-by-character inherit </xsl:with-param>
2169
      </xsl:call-template>
2170
   </xsl:template>
2171

    
2172
   <xsl:template match="@font-size">
2173
      <xsl:call-template name="disable-on-graphics"/>
2174
      <xsl:call-template name="quantitative-values">
2175
         <xsl:with-param name="valuelist"> xx-small x-small small medium large x-large xx-large larger smaller inherit </xsl:with-param>
2176
      </xsl:call-template>
2177
   </xsl:template>
2178

    
2179
   <xsl:template match="@font-stretch">
2180
      <xsl:call-template name="disable-on-graphics"/>
2181
      <xsl:call-template name="quantitative-values"> <!-- this is kinda sorta extension -->
2182
    <xsl:with-param name="valuelist"> normal wider narrower ultra-condensed extra-condensed condensed semi-condensed semi-expanded expanded extra-expanded ultra-expanded inherit </xsl:with-param>
2183
      </xsl:call-template>
2184
   </xsl:template>
2185

    
2186
   <xsl:template match="@font-size-adjust">
2187
      <xsl:call-template name="disable-on-graphics"/>
2188
      <xsl:call-template name="quantitative-values">
2189
         <xsl:with-param name="valuelist"> none inherit </xsl:with-param>
2190
      </xsl:call-template>
2191
   </xsl:template>
2192

    
2193
   <xsl:template match="@font-style">
2194
      <xsl:call-template name="disable-on-graphics"/>
2195
      <xsl:call-template name="enumerated-values">
2196
         <xsl:with-param name="valuelist"> normal italic oblique backslant inherit </xsl:with-param>
2197
      </xsl:call-template>
2198
   </xsl:template>
2199

    
2200
   <xsl:template match="@font-variant">
2201
      <xsl:call-template name="disable-on-graphics"/>
2202
      <xsl:call-template name="enumerated-values">
2203
         <xsl:with-param name="valuelist"> normal small-caps inherit </xsl:with-param>
2204
      </xsl:call-template>
2205
   </xsl:template>
2206

    
2207
   <xsl:template match="@font-weight">
2208
      <xsl:call-template name="disable-on-graphics"/>
2209
      <xsl:call-template name="quantitative-values">
2210
         <xsl:with-param name="valuelist"> normal bold bolder lighter inherit </xsl:with-param>
2211
      </xsl:call-template>
2212
   </xsl:template>
2213

    
2214
   <!-- 7.8. Hyphenation  -->
2215
<xsl:template match="@country">
2216
      <xsl:call-template name="disable-on-graphics"/>
2217
   </xsl:template>
2218

    
2219
   <xsl:template match="@language">
2220
      <xsl:call-template name="disable-on-graphics"/>
2221
   </xsl:template>
2222

    
2223
   <xsl:template match="@script">
2224
      <xsl:call-template name="disable-on-graphics"/>
2225
   </xsl:template>
2226

    
2227
   <xsl:template match="@hyphenate">
2228
      <xsl:call-template name="disable-on-graphics"/>
2229
      <xsl:call-template name="enumerated-values">
2230
         <xsl:with-param name="valuelist"> false true inherit </xsl:with-param>
2231
      </xsl:call-template>
2232
   </xsl:template>
2233

    
2234
   <xsl:template match="@hyphenation-character">
2235
      <xsl:call-template name="disable-on-graphics"/>
2236
   </xsl:template>
2237

    
2238
   <xsl:template match="@hyphenation-push-character-count                    | @hyphenation-remain-character-count">
2239
      <xsl:call-template name="disable-on-graphics"/>
2240
      <xsl:call-template name="quantitative-values">
2241
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2242
      </xsl:call-template>
2243
   </xsl:template>
2244

    
2245

    
2246
   <!-- 7.9 - 7.10. Margin properties - block and inline  -->
2247
<xsl:template match="@margin-top                    | @margin-bottom                    | @margin-left                    | @margin-right">
2248
      <xsl:call-template name="quantitative-values">
2249
         <xsl:with-param name="valuelist"> auto inherit </xsl:with-param>
2250
      </xsl:call-template>
2251
   </xsl:template>
2252

    
2253
   <xsl:template priority="5"
2254
                 match="fo:region-body/@margin-top                    | fo:region-body/@margin-bottom                    | fo:region-body/@margin-left                    | fo:region-body/@margin-right                    | fo:simple-page-master/@margin-top                    | fo:simple-page-master/@margin-bottom                    | fo:simple-page-master/@margin-left                    | fo:simple-page-master/@margin-right">
2255
      <xsl:call-template name="quantitative-values"/>
2256
   </xsl:template>
2257

    
2258
   <xsl:template match="@space-before                    | @space-before.minimum                    | @space-before.optimum                    | @space-before.maximum                    | @space-after                    | @space-after.minimum                    | @space-after.optimum                    | @space-after.maximum                    | @space-start                    | @space-start.minimum                    | @space-start.optimum                    | @space-start.maximum                    | @space-end                    | @space-end.minimum                    | @space-end.optimum                    | @space-end.maximum">
2259
      <xsl:call-template name="quantitative-values">
2260
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2261
      </xsl:call-template>
2262
   </xsl:template>
2263

    
2264

    
2265
   <xsl:template match="@space-before.conditionality                    | @space-after.conditionality                    | @space-start.conditionality                    | @space-end.conditionality">
2266
      <xsl:call-template name="enumerated-values">
2267
         <xsl:with-param name="valuelist"> discard retain </xsl:with-param>
2268
      </xsl:call-template>
2269
   </xsl:template>
2270

    
2271
   <xsl:template match="@space-before.precedence                    | @space-after.precedence                    | @space-start.precedence                    | @space-end.precedence">
2272
      <xsl:call-template name="quantitative-values">
2273
         <xsl:with-param name="valuelist"> force </xsl:with-param>
2274
      </xsl:call-template>
2275
   </xsl:template>
2276

    
2277

    
2278
   <xsl:template match="@start-indent | @end-indent">
2279
      <xsl:call-template name="quantitative-values">
2280
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2281
      </xsl:call-template>
2282
   </xsl:template>
2283

    
2284

    
2285
   <!-- 7.11. Relative position  -->
2286
<xsl:template match="@relative-position">
2287
      <xsl:call-template name="enumerated-values">
2288
         <xsl:with-param name="valuelist"> static relative inherit </xsl:with-param>
2289
      </xsl:call-template>
2290
   </xsl:template>
2291

    
2292
   <!-- 7.12. Area alignment  -->
2293
<xsl:template match="@alignment-adjust">
2294
      <xsl:call-template name="quantitative-values">
2295
         <xsl:with-param name="valuelist"> auto baseline before-edge text-before-edge middle central after-edge text-after-edge ideographic alphabetic hanging mathematical top bottom text-top text-bottom inherit </xsl:with-param>
2296
      </xsl:call-template>
2297
   </xsl:template>
2298

    
2299
   <xsl:template match="@alignment-baseline">
2300
      <xsl:call-template name="enumerated-values">
2301
         <xsl:with-param name="valuelist"> auto baseline before-edge text-before-edge middle central after-edge text-after-edge ideographic alphabetic hanging mathematical top bottom text-top text-bottom inherit </xsl:with-param>
2302
      </xsl:call-template>
2303
   </xsl:template>
2304

    
2305
   <xsl:template match="@baseline-shift">
2306
      <xsl:call-template name="quantitative-values">
2307
         <xsl:with-param name="valuelist"> baseline sub super inherit </xsl:with-param>
2308
      </xsl:call-template>
2309
   </xsl:template>
2310

    
2311
   <xsl:template priority="3" match="@display-align">
2312
      <xsl:call-template name="disable-on-atomic-inlines"/>
2313
      <xsl:call-template name="enumerated-values">
2314
         <xsl:with-param name="valuelist"> auto before center after inherit </xsl:with-param>
2315
      </xsl:call-template>
2316
   </xsl:template>
2317

    
2318
   <xsl:template match="@dominant-baseline">
2319
      <xsl:call-template name="enumerated-values">
2320
         <xsl:with-param name="valuelist"> auto use-script no-change reset-size ideographic alphabetic hanging mathematical central middle text-after-edge text-before-edge inherit </xsl:with-param>
2321
      </xsl:call-template>
2322
   </xsl:template>
2323

    
2324
   <xsl:template match="@relative-align">
2325
      <xsl:call-template name="disable-on-atomic-inlines"/>
2326
      <xsl:call-template name="disable-on-graphics"/>
2327
      <xsl:call-template name="enumerated-values">
2328
         <xsl:with-param name="valuelist"> before baseline inherit </xsl:with-param>
2329
      </xsl:call-template>
2330
   </xsl:template>
2331

    
2332
   <!-- 7.13. Area dimensions  -->
2333
<xsl:template match="@block-progression-dimension                    | @block-progression-dimension.minimum                    | @block-progression-dimension.optimum                    | @block-progression-dimension.maximum                    | @inline-progression-dimension                    | @inline-progression-dimension.minimum                    | @inline-progression-dimension.optimum                    | @inline-progression-dimension.maximum                    | @height                    | @width">
2334
      <xsl:call-template name="disable-on-atomic-inlines"/>
2335
      <xsl:call-template name="quantitative-values">
2336
         <xsl:with-param name="valuelist"> auto inherit </xsl:with-param>
2337
      </xsl:call-template>
2338
   </xsl:template>
2339

    
2340
   <xsl:template match="@max-height | @max-width">
2341
      <xsl:call-template name="disable-on-atomic-inlines"/>
2342
      <xsl:call-template name="quantitative-values">
2343
         <xsl:with-param name="valuelist"> none inherit </xsl:with-param>
2344
      </xsl:call-template>
2345
   </xsl:template>
2346

    
2347
   <xsl:template match="@min-height | @min-width">
2348
      <xsl:call-template name="disable-on-atomic-inlines"/>
2349
      <xsl:call-template name="quantitative-values">
2350
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2351
      </xsl:call-template>
2352
   </xsl:template>
2353

    
2354
   <xsl:template match="@content-height | @content-width">
2355
      <xsl:call-template name="disable-on-atomic-inlines"/>
2356
      <xsl:call-template name="quantitative-values">
2357
         <xsl:with-param name="valuelist"> auto scale-to-fit inherit </xsl:with-param>
2358
      </xsl:call-template>
2359
   </xsl:template>
2360

    
2361
   <xsl:template match="@scaling">
2362
      <xsl:call-template name="disable-on-atomic-inlines"/>
2363
      <xsl:call-template name="enumerated-values">
2364
         <xsl:with-param name="valuelist"> uniform non-uniform inherit </xsl:with-param>
2365
      </xsl:call-template>
2366
   </xsl:template>
2367

    
2368
   <xsl:template match="@scaling-method">
2369
      <xsl:call-template name="disable-on-atomic-inlines"/>
2370
      <xsl:call-template name="enumerated-values">
2371
         <xsl:with-param name="valuelist"> auto integer-pixels resample-any-method inherit </xsl:with-param>
2372
      </xsl:call-template>
2373
   </xsl:template>
2374

    
2375

    
2376
   <!-- 7.14. Block and line-related properties  -->
2377
<xsl:template match="@hyphenation-keep">
2378
      <xsl:call-template name="disable-on-atomic-inlines"/>
2379
      <xsl:call-template name="enumerated-values">
2380
         <xsl:with-param name="valuelist"> auto column page inherit </xsl:with-param>
2381
      </xsl:call-template>
2382
   </xsl:template>
2383

    
2384
   <xsl:template match="@hyphenation-ladder-count">
2385
      <xsl:call-template name="disable-on-atomic-inlines"/>
2386
      <xsl:call-template name="disable-on-graphics"/>
2387
      <xsl:call-template name="quantitative-values">
2388
         <xsl:with-param name="valuelist"> no-limit inherit </xsl:with-param>
2389
      </xsl:call-template>
2390
   </xsl:template>
2391

    
2392
   <xsl:template match="@text-indent | @last-line-end-indent">
2393
      <xsl:call-template name="disable-on-atomic-inlines"/>
2394
      <xsl:call-template name="disable-on-graphics"/>
2395
      <xsl:call-template name="quantitative-values">
2396
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2397
      </xsl:call-template>
2398
   </xsl:template>
2399

    
2400
   <xsl:template match="@line-height">
2401
      <xsl:call-template name="disable-on-graphics"/>
2402
      <xsl:call-template name="quantitative-values">
2403
         <xsl:with-param name="valuelist"> normal inherit </xsl:with-param>
2404
      </xsl:call-template>
2405
   </xsl:template>
2406

    
2407
   <xsl:template match="@line-height.minimum                    | @line-height.optimum                    | @line-height.maximum">
2408
      <xsl:call-template name="disable-on-graphics"/>
2409
      <xsl:call-template name="quantitative-values">
2410
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2411
      </xsl:call-template>
2412
   </xsl:template>
2413

    
2414
   <xsl:template match="@line-height.conditionality">
2415
      <xsl:call-template name="disable-on-atomic-inlines"/>
2416
      <xsl:call-template name="disable-on-graphics"/>
2417
      <xsl:call-template name="enumerated-values">
2418
         <xsl:with-param name="valuelist"> discard retain </xsl:with-param>
2419
      </xsl:call-template>
2420
   </xsl:template>
2421

    
2422
   <xsl:template match="@line-height.precedence">
2423
      <xsl:call-template name="disable-on-atomic-inlines"/>
2424
      <xsl:call-template name="disable-on-graphics"/>
2425
      <xsl:call-template name="quantitative-values">
2426
         <xsl:with-param name="valuelist"> force </xsl:with-param>
2427
      </xsl:call-template>
2428
   </xsl:template>
2429

    
2430
   <xsl:template match="@line-height-shift-adjustment">
2431
      <xsl:call-template name="disable-on-atomic-inlines"/>
2432
      <xsl:call-template name="disable-on-graphics"/>
2433
      <xsl:call-template name="enumerated-values">
2434
         <xsl:with-param name="valuelist"> consider-shifts disregard-shifts inherit </xsl:with-param>
2435
      </xsl:call-template>
2436
   </xsl:template>
2437

    
2438
   <xsl:template match="@line-stacking-strategy">
2439
      <xsl:call-template name="disable-on-atomic-inlines"/>
2440
      <xsl:call-template name="disable-on-graphics"/>
2441
      <xsl:call-template name="enumerated-values">
2442
         <xsl:with-param name="valuelist"> line-height font-height max-height inherit </xsl:with-param>
2443
      </xsl:call-template>
2444
   </xsl:template>
2445

    
2446
   <xsl:template match="@linefeed-treatment">
2447
      <xsl:call-template name="disable-on-atomic-inlines"/>
2448
      <xsl:call-template name="disable-on-graphics"/>
2449
      <xsl:call-template name="enumerated-values">
2450
         <xsl:with-param name="valuelist"> ignore preserve treat-as-space treat-as-zero-width-space inherit </xsl:with-param>
2451
      </xsl:call-template>
2452
   </xsl:template>
2453

    
2454
   <xsl:template match="@white-space-treatment">
2455
      <xsl:call-template name="disable-on-atomic-inlines"/>
2456
      <xsl:call-template name="disable-on-graphics"/>
2457
      <xsl:call-template name="enumerated-values">
2458
         <xsl:with-param name="valuelist"> ignore preserve ignore-if-before-linefeed ignore-if-after-linefeed ignore-if-surrounding-linefeed inherit </xsl:with-param>
2459
      </xsl:call-template>
2460
   </xsl:template>
2461

    
2462
   <xsl:template match="@text-align">
2463
      <xsl:call-template name="disable-on-atomic-inlines"/>
2464
      <xsl:variable name="keyword-charset"
2465
                    select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
2466
      <xsl:variable name="token" select="normalize-space()"/>
2467
      <xsl:if test="string-length($token) != 0 and                 string-length(translate($token, $keyword-charset, '')) = 0">
2468
         <xsl:call-template name="enumerated-values">
2469
            <xsl:with-param name="valuelist"> start center end justify inside outside left right inherit </xsl:with-param>
2470
         </xsl:call-template>
2471
      </xsl:if>
2472
   </xsl:template>
2473

    
2474

    
2475
   <xsl:template match="@text-align-last">
2476
      <xsl:call-template name="disable-on-atomic-inlines"/>
2477
      <xsl:call-template name="disable-on-graphics"/>
2478
      <xsl:call-template name="enumerated-values">
2479
         <xsl:with-param name="valuelist"> relative start center end justify inside outside left right inherit </xsl:with-param>
2480
      </xsl:call-template>
2481
   </xsl:template>
2482

    
2483
   <xsl:template match="@white-space-collapse">
2484
      <xsl:call-template name="disable-on-atomic-inlines"/>
2485
      <xsl:call-template name="disable-on-graphics"/>
2486
      <xsl:call-template name="enumerated-values">
2487
         <xsl:with-param name="valuelist"> false true inherit </xsl:with-param>
2488
      </xsl:call-template>
2489
   </xsl:template>
2490

    
2491
   <xsl:template match="@wrap-option">
2492
      <xsl:call-template name="disable-on-atomic-inlines"/>
2493
      <xsl:call-template name="disable-on-graphics"/>
2494
      <xsl:call-template name="enumerated-values">
2495
         <xsl:with-param name="valuelist"> no-wrap wrap inherit </xsl:with-param>
2496
      </xsl:call-template>
2497
   </xsl:template>
2498

    
2499

    
2500
   <!-- 7.15. Character properties -->
2501
<xsl:template match="fo:character/@character"/>
2502

    
2503
   <xsl:template match="@letter-spacing.minimum                     | @letter-spacing.optimum                      | @letter-spacing.maximum                      | @letter-spacing                     | @word-spacing.minimum                     | @word-spacing.optimum                     | @word-spacing.maximum                     | @word-spacing">
2504
      <xsl:call-template name="disable-on-graphics"/>
2505
      <xsl:call-template name="quantitative-values">
2506
         <xsl:with-param name="valuelist"> normal inherit </xsl:with-param>
2507
      </xsl:call-template>
2508
   </xsl:template>
2509

    
2510
   <xsl:template match="@word-spacing.conditionality                    | @letter-spacing.conditionality">
2511
      <xsl:call-template name="enumerated-values">
2512
         <xsl:with-param name="valuelist"> discard retain </xsl:with-param>
2513
      </xsl:call-template>
2514
   </xsl:template>
2515

    
2516
   <xsl:template match="@word-spacing.precedence                    | @letter-spacing.precedence">
2517
      <xsl:call-template name="quantitative-values">
2518
         <xsl:with-param name="valuelist"> force </xsl:with-param>
2519
      </xsl:call-template>
2520
   </xsl:template>
2521

    
2522

    
2523
   <xsl:template match="@suppress-at-line-break">
2524
      <xsl:call-template name="enumerated-values">
2525
         <xsl:with-param name="valuelist"> auto suppress retain inherit </xsl:with-param>
2526
      </xsl:call-template>
2527
   </xsl:template>
2528

    
2529
   <xsl:template match="@text-decoration">
2530
      <xsl:call-template name="disable-on-graphics"/>
2531
   </xsl:template>
2532

    
2533
   <xsl:template match="@text-shadow">
2534
      <xsl:call-template name="disable-on-graphics"/>
2535
   </xsl:template>
2536

    
2537
   <xsl:template match="@text-transform">
2538
      <xsl:call-template name="disable-on-graphics"/>
2539
      <xsl:call-template name="enumerated-values">
2540
         <xsl:with-param name="valuelist"> capitalize uppercase lowercase none inherit </xsl:with-param>
2541
      </xsl:call-template>
2542
   </xsl:template>
2543

    
2544
   <xsl:template match="@treat-as-word-space">
2545
      <xsl:call-template name="disable-on-graphics"/>
2546
      <xsl:call-template name="enumerated-values">
2547
         <xsl:with-param name="valuelist"> auto false true inherit </xsl:with-param>
2548
      </xsl:call-template>
2549
   </xsl:template>
2550

    
2551
   <!-- 7.16. Color properties -->
2552
<xsl:template match="@color"/>
2553

    
2554
   <xsl:template match="fo:color-profile/@color-profile-name" priority="5"/>
2555

    
2556
   <xsl:template match="fo:color-profile/@rendering-intent                    | fo:declarations/@rendering-intent                    | fo:root/@rendering-intent"
2557
                 priority="5">
2558
      <xsl:call-template name="enumerated-values">
2559
         <xsl:with-param name="valuelist"> auto perceptual relative-colorimetric saturation absolute-colorimetric inherit </xsl:with-param>
2560
      </xsl:call-template>
2561
   </xsl:template>
2562

    
2563

    
2564
   <!-- 7.17. Float properties -->
2565
<xsl:template match="@clear">
2566
      <xsl:call-template name="disable-on-atomic-inlines"/>
2567
      <xsl:call-template name="disable-on-graphics"/>
2568
      <xsl:call-template name="enumerated-values">
2569
         <xsl:with-param name="valuelist"> start end left right both none inherit </xsl:with-param>
2570
      </xsl:call-template>
2571
   </xsl:template>
2572

    
2573
   <xsl:template match="@float">
2574
      <xsl:call-template name="disable-on-atomic-inlines"/>
2575
      <xsl:call-template name="disable-on-graphics"/>
2576
      <xsl:call-template name="enumerated-values">
2577
         <xsl:with-param name="valuelist"> before start end left right inside outside none inherit </xsl:with-param>
2578
      </xsl:call-template>
2579

    
2580
      <xsl:if test="$strictness &gt; 1">
2581
         <xsl:if test=".='inside' or .='outside'">
2582
            <xsl:call-template name="print-warning">
2583
               <xsl:with-param name="msg">Value "<xsl:value-of select="."/>" for 'float' attribute is a RenderX extension.</xsl:with-param>
2584
            </xsl:call-template>  
2585
         </xsl:if>
2586
      </xsl:if>
2587
   </xsl:template>
2588

    
2589
   <xsl:template match="@intrusion-displace">
2590
      <xsl:call-template name="disable-on-atomic-inlines"/>
2591
      <xsl:call-template name="disable-on-graphics"/>
2592
      <xsl:call-template name="enumerated-values">
2593
         <xsl:with-param name="valuelist"> auto none line indent block inherit </xsl:with-param>
2594
      </xsl:call-template>
2595
   </xsl:template>
2596

    
2597
   <!-- 7.18. Keeps and breaks -->
2598
<xsl:template match="@break-after | @break-before">
2599
      <xsl:call-template name="disable-on-atomic-inlines"/>
2600
      <xsl:call-template name="disable-on-graphics"/>
2601
      <xsl:call-template name="enumerated-values">
2602
         <xsl:with-param name="valuelist"> auto column page even-page odd-page inherit </xsl:with-param>
2603
      </xsl:call-template>
2604
   </xsl:template>
2605

    
2606
   <xsl:template match="@keep-together                    | @keep-together.within-line                    | @keep-together.within-column                    | @keep-together.within-page                    | @keep-with-next                    | @keep-with-next.within-line                    | @keep-with-next.within-column                    | @keep-with-next.within-page                    | @keep-with-previous                    | @keep-with-previous.within-line                    | @keep-with-previous.within-column                    | @keep-with-previous.within-page">
2607
      <xsl:call-template name="quantitative-values">
2608
         <xsl:with-param name="valuelist"> auto always inherit </xsl:with-param>
2609
      </xsl:call-template>
2610
   </xsl:template>
2611

    
2612
   <xsl:template match="@orphans | @widows">
2613
      <xsl:call-template name="disable-on-atomic-inlines"/>
2614
      <xsl:call-template name="disable-on-graphics"/>
2615
      <xsl:call-template name="quantitative-values">
2616
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2617
      </xsl:call-template>
2618
   </xsl:template>
2619

    
2620

    
2621
   <!-- 7.19. Layout-related properties -->
2622
<xsl:template priority="3" match="@clip"/>
2623

    
2624
   <xsl:template priority="3" match="@overflow">
2625
      <xsl:call-template name="enumerated-values">
2626
         <xsl:with-param name="valuelist"> visible hidden scroll error-if-overflow auto inherit </xsl:with-param>
2627
      </xsl:call-template>
2628
   </xsl:template>
2629

    
2630
   <xsl:template priority="3" match="@reference-orientation">
2631
      <xsl:call-template name="disable-on-atomic-inlines"/>
2632
      <xsl:call-template name="disable-on-graphics"/>
2633
      <xsl:call-template name="enumerated-values">
2634
         <xsl:with-param name="valuelist"> 0 90 180 270 -90 -180 -270 inherit </xsl:with-param>
2635
      </xsl:call-template>
2636
   </xsl:template>
2637

    
2638
   <xsl:template priority="5" match="fo:simple-page-master/@reference-orientation">
2639
      <xsl:call-template name="enumerated-values">
2640
         <xsl:with-param name="valuelist"> 0 90 180 270 -90 -180 -270 inherit </xsl:with-param>
2641
      </xsl:call-template>
2642
   </xsl:template>
2643

    
2644
   <xsl:template match="@span">
2645
      <xsl:if test="ancestor::fo:static-content">
2646
         <xsl:call-template name="print-error">
2647
            <xsl:with-param name="msg">Attribute 'span' cannot be used inside '<xsl:value-of select="name(ancestor::fo:static-content[1])"/>'. </xsl:with-param>
2648
         </xsl:call-template>
2649
      </xsl:if>
2650
      <xsl:call-template name="disable-on-atomic-inlines"/>
2651
      <xsl:call-template name="disable-on-graphics"/>
2652
      <xsl:call-template name="enumerated-values">
2653
         <xsl:with-param name="valuelist"> none all inherit </xsl:with-param>
2654
      </xsl:call-template>
2655
   </xsl:template>
2656

    
2657
   <!-- 7.20. Leader properties -->
2658
<xsl:template match="@leader-alignment">
2659
      <xsl:call-template name="disable-on-atomic-inlines"/>
2660
      <xsl:call-template name="disable-on-graphics"/>
2661
      <xsl:call-template name="enumerated-values">
2662
         <xsl:with-param name="valuelist"> none reference-area page inherit </xsl:with-param>
2663
      </xsl:call-template>
2664
   </xsl:template>
2665

    
2666
   <xsl:template match="@leader-pattern">
2667
      <xsl:call-template name="disable-on-atomic-inlines"/>
2668
      <xsl:call-template name="disable-on-graphics"/>
2669
      <xsl:call-template name="enumerated-values">
2670
         <xsl:with-param name="valuelist"> space rule dots use-content inherit </xsl:with-param>
2671
      </xsl:call-template>
2672
   </xsl:template>
2673

    
2674
   <xsl:template match="@leader-pattern-width">
2675
      <xsl:call-template name="disable-on-atomic-inlines"/>
2676
      <xsl:call-template name="disable-on-graphics"/>
2677
      <xsl:call-template name="quantitative-values">
2678
         <xsl:with-param name="valuelist"> use-font-metrics inherit </xsl:with-param>
2679
      </xsl:call-template>
2680
   </xsl:template>
2681

    
2682
   <xsl:template match="@leader-length                    | @leader-length.minimum                    | @leader-length.optimum                    | @leader-length.maximum">
2683
      <xsl:call-template name="disable-on-atomic-inlines"/>
2684
      <xsl:call-template name="disable-on-graphics"/>
2685
      <xsl:call-template name="quantitative-values">
2686
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2687
      </xsl:call-template>
2688
   </xsl:template>
2689

    
2690
   <xsl:template match="@rule-style">
2691
      <xsl:call-template name="disable-on-atomic-inlines"/>
2692
      <xsl:call-template name="disable-on-graphics"/>
2693
      <xsl:call-template name="enumerated-values">
2694
         <xsl:with-param name="valuelist"> none dotted dashed solid double groove ridge inherit </xsl:with-param>
2695
      </xsl:call-template>
2696
   </xsl:template>
2697

    
2698
   <xsl:template match="@rule-thickness">
2699
      <xsl:call-template name="disable-on-atomic-inlines"/>
2700
      <xsl:call-template name="disable-on-graphics"/>
2701
      <xsl:call-template name="quantitative-values">
2702
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2703
      </xsl:call-template>
2704
   </xsl:template>
2705

    
2706
   <!-- 7.21. Dynamic effects and hyperrefs -->
2707
<xsl:template match="fo:multi-property-set/@active-state">
2708
      <xsl:call-template name="enumerated-values">
2709
         <xsl:with-param name="valuelist"> link visited active hover focus </xsl:with-param>
2710
      </xsl:call-template>
2711
   </xsl:template>
2712

    
2713
   <xsl:template match="@auto-restore">
2714
      <xsl:call-template name="disable-on-atomic-inlines"/>
2715
      <xsl:call-template name="disable-on-graphics"/>
2716
      <xsl:call-template name="enumerated-values">
2717
         <xsl:with-param name="valuelist"> false true </xsl:with-param>
2718
      </xsl:call-template>
2719
   </xsl:template>
2720

    
2721
   <xsl:template match="fo:multi-case/@case-name"/>
2722
   <xsl:template match="fo:multi-case/@case-title"/>
2723

    
2724
   <xsl:template match="fo:basic-link/@destination-placement-offset">
2725
      <xsl:call-template name="quantitative-values"/>
2726
   </xsl:template>
2727

    
2728
   <xsl:template match="fo:basic-link/@external-destination">
2729
      <xsl:call-template name="check-url"/>
2730
   </xsl:template>
2731
   <xsl:template match="rx:bookmark/@external-destination" priority="5">
2732
      <xsl:call-template name="check-url"/>
2733
   </xsl:template>
2734

    
2735
   <xsl:template match="fo:basic-link/@internal-destination"/>
2736
   <xsl:template match="rx:bookmark/@internal-destination" priority="5"/>
2737

    
2738
   <xsl:template match="rx:bookmark/@collapse-subtree" priority="5">
2739
      <xsl:call-template name="enumerated-values">
2740
         <xsl:with-param name="valuelist"> true false </xsl:with-param>
2741
      </xsl:call-template>
2742
   </xsl:template>
2743

    
2744
   <xsl:template match="fo:root/@rx:initial-destination"/>
2745

    
2746
   <xsl:template match="fo:basic-link/@indicate-destination">
2747
      <xsl:call-template name="enumerated-values">
2748
         <xsl:with-param name="valuelist"> true false </xsl:with-param>
2749
      </xsl:call-template>
2750
   </xsl:template>
2751

    
2752
   <xsl:template match="fo:basic-link/@show-destination">
2753
      <xsl:call-template name="enumerated-values">
2754
         <xsl:with-param name="valuelist"> replace new </xsl:with-param>
2755
      </xsl:call-template>
2756
   </xsl:template>
2757
   <xsl:template match="rx:bookmark/@show-destination" priority="5">
2758
      <xsl:call-template name="enumerated-values">
2759
         <xsl:with-param name="valuelist"> replace new </xsl:with-param>
2760
      </xsl:call-template>
2761
   </xsl:template>
2762

    
2763

    
2764
   <xsl:template match="fo:multi-case/@starting-state">
2765
      <xsl:call-template name="enumerated-values">
2766
         <xsl:with-param name="valuelist"> show hide </xsl:with-param>
2767
      </xsl:call-template>
2768
   </xsl:template>
2769

    
2770
   <xsl:template match="fo:multi-toggle/@switch-to"/>
2771
   <xsl:template match="fo:basic-link/@target-presentation-context"/>
2772
   <xsl:template match="fo:basic-link/@target-processing-context"/>
2773
   <xsl:template match="fo:basic-link/@target-stylesheet"/>
2774

    
2775
   <!-- 7.22. Marker properties -->
2776
<xsl:template match="fo:marker/@marker-class-name"/>
2777
   <xsl:template match="fo:retrieve-marker/@retrieve-class-name"/>
2778

    
2779
   <xsl:template match="fo:retrieve-marker/@retrieve-position">
2780
      <xsl:call-template name="enumerated-values">
2781
         <xsl:with-param name="valuelist"> first-starting-within-page first-including-carryover last-starting-within-page last-ending-within-page </xsl:with-param>
2782
      </xsl:call-template>
2783
   </xsl:template>
2784

    
2785
   <xsl:template match="fo:retrieve-marker/@retrieve-boundary">
2786
      <xsl:call-template name="enumerated-values">
2787
         <xsl:with-param name="valuelist"> page page-sequence document </xsl:with-param>
2788
      </xsl:call-template>
2789
   </xsl:template>
2790

    
2791

    
2792
   <!-- 7.23. Number format properties -->
2793
<xsl:template match="fo:page-sequence/@format | rx:ruler/@format"/>
2794
   <xsl:template match="fo:page-sequence/@grouping-separator | rx:ruler/@grouping-separator"/>
2795

    
2796
   <xsl:template match="fo:page-sequence/@grouping-size | rx:ruler/@grouping-size">
2797
      <xsl:call-template name="quantitative-values"/>
2798
   </xsl:template>
2799

    
2800
   <xsl:template match="fo:page-sequence/@letter-value | rx:ruler/@letter-value">
2801
      <xsl:call-template name="enumerated-values">
2802
         <xsl:with-param name="valuelist"> auto alphabetic traditional </xsl:with-param>
2803
      </xsl:call-template>
2804
   </xsl:template>
2805

    
2806
   <!-- 7.24. Pagination -->
2807
<xsl:template priority="5" match="fo:conditional-page-master-reference/@blank-or-not-blank">
2808
      <xsl:call-template name="enumerated-values">
2809
         <xsl:with-param name="valuelist"> blank not-blank any </xsl:with-param>
2810
      </xsl:call-template>
2811
   </xsl:template>
2812

    
2813
   <xsl:template priority="5" match="fo:conditional-page-master-reference/@odd-or-even">
2814
      <xsl:call-template name="enumerated-values">
2815
         <xsl:with-param name="valuelist"> even odd any </xsl:with-param>
2816
      </xsl:call-template>
2817
   </xsl:template>
2818

    
2819
   <xsl:template priority="5" match="fo:conditional-page-master-reference/@page-position">
2820
      <xsl:call-template name="enumerated-values">
2821
         <xsl:with-param name="valuelist"> first last rest any </xsl:with-param>
2822
      </xsl:call-template>
2823
   </xsl:template>
2824

    
2825
   <xsl:template priority="5" match="fo:region-body/@column-count">
2826
      <xsl:call-template name="quantitative-values"/>
2827
   </xsl:template>
2828

    
2829
   <xsl:template priority="5" match="fo:region-body/@column-gap">
2830
      <xsl:call-template name="quantitative-values"/>
2831
   </xsl:template>
2832

    
2833
   <xsl:template match="rx:flow-section/@column-count">
2834
      <xsl:call-template name="quantitative-values"/>
2835
   </xsl:template>
2836

    
2837
   <xsl:template match="rx:flow-section/@column-gap">
2838
      <xsl:call-template name="quantitative-values"/>
2839
   </xsl:template>
2840

    
2841
   <xsl:template priority="5"
2842
                 match="fo:region-before/@extent                    | fo:region-after/@extent                    | fo:region-start/@extent                    | fo:region-end/@extent">
2843
      <xsl:call-template name="quantitative-values"/>
2844
   </xsl:template>
2845

    
2846
   <xsl:template match="fo:flow/@flow-name | fo:static-content/@flow-name"/>
2847

    
2848
   <xsl:template match="fo:page-sequence/@force-page-count">
2849
      <xsl:call-template name="enumerated-values">
2850
         <xsl:with-param name="valuelist"> auto even odd end-on-even end-on-odd no-force </xsl:with-param>
2851
      </xsl:call-template>
2852
   </xsl:template>
2853

    
2854
   <xsl:template match="fo:page-sequence/@initial-page-number">
2855
      <xsl:call-template name="quantitative-values">
2856
         <xsl:with-param name="valuelist"> auto auto-odd auto-even </xsl:with-param>
2857
      </xsl:call-template>
2858
   </xsl:template>
2859

    
2860
   <xsl:template priority="5"
2861
                 match="fo:simple-page-master/@master-name                    | fo:page-sequence-master/@master-name"/>
2862

    
2863
   <xsl:template priority="5"
2864
                 match="fo:page-sequence/@master-reference                    | fo:single-page-master-reference/@master-reference                    | fo:repeatable-page-master-reference/@master-reference                    | fo:conditional-page-master-reference/@master-reference"/>
2865

    
2866
   <xsl:template priority="5"
2867
                 match="fo:repeatable-page-master-reference/@maximum-repeats                    | fo:repeatable-page-master-alternatives/@maximum-repeats">
2868
      <xsl:call-template name="quantitative-values">
2869
         <xsl:with-param name="valuelist"> no-limit </xsl:with-param>
2870
      </xsl:call-template>
2871
   </xsl:template>
2872

    
2873

    
2874
   <xsl:template match="fo:root/@media-usage">
2875
      <xsl:call-template name="enumerated-values">
2876
         <xsl:with-param name="valuelist"> auto paginate bounded-in-one-dimension unbounded </xsl:with-param>
2877
      </xsl:call-template>
2878
   </xsl:template>
2879

    
2880
   <xsl:template priority="5"
2881
                 match="fo:simple-page-master/@page-height                    | fo:simple-page-master/@page-width">
2882
      <xsl:call-template name="quantitative-values">
2883
         <xsl:with-param name="valuelist"> auto indefinite </xsl:with-param>
2884
      </xsl:call-template>
2885
   </xsl:template>
2886

    
2887
   <xsl:template priority="5"
2888
                 match="fo:region-before/@precedence                    | fo:region-after/@precedence                    | fo:region-start/@precedence                    | fo:region-end/@precedence">
2889
      <xsl:call-template name="enumerated-values">
2890
         <xsl:with-param name="valuelist"> true false </xsl:with-param>
2891
      </xsl:call-template>
2892
   </xsl:template>
2893

    
2894
   <xsl:template priority="5"
2895
                 match="fo:region-body/@region-name                    | fo:region-before/@region-name                    | fo:region-after/@region-name                    | fo:region-start/@region-name                    | fo:region-end/@region-name"/>
2896

    
2897
   <!-- 7.25. Table properties -->
2898
<xsl:template match="@border-after-precedence                    | @border-before-precedence                    | @border-end-precedence                    | @border-start-precedence">
2899
      <xsl:call-template name="disable-on-atomic-inlines"/>
2900
      <xsl:call-template name="disable-on-graphics"/>
2901
      <xsl:call-template name="quantitative-values">
2902
         <xsl:with-param name="valuelist"> force inherit </xsl:with-param>
2903
      </xsl:call-template>
2904
   </xsl:template>
2905

    
2906
   <xsl:template match="@border-collapse">
2907
      <xsl:call-template name="disable-on-atomic-inlines"/>
2908
      <xsl:call-template name="disable-on-graphics"/>
2909
      <xsl:call-template name="enumerated-values">
2910
         <xsl:with-param name="valuelist"> collapse collapse-with-precedence separate inherit </xsl:with-param>
2911
      </xsl:call-template>
2912
   </xsl:template>
2913

    
2914
   <xsl:template match="@border-separation                    | @border-separation.block-progression-direction                    | @border-separation.inline-progression-direction">
2915
      <xsl:call-template name="disable-on-atomic-inlines"/>
2916
      <xsl:call-template name="disable-on-graphics"/>
2917
      <xsl:call-template name="quantitative-values">
2918
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2919
      </xsl:call-template>
2920
   </xsl:template>
2921

    
2922

    
2923
   <xsl:template match="@caption-side">
2924
      <xsl:call-template name="disable-on-atomic-inlines"/>
2925
      <xsl:call-template name="disable-on-graphics"/>
2926
      <xsl:call-template name="enumerated-values">
2927
         <xsl:with-param name="valuelist"> before after start end top bottom left right inherit </xsl:with-param>
2928
      </xsl:call-template>
2929
   </xsl:template>
2930

    
2931
   <xsl:template match="fo:table-column/@column-number                    | fo:table-cell/@column-number">
2932
      <xsl:call-template name="quantitative-values"/>
2933
   </xsl:template>
2934

    
2935
   <xsl:template match="fo:table-column/@column-width">
2936
      <xsl:call-template name="quantitative-values"/>
2937
   </xsl:template>
2938

    
2939
   <xsl:template match="@empty-cells">
2940
      <xsl:call-template name="disable-on-atomic-inlines"/>
2941
      <xsl:call-template name="disable-on-graphics"/>
2942
      <xsl:call-template name="enumerated-values">
2943
         <xsl:with-param name="valuelist"> show hide inherit </xsl:with-param>
2944
      </xsl:call-template>
2945
   </xsl:template>
2946

    
2947
   <xsl:template match="fo:table-cell/@ends-row                    | fo:table-cell/@starts-row">
2948
      <xsl:call-template name="enumerated-values">
2949
         <xsl:with-param name="valuelist"> true false </xsl:with-param>
2950
      </xsl:call-template>
2951
   </xsl:template>
2952

    
2953
   <xsl:template match="fo:table-column/@number-columns-repeated">
2954
      <xsl:call-template name="quantitative-values"/>
2955
   </xsl:template>
2956

    
2957
   <xsl:template match="fo:table-column/@number-columns-spanned                    | fo:table-cell/@number-columns-spanned">
2958
      <xsl:call-template name="quantitative-values"/>
2959
   </xsl:template>
2960

    
2961
   <xsl:template match="fo:table-cell/@number-rows-spanned">
2962
      <xsl:call-template name="quantitative-values"/>
2963
   </xsl:template>
2964

    
2965
   <xsl:template match="@table-layout">
2966
      <xsl:call-template name="disable-on-atomic-inlines"/>
2967
      <xsl:call-template name="disable-on-graphics"/>
2968
      <xsl:call-template name="enumerated-values">
2969
         <xsl:with-param name="valuelist"> auto fixed inherit </xsl:with-param>
2970
      </xsl:call-template>
2971
   </xsl:template>
2972

    
2973
   <xsl:template match="fo:table/@table-omit-footer-at-break                    | fo:table/@table-omit-header-at-break                     | fo:table/@rx:table-omit-initial-header                    | fo:table/@rx:table-omit-final-footer">
2974
      <xsl:call-template name="enumerated-values">
2975
         <xsl:with-param name="valuelist"> true false </xsl:with-param>
2976
      </xsl:call-template>
2977
   </xsl:template>
2978

    
2979

    
2980
   <!-- 7.26. Writing mode -->
2981
<xsl:template match="@direction">
2982
      <xsl:call-template name="disable-on-graphics"/>
2983
      <xsl:call-template name="enumerated-values">
2984
         <xsl:with-param name="valuelist"> ltr rtl inherit </xsl:with-param>
2985
      </xsl:call-template>
2986
   </xsl:template>
2987

    
2988
   <xsl:template match="@glyph-orientation-horizontal">
2989
      <xsl:call-template name="disable-on-graphics"/>
2990
      <xsl:call-template name="quantitative-values">
2991
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
2992
      </xsl:call-template>
2993
   </xsl:template>
2994

    
2995
   <xsl:template match="@glyph-orientation-vertical">
2996
      <xsl:call-template name="disable-on-graphics"/>
2997
      <xsl:call-template name="quantitative-values">
2998
         <xsl:with-param name="valuelist"> auto inherit </xsl:with-param>
2999
      </xsl:call-template>
3000
   </xsl:template>
3001

    
3002
   <xsl:template match="@text-altitude | @text-depth">
3003
      <xsl:call-template name="quantitative-values">
3004
         <xsl:with-param name="valuelist"> use-font-metrics inherit </xsl:with-param>
3005
      </xsl:call-template>
3006
   </xsl:template>
3007

    
3008

    
3009
   <xsl:template match="@unicode-bidi">
3010
      <xsl:call-template name="enumerated-values">
3011
         <xsl:with-param name="valuelist"> normal embed bidi-override inherit </xsl:with-param>
3012
      </xsl:call-template>
3013
   </xsl:template>
3014

    
3015
   <xsl:template priority="3" match="@writing-mode">
3016
      <xsl:call-template name="disable-on-atomic-inlines"/>
3017
      <xsl:call-template name="disable-on-graphics"/>
3018
      <xsl:call-template name="enumerated-values">
3019
         <xsl:with-param name="valuelist"> lr-tb rl-tb tb-rl tb-lr lr-alternating-rl-tb lr-inverting-rl-tb lr-bt rl-bt bt-rl bt-lr lr-alternating-rl-bt lr-inverting-rl-bt tb-lr-in-lr-pairs lr rl tb inherit </xsl:with-param>
3020
      </xsl:call-template>
3021
   </xsl:template>
3022

    
3023
   <xsl:template priority="5" match="fo:simple-page-master/@writing-mode">
3024
      <xsl:call-template name="enumerated-values">
3025
         <xsl:with-param name="valuelist"> lr-tb rl-tb tb-rl tb-lr lr-alternating-rl-tb lr-inverting-rl-tb lr-bt rl-bt bt-rl bt-lr lr-alternating-rl-bt lr-inverting-rl-bt tb-lr-in-lr-pairs lr rl tb inherit </xsl:with-param>
3026
      </xsl:call-template>
3027
   </xsl:template>
3028

    
3029

    
3030
   <!-- 7.27. Miscellaneous properties -->
3031
<xsl:template match="fo:external-graphic/@content-type                    | fo:instream-foreign-object/@content-type                    | rx:background-content-type"
3032
                 priority="3">
3033
      <xsl:variable name="val" select="normalize-space()"/>
3034
      <xsl:choose>
3035
         <xsl:when test="$val = 'auto'"/>
3036
         <xsl:when test="starts-with($val, 'content-type:')"/>
3037
         <xsl:when test="starts-with($val, 'namespace:')"/>
3038
         <xsl:otherwise>
3039
            <xsl:call-template name="print-warning">
3040
               <xsl:with-param name="msg">Attribute '<xsl:value-of select="name()"/>' cannot have a value of "<xsl:value-of select="."/>": if not 'auto', it should be prefixed by either 'namespace:' or 'content-type:'.</xsl:with-param>
3041
            </xsl:call-template>
3042
         </xsl:otherwise>
3043
      </xsl:choose>
3044
   </xsl:template>
3045

    
3046

    
3047
   <xsl:template match="@id"/>
3048
   <xsl:template match="fo:page-number-citation/@ref-id"/>
3049
   <xsl:template match="rx:page-number-citation-last/@ref-id"/>
3050
   <xsl:template match="rx:end-index-range/@ref-id"/>
3051

    
3052
   <xsl:template match="@provisional-label-separation                    | @provisional-distance-between-starts">
3053
      <xsl:call-template name="disable-on-atomic-inlines"/>
3054
      <xsl:call-template name="disable-on-graphics"/>
3055
      <xsl:call-template name="quantitative-values">
3056
         <xsl:with-param name="valuelist"> inherit </xsl:with-param>
3057
      </xsl:call-template>
3058
   </xsl:template>
3059

    
3060
   <xsl:template match="@score-spaces">
3061
      <xsl:call-template name="disable-on-graphics"/>
3062
      <xsl:call-template name="enumerated-values">
3063
         <xsl:with-param name="valuelist"> true false inherit </xsl:with-param>
3064
      </xsl:call-template>
3065
   </xsl:template>
3066

    
3067
   <xsl:template match="fo:external-graphic/@src">
3068
      <xsl:call-template name="check-url"/>
3069
   </xsl:template>
3070

    
3071

    
3072
   <xsl:template priority="5" match="fo:color-profile/@src">
3073
      <xsl:call-template name="check-url"/>
3074
   </xsl:template>
3075

    
3076
   <xsl:template match="@visibility">
3077
      <xsl:call-template name="enumerated-values">
3078
         <xsl:with-param name="valuelist"> visible hidden collapse inherit </xsl:with-param>
3079
      </xsl:call-template>
3080
   </xsl:template>
3081

    
3082
   <xsl:template match="@z-index">
3083
      <xsl:call-template name="quantitative-values">
3084
         <xsl:with-param name="valuelist"> auto inherit </xsl:with-param>
3085
      </xsl:call-template>
3086
   </xsl:template>
3087

    
3088

    
3089
   <!-- 7.28. Shorthands -->
3090
<xsl:template priority="3" match="@background"/>
3091
   <xsl:template priority="3" match="@background-position"/>
3092
   <xsl:template priority="3" match="@border"/>
3093
   <xsl:template priority="3"
3094
                 match="@border-top                    | @border-bottom                    | @border-left                    | @border-right"/>
3095
   <xsl:template priority="3" match="@border-color"/>
3096
   <xsl:template priority="3" match="@border-style"/>
3097
   <xsl:template match="@border-spacing"/>
3098
   <xsl:template priority="3" match="@border-width"/>
3099
   <xsl:template match="@cue"/>
3100
   <xsl:template match="@font">
3101
      <xsl:call-template name="disable-on-graphics"/>
3102
   </xsl:template>
3103
   <xsl:template match="@margin"/>
3104
   <xsl:template priority="5"
3105
                 match="fo:simple-page-master/@margin                    | fo:region-body/@margin"/>
3106

    
3107
   <xsl:template priority="3" match="@padding"/>
3108

    
3109
   <xsl:template match="@page-break-after | @page-break-before">
3110
      <xsl:call-template name="disable-on-atomic-inlines"/>
3111
      <xsl:call-template name="disable-on-graphics"/>
3112
      <xsl:call-template name="enumerated-values">
3113
         <xsl:with-param name="valuelist"> auto always avoid left right inherit </xsl:with-param>
3114
      </xsl:call-template>
3115
   </xsl:template>
3116

    
3117
   <xsl:template match="@page-break-inside">
3118
      <xsl:call-template name="disable-on-graphics"/>
3119
      <xsl:call-template name="enumerated-values">
3120
         <xsl:with-param name="valuelist"> auto avoid inherit </xsl:with-param>
3121
      </xsl:call-template>
3122
   </xsl:template>
3123

    
3124
   <xsl:template match="@pause"/>
3125

    
3126
   <xsl:template match="@position">
3127
      <xsl:call-template name="enumerated-values">
3128
         <xsl:with-param name="valuelist"> static relative absolute fixed inherit </xsl:with-param>
3129
      </xsl:call-template>
3130
   </xsl:template>
3131

    
3132
   <xsl:template priority="5" match="fo:simple-page-master/@size">
3133
      <xsl:call-template name="quantitative-values">
3134
         <xsl:with-param name="valuelist"> auto landscape portrait </xsl:with-param>
3135
      </xsl:call-template>
3136
   </xsl:template>
3137

    
3138
   <xsl:template match="@vertical-align">
3139
      <xsl:call-template name="quantitative-values">
3140
         <xsl:with-param name="valuelist"> baseline middle sub super text-top text-bottom top bottom inherit </xsl:with-param>
3141
      </xsl:call-template>
3142
   </xsl:template>
3143

    
3144
   <xsl:template match="@white-space">
3145
      <xsl:call-template name="disable-on-graphics"/>
3146
      <xsl:call-template name="enumerated-values">
3147
         <xsl:with-param name="valuelist"> normal pre nowrap inherit </xsl:with-param>
3148
      </xsl:call-template>
3149
   </xsl:template>
3150

    
3151
   <xsl:template match="@xml:lang">
3152
      <xsl:call-template name="disable-on-graphics"/>
3153
   </xsl:template>
3154

    
3155

    
3156
   <!-- RenderX extensions -->
3157

    
3158
<xsl:template match="@rx:background-content-width                    | @rx:background-content-height"
3159
                 priority="3">
3160
      <xsl:call-template name="quantitative-values">
3161
         <xsl:with-param name="valuelist"> auto scale-to-fit inherit </xsl:with-param>
3162
      </xsl:call-template>
3163
   </xsl:template>
3164

    
3165
   <xsl:template match="@rx:background-scaling" priority="3">
3166
      <xsl:call-template name="enumerated-values">
3167
         <xsl:with-param name="valuelist"> uniform non-uniform inherit </xsl:with-param>
3168
      </xsl:call-template>
3169
   </xsl:template>
3170

    
3171
   <xsl:template match="rx:meta-field/@name" priority="5"/>
3172
   <xsl:template match="rx:meta-field/@value" priority="5"/>
3173

    
3174
   <xsl:template match="@rx:key | rx:begin-index-range/@key"/>
3175

    
3176
   <xsl:template match="rx:pinpoint/@value"/>
3177

    
3178
   <xsl:template match="rx:page-index/@ref-key | rx:index-item/@ref-key"/>
3179

    
3180
   <xsl:template match="@rx:list-separator | rx:page-index/@list-separator">
3181
      <xsl:call-template name="disable-on-atomic-inlines"/>
3182
      <xsl:call-template name="disable-on-graphics"/>
3183
   </xsl:template>
3184

    
3185
   <xsl:template match="@rx:range-separator | rx:page-index/@range-separator | rx:index-item/@range-separator">
3186
      <xsl:call-template name="disable-on-atomic-inlines"/>
3187
      <xsl:call-template name="disable-on-graphics"/>
3188
   </xsl:template>
3189

    
3190
   <xsl:template match="@rx:merge-subsequent-page-numbers | rx:page-index/@merge-subsequent-page-numbers | rx:index-item/@merge-subsequent-page-numbers">
3191
      <xsl:call-template name="disable-on-atomic-inlines"/>
3192
      <xsl:call-template name="disable-on-graphics"/>
3193
      <xsl:call-template name="enumerated-values">
3194
         <xsl:with-param name="valuelist"> false true </xsl:with-param>
3195
      </xsl:call-template>
3196
   </xsl:template>
3197

    
3198
   <xsl:template match="@rx:link-back | rx:page-index/@link-back | rx:index-item/@link-back">
3199
      <xsl:call-template name="disable-on-atomic-inlines"/>
3200
      <xsl:call-template name="disable-on-graphics"/>
3201
      <xsl:call-template name="enumerated-values">
3202
         <xsl:with-param name="valuelist"> false true </xsl:with-param>
3203
      </xsl:call-template>
3204
   </xsl:template>
3205

    
3206
   <!-- =================================== -->
3207
<!-- Print an error message              -->
3208

    
3209
<xsl:template name="print-error">
3210
      <xsl:param name="msg"/>
3211
      <xsl:message>[error] <xsl:value-of select="normalize-space($msg)"/>
3212
      </xsl:message>
3213
   </xsl:template>
3214

    
3215
   <!-- =================================== -->
3216
<!-- Print a warning message             -->
3217

    
3218
<xsl:template name="print-warning">
3219
      <xsl:param name="msg"/>
3220
      <xsl:message>[warning] <xsl:value-of select="normalize-space($msg)"/>
3221
      </xsl:message>
3222
   </xsl:template>
3223

    
3224
</xsl:stylesheet>