flazz-schematron 0.0.0 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1749 @@
1
+ <?xml version="1.0"?><?xar XSLT?>
2
+
3
+ <!--
4
+ OVERVIEW
5
+
6
+ ASCC/Schematron.com Skeleton Module for ISO Schematron (for XSLT1 systems)
7
+
8
+ ISO Schematron is a language for making assertion about the presence or absence
9
+ of patterns in XML documents. It is typically used for as a schema language, or
10
+ to augment existing schema languages, and to check business rules. It is very
11
+ powerful, yet quite simple: a developer only need know XPath and about five other
12
+ elements.
13
+
14
+ This is an open source implementation of ISO Schematron in XSLT. Although ISO does
15
+ not allow reference implementations which might compete with the text of the
16
+ standard, this code has been compiled by Rick Jelliffe, inventor of Schematron
17
+ and editor of the ISO standard; so developers can certainly use it as an
18
+ unofficial reference implementation for clarification.
19
+
20
+ This implementation is based on one by Oliver Becker. API documentation is
21
+ available separately; try www.schematron.com for this. Funding for this
22
+ stylesheet over the years has come from Topologi Pty. Ltd., Geotempo Ltd.,
23
+ and ASCC, Tapei.
24
+
25
+ There are two versions of this skeleton: one is tailored for XSLT1 processors
26
+ and the other is tailored for XSLT2 processors. Future versions of the
27
+ XSLT2 skeleton may support more features than that the XSLT 1 skeleton.
28
+ -->
29
+ <!--
30
+ TIPS
31
+
32
+ A tip for new users of Schematron: make your assertions contain positive messages
33
+ about what is expected, rather than error messages. For example, use the form
34
+ "An X should have a Y, because Z".
35
+
36
+ Another tip is that Schematron provides an
37
+ element <sch:ns> for declaring the namespaces and prefixes used in Xpaths in
38
+ attribute values; it does not extend the XML Namespaces mechanism: if a name
39
+ in an XPath has a prefix, there must be an <sch:ns> element for that prefix; if
40
+ a name in an XPath does not have a prefix, it is always in no namespace.
41
+
42
+ A tip for implementers of Schematron, either using this API or re-implementing it:
43
+ make the value of the diagnostics, flags and richer features available if possible;
44
+ Schematron has many of the optional richer features which, if implemented, provide
45
+ a compelling alternative approach to validation and business-rules checking compared
46
+ to other schema languages and programs.
47
+
48
+ If you create your own meta-stylesheet to override this one, it is a
49
+ good idea to have both in the same directory and to run the stylesheet
50
+ from that directory, as many XSLT implementations have ideosyncratic
51
+ handling of URLs: keep it simple.
52
+ -->
53
+
54
+
55
+ <!--
56
+ INVOCATION INFORMATION
57
+
58
+ The following parameters are available
59
+
60
+ phase NMTOKEN | "#ALL" (default) Select the phase for validation
61
+ allow-foreign "true" | "false" (default) Pass non-Schematron elements to the generated stylesheet
62
+ sch.exslt.imports semi-colon delimited string of filenames for some EXSLT implementations
63
+ message-newline "true" (default) | "false" Generate an extra newline at the end of messages
64
+ optimize "visit-no-attributes"
65
+ debug "true" | "false" (default) Debug mode lets compilation continue despite problems
66
+ attributes "true" | "false" (Autodetecting) Use only when the schema has no attributes as the context nodes
67
+ only-child-elements "true" | "false" (Autodetecting) Use only when the schema has no comments
68
+ or PI as the context nodes
69
+
70
+ The following parameters can be specified as Schematron variables in diagnostics, assertions and so on.
71
+ fileNameParameter string
72
+ fileDirParameter string
73
+ archiveNameParameter string In case of ZIP files
74
+ archiveDirParameter string In case of ZIP files
75
+ output-encoding Use when outputting to XML
76
+
77
+ Experimental: USE AT YOUR OWN RISK
78
+ visit-text "true" "false" Also visist text nodes for context. WARNING: NON_STARDARD.
79
+ select-contents '' | 'key' | '//' Select different implementation strategies
80
+
81
+ Conventions: Meta-stylesheets that override this may use the following parameters
82
+ generate-paths=true|false generate the @location attribute with XPaths
83
+ diagnose= yes | no Add the diagnostics to the assertion test in reports
84
+ terminate= yes | no Terminate on the first failed assertion or successful report
85
+ -->
86
+
87
+ <!--
88
+ XSLT VERSION SUPPORT
89
+
90
+ XSLT 1:
91
+ A schema using the standard XSLT 1 query binding will have a /schema/@queryBinding='xslt' or
92
+ nothing.
93
+
94
+ * Note: XT does not implement key() and will die if given it.
95
+ * Add all formal parameters to default templates
96
+ * Fix missing apply-templates from process-ns and add params back
97
+
98
+ EXSLT: Experimental support
99
+ A schema using the EXSLT query binding will have a /schema/@queryBinding='exslt'.
100
+ It is built on XSLT 1. After experience is gained, this binding is expected to be
101
+ formalized as part of ISO Schematron, which currently reserves the "exslt" name for this purpose.
102
+
103
+ Some EXSLT engines have the extra functions built-in. For these, there is no need to
104
+ provide library locations. For engines that require the functions, either hard code
105
+ them in this script or provide them on the command-line argument.
106
+
107
+ -->
108
+ <!--
109
+ PROCESS INFORMATION
110
+
111
+ This stylesheet compiles a Schematron schema (*.sch) into XSLT code (*.xsl).
112
+ The generated XSLT code can then be run against an XML file (*.xml, etc) and
113
+ will produce validation results.
114
+
115
+ The output of validation results is performed using named templates (process-*).
116
+ These can be overridden easily by making a new XSLT stylesheet that imports this
117
+ stylesheet but has its own version of the relevant process-* templates. Several
118
+ of these invoking stylesheets are available: "iso_svrl.xsl", for example generates
119
+ ISO Schematron Validation Report Language format results.
120
+
121
+ In this version of the stylesheet, the ISO feature called "abstract patterns" is
122
+ implemented using macro processing: a prior XSLT stage to which converts uses
123
+ of abstract patterns into normal patterns. If you do not use abstract patterns,
124
+ it is not necessary to preprocess the schema.
125
+
126
+ To summarize, a basic process flow for some commandline processor is like this:
127
+ XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_schematron_skeleton.xsl
128
+ XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
129
+
130
+ iso_svrl.xslt is an implementation of Schematron that can use this skeleton and
131
+ generate ISO SVRL reports. A process flow for some commandline processor would
132
+ be like this:
133
+ XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_svrl.xsl
134
+ XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
135
+
136
+ It is not impossible that ultimately a third stage, to handle macro-preprocessing
137
+ and inclusion, might be necessary. (The trade-off is in making this XSLT more
138
+ complex compared to making the outer process more complex.)
139
+
140
+ This version has so far been tested with
141
+ Saxon 8
142
+ MSXML 4 (or 6?)
143
+
144
+ Please note that if you are using SAXON and JAXP, then you should use
145
+ System.setProperty("javax.xml.transform.TransformerFactory",
146
+ "net.sf.saxon.TransformerFactoryImpl");
147
+ rather than
148
+ System.setProperty("javax.xml.xpath.TransformerFactory",
149
+ "net.sf.saxon.TransformerFactoryImpl");
150
+ which is does not work, at least for the versions of SAXON we tried.
151
+ -->
152
+ <!--
153
+ LEGAL INFORMATION
154
+
155
+ Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
156
+
157
+ This software is provided 'as-is', without any express or implied warranty.
158
+ In no event will the authors be held liable for any damages arising from
159
+ the use of this software.
160
+
161
+ Permission is granted to anyone to use this software for any purpose,
162
+ including commercial applications, and to alter it and redistribute it freely,
163
+ subject to the following restrictions:
164
+
165
+ 1. The origin of this software must not be misrepresented; you must not claim
166
+ that you wrote the original software. If you use this software in a product,
167
+ an acknowledgment in the product documentation would be appreciated but is
168
+ not required.
169
+
170
+ 2. Altered source versions must be plainly marked as such, and must not be
171
+ misrepresented as being the original software.
172
+
173
+ 3. This notice may not be removed or altered from any source distribution.
174
+ -->
175
+ <!--
176
+ VERSION INFORMATION
177
+ 2008-08-06
178
+ * TT Top-level lets need to be implemented using xsl:param not xsl:variable
179
+ * TT xsl:param/@select must have XPath or not be specified
180
+
181
+ Version: 2008-07-28
182
+ * KH schematron-get-full-path-3 has [index] even on top step
183
+ * RJ fix schematron-get-full-path to have namespace predicate, I don't know why this was removed
184
+
185
+ Version: 2008-07-24
186
+ * RJ clean out commented out namespace handling code
187
+ * RJ add support for experimental non-standard attribute report/@action
188
+ and assert/@action, and add parameter not in the published API (should
189
+ not break anything, it is XSLT1)
190
+ * RJ Remove remaining XSLT2 code for ease of reading
191
+
192
+ Version: 2008-07-14 minor update for inclusion experiments
193
+ * RJ Clean up zero-length fragment test on include
194
+ * RJ Add experimental support for include containers
195
+ * RJ For path generation, test for //iso:schema not just /iso:schema, for potential embedded Schematron support
196
+ * RJ Don't generate double error messages for old namespace elements
197
+ * RJ Experimental iso:rule/iso:title just kept as comment (bigger request Uche Ogbuji)
198
+ * RJ Remove spurious debug messages
199
+ * RJ Fix bug that prevented including patterns in this (report Roger
200
+ Costello)
201
+
202
+ Version: 2007-10-17
203
+ From this version on I am forking XSLT2 support to a different version of the script.
204
+ This is due to the increasingly horrible state of the namespace handling code as well
205
+ as other inconsistencies between the major implementations of different versions.
206
+ The intent is that future versions of this will have XSLT2 isms removed and be simplified
207
+ to cope with only XSLT1 and EXLST. Note that though this version is called
208
+ iso_schematron_skeleton_for_xslt1, the various meta-stylesheets will continue to just call
209
+ iso_schematron_skeleton: it is up to you to rename the stylesheet to the one you want to
210
+ use.
211
+
212
+ * RJ fix FULL-PATH problem with attribute names
213
+
214
+
215
+ Version: 2007-07-19
216
+ Accept most changes in David Carlisle's fork, but continue as XSLT1 script:
217
+ http://dpcarlisle.blogspot.com/search/label/schematron
218
+ * DPC Remove "optimize" parameter
219
+ * DPC Add autodetecting optimize parameter attribute to skip checking attribute
220
+ context
221
+ * DPC Add autodetecting optimize parameter only-child-elements turn off checking for
222
+ comments and PIs
223
+ * DPC (Experimental: NON_STANDARD DANGER!) Add param visit-text to viist text
224
+ nodes too for context
225
+ * DPC Fix inclusion syntax to allow #
226
+ * DPC Priorities count up from 1000 not down from 4000 to allow more rules
227
+ * RJ Add new template for titles of schemas, with existing behaviour.
228
+ Override process-schema-title for custom processing of title
229
+
230
+
231
+ Version: 2007-04-04
232
+ * RJ debug mode param
233
+ * RJ alter mixed test to only test mixed branches, so the same document
234
+ could have old and new namespaces schemas in it, but each schema must
235
+ be distinct, just so as not to overconstrain things.
236
+ * KH zero-length include/@href is fatal error, but allow debug mode
237
+ * SB add hint on SAXON and JAXP
238
+ * DC generate-full-path-1 generates XLST1 code by default
239
+ Version: 2007-03-05
240
+ * AS Typo for EXSLT randome, improve comment
241
+ * KH get-schematron-full-path-2 needs to apply to attributes too
242
+ * DP document policy on extensions better
243
+ * DC use copy-of not copy for foreign elements
244
+ * DC add generate-path-2
245
+ * DC don't try to apply templates to attribute axis on attribute nodes, to
246
+ stop SAXON warning.
247
+ * RJ improve reporting of typos
248
+
249
+ Version: 2007-02-08
250
+ * KH Schematron fullpath implementation: @* handled twice and / missing
251
+ * KH Change stylesheetbody from named template to mode to allow implementers more flexibility.
252
+ Move process-ns to outside the stylesheet body.
253
+ * DP, FG, fix handling of xslt:key
254
+ * FG no iso:title/@class
255
+ * Experimental optimization 'visit-no-attributes'
256
+ * KH Experimental added schematron-get-full-path-2 which gives prefixed version for humans
257
+ * DC Move stylesheet/@version generation to after namespace handling
258
+ * DC, FG EXSLT namespace handling code
259
+ * FG add ref and commented code from FG's page on namespaces
260
+ * Start adding normalize-space() to parameter code
261
+ * Add a space between diagnostics
262
+
263
+ Version: 2007-01-22
264
+ * DP change = ($start) to = $start and =($phase) to =$phase
265
+ to run under Saxon 8.8j
266
+ * FG better title section using ( @id | sch:title)[last()]
267
+ * Default query language binding is "xslt" not "xslt1"
268
+
269
+ Version: 2007-01-19
270
+ * Simplify message newline code
271
+ * Remove termination and xpath appending to message options:
272
+ factor out as iso_schematron_terminator.xsl
273
+ * Comment out XSLT2 namespace fix temporarily
274
+
275
+ Version: 2007-01-18 (First beta candidate for comment)
276
+ * DC remove xml:space="preserve"
277
+ * FG improve comment on import statement
278
+ * DC improve comments on invocation section
279
+ * Add exploratory support for sch:schema[@queryBinding='xpath']
280
+ by allowing it and warning as lets are found
281
+ * Be strict about queryBinding spelling errors
282
+ * Extra comments on the different queryBindings
283
+ * KH Add option "message-paths" to generate XPath from output
284
+ * KH Add option "terminate" to halt with an error after the first assertion
285
+ * KH refactor paths in schematron-full-path
286
+ * Improve (?) namespace handling: no dummy attributes for prefix "xsl" generated
287
+
288
+ Version: 2007-01-15
289
+ * FG fix for calling templates
290
+ * Add formal parameters to default templates: may help XSLT 2
291
+ * Fix get-schematron-full-path
292
+ * Include skeleton1-6 is commented out by default
293
+
294
+ Version:2007-01-12 (Pre-beta release to Schematron-love-in maillist)
295
+ * Add many extra parameters to the process-* calls, so that almost
296
+ all the information in the schema can be provided to client programs.
297
+ Also, rearrange the parameters to fit in with the ISO schema, which
298
+ has "rich" and "linkable" attribute groups.
299
+ * Warn on diagnostics with no ID once only
300
+ * Improved path reporting, to handle for namespaces
301
+ * Add process-title dummy template for API
302
+ * Add command-line parameter allow-foreign (true|false) to suppress
303
+ warnings one foreign elements and pass them through to the generated
304
+ stylesheet
305
+ * remove legacy templates for the old ASCC namespace and no namespace,
306
+ and use an import statement instead. Much cleaner now!
307
+ * patterns use @id not @name
308
+ * titles can contain sub-elements
309
+ * start change sch:rule to allow attributes, PIs and comments
310
+ * the default process-* for inline elements add a leading and trailing
311
+ space, to reduce the chance of concatenation.
312
+ * add comments to make the generated code clearer
313
+
314
+ Version:2006-11-07 (ISO: first release private to schematron-love-in maillist for review)
315
+ * Duplicate pattern templates, for handling ISO namespace
316
+ * Add priority onto default and paragraph templates
317
+ * Add namespace checks
318
+ * Handle key in xsl namespace not iso
319
+ * Add include
320
+ * Improve namespace handling
321
+ * Preliminary XSLT2 and EXSLT support
322
+ * Refactor iso:schema for clarity
323
+
324
+ Version: 2003-05-26
325
+ * Fix bug with key
326
+ Version: 2003-04-16
327
+ * handle 1.6 let expressions
328
+ * make key use XSLT names, and allow anywhere
329
+ Version: 2001-06-13
330
+ * same skeleton now supports namespace or no namespace
331
+ * parameters to handlers updated for all 1.5 attributes
332
+ * diagnostic hints supported: command-line option diagnose=yes|no
333
+ * phases supported: command-line option phase=#ALL|...
334
+ * abstract rules
335
+ * compile-time error messages
336
+ * add utility routine generate-id-from-path
337
+
338
+ Contributors: Rick Jelliffe (original), Oliver Becker (architecture, XSLT2),
339
+ Miloslav Nic (diagnostic, phase, options), Ludwig Svenonius (abstract)
340
+ Uche Ogbuji (misc. bug fixes), Jim Ancona (SAXON workaround),
341
+ Francis Norton (generate-id-from-path), Robert Leftwich, Bryan Rasmussen,
342
+ Dave Pawson (include, fallback), Florent Georges (namespaces, exslt, attribute
343
+ context), Benoit Maisonny (attribute context), John Dumps (process-message newline),
344
+ Cliff Stanford (diagnostics and other newlines)
345
+
346
+
347
+ KNOWN TYPICAL LIMITATIONS:
348
+ * Don't use <sch:ns prefix="xsl" .../> with a namespace other than the standard
349
+ XSLT one. This would be a bizarre thing to do anyway.
350
+ * Don't use other prefixes for the XSLT namespace either; some implementations will
351
+ not handle it correctly.
352
+
353
+ EXTENSIONS:
354
+ ISO Schematron is designed as a framework with some standard query language
355
+ bindings. If you need to support other features, please do so safely by making
356
+ up your own @queryLanguage name: this makes it clear that your schema requires
357
+ special features. For example, default ISO Schematron does not support user
358
+ defined functions; so if you want to use the user defined function feature
359
+ in XSLT, you need to have a schema with some queryBinding attribute name like
360
+ "XSLT-with-my-functions" or whatever.
361
+ -->
362
+
363
+
364
+
365
+
366
+ <xsl:stylesheet version="1.0"
367
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
368
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
369
+ xmlns:sch="http://www.ascc.net/xml/schematron"
370
+ xmlns:iso="http://purl.oclc.org/dsdl/schematron"
371
+ xmlns:exsl="http://exslt.org/common"
372
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt"
373
+ extension-element-prefixes="exsl msxsl"
374
+ >
375
+ <!-- This program implements ISO Schematron, except for abstract patterns which require a preprocess. -->
376
+
377
+
378
+ <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
379
+
380
+
381
+ <!-- Category: top-level-element -->
382
+ <xsl:output method="xml" omit-xml-declaration="no" standalone="yes" indent="yes"/>
383
+
384
+
385
+ <xsl:param name="phase">
386
+ <xsl:choose>
387
+ <xsl:when test="//sch:schema/@defaultPhase">
388
+ <xsl:value-of select="//sch:schema/@defaultPhase"/>
389
+ </xsl:when>
390
+ <xsl:when test="//iso:schema/@defaultPhase">
391
+ <xsl:value-of select="//iso:schema/@defaultPhase"/>
392
+ </xsl:when>
393
+ <xsl:otherwise>#ALL</xsl:otherwise>
394
+ </xsl:choose>
395
+ </xsl:param>
396
+
397
+ <xsl:param name="allow-foreign">false</xsl:param>
398
+
399
+ <xsl:param name="message-newline">true</xsl:param>
400
+
401
+ <!-- DPC set to true if contexts should be checked on attribute nodes
402
+ defaults to true if there is any possibility that a context could match an attribute,
403
+ err on the side if caution, a context of *[.='@'] would cause this param to defualt to true
404
+ even though @ is in a string
405
+ -->
406
+ <xsl:param name="attributes">
407
+ <xsl:choose>
408
+ <xsl:when test="//iso:rule[contains(@context,'@') or contains(@context,'attribute')]">true</xsl:when>
409
+ <xsl:otherwise>false</xsl:otherwise>
410
+ </xsl:choose>
411
+ </xsl:param>
412
+
413
+ <!-- DPC set to true if contexts should be checked on just elements in the child axis
414
+ defaults to true if there is any possibility that a context could match an comment or PI
415
+ err on the side if caution, a context of *[.='('] would cause this param to defualt to true
416
+ even though ( is in a string, but node() comment() and processing-instruction() all have a (
417
+ -->
418
+ <xsl:param name="only-child-elements">
419
+ <xsl:choose>
420
+ <xsl:when test="//iso:rule[contains(@context,'(')]">true</xsl:when>
421
+ <xsl:otherwise>false</xsl:otherwise>
422
+ </xsl:choose>
423
+ </xsl:param>
424
+
425
+ <!-- DPC set to true if contexts should be checked on text nodes nodes (if only-child-elements is false)
426
+ THIS IS NON CONFORMANT BEHAVIOUR JUST FOR DISCUSSION OF A POSSIBLE CHANGE TO THE
427
+ SPECIFICATION. THIS PARAM SHOULD GO IF THE FINAL DECISION IS THAT THE SPEC DOES NOT CHANGE.
428
+ Always defaults to false
429
+ -->
430
+ <xsl:param name="visit-text" select="'false'"/>
431
+
432
+ <!-- DPC
433
+ When selecting contexts the specified behaviour is
434
+ @*|node()[not(self::text())]
435
+ The automatic settings may use
436
+ node()[not(self::text())]
437
+ @*|*
438
+ *
439
+ instead for schema for which they are equivalent.
440
+ If the params are set explictly the above may be used, and also either if
441
+ @*
442
+ @*|node()
443
+ in all cases the result may not be equivalent, for example if you specify no attributes and the schema
444
+ does have attribute contexts they will be silently ignored.
445
+
446
+ after testing it turns out that
447
+ node()[not(self::text())] is slower in saxon than *|comment()|processing-instruction()
448
+ which I find a bit surprising but anyway I'll use the longr faster version.
449
+ -->
450
+ <xsl:variable name="context-xpath">
451
+ <xsl:if test="$attributes='true'">@*|</xsl:if>
452
+ <xsl:choose>
453
+ <xsl:when test="$only-child-elements='true'">*</xsl:when>
454
+ <xsl:when test="$visit-text='true'">node()</xsl:when>
455
+ <xsl:otherwise>*|comment()|processing-instruction()</xsl:otherwise>
456
+ </xsl:choose>
457
+ </xsl:variable>
458
+
459
+ <!-- DPC if this is set to
460
+ '' use recursive templates to iterate over document tree,
461
+ 'key' select all contexts with a key rather than walking the tree explictly in each mode
462
+ '//' select all contexts with // a key rather than walking the tree explictly in each mode (XSLT2 only)
463
+ -->
464
+ <xsl:param name="select-contexts" select="''"/>
465
+
466
+
467
+ <xsl:param name="output-encoding"/>
468
+ <!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
469
+ <xsl:param name="sch.exslt.imports"/>
470
+
471
+ <xsl:param name="debug">false</xsl:param>
472
+
473
+ <!-- Simple namespace check -->
474
+ <xsl:template match="/">
475
+ <xsl:if test="//sch:*[ancestor::iso:* or descendant::iso:*]">
476
+ <xsl:message>Schema error: Schematron elements in old and new namespaces found</xsl:message>
477
+ <xsl:if test=" $debug = 'false' " />
478
+ </xsl:if>
479
+
480
+ <xsl:apply-templates />
481
+ </xsl:template>
482
+
483
+
484
+ <!-- ============================================================== -->
485
+ <!-- ISO SCHEMATRON SCHEMA ELEMENT -->
486
+ <!-- Not handled: Abstract patterns. A pre-processor is assumed. -->
487
+ <!-- ============================================================== -->
488
+
489
+ <!-- SCHEMA -->
490
+ <!-- Default uses XSLT 1 -->
491
+ <xsl:template match="iso:schema[not(@queryBinding) or @queryBinding='xslt'
492
+ or @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'
493
+ or @queryBinding='xpath']">
494
+ <xsl:if test="
495
+ @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'">
496
+ <xsl:message>Schema error: in the queryBinding attribute, use 'xslt'</xsl:message>
497
+ </xsl:if>
498
+ <axsl:stylesheet>
499
+ <xsl:apply-templates select="iso:ns"/>
500
+ <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
501
+ <xsl:attribute name="version">1.0</xsl:attribute>
502
+
503
+ <xsl:apply-templates select="." mode="stylesheetbody"/>
504
+ <!-- was xsl:call-template name="stylesheetbody"/ -->
505
+ </axsl:stylesheet>
506
+ </xsl:template>
507
+
508
+ <!-- Using EXSLT with all modeles (except function module: not applicable) -->
509
+ <xsl:template match="iso:schema[@queryBinding='exslt']" priority="10">
510
+ <xsl:comment>This XSLT was automatically generated from a Schematron schema.</xsl:comment>
511
+ <axsl:stylesheet
512
+ xmlns:date="http://exslt.org/dates-and-times"
513
+ xmlns:dyn="http://exslt.org/dynamic"
514
+ xmlns:exsl="http://exslt.org/common"
515
+ xmlns:math="http://exslt.org/math"
516
+ xmlns:random="http://exslt.org/random"
517
+ xmlns:regexp="http://exslt.org/regular-expressions"
518
+ xmlns:set="http://exslt.org/sets"
519
+ xmlns:str="http://exslt.org/strings"
520
+ extension-element-prefixes="date dyn exsl math random regexp set str" >
521
+
522
+ <xsl:apply-templates select="iso:ns"/>
523
+ <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
524
+ <xsl:attribute name="version">1.0</xsl:attribute>
525
+
526
+ <xsl:apply-templates select="." mode="stylesheetbody"/>
527
+ <!-- was xsl:call-template name="stylesheetbody"/ -->
528
+ </axsl:stylesheet>
529
+ </xsl:template>
530
+
531
+
532
+ <!-- Default uses XSLT 1 -->
533
+ <xsl:template match="iso:schema" priority="-1">
534
+ <xsl:message terminate="yes" >Fail: This implementation of ISO Schematron does not work with
535
+ schemas using the "<xsl:value-of select="@queryBinding"/>" query language.</xsl:message>
536
+ </xsl:template>
537
+
538
+ <xsl:template match="*" mode="stylesheetbody">
539
+ <!--xsl:template name="stylesheetbody"-->
540
+ <xsl:comment>Implementers: please note that overriding process-prolog or process-root is
541
+ the preferred method for meta-stylesheets to use where possible. </xsl:comment><xsl:text>&#10;</xsl:text>
542
+
543
+ <!-- These parameters may contain strings with the name and directory of the file being
544
+ validated. For convenience, if the caller only has the information in a single string,
545
+ that string could be put in fileDirParameter. The archives parameters are available
546
+ for ZIP archives.
547
+ -->
548
+
549
+ <axsl:param name="archiveDirParameter" />
550
+ <axsl:param name="archiveNameParameter" />
551
+ <axsl:param name="fileNameParameter" />
552
+ <axsl:param name="fileDirParameter" />
553
+
554
+ <xsl:call-template name="iso:exslt.add.imports" />
555
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PHASES</xsl:comment><xsl:text>&#10;</xsl:text>
556
+ <xsl:call-template name="handle-phase"/>
557
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PROLOG</xsl:comment><xsl:text>&#10;</xsl:text>
558
+ <xsl:call-template name="process-prolog"/>
559
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>KEYS</xsl:comment><xsl:text>&#10;</xsl:text>
560
+ <xsl:apply-templates mode="do-keys" select="xsl:key "/>
561
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>DEFAULT RULES</xsl:comment><xsl:text>&#10;</xsl:text>
562
+ <xsl:call-template name="generate-default-rules" />
563
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMA METADATA</xsl:comment><xsl:text>&#10;</xsl:text>
564
+ <xsl:call-template name="handle-root"/>
565
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMATRON PATTERNS</xsl:comment><xsl:text>&#10;</xsl:text>
566
+
567
+ <xsl:apply-templates select="*[not(self::iso:ns)] " />
568
+ </xsl:template>
569
+
570
+ <xsl:template name="iso:exslt.add.imports">
571
+ <xsl:param name="imports" select="$sch.exslt.imports"/>
572
+ <xsl:choose>
573
+ <xsl:when test="contains($imports, ';')">
574
+ <axsl:import href="{ substring-before($imports, ';') }"/>
575
+ <xsl:call-template name="iso:exslt.add.imports">
576
+ <xsl:with-param name="imports" select="substring-after($imports, ';')"/>
577
+ </xsl:call-template>
578
+ </xsl:when>
579
+ <xsl:when test="$imports">
580
+ <axsl:import href="{ $imports }"/>
581
+ </xsl:when>
582
+ </xsl:choose>
583
+ </xsl:template>
584
+
585
+ <xsl:template name="handle-phase" >
586
+ <xsl:if test="not(normalize-space( $phase ) = '#ALL')">
587
+ <xsl:if test="not(iso:phase[@id = normalize-space( $phase )])">
588
+ <xsl:message>Phase Error: no phase with name <xsl:value-of select="normalize-space( $phase )"
589
+ /> has been defined.</xsl:message>
590
+ </xsl:if>
591
+ </xsl:if>
592
+ </xsl:template>
593
+
594
+ <xsl:template name="generate-default-rules">
595
+ <xsl:text>&#10;&#10;</xsl:text>
596
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH</xsl:comment><xsl:text>&#10;</xsl:text>
597
+ <xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text>&#10;</xsl:text>
598
+ <axsl:template match="*" mode="schematron-get-full-path">
599
+ <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
600
+
601
+ <!-- XSLT1 syntax -->
602
+
603
+ <axsl:text>/</axsl:text>
604
+ <axsl:choose>
605
+ <axsl:when test="namespace-uri()=''">
606
+ <axsl:value-of select="name()"/>
607
+ <axsl:variable name="p" select="1+
608
+ count(preceding-sibling::*[name()=name(current())])" />
609
+ <axsl:if test="$p&gt;1 or following-sibling::*[name()=name(current())]">
610
+ <xsl:text/>[<axsl:value-of select="$p"/>]<xsl:text/>
611
+ </axsl:if>
612
+ </axsl:when>
613
+ <axsl:otherwise>
614
+ <axsl:text>*[local-name()='</axsl:text>
615
+ <axsl:value-of select="local-name()"/><axsl:text>' and namespace-uri()='</axsl:text>
616
+ <axsl:value-of select="namespace-uri()"/>
617
+ <axsl:text>']</axsl:text>
618
+ <axsl:variable name="p" select="1+
619
+ count(preceding-sibling::*[local-name()=local-name(current())])" />
620
+ <axsl:if test="$p&gt;1 or following-sibling::*[local-name()=local-name(current())]">
621
+ <xsl:text/>[<axsl:value-of select="$p"/>]<xsl:text/>
622
+ </axsl:if>
623
+ </axsl:otherwise>
624
+ </axsl:choose>
625
+ </axsl:template>
626
+
627
+
628
+ <axsl:template match="@*" mode="schematron-get-full-path">
629
+
630
+ <!-- XSLT1 syntax -->
631
+ <axsl:text>/</axsl:text>
632
+ <axsl:choose>
633
+ <axsl:when test="namespace-uri()=''">@<axsl:value-of
634
+ select="name()"/></axsl:when>
635
+ <axsl:otherwise>
636
+ <axsl:text>@*[local-name()='</axsl:text>
637
+ <axsl:value-of select="local-name()"/>
638
+ <axsl:text>' and namespace-uri()='</axsl:text>
639
+ <axsl:value-of select="namespace-uri()"/>
640
+ <axsl:text>']</axsl:text>
641
+ </axsl:otherwise>
642
+ </axsl:choose>
643
+
644
+ </axsl:template>
645
+
646
+
647
+ <xsl:text>&#10;&#10;</xsl:text>
648
+
649
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH-2</xsl:comment>
650
+ <xsl:text>&#10;</xsl:text>
651
+ <xsl:comment>This mode can be used to generate prefixed XPath for humans</xsl:comment>
652
+ <xsl:text>&#10;</xsl:text>
653
+ <!--simplify the error messages by using the namespace prefixes of the
654
+ instance rather than the generic namespace-uri-styled qualification-->
655
+ <axsl:template match="node() | @*" mode="schematron-get-full-path-2">
656
+ <!--report the element hierarchy-->
657
+ <axsl:for-each select="ancestor-or-self::*">
658
+ <axsl:text>/</axsl:text>
659
+ <axsl:value-of select="name(.)"/>
660
+ <axsl:if test="preceding-sibling::*[name(.)=name(current())]">
661
+ <axsl:text>[</axsl:text>
662
+ <axsl:value-of
663
+ select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
664
+ <axsl:text>]</axsl:text>
665
+ </axsl:if>
666
+ </axsl:for-each>
667
+ <!--report the attribute-->
668
+ <axsl:if test="not(self::*)">
669
+ <axsl:text/>/@<axsl:value-of select="name(.)"/>
670
+ </axsl:if>
671
+ </axsl:template>
672
+
673
+ <xsl:text>&#10;&#10;</xsl:text>
674
+ <xsl:comment>MODE: GENERATE-ID-FROM-PATH </xsl:comment><xsl:text>&#10;</xsl:text>
675
+ <!-- repeatable-id maker derived from Francis Norton's. -->
676
+ <!-- use this if you need generate ids in separate passes,
677
+ because generate-id() is not guaranteed to produce the same
678
+ results each time. These ids are not XML names but closer to paths. -->
679
+ <axsl:template match="/" mode="generate-id-from-path"/>
680
+ <axsl:template match="text()" mode="generate-id-from-path">
681
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
682
+ <axsl:value-of select="concat('.text-', 1+count(preceding-sibling::text()), '-')"/>
683
+ </axsl:template>
684
+ <axsl:template match="comment()" mode="generate-id-from-path">
685
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
686
+ <axsl:value-of select="concat('.comment-', 1+count(preceding-sibling::comment()), '-')"/>
687
+ </axsl:template>
688
+ <axsl:template match="processing-instruction()" mode="generate-id-from-path">
689
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
690
+ <axsl:value-of
691
+ select="concat('.processing-instruction-', 1+count(preceding-sibling::processing-instruction()), '-')"/>
692
+ </axsl:template>
693
+ <axsl:template match="@*" mode="generate-id-from-path">
694
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
695
+ <axsl:value-of select="concat('.@', name())"/>
696
+ </axsl:template>
697
+ <axsl:template match="*" mode="generate-id-from-path" priority="-0.5">
698
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
699
+ <axsl:text>.</axsl:text>
700
+ <!--
701
+ <axsl:choose>
702
+ <axsl:when test="count(. | ../namespace::*) = count(../namespace::*)">
703
+ <axsl:value-of select="concat('.namespace::-',1+count(namespace::*),'-')"/>
704
+ </axsl:when>
705
+ <axsl:otherwise>
706
+ -->
707
+ <axsl:value-of
708
+ select="concat('.',name(),'-',1+count(preceding-sibling::*[name()=name(current())]),'-')"/>
709
+ <!--
710
+ </axsl:otherwise>
711
+ </axsl:choose>
712
+ -->
713
+ </axsl:template>
714
+
715
+
716
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH-3</xsl:comment>
717
+
718
+ <xsl:text>&#10;</xsl:text>
719
+ <xsl:comment>This mode can be used to generate prefixed XPath for humans
720
+ (Top-level element has index)</xsl:comment>
721
+ <xsl:text>&#10;</xsl:text>
722
+ <!--simplify the error messages by using the namespace prefixes of the
723
+ instance rather than the generic namespace-uri-styled qualification-->
724
+ <axsl:template match="node() | @*" mode="schematron-get-full-path-3">
725
+ <!--report the element hierarchy-->
726
+ <axsl:for-each select="ancestor-or-self::*">
727
+ <axsl:text>/</axsl:text>
728
+ <axsl:value-of select="name(.)"/>
729
+ <axsl:if test="parent::*">
730
+ <axsl:text>[</axsl:text>
731
+ <axsl:value-of
732
+ select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
733
+ <axsl:text>]</axsl:text>
734
+ </axsl:if>
735
+ </axsl:for-each>
736
+ <!--report the attribute-->
737
+ <axsl:if test="not(self::*)">
738
+ <axsl:text/>/@<axsl:value-of select="name(.)"/>
739
+ </axsl:if>
740
+ </axsl:template>
741
+
742
+ <xsl:text>&#10;&#10;</xsl:text>
743
+ <xsl:comment>MODE: GENERATE-ID-2 </xsl:comment><xsl:text>&#10;</xsl:text>
744
+ <!-- repeatable-id maker from David Carlisle. -->
745
+ <!-- use this if you need generate IDs in separate passes,
746
+ because generate-id() is not guaranteed to produce the same
747
+ results each time. These IDs are well-formed XML NMTOKENS -->
748
+ <axsl:template match="/" mode="generate-id-2">U</axsl:template>
749
+
750
+ <axsl:template match="*" mode="generate-id-2" priority="2">
751
+ <axsl:text>U</axsl:text>
752
+ <axsl:number level="multiple" count="*"/>
753
+ </axsl:template>
754
+
755
+ <axsl:template match="node()" mode="generate-id-2">
756
+ <axsl:text>U.</axsl:text>
757
+ <axsl:number level="multiple" count="*"/>
758
+ <axsl:text>n</axsl:text>
759
+ <axsl:number count="node()"/>
760
+ </axsl:template>
761
+
762
+ <axsl:template match="@*" mode="generate-id-2">
763
+ <axsl:text>U.</axsl:text>
764
+ <axsl:number level="multiple" count="*"/>
765
+ <axsl:text>_</axsl:text>
766
+ <axsl:value-of select="string-length(local-name(.))"/>
767
+ <axsl:text>_</axsl:text>
768
+ <axsl:value-of select="translate(name(),':','.')"/>
769
+ </axsl:template>
770
+
771
+
772
+ <xsl:comment>Strip characters</xsl:comment>
773
+ <axsl:template match="text()" priority="-1" />
774
+
775
+ </xsl:template>
776
+
777
+ <xsl:template name="handle-root">
778
+ <!-- Process the top-level element -->
779
+ <axsl:template match="/">
780
+ <xsl:call-template name="process-root">
781
+ <xsl:with-param
782
+ name="title" select="(@id | iso:title)[last()]"/>
783
+ <xsl:with-param name="version" select="'iso'" />
784
+ <xsl:with-param name="schemaVersion" select="@schemaVersion" />
785
+ <xsl:with-param name="queryBinding" select="@queryBinding" />
786
+ <xsl:with-param name="contents">
787
+ <xsl:apply-templates mode="do-all-patterns"/>
788
+ </xsl:with-param>
789
+
790
+ <!-- "Rich" properties -->
791
+ <xsl:with-param name="fpi" select="@fpi"/>
792
+ <xsl:with-param name="icon" select="@icon"/>
793
+ <xsl:with-param name="id" select="@id"/>
794
+ <xsl:with-param name="lang" select="@xml:lang"/>
795
+ <xsl:with-param name="see" select="@see" />
796
+ <xsl:with-param name="space" select="@xml:space" />
797
+
798
+
799
+ <!-- Non-standard extensions not part of the API yet -->
800
+ <xsl:with-param name="action" select="@action" />
801
+ </xsl:call-template>
802
+ </axsl:template>
803
+
804
+
805
+ </xsl:template>
806
+
807
+ <!-- ============================================================== -->
808
+ <!-- ISO SCHEMATRON ELEMENTS -->
809
+ <!-- ============================================================== -->
810
+
811
+ <!-- ISO ACTIVE -->
812
+ <xsl:template match="iso:active">
813
+ <xsl:if test="not(@pattern)">
814
+ <xsl:message>Markup Error: no pattern attribute in &lt;active></xsl:message>
815
+ </xsl:if>
816
+
817
+ <xsl:if test="not(../../iso:pattern[@id = current()/@pattern])
818
+ and not(../../iso:include)">
819
+ <xsl:message>Reference Error: the pattern "<xsl:value-of select="@pattern"
820
+ />" has been activated but is not declared</xsl:message>
821
+ </xsl:if>
822
+ </xsl:template>
823
+
824
+ <!-- ISO ASSERT and REPORT -->
825
+ <xsl:template match="iso:assert">
826
+
827
+ <xsl:if test="not(@test)">
828
+ <xsl:message>Markup Error: no test attribute in &lt;assert</xsl:message>
829
+ </xsl:if>
830
+ <xsl:text>&#10;&#10; </xsl:text>
831
+ <xsl:comment>ASSERT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
832
+
833
+ <axsl:choose>
834
+ <axsl:when test="{@test}"/>
835
+ <axsl:otherwise>
836
+ <xsl:call-template name="process-assert">
837
+ <xsl:with-param name="test" select="normalize-space(@test)" />
838
+ <xsl:with-param name="diagnostics" select="@diagnostics"/>
839
+ <xsl:with-param name="flag" select="@flag"/>
840
+
841
+ <!-- "Rich" properties -->
842
+ <xsl:with-param name="fpi" select="@fpi"/>
843
+ <xsl:with-param name="icon" select="@icon"/>
844
+ <xsl:with-param name="id" select="@id"/>
845
+ <xsl:with-param name="lang" select="@xml:lang"/>
846
+ <xsl:with-param name="see" select="@see" />
847
+ <xsl:with-param name="space" select="@xml:space" />
848
+
849
+ <!-- "Linking" properties -->
850
+ <xsl:with-param name="role" select="@role" />
851
+ <xsl:with-param name="subject" select="@subject" />
852
+ </xsl:call-template>
853
+
854
+ </axsl:otherwise>
855
+ </axsl:choose>
856
+ </xsl:template>
857
+ <xsl:template match="iso:report">
858
+
859
+ <xsl:if test="not(@test)">
860
+ <xsl:message>Markup Error: no test attribute in &lt;report></xsl:message>
861
+ </xsl:if>
862
+
863
+ <xsl:text>&#10;&#10; </xsl:text>
864
+ <xsl:comment>REPORT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
865
+
866
+ <axsl:if test="{@test}">
867
+
868
+ <xsl:call-template name="process-report">
869
+ <xsl:with-param name="test" select="normalize-space(@test)" />
870
+ <xsl:with-param name="diagnostics" select="@diagnostics"/>
871
+
872
+ <!-- "Rich" properties -->
873
+ <xsl:with-param name="fpi" select="@fpi"/>
874
+ <xsl:with-param name="icon" select="@icon"/>
875
+ <xsl:with-param name="id" select="@id"/>
876
+ <xsl:with-param name="lang" select="@xml:lang"/>
877
+ <xsl:with-param name="see" select="@see" />
878
+ <xsl:with-param name="space" select="@xml:space" />
879
+
880
+ <!-- "Linking" properties -->
881
+ <xsl:with-param name="role" select="@role" />
882
+ <xsl:with-param name="subject" select="@subject" />
883
+ </xsl:call-template>
884
+
885
+ </axsl:if>
886
+ </xsl:template>
887
+
888
+
889
+ <!-- ISO DIAGNOSTIC -->
890
+ <!-- We use a mode here to maintain backwards compatability, instead of adding it
891
+ to the other mode.
892
+ -->
893
+ <xsl:template match="iso:diagnostic" mode="check-diagnostics">
894
+ <xsl:if test="not(@id)">
895
+ <xsl:message>Markup Error: no id attribute in &lt;diagnostic></xsl:message>
896
+ </xsl:if>
897
+ </xsl:template>
898
+
899
+ <xsl:template match="iso:diagnostic" >
900
+ <xsl:call-template name="process-diagnostic">
901
+
902
+ <!-- "Rich" properties -->
903
+ <xsl:with-param name="fpi" select="@fpi"/>
904
+ <xsl:with-param name="icon" select="@icon"/>
905
+ <xsl:with-param name="id" select="@id"/>
906
+ <xsl:with-param name="lang" select="@xml:lang"/>
907
+ <xsl:with-param name="see" select="@see" />
908
+ <xsl:with-param name="space" select="@xml:space" />
909
+ </xsl:call-template>
910
+ </xsl:template>
911
+
912
+ <!-- ISO DIAGNOSTICS -->
913
+ <xsl:template match="iso:diagnostics" >
914
+ <xsl:apply-templates mode="check-diagnostics" select="*" />
915
+ </xsl:template>
916
+
917
+ <!-- ISO DIR -->
918
+ <xsl:template match="iso:dir" mode="text" >
919
+ <xsl:call-template name="process-dir">
920
+ <xsl:with-param name="value" select="@value"/>
921
+ </xsl:call-template>
922
+ </xsl:template>
923
+
924
+ <!-- ISO EMPH -->
925
+ <xsl:template match="iso:emph" mode="text">
926
+
927
+ <xsl:call-template name="process-emph"/>
928
+
929
+ </xsl:template>
930
+
931
+ <!-- ISO EXTENDS -->
932
+ <xsl:template match="iso:extends">
933
+ <xsl:if test="not(@rule)">
934
+ <xsl:message>Markup Error: no rule attribute in &lt;extends></xsl:message>
935
+ </xsl:if>
936
+ <xsl:if test="not(//iso:rule[@abstract='true'][@id= current()/@rule] )">
937
+ <xsl:message>Reference Error: the abstract rule "<xsl:value-of select="@rule"
938
+ />" has been referenced but is not declared</xsl:message>
939
+ </xsl:if>
940
+ <xsl:call-template name="IamEmpty" />
941
+
942
+ <xsl:if test="//iso:rule[@id=current()/@rule]">
943
+ <xsl:apply-templates select="//iso:rule[@id=current()/@rule]"
944
+ mode="extends"/>
945
+ </xsl:if>
946
+
947
+ </xsl:template>
948
+
949
+ <!-- KEY: ISO has no KEY -->
950
+ <!-- NOTE:
951
+ Key has had a checkered history. Schematron 1.0 allowed it in certain places, but
952
+ users came up with a different location, which has now been adopted.
953
+
954
+ XT, the early XSLT processor, did not implement key and died when it was present.
955
+ So there are some versions of the Schematron skeleton for XT that strip out all
956
+ key elements.
957
+
958
+ Xalan (e.g. Xalan4C 1.0 and a Xalan4J) also had a funny. A fix involved making
959
+ a top-level parameter called $hiddenKey and then using that instead of matching
960
+ "key". This has been removed.
961
+ -->
962
+ <xsl:template match="xsl:key" mode="do-keys" >
963
+ <xsl:if test="not(@name)">
964
+ <xsl:message>Markup Error: no name attribute in &lt;key></xsl:message>
965
+ </xsl:if>
966
+ <xsl:if test="not(@path) and not(@use)">
967
+ <xsl:message>Markup Error: no path or use attribute in &lt;key></xsl:message>
968
+ </xsl:if>
969
+ <xsl:choose>
970
+ <xsl:when test="parent::iso:rule ">
971
+ <xsl:call-template name="IamEmpty" />
972
+ <xsl:choose>
973
+ <xsl:when test="@path">
974
+ <axsl:key match="{../@context}" name="{@name}" use="{@path}"/>
975
+ </xsl:when>
976
+ <xsl:otherwise>
977
+ <axsl:key match="{../@context}" name="{@name}" use="{@use}"/>
978
+ </xsl:otherwise>
979
+ </xsl:choose>
980
+ </xsl:when>
981
+ <xsl:otherwise>
982
+ <xsl:if test="not(@match) ">
983
+ <xsl:message>Markup Error: no path or use attribute in &lt;key></xsl:message>
984
+ </xsl:if>
985
+ <axsl:key>
986
+ <xsl:copy-of select="@*"/>
987
+ </axsl:key>
988
+ </xsl:otherwise>
989
+ </xsl:choose>
990
+ </xsl:template>
991
+
992
+ <xsl:template match="xsl:key " /><!-- swallow -->
993
+
994
+ <xsl:template match="iso:key " >
995
+ <xsl:message>Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace.</xsl:message>
996
+ </xsl:template>
997
+
998
+ <!-- ISO INCLUDE -->
999
+ <!-- This is only a fallback. Include really needs to have been done before this as a separate pass.-->
1000
+
1001
+ <xsl:template match="iso:include[not(normalize-space(@href))]"
1002
+ priority="1">
1003
+ <xsl:if test=" $debug = 'false' ">
1004
+ <xsl:message terminate="yes">Schema error: Empty href= attribute for include directive.</xsl:message>
1005
+ </xsl:if>
1006
+
1007
+ </xsl:template>
1008
+
1009
+ <!-- Extend the URI syntax to allow # refererences -->
1010
+ <!-- Add experimental support for simple containers like /xxx:xxx/iso:pattern to allow better includes -->
1011
+ <xsl:template match="iso:include">
1012
+ <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
1013
+ <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
1014
+
1015
+ <xsl:choose>
1016
+
1017
+ <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
1018
+ <xsl:message>Error: Impossible URL in Schematron include</xsl:message>
1019
+ </xsl:when>
1020
+
1021
+ <xsl:when test="string-length( $fragment-id ) &gt; 0">
1022
+ <xsl:variable name="theDocument" select="document( $document-uri,/ )" />
1023
+ <xsl:variable name="theFragment" select="$theDocument//iso:*[@id= $fragment-id ]" />
1024
+ <xsl:if test=" $theFragment/self::iso:schema ">
1025
+ <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
1026
+ </xsl:if>
1027
+ <xsl:apply-templates select=" $theFragment"/>
1028
+ </xsl:when>
1029
+
1030
+ <xsl:otherwise>
1031
+ <xsl:variable name="theDocument" select="document( $document-uri,/ )" />
1032
+ <xsl:variable name="theFragment" select="$theDocument/iso:*" />
1033
+ <xsl:variable name="theContainedFragments" select="$theDocument/*/iso:*" />
1034
+ <xsl:if test=" $theFragment/self::iso:schema or $theContainedFragments/self::iso:schema">
1035
+ <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
1036
+ </xsl:if>
1037
+ <xsl:apply-templates select="$theFragment | $theContainedFragments "/>
1038
+ </xsl:otherwise>
1039
+ </xsl:choose>
1040
+ </xsl:template>
1041
+
1042
+ <!-- This is to handle the particular case of including patterns -->
1043
+ <xsl:template match="iso:include" mode="do-all-patterns">
1044
+ <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
1045
+ <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
1046
+
1047
+ <xsl:choose>
1048
+
1049
+ <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
1050
+ <xsl:message>Error: Impossible URL in Schematron include</xsl:message>
1051
+ </xsl:when>
1052
+
1053
+ <xsl:when test="string-length( $fragment-id ) &gt; 0">
1054
+ <xsl:variable name="theDocument" select="document( $document-uri,/ )" />
1055
+ <xsl:variable name="theFragment" select="$theDocument//iso:*[@id= $fragment-id ]" />
1056
+ <xsl:if test=" $theFragment/self::iso:schema ">
1057
+ <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
1058
+ </xsl:if>
1059
+ <xsl:apply-templates select=" $theFragment" mode="do-all-patterns"/>
1060
+ </xsl:when>
1061
+
1062
+ <xsl:otherwise>
1063
+ <!-- Import the top-level element if it is in schematron namespace,
1064
+ or its children otherwise, to allow a simple containment mechanism. -->
1065
+ <xsl:variable name="theDocument" select="document( $document-uri,/ )" />
1066
+ <xsl:variable name="theFragment" select="$theDocument/iso:*" />
1067
+ <xsl:variable name="theContainedFragments" select="$theDocument/*/iso:*" />
1068
+ <xsl:if test=" $theFragment/self::iso:schema or $theContainedFragments/self::iso:schema">
1069
+ <xsl:message>Schema error: Use include to include fragments, not a whole schema</xsl:message>
1070
+ </xsl:if>
1071
+ <xsl:apply-templates select="$theFragment | $theContainedFragments "
1072
+ mode="do-all-patterns" />
1073
+ </xsl:otherwise>
1074
+ </xsl:choose>
1075
+ </xsl:template>
1076
+
1077
+ <!-- ISO LET -->
1078
+ <xsl:template match="iso:let" >
1079
+ <xsl:if test="ancestor::iso:schema[@queryBinding='xpath']">
1080
+ <xsl:message>Warning: Variables should not be used with the "xpath" query language binding.</xsl:message>
1081
+ </xsl:if>
1082
+
1083
+ <!-- lets at the top-level are implemented as parameters -->
1084
+
1085
+ <xsl:choose>
1086
+ <xsl:when test="parent::iso:schema">
1087
+ <!-- it is an error to have an empty param/@select because an XPath is expected -->
1088
+ <axsl:param name="{@name}" select="{@value}">
1089
+ <xsl:if test="string-length(@value) &gt; 0">
1090
+ <xsl:attribute name="select"><xsl:value-of select="@value"/></xsl:attribute>
1091
+ </xsl:if>
1092
+ </axsl:param>
1093
+ </xsl:when>
1094
+ <xsl:otherwise>
1095
+ <axsl:variable name="{@name}" select="{@value}"/>
1096
+ </xsl:otherwise>
1097
+ </xsl:choose>
1098
+
1099
+ </xsl:template>
1100
+
1101
+ <!-- ISO NAME -->
1102
+ <xsl:template match="iso:name" mode="text">
1103
+
1104
+ <xsl:if test="@path">
1105
+ <xsl:call-template name="process-name">
1106
+ <xsl:with-param name="name" select="concat('name(',@path,')')"/>
1107
+ </xsl:call-template>
1108
+ </xsl:if>
1109
+ <xsl:if test="not(@path)">
1110
+ <xsl:call-template name="process-name">
1111
+ <xsl:with-param name="name" select="'name(.)'"/>
1112
+ </xsl:call-template>
1113
+ </xsl:if>
1114
+ <xsl:call-template name="IamEmpty" />
1115
+ </xsl:template>
1116
+
1117
+ <!-- ISO NS -->
1118
+ <!-- Namespace handling is XSLT is quite tricky and implementation dependent -->
1119
+ <xsl:template match="iso:ns">
1120
+ <xsl:call-template name="handle-namespace" />
1121
+ </xsl:template>
1122
+
1123
+ <!-- This template is just to provide the API hook -->
1124
+ <xsl:template match="iso:ns" mode="do-all-patterns" >
1125
+ <xsl:if test="not(@uri)">
1126
+ <xsl:message>Markup Error: no uri attribute in &lt;ns></xsl:message>
1127
+ </xsl:if>
1128
+ <xsl:if test="not(@prefix)">
1129
+ <xsl:message>Markup Error: no prefix attribute in &lt;ns></xsl:message>
1130
+ </xsl:if>
1131
+ <xsl:call-template name="IamEmpty" />
1132
+ <xsl:call-template name="process-ns" >
1133
+ <xsl:with-param name="prefix" select="@prefix"/>
1134
+ <xsl:with-param name="uri" select="@uri"/>
1135
+ </xsl:call-template>
1136
+ </xsl:template>
1137
+
1138
+ <!-- ISO P -->
1139
+ <xsl:template match="iso:schema/iso:p " mode="do-schema-p" >
1140
+ <xsl:call-template name="process-p">
1141
+ <xsl:with-param name="class" select="@class"/>
1142
+ <xsl:with-param name="icon" select="@icon"/>
1143
+ <xsl:with-param name="id" select="@id"/>
1144
+ <xsl:with-param name="lang" select="@xml:lang"/>
1145
+ </xsl:call-template>
1146
+ </xsl:template>
1147
+ <xsl:template match="iso:pattern/iso:p " mode="do-pattern-p" >
1148
+ <xsl:call-template name="process-p">
1149
+ <xsl:with-param name="class" select="@class"/>
1150
+ <xsl:with-param name="icon" select="@icon"/>
1151
+ <xsl:with-param name="id" select="@id"/>
1152
+ <xsl:with-param name="lang" select="@xml:lang"/>
1153
+ </xsl:call-template>
1154
+ </xsl:template>
1155
+
1156
+ <!-- Currently, iso:p in other position are not passed through to the API -->
1157
+ <xsl:template match="iso:phase/iso:p" />
1158
+ <xsl:template match="iso:p " priority="-1" />
1159
+
1160
+ <!-- ISO PATTERN -->
1161
+ <xsl:template match="iso:pattern" mode="do-all-patterns">
1162
+ <xsl:if test="($phase = '#ALL')
1163
+ or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
1164
+ <xsl:call-template name="process-pattern">
1165
+ <!-- the following select statement assumes that
1166
+ @id | sch:title returns node-set in document order:
1167
+ we want the title if it is there, otherwise the @id attribute -->
1168
+ <xsl:with-param name="name" select="(@id | iso:title )[last()]"/>
1169
+ <xsl:with-param name="is-a" select="''"/>
1170
+
1171
+ <!-- "Rich" properties -->
1172
+ <xsl:with-param name="fpi" select="@fpi"/>
1173
+ <xsl:with-param name="icon" select="@icon"/>
1174
+ <xsl:with-param name="id" select="@id"/>
1175
+ <xsl:with-param name="lang" select="@xml:lang"/>
1176
+ <xsl:with-param name="see" select="@see" />
1177
+ <xsl:with-param name="space" select="@xml:space" />
1178
+ </xsl:call-template>
1179
+ <xsl:choose>
1180
+ <xsl:when test="$select-contexts='key'">
1181
+ <axsl:apply-templates select="key('M','M{count(preceding-sibling::*)}')" mode="M{count(preceding-sibling::*)}"/>
1182
+ </xsl:when>
1183
+ <xsl:when test="$select-contexts='//'">
1184
+ <axsl:apply-templates mode="M{count(preceding-sibling::*)}">
1185
+ <xsl:attribute name="select">
1186
+ <xsl:text>//(</xsl:text>
1187
+ <xsl:for-each select="iso:rule/@context">
1188
+ <xsl:text>(</xsl:text>
1189
+ <xsl:value-of select="."/>
1190
+ <xsl:text>)</xsl:text>
1191
+ <xsl:if test="position()!=last()">|</xsl:if>
1192
+ </xsl:for-each>
1193
+ <xsl:text>)</xsl:text>
1194
+ <xsl:if test="$visit-text='false'">[not(self::text())]</xsl:if>
1195
+ </xsl:attribute>
1196
+ </axsl:apply-templates>
1197
+ </xsl:when>
1198
+ <xsl:otherwise>
1199
+ <axsl:apply-templates select="/" mode="M{count(preceding-sibling::*)}"/>
1200
+ </xsl:otherwise>
1201
+ </xsl:choose>
1202
+ </xsl:if>
1203
+ </xsl:template>
1204
+
1205
+ <xsl:template match="iso:pattern[@abstract='true']">
1206
+
1207
+ <xsl:message>Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already
1208
+ </xsl:message>
1209
+ </xsl:template>
1210
+
1211
+ <!-- Here is the template for the normal case of patterns -->
1212
+ <xsl:template match="iso:pattern[not(@abstract='true')]">
1213
+
1214
+ <xsl:if test="($phase = '#ALL')
1215
+ or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
1216
+
1217
+ <xsl:text>&#10;&#10;</xsl:text>
1218
+ <xsl:comment>PATTERN <xsl:value-of select="@id" /> <xsl:value-of select="iso:title" /> </xsl:comment><xsl:text>&#10;</xsl:text>
1219
+ <xsl:apply-templates />
1220
+
1221
+ <!-- DPC select-contexts test -->
1222
+ <xsl:if test="not($select-contexts)">
1223
+ <axsl:template match="text()" priority="-1" mode="M{count(preceding-sibling::*)}">
1224
+ <!-- strip characters -->
1225
+ </axsl:template>
1226
+
1227
+ <!-- DPC introduce context-xpath variable -->
1228
+ <axsl:template match="@*|node()"
1229
+ priority="-2"
1230
+ mode="M{ count(preceding-sibling::*) }">
1231
+ <axsl:apply-templates select="{$context-xpath}" mode="M{count(preceding-sibling::*)}"/>
1232
+ </axsl:template>
1233
+ </xsl:if>
1234
+ </xsl:if>
1235
+ </xsl:template>
1236
+
1237
+ <!-- ISO PHASE -->
1238
+ <xsl:template match="iso:phase" >
1239
+ <xsl:if test="not(@id)">
1240
+ <xsl:message>Markup Error: no id attribute in &lt;phase></xsl:message>
1241
+ </xsl:if>
1242
+ <xsl:apply-templates/>
1243
+ </xsl:template>
1244
+
1245
+ <!-- ISO RULE -->
1246
+ <xsl:template match="iso:rule[not(@abstract='true')] ">
1247
+ <xsl:if test="not(@context)">
1248
+ <xsl:message>Markup Error: no context attribute in &lt;rule></xsl:message>
1249
+ </xsl:if>
1250
+ <xsl:text>&#10;&#10; </xsl:text>
1251
+ <xsl:comment>RULE <xsl:value-of select="@id" /> </xsl:comment><xsl:text>&#10;</xsl:text>
1252
+ <xsl:if test="iso:title">
1253
+ <xsl:comment><xsl:value-of select="iso:title" /></xsl:comment>
1254
+ </xsl:if>
1255
+ <!-- DPC select-contexts -->
1256
+ <xsl:if test="$select-contexts='key'">
1257
+ <axsl:key name="M"
1258
+ match="{@context}"
1259
+ use="'M{count(../preceding-sibling::*)}'"/>
1260
+ </xsl:if>
1261
+
1262
+
1263
+ <!-- DPC priorities count up from 1000 not down from 4000 (templates in same priority order as before) -->
1264
+ <axsl:template match="{@context}"
1265
+ priority="{1000 + count(following-sibling::*)}" mode="M{count(../preceding-sibling::*)}">
1266
+ <xsl:call-template name="process-rule">
1267
+ <xsl:with-param name="context" select="@context"/>
1268
+
1269
+ <!-- "Rich" properties -->
1270
+ <xsl:with-param name="fpi" select="@fpi"/>
1271
+ <xsl:with-param name="icon" select="@icon"/>
1272
+ <xsl:with-param name="id" select="@id"/>
1273
+ <xsl:with-param name="lang" select="@xml:lang"/>
1274
+ <xsl:with-param name="see" select="@see" />
1275
+ <xsl:with-param name="space" select="@xml:space" />
1276
+
1277
+ <!-- "Linking" properties -->
1278
+ <xsl:with-param name="role" select="@role" />
1279
+ <xsl:with-param name="subject" select="@subject" />
1280
+ </xsl:call-template>
1281
+ <xsl:apply-templates/>
1282
+ <!-- DPC introduce context-xpath and select-contexts variables -->
1283
+ <xsl:if test="not($select-contexts)">
1284
+ <axsl:apply-templates select="{$context-xpath}" mode="M{count(../preceding-sibling::*)}"/>
1285
+ </xsl:if>
1286
+ </axsl:template>
1287
+ </xsl:template>
1288
+
1289
+
1290
+ <!-- ISO ABSTRACT RULE -->
1291
+ <xsl:template match="iso:rule[@abstract='true'] " >
1292
+ <xsl:if test=" not(@id)">
1293
+ <xsl:message>Markup Error: no id attribute on abstract &lt;rule></xsl:message>
1294
+ </xsl:if>
1295
+ <xsl:if test="@context">
1296
+ <xsl:message>Markup Error: (2) context attribute on abstract &lt;rule></xsl:message>
1297
+ </xsl:if>
1298
+ </xsl:template>
1299
+
1300
+ <xsl:template match="iso:rule[@abstract='true']"
1301
+ mode="extends" >
1302
+ <xsl:if test="@context">
1303
+ <xsl:message>Markup Error: context attribute on abstract &lt;rule></xsl:message>
1304
+ </xsl:if>
1305
+ <xsl:apply-templates/>
1306
+ </xsl:template>
1307
+
1308
+ <!-- ISO SPAN -->
1309
+ <xsl:template match="iso:span" mode="text">
1310
+ <xsl:call-template name="process-span">
1311
+ <xsl:with-param name="class" select="@class"/>
1312
+ </xsl:call-template>
1313
+ </xsl:template>
1314
+
1315
+ <!-- ISO TITLE -->
1316
+
1317
+ <xsl:template match="iso:schema/iso:title" priority="1">
1318
+ <xsl:call-template name="process-schema-title" />
1319
+ </xsl:template>
1320
+
1321
+
1322
+ <xsl:template match="iso:title" >
1323
+ <xsl:call-template name="process-title" />
1324
+ </xsl:template>
1325
+
1326
+
1327
+ <!-- ISO VALUE-OF -->
1328
+ <xsl:template match="iso:value-of" mode="text" >
1329
+ <xsl:if test="not(@select)">
1330
+ <xsl:message>Markup Error: no select attribute in &lt;value-of></xsl:message>
1331
+ </xsl:if>
1332
+ <xsl:call-template name="IamEmpty" />
1333
+
1334
+ <xsl:choose>
1335
+ <xsl:when test="@select">
1336
+ <xsl:call-template name="process-value-of">
1337
+ <xsl:with-param name="select" select="@select"/>
1338
+ </xsl:call-template>
1339
+ </xsl:when>
1340
+ <xsl:otherwise >
1341
+ <xsl:call-template name="process-value-of">
1342
+ <xsl:with-param name="select" select="'.'"/>
1343
+ </xsl:call-template>
1344
+ </xsl:otherwise>
1345
+ </xsl:choose>
1346
+
1347
+ </xsl:template>
1348
+
1349
+
1350
+ <!-- ============================================================== -->
1351
+ <!-- DEFAULT TEXT HANDLING -->
1352
+ <!-- ============================================================== -->
1353
+ <xsl:template match="text()" priority="-1" mode="do-keys">
1354
+ <!-- strip characters -->
1355
+ </xsl:template>
1356
+ <xsl:template match="text()" priority="-1" mode="do-all-patterns">
1357
+ <!-- strip characters -->
1358
+ </xsl:template>
1359
+ <xsl:template match="text()" priority="-1" mode="do-schema-p">
1360
+ <!-- strip characters -->
1361
+ </xsl:template>
1362
+ <xsl:template match="text()" priority="-1" mode="do-pattern-p">
1363
+ <!-- strip characters -->
1364
+ </xsl:template>
1365
+
1366
+ <xsl:template match="text()" priority="-1">
1367
+ <!-- Strip characters -->
1368
+ </xsl:template>
1369
+
1370
+ <xsl:template match="text()" mode="text">
1371
+ <xsl:value-of select="."/>
1372
+ </xsl:template>
1373
+
1374
+ <xsl:template match="text()" mode="inline-text">
1375
+ <xsl:value-of select="."/>
1376
+ </xsl:template>
1377
+
1378
+ <!-- ============================================================== -->
1379
+ <!-- UTILITY TEMPLATES -->
1380
+ <!-- ============================================================== -->
1381
+ <xsl:template name="IamEmpty">
1382
+ <xsl:if test="count( * )">
1383
+ <xsl:message>
1384
+ <xsl:text>Warning: </xsl:text>
1385
+ <xsl:value-of select="name(.)"/>
1386
+ <xsl:text> must not contain any child elements</xsl:text>
1387
+ </xsl:message>
1388
+ </xsl:if>
1389
+ </xsl:template>
1390
+
1391
+ <xsl:template name="diagnosticsSplit">
1392
+ <!-- Process at the current point the first of the <diagnostic> elements
1393
+ referred to parameter str, and then recurse -->
1394
+ <xsl:param name="str"/>
1395
+ <xsl:variable name="start">
1396
+ <xsl:choose>
1397
+ <xsl:when test="contains($str,' ')">
1398
+ <xsl:value-of select="substring-before($str,' ')"/>
1399
+ </xsl:when>
1400
+ <xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
1401
+ </xsl:choose>
1402
+ </xsl:variable>
1403
+
1404
+ <xsl:variable name="end">
1405
+ <xsl:if test="contains($str,' ')">
1406
+ <xsl:value-of select="substring-after($str,' ')"/>
1407
+ </xsl:if>
1408
+ </xsl:variable>
1409
+
1410
+ <!-- This works with all namespaces -->
1411
+ <xsl:if test="not(string-length(normalize-space($start)) = 0)
1412
+ and not(//iso:diagnostic[@id = $start])
1413
+ and not(//sch:diagnostic[@id = $start])
1414
+ and not(//diagnostic[@id = $start])">
1415
+ <xsl:message>Reference error: A diagnostic "<xsl:value-of select="string($start)"
1416
+ />" has been referenced but is not declared</xsl:message>
1417
+ </xsl:if>
1418
+
1419
+ <xsl:if test="string-length(normalize-space($start)) > 0">
1420
+ <xsl:text> </xsl:text>
1421
+ <xsl:apply-templates
1422
+ select="//iso:diagnostic[@id = $start ]
1423
+ | //sch:diagnostic[@id = $start ]
1424
+ | //diagnostic[@id= $start ]"/>
1425
+ </xsl:if>
1426
+
1427
+ <xsl:if test="not($end='')">
1428
+ <xsl:call-template name="diagnosticsSplit">
1429
+ <xsl:with-param name="str" select="$end"/>
1430
+ </xsl:call-template>
1431
+ </xsl:if>
1432
+ </xsl:template>
1433
+
1434
+ <!-- It would be nice to use this but xsl:namespace does not
1435
+ allow a fallback -->
1436
+ <!--xsl:template name="handle-namespace" version="2.0">
1437
+ <xsl:namespace name="{@prefix}" select="@uri">
1438
+ </xsl:template-->
1439
+
1440
+ <xsl:template name="handle-namespace">
1441
+ <!-- experimental code from http://eccnet.eccnet.com/pipermail/schematron-love-in/2006-June/000104.html -->
1442
+ <!-- Handle namespaces differently for exslt systems, msxml, and default, only using XSLT1 syntax -->
1443
+ <!-- For more info see http://fgeorges.blogspot.com/2007/01/creating-namespace-nodes-in-xslt-10.html -->
1444
+ <xsl:choose>
1445
+ <!-- The following code works for XSLT1 -->
1446
+ <xsl:when test="function-available('exsl:node-set')">
1447
+ <xsl:variable name="ns-dummy-elements">
1448
+ <xsl:element name="{@prefix}:dummy" namespace="{@uri}"/>
1449
+ </xsl:variable>
1450
+ <xsl:variable name="p" select="@prefix"/>
1451
+ <xsl:copy-of select="exsl:node-set($ns-dummy-elements)
1452
+ /*/namespace::*[local-name()=$p]"/>
1453
+ </xsl:when>
1454
+
1455
+ <!-- End XSLT1 code -->
1456
+
1457
+ <!-- Not tested yet
1458
+ <xsl:when test="function-available('msxsl:node-set')">
1459
+ <xsl:variable name="ns-dummy-elements">
1460
+ <xsl:element name="{ $prefix }:e" namespace="{ $uri }"/>
1461
+ </xsl:variable>
1462
+ <xsl:copy-of select="msxsl:node-set($ns-dummy-elements)/*/namespace::*"/>
1463
+ </xsl:when>
1464
+ -->
1465
+
1466
+ <xsl:when test="@prefix = 'xsl' ">
1467
+ <!-- Do not generate dummy attributes with the xsl: prefix, as these
1468
+ are errors against XSLT, because we presume that the output
1469
+ stylesheet uses the xsl prefix. In any case, there would already
1470
+ be a namespace declaration for the XSLT namespace generated
1471
+ automatically, presumably using "xsl:".
1472
+ -->
1473
+ </xsl:when>
1474
+
1475
+ <xsl:when test="@uri = 'http://www.w3.org/1999/XSL/Transform'">
1476
+ <xsl:message terminate="yes">
1477
+ <xsl:text>Using the XSLT namespace with a prefix other than "xsl" in </xsl:text>
1478
+ <xsl:text>Schematron rules is not supported </xsl:text>
1479
+ <xsl:text>in this processor: </xsl:text>
1480
+ <xsl:value-of select="system-property('xsl:vendor')"/>
1481
+ </xsl:message>
1482
+ </xsl:when>
1483
+
1484
+ <xsl:otherwise>
1485
+ <xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}" />
1486
+
1487
+ </xsl:otherwise>
1488
+ </xsl:choose>
1489
+
1490
+
1491
+ </xsl:template>
1492
+
1493
+ <!-- ============================================================== -->
1494
+ <!-- UNEXPECTED ELEMENTS -->
1495
+ <!-- ============================================================== -->
1496
+
1497
+ <xsl:template match="iso:*" priority="-2">
1498
+ <xsl:message>
1499
+ <xsl:text>Error: unrecognized element in ISO Schematron namespace: check spelling
1500
+ and capitalization</xsl:text>
1501
+ <xsl:value-of select="name(.)"/>
1502
+ </xsl:message>
1503
+ </xsl:template>
1504
+
1505
+
1506
+ <!-- Swallow old namespace elements: there is an upfront test for them elsewhere -->
1507
+ <xsl:template match="sch:*" priority="-2" />
1508
+
1509
+ <xsl:template match="*" priority="-3">
1510
+ <xsl:choose>
1511
+ <xsl:when test=" $allow-foreign = 'false' ">
1512
+ <xsl:message>
1513
+ <xsl:text>Warning: unrecognized element </xsl:text>
1514
+ <xsl:value-of select="name(.)"/>
1515
+ </xsl:message>
1516
+ </xsl:when>
1517
+ <xsl:otherwise>
1518
+ <xsl:copy-of select="." />
1519
+ </xsl:otherwise>
1520
+ </xsl:choose>
1521
+ </xsl:template>
1522
+
1523
+ <xsl:template match="iso:*" mode="text" priority="-2" />
1524
+ <xsl:template match="*" mode="text" priority="-3">
1525
+ <xsl:choose>
1526
+ <xsl:when test=" $allow-foreign = 'false' ">
1527
+ <xsl:message>
1528
+ <xsl:text>Warning: unrecognized element </xsl:text>
1529
+ <xsl:value-of select="name(.)"/>
1530
+ </xsl:message>
1531
+ </xsl:when>
1532
+ <xsl:otherwise>
1533
+ <xsl:copy-of select="." />
1534
+ </xsl:otherwise>
1535
+ </xsl:choose>
1536
+ </xsl:template>
1537
+
1538
+ <!-- ============================================================== -->
1539
+ <!-- DEFAULT NAMED TEMPLATES -->
1540
+ <!-- These are the actions that are performed unless overridden -->
1541
+ <!-- ============================================================== -->
1542
+
1543
+ <xsl:template name="process-prolog"/>
1544
+ <!-- no params -->
1545
+
1546
+ <xsl:template name="process-root">
1547
+ <xsl:param name="contents"/>
1548
+ <xsl:param name="id" />
1549
+ <xsl:param name="version" />
1550
+ <xsl:param name="schemaVersion" />
1551
+ <xsl:param name="queryBinding" />
1552
+ <xsl:param name="title" />
1553
+
1554
+
1555
+ <!-- "Rich" parameters -->
1556
+ <xsl:param name="fpi" />
1557
+ <xsl:param name="icon" />
1558
+ <xsl:param name="lang" />
1559
+ <xsl:param name="see" />
1560
+ <xsl:param name="space" />
1561
+
1562
+ <xsl:copy-of select="$contents"/>
1563
+ </xsl:template>
1564
+
1565
+ <xsl:template name="process-assert">
1566
+
1567
+ <xsl:param name="test"/>
1568
+ <xsl:param name="diagnostics" />
1569
+ <xsl:param name="id" />
1570
+ <xsl:param name="flag" />
1571
+
1572
+ <!-- "Linkable" parameters -->
1573
+ <xsl:param name="role"/>
1574
+ <xsl:param name="subject"/>
1575
+
1576
+ <!-- "Rich" parameters -->
1577
+ <xsl:param name="fpi" />
1578
+ <xsl:param name="icon" />
1579
+ <xsl:param name="lang" />
1580
+ <xsl:param name="see" />
1581
+ <xsl:param name="space" />
1582
+
1583
+
1584
+ <xsl:call-template name="process-message">
1585
+ <xsl:with-param name="pattern" select="$test"/>
1586
+ <xsl:with-param name="role" select="$role"/>
1587
+ </xsl:call-template>
1588
+
1589
+
1590
+ </xsl:template>
1591
+
1592
+ <xsl:template name="process-report">
1593
+ <xsl:param name="test"/>
1594
+ <xsl:param name="diagnostics" />
1595
+ <xsl:param name="id" />
1596
+ <xsl:param name="flag" />
1597
+
1598
+ <!-- "Linkable" parameters -->
1599
+ <xsl:param name="role"/>
1600
+ <xsl:param name="subject"/>
1601
+
1602
+ <!-- "Rich" parameters -->
1603
+ <xsl:param name="fpi" />
1604
+ <xsl:param name="icon" />
1605
+ <xsl:param name="lang" />
1606
+ <xsl:param name="see" />
1607
+ <xsl:param name="space" />
1608
+
1609
+ <xsl:call-template name="process-message">
1610
+ <xsl:with-param name="pattern" select="$test"/>
1611
+ <xsl:with-param name="role" select="$role"/>
1612
+ </xsl:call-template>
1613
+ </xsl:template>
1614
+
1615
+ <xsl:template name="process-diagnostic">
1616
+ <xsl:param name="id" />
1617
+
1618
+ <!-- "Rich" parameters -->
1619
+ <xsl:param name="fpi" />
1620
+ <xsl:param name="icon" />
1621
+ <xsl:param name="lang" />
1622
+ <xsl:param name="see" />
1623
+ <xsl:param name="space" />
1624
+
1625
+ <!-- We generate too much whitespace rather than risking concatenation -->
1626
+ <axsl:text> </axsl:text>
1627
+ <xsl:apply-templates mode="text"/>
1628
+ <axsl:text> </axsl:text>
1629
+ </xsl:template>
1630
+
1631
+ <xsl:template name="process-dir">
1632
+ <xsl:param name="value" />
1633
+
1634
+ <!-- We generate too much whitespace rather than risking concatenation -->
1635
+ <axsl:text> </axsl:text>
1636
+ <xsl:apply-templates mode="inline-text"/>
1637
+ <axsl:text> </axsl:text>
1638
+ </xsl:template>
1639
+
1640
+ <xsl:template name="process-emph">
1641
+ <!-- We generate too much whitespace rather than risking concatenation -->
1642
+ <axsl:text> </axsl:text>
1643
+ <xsl:apply-templates mode="inline-text"/>
1644
+ <axsl:text> </axsl:text>
1645
+ </xsl:template>
1646
+
1647
+ <xsl:template name="process-name">
1648
+ <xsl:param name="name"/>
1649
+
1650
+ <!-- We generate too much whitespace rather than risking concatenation -->
1651
+ <axsl:text> </axsl:text>
1652
+ <axsl:value-of select="{$name}"/>
1653
+ <axsl:text> </axsl:text>
1654
+
1655
+ </xsl:template>
1656
+
1657
+ <xsl:template name="process-ns" >
1658
+ <!-- Note that process-ns is for reporting. The sch:ns elements are
1659
+ independently used in the sch:schema template to provide namespace bindings -->
1660
+ <xsl:param name="prefix"/>
1661
+ <xsl:param name="uri" />
1662
+ </xsl:template>
1663
+
1664
+ <xsl:template name="process-p">
1665
+ <xsl:param name="id" />
1666
+ <xsl:param name="class" />
1667
+ <xsl:param name="icon" />
1668
+ <xsl:param name="lang" />
1669
+ </xsl:template>
1670
+
1671
+ <xsl:template name="process-pattern">
1672
+ <xsl:param name="id" />
1673
+ <xsl:param name="name" />
1674
+ <xsl:param name="is-a" />
1675
+
1676
+ <!-- "Rich" parameters -->
1677
+ <xsl:param name="fpi" />
1678
+ <xsl:param name="icon" />
1679
+ <xsl:param name="lang" />
1680
+ <xsl:param name="see" />
1681
+ <xsl:param name="space" />
1682
+ </xsl:template>
1683
+
1684
+
1685
+ <xsl:template name="process-rule">
1686
+ <xsl:param name="context" />
1687
+
1688
+ <xsl:param name="id" />
1689
+ <xsl:param name="flag" />
1690
+
1691
+ <!-- "Linkable" parameters -->
1692
+ <xsl:param name="role"/>
1693
+ <xsl:param name="subject"/>
1694
+
1695
+ <!-- "Rich" parameters -->
1696
+ <xsl:param name="fpi" />
1697
+ <xsl:param name="icon" />
1698
+ <xsl:param name="lang" />
1699
+ <xsl:param name="see" />
1700
+ <xsl:param name="space" />
1701
+ </xsl:template>
1702
+
1703
+ <xsl:template name="process-span" >
1704
+ <xsl:param name="class" />
1705
+
1706
+ <!-- We generate too much whitespace rather than risking concatenation -->
1707
+ <axsl:text> </axsl:text>
1708
+ <xsl:apply-templates mode="inline-text"/>
1709
+ <axsl:text> </axsl:text>
1710
+ </xsl:template>
1711
+
1712
+ <xsl:template name="process-title" >
1713
+ <xsl:param name="class" />
1714
+ <xsl:call-template name="process-p">
1715
+ <xsl:with-param name="class">title</xsl:with-param>
1716
+ </xsl:call-template>
1717
+ </xsl:template>
1718
+
1719
+ <xsl:template name="process-schema-title" >
1720
+ <xsl:param name="class" />
1721
+ <xsl:call-template name="process-title">
1722
+ <xsl:with-param name="class">schema-title</xsl:with-param>
1723
+ </xsl:call-template>
1724
+ </xsl:template>
1725
+
1726
+ <xsl:template name="process-value-of">
1727
+ <xsl:param name="select"/>
1728
+
1729
+ <!-- We generate too much whitespace rather than risking concatenation -->
1730
+ <axsl:text> </axsl:text>
1731
+ <axsl:value-of select="{$select}"/>
1732
+ <axsl:text> </axsl:text>
1733
+ </xsl:template>
1734
+
1735
+ <!-- default output action: the simplest customization is to just override this -->
1736
+ <xsl:template name="process-message">
1737
+ <xsl:param name="pattern" />
1738
+ <xsl:param name="role" />
1739
+
1740
+ <xsl:apply-templates mode="text"/>
1741
+ <xsl:if test=" $message-newline = 'true'" >
1742
+ <axsl:value-of select="string('&#10;')"/>
1743
+ </xsl:if>
1744
+
1745
+ </xsl:template>
1746
+ </xsl:stylesheet>
1747
+
1748
+
1749
+