schematron-wrapper 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,55 @@
1
+ <?xml version="1.0" ?><?xar XSLT?>
2
+ <!-- Implmentation for the Schematron XML Schema Language.
3
+ http://www.ascc.net/xml/resource/schematron/schematron.html
4
+
5
+ Copyright (c) 2000,2001 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
6
+
7
+ This software is provided 'as-is', without any express or implied warranty.
8
+ In no event will the authors be held liable for any damages arising from
9
+ the use of this software.
10
+
11
+ Permission is granted to anyone to use this software for any purpose,
12
+ including commercial applications, and to alter it and redistribute it freely,
13
+ subject to the following restrictions:
14
+
15
+ 1. The origin of this software must not be misrepresented; you must not claim
16
+ that you wrote the original software. If you use this software in a product,
17
+ an acknowledgment in the product documentation would be appreciated but is
18
+ not required.
19
+
20
+ 2. Altered source versions must be plainly marked as such, and must not be
21
+ misrepresented as being the original software.
22
+
23
+ 3. This notice may not be removed or altered from any source distribution.
24
+ -->
25
+
26
+ <!-- Schematron message -->
27
+
28
+ <xsl:stylesheet
29
+ version="2.0"
30
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
31
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias">
32
+
33
+ <xsl:import href="iso_schematron_skeleton_for_saxon.xsl"/>
34
+
35
+ <xsl:template name="process-prolog">
36
+ <axsl:output method="text" />
37
+ </xsl:template>
38
+
39
+ <!-- use default rule for process-root: copy contens / ignore title -->
40
+ <!-- use default rule for process-pattern: ignore name and see -->
41
+ <!-- use default rule for process-name: output name -->
42
+ <!-- use default rule for process-assert and process-report:
43
+ call process-message -->
44
+
45
+ <xsl:template name="process-message">
46
+ <xsl:param name="pattern" />
47
+ <xsl:param name="role" />
48
+ <axsl:message>
49
+ <xsl:apply-templates mode="text"
50
+ /> (<xsl:value-of select="$pattern" />
51
+ <xsl:if test="$role"> / <xsl:value-of select="$role" />
52
+ </xsl:if>)</axsl:message>
53
+ </xsl:template>
54
+
55
+ </xsl:stylesheet>
@@ -0,0 +1,2299 @@
1
+ <?xml version="1.0"?><?xar XSLT?>
2
+
3
+ <!--
4
+ OVERVIEW
5
+
6
+ ASCC/Schematron.com Skeleton Module for ISO Schematron (for XSLT2 systems)
7
+
8
+ ISO Schematron is a language for making assertion about the presence or absense
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 <iso: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 <iso: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
+ debug "true" | "false" (default) Debug mode lets compilation continue despite problems
65
+ attributes "true" | "false" (Autodetecting) Use only when the schema has no attributes as the context nodes
66
+ only-child-elements "true" | "false" (Autodetecting) Use only when the schema has no comments
67
+ or PI as the context nodes
68
+ langCode ISO language code language for skeleton errors, if available
69
+ terminate= yes | no | true | false | assert Terminate on the first failed assertion or successful report
70
+ Note whether any output at all is generated depends on the XSLT implementation.
71
+
72
+ The following parameters can be specified as Schematron variables in diagnostics, assertions and so on.
73
+ fileNameParameter string
74
+ fileDirParameter string
75
+ archiveNameParameter string In case of ZIP files
76
+ archiveDirParameter string In case of ZIP files
77
+
78
+ Experimental: USE AT YOUR OWN RISK
79
+ visit-text "true" "false" Also visist text nodes for context. WARNING: NON_STARDARD.
80
+ select-contents '' | 'key' | '//' Select different implementation strategies
81
+
82
+ Conventions: Meta-stylesheets that override this may use the following parameters
83
+ generate-paths=true|false generate the @location attribute with XPaths
84
+ full-path-notation = 1|2|3 select the notation for the full paths: 1=computer, 2=human, 3=obsolescent
85
+ diagnose= yes | no Add the diagnostics to the assertion test in reports
86
+
87
+ -->
88
+
89
+ <!--
90
+ XSLT VERSION SUPPORT
91
+
92
+ XSLT 1:
93
+ A schema using the standard XSLT 1 query binding will have a /schema/@queryBinding='xslt' or
94
+ nothing.
95
+
96
+ * Note: XT does not implement key() and will die if given it.
97
+ * Add all formal parameters to default templates
98
+ * Fix missing apply-templates from process-ns and add params back
99
+
100
+ EXSLT: Experimental support
101
+ A schema using the EXSLT query binding will have a /schema/@queryBinding='exslt'.
102
+ It is built on XSLT 1. After experience is gained, this binding is expected to be
103
+ formalized as part of ISO Schematron, which currently reserves the "exslt" name for this purpose.
104
+
105
+ Some EXSLT engines have the extra functions built-in. For these, there is no need to
106
+ provide library locations. For engines that require the functions, either hard code
107
+ them in this script or provide them on the command-line argument.
108
+
109
+ XSLT 2: Experimental support
110
+ A schema using the XSLT 2 query binding will have a /schema/@queryBinding='xslt2'.
111
+ This binding is expected to be formalized as part of ISO
112
+ Schematron, which currently reserves the "xslt2" name for this purpose.
113
+ The xsl:import-schema, xsl:key and xsl:function elements are allowed as top elements.
114
+
115
+ XPATH: Experimental support
116
+ A schema using the XPATH query binding will have a /schema/@queryBinding='xpath'.
117
+ It can run with XSLT 1 and is a strict superset of default ISO Schematron. After
118
+ experience is gained, this binding is expected to be formalized as part of ISO
119
+ Schematron, which currently reserves the "xpath" name for this purpose.
120
+
121
+ The intent of this query binding is to support minimal non-XSLT implementations of
122
+ Schematron that use simple XPath APIs. These not only have fewer functions available
123
+ than the XSLT version of XPath, but some of them do not support variables.
124
+ Consequently, in this binding, the <let> element and command-line variables passed
125
+ to the schema should not be used?
126
+ The xsl:import-schema element is not allowed.
127
+
128
+ -->
129
+ <!--
130
+ PROCESS INFORMATION
131
+
132
+ This stylesheet compiles a Schematron schema (*.sch) into XSLT code (*.xsl).
133
+ The generated XSLT code can then be run against an XML file (*.xml, etc) and
134
+ will produce validation results.
135
+
136
+ The output of validation results is performed using named templates (process-*).
137
+ These can be overridden easily by making a new XSLT stylesheet that imports this
138
+ stylesheet but has its own version of the relevant process-* templates. Several
139
+ of these invoking stylesheets are available: "iso_svrl.xsl", for example generates
140
+ ISO Schematron Validation Report Language format results.
141
+
142
+ In this version of the stylesheet, the ISO feature called "abstract patterns" is
143
+ implemented using macro processing: a prior XSLT stage to which converts uses
144
+ of abstract patterns into normal patterns. If you do not use abstract patterns,
145
+ it is not necessary to preprocess the schema.
146
+
147
+ To summarize, a basic process flow for some commandline processor is like this:
148
+ XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_schematron_skeleton.xsl
149
+ XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
150
+
151
+ iso_svrl.xslt is an implementation of Schematron that can use this skeleton and
152
+ generate ISO SVRL reports. A process flow for some commandline processor would
153
+ be like this:
154
+ XSLT -input=xxx.sch -output=xxx.xsl -stylesheet=iso_svrl.xsl
155
+ XSLT -input=document.xml -output=xxx-document.results -stylesheet=xxx.xsl
156
+
157
+ It is not impossible that ultimately a third stage, to handle macro-preprocessing
158
+ and inclusion, might be necessary. (The trade-off is in making this XSLT more
159
+ complex compared to making the outer process more complex.)
160
+
161
+ This version has been developed to work with
162
+ Saxon 9
163
+ For versions for XSLT 1 processors, see www.xml.com
164
+
165
+ Please note that if you are using SAXON and JAXP, then you should use
166
+ System.setProperty("javax.xml.transform.TransformerFactory",
167
+ "net.sf.saxon.TransformerFactoryImpl");
168
+ rather than
169
+ System.setProperty("javax.xml.xpath.TransformerFactory",
170
+ "net.sf.saxon.TransformerFactoryImpl");
171
+ which is does not work, at least for the versions of SAXON we tried.
172
+ -->
173
+ <!--
174
+ LEGAL INFORMATION
175
+
176
+ Copyright (c) 2000-2010 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
177
+
178
+ This software is provided 'as-is', without any express or implied warranty.
179
+ In no event will the authors be held liable for any damages arising from
180
+ the use of this software.
181
+
182
+ Permission is granted to anyone to use this software for any purpose,
183
+ including commercial applications, and to alter it and redistribute it freely,
184
+ subject to the following restrictions:
185
+
186
+ 1. The origin of this software must not be misrepresented; you must not claim
187
+ that you wrote the original software. If you use this software in a product,
188
+ an acknowledgment in the product documentation would be appreciated but is
189
+ not required.
190
+
191
+ 2. Altered source versions must be plainly marked as such, and must not be
192
+ misrepresented as being the original software.
193
+
194
+ 3. This notice may not be removed or altered from any source distribution.
195
+ -->
196
+ <!--
197
+ VERSION INFORMATION
198
+ 2010-04-14
199
+ * RJ Reorder call-template in exslt case only, report by BD
200
+ * Add command line parameter 'terminate' which will terminate on first failed
201
+ assert and (optionally) successful report.
202
+ 2010-01-24
203
+ * RJ Allow let elements to have direct content instead of @value
204
+ 2009-08020
205
+ * RJ Give better scoping to resolution of abstract rules
206
+ 2009-07-07
207
+ * RJ Fix up warning on looking for @* on root TODO CHECK!!!!
208
+ 2009-05-10
209
+ * RJ Fix up incorrect use of tunnel
210
+ 2009-02-25
211
+ * RJ Fix up variable names so none are used twice in same template
212
+ 2009-02-19
213
+ * RJ add experimental support for pattern/@documents
214
+ This takes an XPath that returns a sequence of strings, treats them as
215
+ relative URI references, and goes through these. It may need to be expanded
216
+ to allow absolute paths.
217
+ 2008-09-19 RJ
218
+ * Add mode schematron-select-full-path and param full-path-notation
219
+
220
+ 2008-08-19
221
+ * RJ Add experimental property element.
222
+ This acts like the diagnostics element. An attribute rule/@properties,
223
+ assert/@properties and report/@properties can contain a list of ids
224
+ which reference a /schema/proporties/property/@id. This is a property
225
+ which will be carried over to the output, eg SVRL. It can have @name,
226
+ and the value is @value or the contents. Properties on rules are
227
+ properties regardless of validation: they should apply to the subject
228
+ element. Properties on asserts and reports only make it through in the
229
+ negative case, at the moment, so they are really just a place to hold
230
+ structured info, eg. for diagnostics. The properties mechanism addresses
231
+ a bother with Schematron, that you have to post-process the document to
232
+ get any kind of structured data that might be nice in the output report.
233
+
234
+
235
+ 2008-08-14
236
+ * RJ move all messages into localization strings, add langCode parameter,
237
+ named template to call external file in same directory as this xslt.
238
+ The file should be called sch-message-$langCode.xhtml ($langCode example "en")
239
+
240
+ 2008-08-11
241
+ * TT report/@flag was missing
242
+ 2008-08-06
243
+ * TT Top-level lets need to be implemented using xsl:param not xsl:variable
244
+ * TT xsl:param/@select must have XPath or not be specified
245
+
246
+ 2008-08-04
247
+ * RJ add saxon namespace to output to allow extension functions
248
+ Version: 2008-07-28
249
+ * KH schematron-get-full-path-3 has [index] even on top step
250
+ Version: 2008-07-24
251
+ * RJ clean out commented out namespace handling code
252
+ * RJ allow schema/@queryBinding='xpath2' and warn if variables are
253
+ used
254
+
255
+ Version: 2008-07-14 update for XSLT2 and inclusion experiments
256
+ * RJ Clean up zero-length fragment test on include
257
+ * RJ Add experimental support for include containers
258
+ * RJ Add support for xsl:import-schema (request Paul Hermans)
259
+ * RJ Add support for xsl:function
260
+ * RJ For path generation, test for //iso:schema not just /iso:schema, for potential embedded Schematron support
261
+ * RJ Don't generate double error messages for old namespace elements
262
+ * RJ Experimental iso:rule/iso:title just kept as comment (bigger request Uche Ogbuji)
263
+ * RJ Fix bug that prevented including patterns in this (report Roger
264
+ Costello)
265
+ Version: 2007-10-17
266
+ Forked out version just to support SAXON 8 and potentially other XSLT2 processors.
267
+ * RJ use xsl:namespace element
268
+ * RJ use schold as namespace for old schematron, to prevent SAXON complaining
269
+ when validating the Schematron schema for Schematron
270
+ * RJ fix FULL-PATH for attributes
271
+
272
+ Version: 2007-07-19
273
+ Accept most changes in David Carlisle's fork, but continue as XSLT1 script:
274
+ http://dpcarlisle.blogspot.com/search/label/schematron
275
+ * DPC Remove "optimize" parameter
276
+ * DPC Add autodetecting optimize parameter attribute to skip checking attribute
277
+ context
278
+ * DPC Add autodetecting optimize parameter only-child-elements turn off checking for
279
+ comments and PIs
280
+ * DPC (Experimental: NON_STANDARD DANGER!) Add param visit-text to viist text
281
+ nodes too for context
282
+ * DPC Fix inclusion syntax to allow #
283
+ * DPC Priorities count up from 1000 not down from 4000 to allow more rules
284
+ * RJ Add new template for titles of schemas, with existing behaviour.
285
+ Override process-schema-title for custom processing of title
286
+
287
+
288
+ Version: 2007-04-04
289
+ * RJ debug mode param
290
+ * RJ alter mixed test to only test mixed branches, so the same document
291
+ could have old and new namespaces schemas in it, but each schema must
292
+ be distinct, just so as not to overconstrain things.
293
+ * KH zero-length include/@href is fatal error, but allow debug mode
294
+ * SB add hint on SAXON and JAXP
295
+ * DC generate-full-path-1 generates XLST1 code by default
296
+ Version: 2007-03-05
297
+ * AS Typo for EXSLT randome, improve comment
298
+ * KH get-schematron-full-path-2 needs to apply to attributes too
299
+ * DP document policy on extensions better
300
+ * DC use copy-of not copy for foreign elements
301
+ * DC add generate-path-2
302
+ * DC don't try to apply templates to attribute axis on attribute nodes, to
303
+ stop SAXON warning.
304
+ * RJ improve reporting of typos
305
+
306
+ Version: 2007-02-08
307
+ * KH Schematron fullpath implementation: @* handled twice and / missing
308
+ * KH Change stylesheetbody from named template to mode to allow implementers more flexibility.
309
+ Move process-ns to outside the stylesheet body.
310
+ * DP, FG, fix handling of xslt:key
311
+ * FG no iso:title/@class
312
+ * Experimental optimization 'visit-no-attributes'
313
+ * KH Experimental added schematron-get-full-path-2 which gives prefixed version for humans
314
+ * DC Move stylesheet/@version generation to after namespace handling
315
+ * DC, FG EXSLT namespace handling code
316
+ * FG add ref and commented code from FG's page on namespaces
317
+ * Start adding normalize-space() to parameter code
318
+ * Add a space between diagnostics
319
+
320
+ Version: 2007-01-22
321
+ * DP change = ($start) to = $start and =($phase) to =$phase
322
+ to run under Saxon 8.8j
323
+ * FG better title section using ( @id | iso:title)[last()]
324
+ * Default query language binding is "xslt" not "xslt1"
325
+
326
+ Version: 2007-01-19
327
+ * Simplify message newline code
328
+ * Remove termination and xpath appending to message options:
329
+ factor out as iso_schematron_terminator.xsl
330
+ * Comment out XSLT2 namespace fix temporarily
331
+
332
+ Version: 2007-01-18 (First beta candidate for comment)
333
+ * DC remove xml:space="preserve"
334
+ * FG improve comment on import statement
335
+ * DC improve comments on invocation section
336
+ * Add exploratory support for iso:schema[@queryBinding='xpath']
337
+ by allowing it and warning as lets are found
338
+ * Be strict about queryBinding spelling errors
339
+ * Extra comments on the different queryBindings
340
+ * KH Add option "message-paths" to generate XPath from output
341
+ * KH Add option "terminate" to halt with an error after the first assertion
342
+ * KH refactor paths in schematron-full-path
343
+ * Improve (?) namespace handling: no dummy attributes for prefix "xsl" generated
344
+
345
+ Version: 2007-01-15
346
+ * FG fix for calling templates
347
+ * Add formal parameters to default templates: may help XSLT 2
348
+ * Fix get-schematron-full-path
349
+ * Include skeleton1-6 is commented out by default
350
+
351
+ Version:2007-01-12 (Pre-beta release to Schematron-love-in maillist)
352
+ * Add many extra parameters to the process-* calls, so that almost
353
+ all the information in the schema can be provided to client programs.
354
+ Also, rearrange the parameters to fit in with the ISO schema, which
355
+ has "rich" and "linkable" attribute groups.
356
+ * Warn on diagnostics with no ID once only
357
+ * Improved path reporting, to handle for namespaces
358
+ * Add process-title dummy template for API
359
+ * Add command-line parameter allow-foreign (true|false) to suppress
360
+ warnings one foreign elements and pass them through to the generated
361
+ stylesheet
362
+ * remove legacy templates for the old ASCC namespace and no namespace,
363
+ and use an import statement instead. Much cleaner now!
364
+ * patterns use @id not @name
365
+ * titles can contain sub-elements
366
+ * start change iso:rule to allow attributes, PIs and comments
367
+ * the default process-* for inline elements add a leading and trailing
368
+ space, to reduce the chance of concatenation.
369
+ * add comments to make the generated code clearer
370
+
371
+ Version:2006-11-07 (ISO: first release private to schematron-love-in maillist for review)
372
+ * Duplicate pattern templates, for handling ISO namespace
373
+ * Add priority onto default and paragraph templates
374
+ * Add namespace checks
375
+ * Handle key in xsl namespace not iso
376
+ * Add include
377
+ * Improve namespace handling
378
+ * Preliminary XSLT2 and EXSLT support
379
+ * Refactor iso:schema for clarity
380
+
381
+ Version: 2003-05-26
382
+ * Fix bug with key
383
+ Version: 2003-04-16
384
+ * handle 1.6 let expressions
385
+ * make key use XSLT names, and allow anywhere
386
+ Version: 2001-06-13
387
+ * same skeleton now supports namespace or no namespace
388
+ * parameters to handlers updated for all 1.5 attributes
389
+ * diagnostic hints supported: command-line option diagnose=yes|no
390
+ * phases supported: command-line option phase=#ALL|...
391
+ * abstract rules
392
+ * compile-time error messages
393
+ * add utility routine generate-id-from-path
394
+
395
+ Contributors: Rick Jelliffe (original), Oliver Becker (architecture, XSLT2),
396
+ Miloslav Nic (diagnostic, phase, options), Ludwig Svenonius (abstract)
397
+ Uche Ogbuji (misc. bug fixes), Jim Ancona (SAXON workaround),
398
+ Francis Norton (generate-id-from-path), Robert Leftwich, Bryan Rasmussen,
399
+ Dave Pawson (include, fallback), Florent Georges (namespaces, exslt, attribute
400
+ context), Benoit Maisonny (attribute context), John Dumps (process-message newline),
401
+ Cliff Stanford (diagnostics and other newlines)
402
+
403
+
404
+
405
+
406
+ KNOWN TYPICAL LIMITATIONS:
407
+ * Don't use <iso:ns prefix="xsl" .../> with a namespace other than the standard
408
+ XSLT one. This would be a bizarre thing to do anyway.
409
+ * Don't use other prefixes for the XSLT namespace either; some implementations will
410
+ not handle it correctly.
411
+
412
+ EXTENSIONS:
413
+ ISO Schematron is designed as a framework with some standard query language
414
+ bindings. If you need to support other features, please do so safely by making
415
+ up your own @queryLanguage name: this makes it clear that your schema requires
416
+ special features. For example, default ISO Schematron does not support user
417
+ defined functions; so if you want to use the user defined function feature
418
+ in XSLT, you need to have a schema with some queryBinding attribute name like
419
+ "XSLT-with-my-functions" or whatever.
420
+ -->
421
+
422
+
423
+
424
+
425
+ <xsl:stylesheet
426
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
427
+ xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
428
+ xmlns:schold="http://www.ascc.net/xml/schematron"
429
+ xmlns:iso="http://purl.oclc.org/dsdl/schematron"
430
+ xmlns:exsl="http://exslt.org/common"
431
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
432
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
433
+ extension-element-prefixes="exsl"
434
+ version="2.0"
435
+ >
436
+ <!-- This program implements ISO Schematron, except for abstract patterns
437
+ which require a preprocess.
438
+ -->
439
+
440
+
441
+ <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
442
+
443
+
444
+ <!-- Category: top-level-element -->
445
+ <xsl:output method="xml" omit-xml-declaration="no" standalone="yes" indent="yes"/>
446
+
447
+
448
+
449
+ <xsl:param name="phase">
450
+ <xsl:choose>
451
+ <xsl:when test="//iso:schema/@defaultPhase">
452
+ <xsl:value-of select="//iso:schema/@defaultPhase"/>
453
+ </xsl:when>
454
+ <xsl:otherwise>#ALL</xsl:otherwise>
455
+ </xsl:choose>
456
+ </xsl:param>
457
+
458
+ <xsl:param name="allow-foreign">false</xsl:param>
459
+
460
+ <xsl:param name="message-newline">true</xsl:param>
461
+
462
+ <!-- DPC set to true if contexts should be checked on attribute nodes
463
+ defaults to true if there is any possibility that a context could match an attribute,
464
+ err on the side if caution, a context of *[.='@'] would cause this param to defualt to true
465
+ even though @ is in a string
466
+ -->
467
+ <xsl:param name="attributes">
468
+ <xsl:choose>
469
+ <xsl:when test="//iso:rule[contains(@context,'@') or contains(@context,'attribute')]">true</xsl:when>
470
+ <xsl:otherwise>false</xsl:otherwise>
471
+ </xsl:choose>
472
+ </xsl:param>
473
+
474
+ <!-- DPC set to true if contexts should be checked on just elements in the child axis
475
+ defaults to true if there is any possibility that a context could match an comment or PI
476
+ err on the side if caution, a context of *[.='('] would cause this param to defualt to true
477
+ even though ( is in a string, but node() comment() and processing-instruction() all have a (
478
+ -->
479
+ <xsl:param name="only-child-elements">
480
+ <xsl:choose>
481
+ <xsl:when test="//iso:rule[contains(@context,'(')]">true</xsl:when>
482
+ <xsl:otherwise>false</xsl:otherwise>
483
+ </xsl:choose>
484
+ </xsl:param>
485
+
486
+ <!-- DPC set to true if contexts should be checked on text nodes nodes (if only-child-elements is false)
487
+ THIS IS NON CONFORMANT BEHAVIOUR JUST FOR DISCUSSION OF A POSSIBLE CHANGE TO THE
488
+ SPECIFICATION. THIS PARAM SHOULD GO IF THE FINAL DECISION IS THAT THE SPEC DOES NOT CHANGE.
489
+ Always defaults to false
490
+ -->
491
+ <xsl:param name="visit-text" select="'false'"/>
492
+
493
+ <!-- DPC
494
+ When selecting contexts the specified behaviour is
495
+ @*|node()[not(self::text())]
496
+ The automatic settings may use
497
+ node()[not(self::text())]
498
+ @*|*
499
+ *
500
+ instead for schema for which they are equivalent.
501
+ If the params are set explictly the above may be used, and also either if
502
+ @*
503
+ @*|node()
504
+ in all cases the result may not be equivalent, for example if you specify no attributes and the schema
505
+ does have attribute contexts they will be silently ignored.
506
+
507
+ after testing it turns out that
508
+ node()[not(self::text())] is slower in saxon than *|comment()|processing-instruction()
509
+ which I find a bit surprising but anyway I'll use the longr faster version.
510
+ -->
511
+ <xsl:variable name="context-xpath">
512
+ <xsl:if test="$attributes='true' and parent::node() ">@*|</xsl:if>
513
+ <xsl:choose>
514
+ <xsl:when test="$only-child-elements='true'">*</xsl:when>
515
+ <xsl:when test="$visit-text='true'">node()</xsl:when>
516
+ <xsl:otherwise>*|comment()|processing-instruction()</xsl:otherwise>
517
+ </xsl:choose>
518
+ </xsl:variable>
519
+
520
+ <!-- DPC if this is set to
521
+ '' use recursive templates to iterate over document tree,
522
+ 'key' select all contexts with a key rather than walking the tree explictly in each mode
523
+ '//' select all contexts with // a key rather than walking the tree explictly in each mode (XSLT2 only)
524
+ -->
525
+ <xsl:param name="select-contexts" select="''"/>
526
+
527
+
528
+ <!-- e.g. saxon file.xml file.xsl "sch.exslt.imports=.../string.xsl;.../math.xsl" -->
529
+ <xsl:param name="sch.exslt.imports"/>
530
+
531
+ <xsl:param name="debug">false</xsl:param>
532
+
533
+ <!-- Set the language code for messages -->
534
+ <xsl:param name="langCode">default</xsl:param>
535
+
536
+ <!-- Set the default for schematron-select-full-path, i.e. the notation for svrl's @location-->
537
+ <xsl:param name="full-path-notation">1</xsl:param>
538
+
539
+ <xsl:param name="terminate">false</xsl:param>
540
+
541
+ <!-- Simple namespace check -->
542
+ <xsl:template match="/">
543
+ <xsl:if test="//schold:*[ancestor::iso:* or descendant::iso:*]">
544
+
545
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">1</xsl:with-param></xsl:call-template></xsl:message>
546
+
547
+ </xsl:if>
548
+
549
+ <xsl:apply-templates />
550
+ </xsl:template>
551
+
552
+
553
+ <!-- ============================================================== -->
554
+ <!-- ISO SCHEMATRON SCHEMA ELEMENT -->
555
+ <!-- Not handled: Abstract patterns. A pre-processor is assumed. -->
556
+ <!-- ============================================================== -->
557
+
558
+ <!-- SCHEMA -->
559
+ <!-- Default uses XSLT 1 -->
560
+ <xsl:template match="iso:schema[not(@queryBinding) or @queryBinding='xslt'
561
+ or @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'
562
+ or @queryBinding='xpath']">
563
+ <xsl:if test="
564
+ @queryBinding='xslt1' or @queryBinding='XSLT' or @queryBinding='XSLT1'">
565
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">2</xsl:with-param></xsl:call-template></xsl:message>
566
+ </xsl:if>
567
+ <axsl:stylesheet>
568
+ <xsl:apply-templates
569
+ select="iso:ns" />
570
+
571
+ <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
572
+ <xsl:attribute name="version">1.0</xsl:attribute>
573
+
574
+ <xsl:apply-templates select="." mode="stylesheetbody"/>
575
+ <!-- was xsl:call-template name="stylesheetbody"/ -->
576
+ </axsl:stylesheet>
577
+ </xsl:template>
578
+
579
+ <!-- Using EXSLT with all modeles (except function module: not applicable) -->
580
+ <xsl:template match="iso:schema[@queryBinding='exslt']" priority="10">
581
+ <xsl:comment>This XSLT was automatically generated from a Schematron schema.</xsl:comment>
582
+ <axsl:stylesheet
583
+ xmlns:date="http://exslt.org/dates-and-times"
584
+ xmlns:dyn="http://exslt.org/dynamic"
585
+ xmlns:exsl="http://exslt.org/common"
586
+ xmlns:math="http://exslt.org/math"
587
+ xmlns:random="http://exslt.org/random"
588
+ xmlns:regexp="http://exslt.org/regular-expressions"
589
+ xmlns:set="http://exslt.org/sets"
590
+ xmlns:str="http://exslt.org/strings"
591
+ extension-element-prefixes="date dyn exsl math random regexp set str" >
592
+
593
+ <xsl:apply-templates
594
+ select="iso:ns" />
595
+ <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
596
+ <xsl:attribute name="version">1.0</xsl:attribute>
597
+
598
+ <xsl:apply-templates select="." mode="stylesheetbody"/>
599
+ <!-- was xsl:call-template name="stylesheetbody"/ -->
600
+ </axsl:stylesheet>
601
+ </xsl:template>
602
+
603
+ <!-- Using XSLT 2 -->
604
+ <xsl:template
605
+ match="iso:schema[@queryBinding='xslt2' or @queryBinding ='xpath2']"
606
+ priority="10">
607
+ <axsl:stylesheet
608
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
609
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
610
+ xmlns:saxon="http://saxon.sf.net/"
611
+ >
612
+ <xsl:apply-templates
613
+ select="iso:ns" />
614
+ <!-- Handle the namespaces before the version attribute: reported to help SAXON -->
615
+ <xsl:attribute name="version">2.0</xsl:attribute>
616
+
617
+ <xsl:apply-templates select="." mode="stylesheetbody"/>
618
+ <!-- was xsl:call-template name="stylesheetbody"/ -->
619
+ </axsl:stylesheet>
620
+ </xsl:template>
621
+
622
+
623
+ <!-- Uses unknown query language binding -->
624
+ <xsl:template match="iso:schema" priority="-1">
625
+ <xsl:message terminate="yes" ><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">3a</xsl:with-param></xsl:call-template>
626
+ <xsl:value-of select="@queryBinding"/>
627
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">3b</xsl:with-param></xsl:call-template></xsl:message>
628
+ </xsl:template>
629
+
630
+ <xsl:template match="*" mode="stylesheetbody">
631
+ <!--xsl:template name="stylesheetbody"-->
632
+ <xsl:comment>Implementers: please note that overriding process-prolog or process-root is
633
+ the preferred method for meta-stylesheets to use where possible. </xsl:comment><xsl:text>&#10;</xsl:text>
634
+
635
+ <!-- These parameters may contain strings with the name and directory of the file being
636
+ validated. For convenience, if the caller only has the information in a single string,
637
+ that string could be put in fileDirParameter. The archives parameters are available
638
+ for ZIP archives.
639
+ -->
640
+
641
+ <xsl:call-template name="iso:exslt.add.imports" /> <!-- RJ moved report BH -->
642
+ <axsl:param name="archiveDirParameter" />
643
+ <axsl:param name="archiveNameParameter" />
644
+ <axsl:param name="fileNameParameter" />
645
+ <axsl:param name="fileDirParameter" />
646
+
647
+
648
+ <axsl:variable name="document-uri"><axsl:value-of select="document-uri(/)" /></axsl:variable>
649
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PHASES</xsl:comment><xsl:text>&#10;</xsl:text>
650
+ <xsl:call-template name="handle-phase"/>
651
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>PROLOG</xsl:comment><xsl:text>&#10;</xsl:text>
652
+ <xsl:call-template name="process-prolog"/>
653
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>XSD TYPES FOR XSLT2</xsl:comment><xsl:text>&#10;</xsl:text>
654
+ <xsl:apply-templates mode="do-types" select="xsl:import-schema"/>
655
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>KEYS AND FUNCTIONS</xsl:comment><xsl:text>&#10;</xsl:text>
656
+ <xsl:apply-templates mode="do-keys" select="xsl:key | xsl:function "/>
657
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>DEFAULT RULES</xsl:comment><xsl:text>&#10;</xsl:text>
658
+ <xsl:call-template name="generate-default-rules" />
659
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMA SETUP</xsl:comment><xsl:text>&#10;</xsl:text>
660
+ <xsl:call-template name="handle-root"/>
661
+ <xsl:text>&#10;&#10;</xsl:text><xsl:comment>SCHEMATRON PATTERNS</xsl:comment><xsl:text>&#10;</xsl:text>
662
+
663
+ <xsl:apply-templates select="*[not(self::iso:ns)] " />
664
+ </xsl:template>
665
+
666
+ <xsl:template name="iso:exslt.add.imports">
667
+ <xsl:param name="imports" select="$sch.exslt.imports"/>
668
+ <xsl:choose>
669
+ <xsl:when test="contains($imports, ';')">
670
+ <axsl:import href="{ substring-before($imports, ';') }"/>
671
+ <xsl:call-template name="iso:exslt.add.imports">
672
+ <xsl:with-param name="imports" select="substring-after($imports, ';')"/>
673
+ </xsl:call-template>
674
+ </xsl:when>
675
+ <xsl:when test="$imports">
676
+ <axsl:import href="{ $imports }"/>
677
+ </xsl:when>
678
+ </xsl:choose>
679
+ </xsl:template>
680
+
681
+ <xsl:template name="handle-phase" >
682
+ <!-- This just tests that the phase exists -->
683
+ <xsl:if test="not(normalize-space( $phase ) = '#ALL')">
684
+ <xsl:if test="not(iso:phase[@id = normalize-space( $phase )])">
685
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">4a</xsl:with-param></xsl:call-template>
686
+ <xsl:value-of select="normalize-space( $phase )"/>
687
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">4b</xsl:with-param></xsl:call-template></xsl:message>
688
+ </xsl:if>
689
+ </xsl:if>
690
+ </xsl:template>
691
+
692
+ <xsl:template name="generate-default-rules">
693
+ <xsl:text>&#10;&#10;</xsl:text>
694
+ <xsl:comment>MODE: SCHEMATRON-SELECT-FULL-PATH</xsl:comment><xsl:text>&#10;</xsl:text>
695
+ <xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text>&#10;</xsl:text>
696
+ <axsl:template match="*" mode="schematron-select-full-path">
697
+ <xsl:choose>
698
+ <xsl:when test=" $full-path-notation = '1' ">
699
+ <!-- Use for computers, but rather unreadable for humans -->
700
+ <axsl:apply-templates select="." mode="schematron-get-full-path"/>
701
+ </xsl:when>
702
+ <xsl:when test=" $full-path-notation = '2' ">
703
+ <!-- Use for humans, but no good for paths unless namespaces are known out-of-band -->
704
+ <axsl:apply-templates select="." mode="schematron-get-full-path-2"/>
705
+ </xsl:when>
706
+ <xsl:when test=" $full-path-notation = '3' ">
707
+ <!-- Obsolescent. Use for humans, but no good for paths unless namespaces are known out-of-band -->
708
+ <axsl:apply-templates select="." mode="schematron-get-full-path-3"/>
709
+ </xsl:when>
710
+
711
+ <xsl:otherwise >
712
+ <!-- Use for computers, but rather unreadable for humans -->
713
+ <axsl:apply-templates select="." mode="schematron-get-full-path"/>
714
+ </xsl:otherwise>
715
+ </xsl:choose>
716
+ </axsl:template>
717
+
718
+
719
+ <xsl:text>&#10;&#10;</xsl:text>
720
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH</xsl:comment><xsl:text>&#10;</xsl:text>
721
+ <xsl:comment>This mode can be used to generate an ugly though full XPath for locators</xsl:comment><xsl:text>&#10;</xsl:text>
722
+ <axsl:template match="*" mode="schematron-get-full-path">
723
+ <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
724
+ <xsl:choose>
725
+ <xsl:when test="//iso:schema[@queryBinding='xslt2']">
726
+ <!-- XSLT2 syntax -->
727
+ <axsl:text>/</axsl:text>
728
+ <axsl:choose>
729
+ <axsl:when test="namespace-uri()=''"><axsl:value-of select="name()"/></axsl:when>
730
+ <axsl:otherwise>
731
+ <axsl:text>*:</axsl:text>
732
+ <axsl:value-of select="local-name()"/>
733
+ <axsl:text>[namespace-uri()='</axsl:text>
734
+ <axsl:value-of select="namespace-uri()"/>
735
+ <axsl:text>']</axsl:text>
736
+ </axsl:otherwise>
737
+ </axsl:choose>
738
+ <axsl:variable name="preceding" select=
739
+ "count(preceding-sibling::*[local-name()=local-name(current())
740
+ and namespace-uri() = namespace-uri(current())])" />
741
+ <axsl:text>[</axsl:text>
742
+ <axsl:value-of select="1+ $preceding"/>
743
+ <axsl:text>]</axsl:text>
744
+ </xsl:when>
745
+
746
+ <xsl:otherwise>
747
+ <!-- XSLT1 syntax -->
748
+
749
+ <axsl:text>/</axsl:text>
750
+ <axsl:choose>
751
+ <axsl:when test="namespace-uri()=''">
752
+ <axsl:value-of select="name()"/>
753
+ <axsl:variable name="p_1" select="1+
754
+ count(preceding-sibling::*[name()=name(current())])" />
755
+ <axsl:if test="$p_1&gt;1 or following-sibling::*[name()=name(current())]">
756
+ <xsl:text/>[<axsl:value-of select="$p_1"/>]<xsl:text/>
757
+ </axsl:if>
758
+ </axsl:when>
759
+ <axsl:otherwise>
760
+ <axsl:text>*[local-name()='</axsl:text>
761
+ <axsl:value-of select="local-name()"/>
762
+ <axsl:text>']</axsl:text>
763
+ <axsl:variable name="p_2" select="1+
764
+ count(preceding-sibling::*[local-name()=local-name(current())])" />
765
+ <axsl:if test="$p_2&gt;1 or following-sibling::*[local-name()=local-name(current())]">
766
+ <xsl:text/>[<axsl:value-of select="$p_2"/>]<xsl:text/>
767
+ </axsl:if>
768
+ </axsl:otherwise>
769
+ </axsl:choose>
770
+ </xsl:otherwise>
771
+
772
+ </xsl:choose>
773
+ </axsl:template>
774
+
775
+
776
+ <axsl:template match="@*" mode="schematron-get-full-path">
777
+ <xsl:choose>
778
+ <xsl:when test="//iso:schema[@queryBinding='xslt2']">
779
+ <!-- XSLT2 syntax -->
780
+ <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
781
+ <axsl:text>/</axsl:text>
782
+ <axsl:choose>
783
+ <axsl:when test="namespace-uri()=''">@<axsl:value-of select="name()"/></axsl:when>
784
+ <axsl:otherwise>
785
+ <axsl:text>@*[local-name()='</axsl:text>
786
+ <axsl:value-of select="local-name()"/>
787
+ <axsl:text>' and namespace-uri()='</axsl:text>
788
+ <axsl:value-of select="namespace-uri()"/>
789
+ <axsl:text>']</axsl:text>
790
+ </axsl:otherwise>
791
+ </axsl:choose>
792
+ </xsl:when>
793
+
794
+ <xsl:otherwise>
795
+ <!-- XSLT1 syntax -->
796
+ <axsl:text>/</axsl:text>
797
+ <axsl:choose>
798
+ <axsl:when test="namespace-uri()=''">@<axsl:value-of
799
+ select="name()"/></axsl:when>
800
+ <axsl:otherwise>
801
+ <axsl:text>@*[local-name()='</axsl:text>
802
+ <axsl:value-of select="local-name()"/>
803
+ <axsl:text>' and namespace-uri()='</axsl:text>
804
+ <axsl:value-of select="namespace-uri()"/>
805
+ <axsl:text>']</axsl:text>
806
+ </axsl:otherwise>
807
+ </axsl:choose>
808
+
809
+ </xsl:otherwise>
810
+ </xsl:choose>
811
+ </axsl:template>
812
+
813
+ <xsl:text>&#10;&#10;</xsl:text>
814
+
815
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH-2</xsl:comment>
816
+ <xsl:text>&#10;</xsl:text>
817
+ <xsl:comment>This mode can be used to generate prefixed XPath for humans</xsl:comment>
818
+ <xsl:text>&#10;</xsl:text>
819
+ <!--simplify the error messages by using the namespace prefixes of the
820
+ instance rather than the generic namespace-uri-styled qualification-->
821
+ <axsl:template match="node() | @*" mode="schematron-get-full-path-2">
822
+ <!--report the element hierarchy-->
823
+ <axsl:for-each select="ancestor-or-self::*">
824
+ <axsl:text>/</axsl:text>
825
+ <axsl:value-of select="name(.)"/>
826
+ <axsl:if test="preceding-sibling::*[name(.)=name(current())]">
827
+ <axsl:text>[</axsl:text>
828
+ <axsl:value-of
829
+ select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
830
+ <axsl:text>]</axsl:text>
831
+ </axsl:if>
832
+ </axsl:for-each>
833
+ <!--report the attribute-->
834
+ <axsl:if test="not(self::*)">
835
+ <axsl:text/>/@<axsl:value-of select="name(.)"/>
836
+ </axsl:if>
837
+ </axsl:template>
838
+
839
+
840
+ <xsl:comment>MODE: SCHEMATRON-FULL-PATH-3</xsl:comment>
841
+
842
+ <xsl:text>&#10;</xsl:text>
843
+ <xsl:comment>This mode can be used to generate prefixed XPath for humans
844
+ (Top-level element has index)</xsl:comment>
845
+ <xsl:text>&#10;</xsl:text>
846
+ <!--simplify the error messages by using the namespace prefixes of the
847
+ instance rather than the generic namespace-uri-styled qualification-->
848
+ <axsl:template match="node() | @*" mode="schematron-get-full-path-3">
849
+ <!--report the element hierarchy-->
850
+ <axsl:for-each select="ancestor-or-self::*">
851
+ <axsl:text>/</axsl:text>
852
+ <axsl:value-of select="name(.)"/>
853
+ <axsl:if test="parent::*">
854
+ <axsl:text>[</axsl:text>
855
+ <axsl:value-of
856
+ select="count(preceding-sibling::*[name(.)=name(current())])+1"/>
857
+ <axsl:text>]</axsl:text>
858
+ </axsl:if>
859
+ </axsl:for-each>
860
+ <!--report the attribute-->
861
+ <axsl:if test="not(self::*)">
862
+ <axsl:text/>/@<axsl:value-of select="name(.)"/>
863
+ </axsl:if>
864
+ </axsl:template>
865
+
866
+ <xsl:text>&#10;&#10;</xsl:text>
867
+ <xsl:comment>MODE: GENERATE-ID-FROM-PATH </xsl:comment><xsl:text>&#10;</xsl:text>
868
+ <!-- repeatable-id maker derived from Francis Norton's. -->
869
+ <!-- use this if you need generate ids in separate passes,
870
+ because generate-id() is not guaranteed to produce the same
871
+ results each time. These ids are not XML names but closer to paths. -->
872
+ <axsl:template match="/" mode="generate-id-from-path"/>
873
+ <axsl:template match="text()" mode="generate-id-from-path">
874
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
875
+ <axsl:value-of select="concat('.text-', 1+count(preceding-sibling::text()), '-')"/>
876
+ </axsl:template>
877
+ <axsl:template match="comment()" mode="generate-id-from-path">
878
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
879
+ <axsl:value-of select="concat('.comment-', 1+count(preceding-sibling::comment()), '-')"/>
880
+ </axsl:template>
881
+ <axsl:template match="processing-instruction()" mode="generate-id-from-path">
882
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
883
+ <axsl:value-of
884
+ select="concat('.processing-instruction-', 1+count(preceding-sibling::processing-instruction()), '-')"/>
885
+ </axsl:template>
886
+ <axsl:template match="@*" mode="generate-id-from-path">
887
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
888
+ <axsl:value-of select="concat('.@', name())"/>
889
+ </axsl:template>
890
+ <axsl:template match="*" mode="generate-id-from-path" priority="-0.5">
891
+ <axsl:apply-templates select="parent::*" mode="generate-id-from-path"/>
892
+ <axsl:text>.</axsl:text>
893
+ <!--
894
+ <axsl:choose>
895
+ <axsl:when test="count(. | ../namespace::*) = count(../namespace::*)">
896
+ <axsl:value-of select="concat('.namespace::-',1+count(namespace::*),'-')"/>
897
+ </axsl:when>
898
+ <axsl:otherwise>
899
+ -->
900
+ <axsl:value-of
901
+ select="concat('.',name(),'-',1+count(preceding-sibling::*[name()=name(current())]),'-')"/>
902
+ <!--
903
+ </axsl:otherwise>
904
+ </axsl:choose>
905
+ -->
906
+ </axsl:template>
907
+
908
+
909
+ <xsl:text>&#10;&#10;</xsl:text>
910
+ <xsl:comment>MODE: GENERATE-ID-2 </xsl:comment><xsl:text>&#10;</xsl:text>
911
+ <!-- repeatable-id maker from David Carlisle. -->
912
+ <!-- use this if you need generate IDs in separate passes,
913
+ because generate-id() is not guaranteed to produce the same
914
+ results each time. These IDs are well-formed XML NMTOKENS -->
915
+ <axsl:template match="/" mode="generate-id-2">U</axsl:template>
916
+
917
+ <axsl:template match="*" mode="generate-id-2" priority="2">
918
+ <axsl:text>U</axsl:text>
919
+ <axsl:number level="multiple" count="*"/>
920
+ </axsl:template>
921
+
922
+ <axsl:template match="node()" mode="generate-id-2">
923
+ <axsl:text>U.</axsl:text>
924
+ <axsl:number level="multiple" count="*"/>
925
+ <axsl:text>n</axsl:text>
926
+ <axsl:number count="node()"/>
927
+ </axsl:template>
928
+
929
+ <axsl:template match="@*" mode="generate-id-2">
930
+ <axsl:text>U.</axsl:text>
931
+ <axsl:number level="multiple" count="*"/>
932
+ <axsl:text>_</axsl:text>
933
+ <axsl:value-of select="string-length(local-name(.))"/>
934
+ <axsl:text>_</axsl:text>
935
+ <axsl:value-of select="translate(name(),':','.')"/>
936
+ </axsl:template>
937
+
938
+
939
+ <xsl:comment>Strip characters</xsl:comment>
940
+ <axsl:template match="text()" priority="-1" />
941
+
942
+ </xsl:template>
943
+
944
+ <xsl:template name="handle-root">
945
+ <!-- Process the top-level element -->
946
+ <axsl:template match="/">
947
+ <xsl:call-template name="process-root">
948
+ <xsl:with-param
949
+ name="title" select="(@id | iso:title)[last()]"/>
950
+ <xsl:with-param name="version" select="'iso'" />
951
+ <xsl:with-param name="schemaVersion" select="@schemaVersion" />
952
+ <xsl:with-param name="queryBinding" select="@queryBinding" />
953
+ <xsl:with-param name="contents">
954
+ <xsl:apply-templates mode="do-all-patterns"/>
955
+ </xsl:with-param>
956
+
957
+ <!-- "Rich" properties -->
958
+ <xsl:with-param name="fpi" select="@fpi"/>
959
+ <xsl:with-param name="icon" select="@icon"/>
960
+ <xsl:with-param name="id" select="@id"/>
961
+ <xsl:with-param name="lang" select="@xml:lang"/>
962
+ <xsl:with-param name="see" select="@see" />
963
+ <xsl:with-param name="space" select="@xml:space" />
964
+ </xsl:call-template>
965
+ </axsl:template>
966
+
967
+
968
+ </xsl:template>
969
+
970
+ <!-- ============================================================== -->
971
+ <!-- ISO SCHEMATRON ELEMENTS -->
972
+ <!-- ============================================================== -->
973
+
974
+ <!-- ISO ACTIVE -->
975
+ <xsl:template match="iso:active">
976
+ <xsl:if test="not(@pattern)">
977
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">5</xsl:with-param></xsl:call-template></xsl:message>
978
+ </xsl:if>
979
+
980
+ <xsl:if test="not(../../iso:pattern[@id = current()/@pattern])
981
+ and not(../../iso:include)">
982
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">6a</xsl:with-param></xsl:call-template>
983
+ <xsl:value-of select="@pattern"/>
984
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">6b</xsl:with-param></xsl:call-template></xsl:message>
985
+ </xsl:if>
986
+ </xsl:template>
987
+
988
+ <!-- ISO ASSERT and REPORT -->
989
+ <xsl:template match="iso:assert">
990
+
991
+ <xsl:if test="not(@test)">
992
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">7</xsl:with-param></xsl:call-template></xsl:message>
993
+ </xsl:if>
994
+ <xsl:text>&#10;&#10; </xsl:text>
995
+ <xsl:comment>ASSERT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
996
+
997
+ <axsl:choose>
998
+ <axsl:when test="{@test}"/>
999
+ <axsl:otherwise>
1000
+ <xsl:call-template name="process-assert">
1001
+ <xsl:with-param name="test" select="normalize-space(@test)" />
1002
+ <xsl:with-param name="diagnostics" select="@diagnostics"/>
1003
+ <xsl:with-param name="flag" select="@flag"/>
1004
+
1005
+ <xsl:with-param name="properties" select="@properties" />
1006
+
1007
+ <!-- "Rich" properties -->
1008
+ <xsl:with-param name="fpi" select="@fpi"/>
1009
+ <xsl:with-param name="icon" select="@icon"/>
1010
+ <xsl:with-param name="id" select="@id"/>
1011
+ <xsl:with-param name="lang" select="@xml:lang"/>
1012
+ <xsl:with-param name="see" select="@see" />
1013
+ <xsl:with-param name="space" select="@xml:space" />
1014
+
1015
+ <!-- "Linking" properties -->
1016
+ <xsl:with-param name="role" select="@role" />
1017
+ <xsl:with-param name="subject" select="@subject" />
1018
+
1019
+ </xsl:call-template>
1020
+
1021
+
1022
+ </axsl:otherwise>
1023
+ </axsl:choose>
1024
+ </xsl:template>
1025
+ <xsl:template match="iso:report">
1026
+
1027
+ <xsl:if test="not(@test)">
1028
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">8</xsl:with-param></xsl:call-template></xsl:message>
1029
+ </xsl:if>
1030
+
1031
+ <xsl:text>&#10;&#10; </xsl:text>
1032
+ <xsl:comment>REPORT <xsl:value-of select="@role" /> </xsl:comment><xsl:text>&#10;</xsl:text>
1033
+
1034
+ <axsl:if test="{@test}">
1035
+
1036
+ <xsl:call-template name="process-report">
1037
+ <xsl:with-param name="test" select="normalize-space(@test)" />
1038
+ <xsl:with-param name="diagnostics" select="@diagnostics"/>
1039
+ <xsl:with-param name="flag" select="@flag"/>
1040
+
1041
+ <xsl:with-param name="properties" select="@properties" />
1042
+ <!-- "Rich" properties -->
1043
+ <xsl:with-param name="fpi" select="@fpi"/>
1044
+ <xsl:with-param name="icon" select="@icon"/>
1045
+ <xsl:with-param name="id" select="@id"/>
1046
+ <xsl:with-param name="lang" select="@xml:lang"/>
1047
+ <xsl:with-param name="see" select="@see" />
1048
+ <xsl:with-param name="space" select="@xml:space" />
1049
+
1050
+ <!-- "Linking" properties -->
1051
+ <xsl:with-param name="role" select="@role" />
1052
+ <xsl:with-param name="subject" select="@subject" />
1053
+ </xsl:call-template>
1054
+
1055
+ </axsl:if>
1056
+ </xsl:template>
1057
+
1058
+
1059
+ <!-- ISO DIAGNOSTIC -->
1060
+ <!-- We use a mode here to maintain backwards compatability, instead of adding it
1061
+ to the other mode.
1062
+ -->
1063
+ <xsl:template match="iso:diagnostic" mode="check-diagnostics">
1064
+ <xsl:if test="not(@id)">
1065
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">9</xsl:with-param></xsl:call-template></xsl:message>
1066
+ </xsl:if>
1067
+ </xsl:template>
1068
+
1069
+ <xsl:template match="iso:diagnostic" >
1070
+ <xsl:call-template name="process-diagnostic">
1071
+
1072
+ <!-- "Rich" properties -->
1073
+ <xsl:with-param name="fpi" select="@fpi"/>
1074
+ <xsl:with-param name="icon" select="@icon"/>
1075
+ <xsl:with-param name="id" select="@id"/>
1076
+ <xsl:with-param name="lang" select="@xml:lang"/>
1077
+ <xsl:with-param name="see" select="@see" />
1078
+ <xsl:with-param name="space" select="@xml:space" />
1079
+ </xsl:call-template>
1080
+
1081
+ </xsl:template>
1082
+
1083
+ <!-- ISO DIAGNOSTICS -->
1084
+ <xsl:template match="iso:diagnostics" >
1085
+ <xsl:apply-templates mode="check-diagnostics" select="*" />
1086
+ </xsl:template>
1087
+
1088
+ <!-- ISO DIR -->
1089
+ <xsl:template match="iso:dir" mode="text" >
1090
+ <xsl:call-template name="process-dir">
1091
+ <xsl:with-param name="value" select="@value"/>
1092
+ </xsl:call-template>
1093
+ </xsl:template>
1094
+
1095
+ <!-- ISO EMPH -->
1096
+ <xsl:template match="iso:emph" mode="text">
1097
+
1098
+ <xsl:call-template name="process-emph"/>
1099
+
1100
+ </xsl:template>
1101
+
1102
+ <!-- ISO EXTENDS -->
1103
+ <xsl:template match="iso:extends">
1104
+ <xsl:if test="not(@rule)">
1105
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">10</xsl:with-param></xsl:call-template></xsl:message>
1106
+ </xsl:if>
1107
+ <xsl:if test="not(//iso:rule[@abstract='true'][@id= current()/@rule] )">
1108
+ <xsl:message>
1109
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">11a</xsl:with-param></xsl:call-template>
1110
+ <xsl:value-of select="@rule"/>
1111
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">11b</xsl:with-param></xsl:call-template></xsl:message>
1112
+ </xsl:if>
1113
+ <xsl:call-template name="IamEmpty" />
1114
+
1115
+ <xsl:choose>
1116
+ <!-- prefer to use a locally declared rule -->
1117
+ <xsl:when test="parent::*/parent::*/iso:rule[@id=current()/@rule]">
1118
+ <xsl:apply-templates select="parent::*/parent::*/iso:rule[@id=current()/@rule]"
1119
+ mode="extends"/>
1120
+ </xsl:when>
1121
+ <!-- otherwise use a global one: this is not in the 2006 standard -->
1122
+ <xsl:when test="//iso:rule[@id=current()/@rule]">
1123
+ <xsl:apply-templates select="//iso:rule[@id=current()/@rule]"
1124
+ mode="extends"/>
1125
+ </xsl:when>
1126
+ </xsl:choose>
1127
+
1128
+
1129
+ </xsl:template>
1130
+
1131
+ <!-- KEY: ISO has no KEY -->
1132
+ <!-- NOTE:
1133
+ Key has had a checkered history. Schematron 1.0 allowed it in certain places, but
1134
+ users came up with a different location, which has now been adopted.
1135
+
1136
+ XT, the early XSLT processor, did not implement key and died when it was present.
1137
+ So there are some versions of the Schematron skeleton for XT that strip out all
1138
+ key elements.
1139
+
1140
+ Xalan (e.g. Xalan4C 1.0 and a Xalan4J) also had a funny. A fix involved making
1141
+ a top-level parameter called $hiddenKey and then using that instead of matching
1142
+ "key". This has been removed.
1143
+
1144
+ Keys and functions are the same mode, to allow their declaration to be mixed up.
1145
+ -->
1146
+ <xsl:template match="xsl:key" mode="do-keys" >
1147
+ <xsl:if test="not(@name)">
1148
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">12</xsl:with-param></xsl:call-template></xsl:message>
1149
+ </xsl:if>
1150
+ <xsl:if test="not(@path) and not(@use)">
1151
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">13</xsl:with-param></xsl:call-template></xsl:message>
1152
+ </xsl:if>
1153
+ <xsl:choose>
1154
+ <xsl:when test="parent::iso:rule ">
1155
+ <xsl:call-template name="IamEmpty" />
1156
+ <xsl:choose>
1157
+ <xsl:when test="@path">
1158
+ <axsl:key match="{../@context}" name="{@name}" use="{@path}"/>
1159
+ </xsl:when>
1160
+ <xsl:otherwise>
1161
+ <axsl:key match="{../@context}" name="{@name}" use="{@use}"/>
1162
+ </xsl:otherwise>
1163
+ </xsl:choose>
1164
+ </xsl:when>
1165
+ <xsl:otherwise>
1166
+ <xsl:if test="not(@match) ">
1167
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">14</xsl:with-param></xsl:call-template></xsl:message>
1168
+ </xsl:if>
1169
+ <axsl:key>
1170
+ <xsl:copy-of select="@*"/>
1171
+ </axsl:key>
1172
+ </xsl:otherwise>
1173
+ </xsl:choose>
1174
+ </xsl:template>
1175
+
1176
+ <xsl:template match="xsl:key " /><!-- swallow -->
1177
+
1178
+ <xsl:template match="iso:key " >
1179
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">15</xsl:with-param></xsl:call-template></xsl:message>
1180
+ </xsl:template>
1181
+
1182
+ <!-- XSL FUNCTION -->
1183
+ <xsl:template match="xsl:function" mode="do-keys" >
1184
+ <xsl:if test="not(@name)">
1185
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">16</xsl:with-param></xsl:call-template></xsl:message>
1186
+ </xsl:if>
1187
+ <xsl:copy-of select="."/>
1188
+ </xsl:template>
1189
+
1190
+ <xsl:template match="xsl:function " /><!-- swallow -->
1191
+
1192
+ <xsl:template match="iso:function " >
1193
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">17</xsl:with-param></xsl:call-template></xsl:message>
1194
+ </xsl:template>
1195
+
1196
+
1197
+ <!-- ISO INCLUDE -->
1198
+ <!-- This is only a fallback. Include really needs to have been done before this as a separate pass.-->
1199
+
1200
+ <xsl:template match="iso:include[not(normalize-space(@href))]"
1201
+ priority="1">
1202
+ <xsl:if test=" $debug = 'false' ">
1203
+ <xsl:message terminate="yes"><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">18</xsl:with-param></xsl:call-template></xsl:message>
1204
+ </xsl:if>
1205
+
1206
+ </xsl:template>
1207
+
1208
+ <!-- Extend the URI syntax to allow # refererences -->
1209
+ <!-- Note that XSLT2 actually already allows # references, but we override them because it
1210
+ looks unreliable -->
1211
+ <xsl:template match="iso:include">
1212
+ <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
1213
+ <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
1214
+
1215
+ <xsl:choose>
1216
+
1217
+ <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
1218
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">19</xsl:with-param></xsl:call-template></xsl:message>
1219
+ </xsl:when>
1220
+
1221
+ <xsl:when test="string-length( $fragment-id ) &gt; 0">
1222
+ <xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
1223
+ <xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id]" />
1224
+ <xsl:if test="not($theDocument_1)">
1225
+ <xsl:message terminate="no">
1226
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">20a</xsl:with-param></xsl:call-template>
1227
+ <xsl:value-of select="@href"/>
1228
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">20b</xsl:with-param></xsl:call-template>
1229
+ </xsl:message>
1230
+ </xsl:if>
1231
+ <xsl:if test=" $theFragment_1/self::iso:schema ">
1232
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">21</xsl:with-param></xsl:call-template></xsl:message>
1233
+ </xsl:if>
1234
+ <xsl:apply-templates select=" $theFragment_1"/>
1235
+ </xsl:when>
1236
+
1237
+ <xsl:otherwise>
1238
+ <!-- Import the top-level element if it is in schematron namespace,
1239
+ or its children otherwise, to allow a simple containment mechanism. -->
1240
+ <xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
1241
+ <xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
1242
+ <xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
1243
+ <xsl:if test="not($theDocument_2)">
1244
+ <xsl:message terminate="no">
1245
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">20a</xsl:with-param></xsl:call-template>
1246
+ <xsl:value-of select="@href"/>
1247
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">20b</xsl:with-param></xsl:call-template>
1248
+ </xsl:message>
1249
+ </xsl:if>
1250
+ <xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
1251
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">21</xsl:with-param></xsl:call-template></xsl:message>
1252
+ </xsl:if>
1253
+ <xsl:apply-templates select="$theFragment_2 | $theContainedFragments "/>
1254
+ </xsl:otherwise>
1255
+ </xsl:choose>
1256
+ </xsl:template>
1257
+
1258
+ <!-- This is to handle the particular case of including patterns -->
1259
+ <xsl:template match="iso:include" mode="do-all-patterns">
1260
+ <xsl:variable name="document-uri" select="substring-before(concat(@href,'#'), '#')"/>
1261
+ <xsl:variable name="fragment-id" select="substring-after(@href, '#')"/>
1262
+
1263
+ <xsl:choose>
1264
+
1265
+ <xsl:when test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0" >
1266
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">19</xsl:with-param></xsl:call-template></xsl:message>
1267
+ </xsl:when>
1268
+
1269
+ <xsl:when test="string-length( $fragment-id ) &gt; 0">
1270
+ <xsl:variable name="theDocument_1" select="document( $document-uri,/ )" />
1271
+ <xsl:variable name="theFragment_1" select="$theDocument_1//iso:*[@id= $fragment-id ]" />
1272
+ <xsl:if test=" $theFragment_1/self::iso:schema ">
1273
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">21</xsl:with-param></xsl:call-template></xsl:message>
1274
+ </xsl:if>
1275
+ <xsl:apply-templates select=" $theFragment_1" mode="do-all-patterns"/>
1276
+ </xsl:when>
1277
+
1278
+ <xsl:otherwise>
1279
+ <!-- Import the top-level element if it is in schematron namespace,
1280
+ or its children otherwise, to allow a simple containment mechanism. -->
1281
+ <xsl:variable name="theDocument_2" select="document( $document-uri,/ )" />
1282
+ <xsl:variable name="theFragment_2" select="$theDocument_2/iso:*" />
1283
+ <xsl:variable name="theContainedFragments" select="$theDocument_2/*/iso:*" />
1284
+ <xsl:if test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
1285
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">21</xsl:with-param></xsl:call-template></xsl:message>
1286
+ </xsl:if>
1287
+ <xsl:apply-templates select="$theFragment_2 | $theContainedFragments "
1288
+ mode="do-all-patterns" />
1289
+ </xsl:otherwise>
1290
+ </xsl:choose>
1291
+ </xsl:template>
1292
+
1293
+
1294
+ <!-- XSL IMPORT-SCHEMA -->
1295
+ <!-- Importing an XSD schema allows the variour type operations to be available. -->
1296
+ <xsl:template match="xsl:import-schema" mode="do-types" >
1297
+ <xsl:choose>
1298
+ <xsl:when test="ancestor::iso:schema[@queryBinding='xslt2']">
1299
+ <xsl:copy-of select="." />
1300
+ </xsl:when>
1301
+ <xsl:otherwise>
1302
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">22</xsl:with-param></xsl:call-template></xsl:message>
1303
+ </xsl:otherwise>
1304
+ </xsl:choose>
1305
+ </xsl:template>
1306
+
1307
+ <!-- swallow -->
1308
+ <xsl:template match="xsl:import-schema" />
1309
+
1310
+ <xsl:template match="iso:import-schema " >
1311
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">23</xsl:with-param></xsl:call-template></xsl:message>
1312
+ </xsl:template>
1313
+
1314
+ <!-- ISO LET -->
1315
+ <xsl:template match="iso:let" >
1316
+ <xsl:if test="ancestor::iso:schema[@queryBinding='xpath']">
1317
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">24</xsl:with-param></xsl:call-template></xsl:message>
1318
+ </xsl:if>
1319
+ <xsl:if test="ancestor::iso:schema[@queryBinding='xpath2']">
1320
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">25</xsl:with-param></xsl:call-template></xsl:message>
1321
+ </xsl:if>
1322
+
1323
+ <!-- lets at the top-level are implemented as parameters unless they have contents -->
1324
+ <xsl:choose>
1325
+ <xsl:when test="parent::iso:schema">
1326
+ <!-- it is an error to have an empty param/@select because an XPath is expected -->
1327
+ <xsl:choose>
1328
+ <xsl:when test="@value">
1329
+ <axsl:param name="{@name}" select="{@value}">
1330
+ <xsl:if test="string-length(@value) &gt; 0">
1331
+ <xsl:attribute name="select"><xsl:value-of select="@value"/></xsl:attribute>
1332
+ </xsl:if>
1333
+ </axsl:param>
1334
+ </xsl:when>
1335
+ <xsl:otherwise>
1336
+ <axsl:variable name="{@name}" >
1337
+ <xsl:copy-of select="child::node()" />
1338
+ </axsl:variable>
1339
+ </xsl:otherwise>
1340
+ </xsl:choose>
1341
+ </xsl:when>
1342
+ <xsl:otherwise>
1343
+
1344
+ <xsl:choose>
1345
+ <xsl:when test="@value">
1346
+ <axsl:variable name="{@name}" select="{@value}"/>
1347
+ </xsl:when>
1348
+ <xsl:otherwise>
1349
+ <axsl:variable name="{@name}" >
1350
+ <xsl:copy-of select="child::node()" />
1351
+ </axsl:variable>
1352
+ </xsl:otherwise>
1353
+ </xsl:choose>
1354
+
1355
+ </xsl:otherwise>
1356
+ </xsl:choose>
1357
+ </xsl:template>
1358
+
1359
+ <!-- ISO NAME -->
1360
+ <xsl:template match="iso:name" mode="text">
1361
+
1362
+ <xsl:if test="@path">
1363
+ <xsl:call-template name="process-name">
1364
+ <xsl:with-param name="name" select="concat('name(',@path,')')"/>
1365
+ </xsl:call-template>
1366
+ </xsl:if>
1367
+ <xsl:if test="not(@path)">
1368
+ <xsl:call-template name="process-name">
1369
+ <xsl:with-param name="name" select="'name(.)'"/>
1370
+ </xsl:call-template>
1371
+ </xsl:if>
1372
+ <xsl:call-template name="IamEmpty" />
1373
+ </xsl:template>
1374
+
1375
+ <!-- ISO NS -->
1376
+ <!-- Namespace handling is XSLT is quite tricky and implementation dependent -->
1377
+ <xsl:template match="iso:ns">
1378
+ <xsl:call-template name="handle-namespace" />
1379
+ </xsl:template>
1380
+
1381
+ <!-- This template is just to provide the API hook -->
1382
+ <xsl:template match="iso:ns" mode="do-all-patterns" >
1383
+ <xsl:if test="not(@uri)">
1384
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">26</xsl:with-param></xsl:call-template></xsl:message>
1385
+ </xsl:if>
1386
+ <xsl:if test="not(@prefix)">
1387
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">27</xsl:with-param></xsl:call-template></xsl:message>
1388
+ </xsl:if>
1389
+ <xsl:call-template name="IamEmpty" />
1390
+ <xsl:call-template name="process-ns" >
1391
+ <xsl:with-param name="prefix" select="@prefix"/>
1392
+ <xsl:with-param name="uri" select="@uri"/>
1393
+ </xsl:call-template>
1394
+ </xsl:template>
1395
+
1396
+ <!-- ISO P -->
1397
+ <xsl:template match="iso:schema/iso:p " mode="do-schema-p" >
1398
+ <xsl:call-template name="process-p">
1399
+ <xsl:with-param name="class" select="@class"/>
1400
+ <xsl:with-param name="icon" select="@icon"/>
1401
+ <xsl:with-param name="id" select="@id"/>
1402
+ <xsl:with-param name="lang" select="@xml:lang"/>
1403
+ </xsl:call-template>
1404
+ </xsl:template>
1405
+ <xsl:template match="iso:pattern/iso:p " mode="do-pattern-p" >
1406
+ <xsl:call-template name="process-p">
1407
+ <xsl:with-param name="class" select="@class"/>
1408
+ <xsl:with-param name="icon" select="@icon"/>
1409
+ <xsl:with-param name="id" select="@id"/>
1410
+ <xsl:with-param name="lang" select="@xml:lang"/>
1411
+ </xsl:call-template>
1412
+ </xsl:template>
1413
+
1414
+ <!-- Currently, iso:p in other position are not passed through to the API -->
1415
+ <xsl:template match="iso:phase/iso:p" />
1416
+ <xsl:template match="iso:p " priority="-1" />
1417
+
1418
+ <!-- ISO PATTERN -->
1419
+ <xsl:template match="iso:pattern" mode="do-all-patterns">
1420
+ <xsl:if test="($phase = '#ALL')
1421
+ or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
1422
+
1423
+ <!-- Extension to allow validation in multiple documents -->
1424
+ <xsl:choose>
1425
+ <xsl:when test="string-length(normalize-space(@documents))=0" >
1426
+ <xsl:call-template name="handle-pattern" />
1427
+ </xsl:when>
1428
+ <xsl:otherwise>
1429
+ <axsl:variable name="thePath"
1430
+ select="{@documents}"
1431
+ as="xs:string*" />
1432
+
1433
+ <axsl:for-each select="$thePath">
1434
+ <axsl:choose>
1435
+ <axsl:when test="starts-with( ., 'http:') or starts-with(., 'file:' )
1436
+ or starts-with(., '/')"><!-- try as absolute path -->
1437
+ <axsl:for-each select="document(.)">
1438
+ <xsl:call-template name="handle-pattern" />
1439
+ </axsl:for-each>
1440
+ </axsl:when>
1441
+ <axsl:otherwise><!-- is relative path -->
1442
+ <axsl:for-each select="document(concat( $document-uri , '/../', .))">
1443
+ <xsl:call-template name="handle-pattern" />
1444
+ </axsl:for-each>
1445
+ </axsl:otherwise>
1446
+ </axsl:choose>
1447
+ </axsl:for-each>
1448
+ </xsl:otherwise>
1449
+ </xsl:choose>
1450
+ </xsl:if>
1451
+
1452
+ </xsl:template>
1453
+
1454
+ <xsl:template name="handle-pattern">
1455
+ <xsl:call-template name="process-pattern">
1456
+ <!-- the following select statement assumes that
1457
+ @id | iso:title returns node-set in document order:
1458
+ we want the title if it is there, otherwise the @id attribute -->
1459
+ <xsl:with-param name="name" select="(@id | iso:title )[last()]"/>
1460
+ <xsl:with-param name="is-a" select="''"/>
1461
+
1462
+ <!-- "Rich" properties -->
1463
+ <xsl:with-param name="fpi" select="@fpi"/>
1464
+ <xsl:with-param name="icon" select="@icon"/>
1465
+ <xsl:with-param name="id" select="@id"/>
1466
+ <xsl:with-param name="lang" select="@xml:lang"/>
1467
+ <xsl:with-param name="see" select="@see" />
1468
+ <xsl:with-param name="space" select="@xml:space" />
1469
+ </xsl:call-template>
1470
+ <xsl:choose>
1471
+ <!-- Use the key method -->
1472
+ <xsl:when test="$select-contexts='key'">
1473
+ <axsl:apply-templates select="key('M','M{count(preceding-sibling::*)}')" mode="M{count(preceding-sibling::*)}"/>
1474
+ </xsl:when>
1475
+
1476
+ <!-- Use the // method -->
1477
+ <xsl:when test="$select-contexts='//'">
1478
+ <xsl:choose>
1479
+ <xsl:when test="@document">
1480
+ <!-- External document -->
1481
+ <axsl:for-each select="{@document}">
1482
+ <!-- same code as next block, but run from different context -->
1483
+ <axsl:apply-templates mode="M{count(preceding-sibling::*)}" >
1484
+ <xsl:attribute name="select">
1485
+ <xsl:text>//(</xsl:text>
1486
+ <xsl:for-each select="iso:rule/@context">
1487
+ <xsl:text>(</xsl:text>
1488
+ <xsl:value-of select="."/>
1489
+ <xsl:text>)</xsl:text>
1490
+ <xsl:if test="position()!=last()">|</xsl:if>
1491
+ </xsl:for-each>
1492
+ <xsl:text>)</xsl:text>
1493
+ <xsl:if test="$visit-text='false'">[not(self::text())]</xsl:if>
1494
+ </xsl:attribute>
1495
+ </axsl:apply-templates>
1496
+ </axsl:for-each>
1497
+ </xsl:when>
1498
+
1499
+ <xsl:otherwise>
1500
+ <axsl:apply-templates mode="M{count(preceding-sibling::*)}" >
1501
+ <xsl:attribute name="select">
1502
+ <xsl:text>//(</xsl:text>
1503
+ <xsl:for-each select="iso:rule/@context">
1504
+ <xsl:text>(</xsl:text>
1505
+ <xsl:value-of select="."/>
1506
+ <xsl:text>)</xsl:text>
1507
+ <xsl:if test="position()!=last()">|</xsl:if>
1508
+ </xsl:for-each>
1509
+ <xsl:text>)</xsl:text>
1510
+ <xsl:if test="$visit-text='false'">[not(self::text())]</xsl:if>
1511
+ </xsl:attribute>
1512
+ </axsl:apply-templates>
1513
+ </xsl:otherwise>
1514
+ </xsl:choose>
1515
+ </xsl:when>
1516
+
1517
+ <!-- Use complete tree traversal -->
1518
+ <xsl:when test="@document">
1519
+ <!-- External document -->
1520
+ <axsl:for-each select="{@document}">
1521
+ <axsl:apply-templates select="." mode="M{count(preceding-sibling::*)}"/>
1522
+ </axsl:for-each>
1523
+ </xsl:when>
1524
+ <xsl:otherwise>
1525
+ <axsl:apply-templates select="/" mode="M{count(preceding-sibling::*)}"/>
1526
+ </xsl:otherwise>
1527
+ </xsl:choose>
1528
+ <!--/xsl:if-->
1529
+ </xsl:template>
1530
+
1531
+ <xsl:template match="iso:pattern[@abstract='true']">
1532
+
1533
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">28</xsl:with-param></xsl:call-template></xsl:message>
1534
+ </xsl:template>
1535
+
1536
+ <!-- Here is the template for the normal case of patterns -->
1537
+ <xsl:template match="iso:pattern[not(@abstract='true')]">
1538
+
1539
+ <xsl:if test="($phase = '#ALL')
1540
+ or (../iso:phase[@id= $phase]/iso:active[@pattern= current()/@id])">
1541
+ <xsl:text>&#10;&#10;</xsl:text>
1542
+ <xsl:comment>PATTERN <xsl:value-of select="@id" /> <xsl:value-of select="iso:title" /> </xsl:comment><xsl:text>&#10;</xsl:text>
1543
+ <xsl:apply-templates />
1544
+
1545
+ <!-- DPC select-contexts test -->
1546
+ <xsl:if test="not($select-contexts)">
1547
+ <axsl:template match="text()" priority="-1" mode="M{count(preceding-sibling::*)}">
1548
+ <!-- strip characters -->
1549
+ </axsl:template>
1550
+
1551
+ <!-- DPC introduce context-xpath variable -->
1552
+ <axsl:template match="@*|node()"
1553
+ priority="-2"
1554
+ mode="M{ count(preceding-sibling::*) }">
1555
+ <axsl:apply-templates select="{$context-xpath}" mode="M{count(preceding-sibling::*)}"/>
1556
+ </axsl:template>
1557
+ </xsl:if>
1558
+ </xsl:if>
1559
+ </xsl:template>
1560
+
1561
+ <!-- ISO PHASE -->
1562
+ <xsl:template match="iso:phase" >
1563
+ <xsl:if test="not(@id)">
1564
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">29</xsl:with-param></xsl:call-template></xsl:message>
1565
+ </xsl:if>
1566
+ <xsl:apply-templates/>
1567
+ </xsl:template>
1568
+
1569
+
1570
+ <!-- PROPERTY Experiemental -->
1571
+ <!-- We use a mode here to maintain backwards compatability, instead of adding it
1572
+ to the other mode.
1573
+ -->
1574
+ <xsl:template match="iso:property" mode="check-property">
1575
+ <xsl:if test="not(@id)">
1576
+ <xsl:message>No property found with that ID</xsl:message>
1577
+ </xsl:if>
1578
+ </xsl:template>
1579
+
1580
+ <xsl:template match="iso:property" >
1581
+ <xsl:call-template name="process-property">
1582
+
1583
+ <xsl:with-param name="id" select="@id"/>
1584
+
1585
+ <xsl:with-param name="name" select="@name"/>
1586
+ <xsl:with-param name="value" select="@value" />
1587
+ <xsl:with-param name="contents" select="*|text()" />
1588
+ </xsl:call-template>
1589
+
1590
+ </xsl:template>
1591
+
1592
+ <!-- PROPERTIES experimental extension -->
1593
+ <xsl:template match="iso:properties" >
1594
+ <xsl:apply-templates mode="check-properties" select="property" />
1595
+ </xsl:template>
1596
+
1597
+
1598
+
1599
+ <!-- ISO RULE -->
1600
+ <xsl:template match="iso:rule[not(@abstract='true')] ">
1601
+ <xsl:if test="not(@context)">
1602
+ <xsl:message ><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">30</xsl:with-param></xsl:call-template></xsl:message>
1603
+
1604
+ <xsl:message terminate="yes" />
1605
+ </xsl:if>
1606
+ <xsl:text>&#10;&#10; </xsl:text>
1607
+ <xsl:comment>RULE <xsl:value-of select="@id" /> </xsl:comment><xsl:text>&#10;</xsl:text>
1608
+ <xsl:if test="iso:title">
1609
+ <xsl:comment><xsl:value-of select="iso:title" /></xsl:comment>
1610
+ </xsl:if>
1611
+ <!-- DPC select-contexts -->
1612
+ <xsl:if test="$select-contexts='key'">
1613
+ <axsl:key name="M"
1614
+ match="{@context}"
1615
+ use="'M{count(../preceding-sibling::*)}'"/>
1616
+ </xsl:if>
1617
+
1618
+
1619
+ <!-- DPC priorities count up from 1000 not down from 4000 (templates in same priority order as before) -->
1620
+ <axsl:template match="{@context}"
1621
+ priority="{1000 + count(following-sibling::*)}" mode="M{count(../preceding-sibling::*)}">
1622
+
1623
+ <xsl:call-template name="process-rule">
1624
+ <xsl:with-param name="context" select="@context"/>
1625
+
1626
+ <xsl:with-param name="properties" select="@properties" />
1627
+
1628
+ <!-- "Rich" properties -->
1629
+ <xsl:with-param name="fpi" select="@fpi"/>
1630
+ <xsl:with-param name="icon" select="@icon"/>
1631
+ <xsl:with-param name="id" select="@id"/>
1632
+ <xsl:with-param name="lang" select="@xml:lang"/>
1633
+ <xsl:with-param name="see" select="@see" />
1634
+ <xsl:with-param name="space" select="@xml:space" />
1635
+
1636
+ <!-- "Linking" properties -->
1637
+ <xsl:with-param name="role" select="@role" />
1638
+ <xsl:with-param name="subject" select="@subject" />
1639
+ </xsl:call-template>
1640
+
1641
+
1642
+ <xsl:apply-templates/>
1643
+ <!-- DPC introduce context-xpath and select-contexts variables -->
1644
+ <xsl:if test="not($select-contexts)">
1645
+ <axsl:apply-templates select="{$context-xpath}" mode="M{count(../preceding-sibling::*)}"/>
1646
+ </xsl:if>
1647
+ </axsl:template>
1648
+ </xsl:template>
1649
+
1650
+
1651
+ <!-- ISO ABSTRACT RULE -->
1652
+ <xsl:template match="iso:rule[@abstract='true'] " >
1653
+ <xsl:if test=" not(@id)">
1654
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">31</xsl:with-param></xsl:call-template></xsl:message>
1655
+ </xsl:if>
1656
+ <xsl:if test="@context">
1657
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">32</xsl:with-param></xsl:call-template></xsl:message>
1658
+ </xsl:if>
1659
+ </xsl:template>
1660
+
1661
+ <xsl:template match="iso:rule[@abstract='true']"
1662
+ mode="extends" >
1663
+ <xsl:if test="@context">
1664
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">33</xsl:with-param></xsl:call-template></xsl:message>
1665
+ </xsl:if>
1666
+ <xsl:apply-templates/>
1667
+ </xsl:template>
1668
+
1669
+ <!-- ISO SPAN -->
1670
+ <xsl:template match="iso:span" mode="text">
1671
+ <xsl:call-template name="process-span">
1672
+ <xsl:with-param name="class" select="@class"/>
1673
+ </xsl:call-template>
1674
+ </xsl:template>
1675
+
1676
+ <!-- ISO TITLE -->
1677
+
1678
+ <xsl:template match="iso:schema/iso:title" priority="1">
1679
+ <xsl:call-template name="process-schema-title" />
1680
+ </xsl:template>
1681
+
1682
+
1683
+ <xsl:template match="iso:title" >
1684
+ <xsl:call-template name="process-title" />
1685
+ </xsl:template>
1686
+
1687
+
1688
+ <!-- ISO VALUE-OF -->
1689
+ <xsl:template match="iso:value-of" mode="text" >
1690
+ <xsl:if test="not(@select)">
1691
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">34</xsl:with-param></xsl:call-template></xsl:message>
1692
+ </xsl:if>
1693
+ <xsl:call-template name="IamEmpty" />
1694
+
1695
+ <xsl:choose>
1696
+ <xsl:when test="@select">
1697
+ <xsl:call-template name="process-value-of">
1698
+ <xsl:with-param name="select" select="@select"/>
1699
+ </xsl:call-template>
1700
+ </xsl:when>
1701
+ <xsl:otherwise >
1702
+ <xsl:call-template name="process-value-of">
1703
+ <xsl:with-param name="select" select="'.'"/>
1704
+ </xsl:call-template>
1705
+ </xsl:otherwise>
1706
+ </xsl:choose>
1707
+
1708
+ </xsl:template>
1709
+
1710
+
1711
+ <!-- ============================================================== -->
1712
+ <!-- DEFAULT TEXT HANDLING -->
1713
+ <!-- ============================================================== -->
1714
+ <xsl:template match="text()" priority="-1" mode="do-keys">
1715
+ <!-- strip characters -->
1716
+ </xsl:template>
1717
+ <xsl:template match="text()" priority="-1" mode="do-all-patterns">
1718
+ <!-- strip characters -->
1719
+ </xsl:template>
1720
+ <xsl:template match="text()" priority="-1" mode="do-schema-p">
1721
+ <!-- strip characters -->
1722
+ </xsl:template>
1723
+ <xsl:template match="text()" priority="-1" mode="do-pattern-p">
1724
+ <!-- strip characters -->
1725
+ </xsl:template>
1726
+
1727
+ <xsl:template match="text()" priority="-1">
1728
+ <!-- Strip characters -->
1729
+ </xsl:template>
1730
+
1731
+ <xsl:template match="text()" mode="text">
1732
+ <xsl:value-of select="."/>
1733
+ </xsl:template>
1734
+
1735
+ <xsl:template match="text()" mode="inline-text">
1736
+ <xsl:value-of select="."/>
1737
+ </xsl:template>
1738
+
1739
+ <!-- ============================================================== -->
1740
+ <!-- UTILITY TEMPLATES -->
1741
+ <!-- ============================================================== -->
1742
+ <xsl:template name="IamEmpty">
1743
+ <xsl:if test="count( * )">
1744
+ <xsl:message>
1745
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">35a</xsl:with-param></xsl:call-template>
1746
+ <xsl:value-of select="name(.)"/>
1747
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">35b</xsl:with-param></xsl:call-template>
1748
+ </xsl:message>
1749
+ </xsl:if>
1750
+ </xsl:template>
1751
+
1752
+ <xsl:template name="diagnosticsSplit">
1753
+ <!-- Process at the current point the first of the <diagnostic> elements
1754
+ referred to parameter str, and then recurse -->
1755
+ <xsl:param name="str"/>
1756
+ <xsl:variable name="start">
1757
+ <xsl:choose>
1758
+ <xsl:when test="contains($str,' ')">
1759
+ <xsl:value-of select="substring-before($str,' ')"/>
1760
+ </xsl:when>
1761
+ <xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
1762
+ </xsl:choose>
1763
+ </xsl:variable>
1764
+
1765
+ <xsl:variable name="end">
1766
+ <xsl:if test="contains($str,' ')">
1767
+ <xsl:value-of select="substring-after($str,' ')"/>
1768
+ </xsl:if>
1769
+ </xsl:variable>
1770
+
1771
+ <!-- This works with all namespaces -->
1772
+ <xsl:if test="not(string-length(normalize-space($start)) = 0)
1773
+ and not(//iso:diagnostic[@id = $start])
1774
+ and not(//schold:diagnostic[@id = $start])
1775
+ and not(//diagnostic[@id = $start])">
1776
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">36a</xsl:with-param></xsl:call-template>
1777
+ <xsl:value-of select="string($start)"/>
1778
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">36b</xsl:with-param></xsl:call-template></xsl:message>
1779
+ </xsl:if>
1780
+
1781
+ <xsl:if test="string-length(normalize-space($start)) > 0">
1782
+ <xsl:text> </xsl:text>
1783
+ <xsl:apply-templates
1784
+ select="//iso:diagnostic[@id = $start ]
1785
+ | //schold:diagnostic[@id = $start ]
1786
+ | //diagnostic[@id= $start ]"/>
1787
+ </xsl:if>
1788
+
1789
+ <xsl:if test="not($end='')">
1790
+ <xsl:call-template name="diagnosticsSplit">
1791
+ <xsl:with-param name="str" select="$end"/>
1792
+ </xsl:call-template>
1793
+ </xsl:if>
1794
+ </xsl:template>
1795
+
1796
+
1797
+
1798
+ <xsl:template name="propertiesSplit">
1799
+ <!-- Process at the current point the first of the <property> elements
1800
+ referred to parameter str, and then recurse -->
1801
+ <xsl:param name="str"/>
1802
+ <xsl:variable name="start">
1803
+ <xsl:choose>
1804
+ <xsl:when test="contains($str,' ')">
1805
+ <xsl:value-of select="substring-before($str,' ')"/>
1806
+ </xsl:when>
1807
+ <xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
1808
+ </xsl:choose>
1809
+ </xsl:variable>
1810
+
1811
+ <xsl:variable name="end">
1812
+ <xsl:if test="contains($str,' ')">
1813
+ <xsl:value-of select="substring-after($str,' ')"/>
1814
+ </xsl:if>
1815
+ </xsl:variable>
1816
+
1817
+ <!-- This works with all namespaces -->
1818
+ <xsl:if test="not(string-length(normalize-space($start)) = 0)
1819
+ and not(//iso:property[@id = $start])">
1820
+ <xsl:message><xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">36a</xsl:with-param></xsl:call-template>
1821
+ <xsl:value-of select="string($start)"/>
1822
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">36b</xsl:with-param></xsl:call-template></xsl:message>
1823
+ </xsl:if>
1824
+
1825
+ <xsl:if test="string-length(normalize-space($start)) > 0">
1826
+ <xsl:text> </xsl:text>
1827
+ <xsl:apply-templates
1828
+ select="//iso:property[@id = $start ] "/>
1829
+ </xsl:if>
1830
+
1831
+ <xsl:if test="not($end='')">
1832
+ <xsl:call-template name="propertiesSplit">
1833
+ <xsl:with-param name="str" select="$end"/>
1834
+ </xsl:call-template>
1835
+ </xsl:if>
1836
+ </xsl:template>
1837
+
1838
+
1839
+ <!-- It would be nice to use this but xsl:namespace does not
1840
+ allow a fallback -->
1841
+ <!--xsl:template name="handle-namespace" version="2.0">
1842
+ <xsl:namespace name="{@prefix}" select="@uri">
1843
+ </xsl:template-->
1844
+
1845
+ <xsl:template name="handle-namespace">
1846
+ <!-- experimental code from http://eccnet.eccnet.com/pipermail/schematron-love-in/2006-June/000104.html -->
1847
+ <!-- Handle namespaces differently for exslt systems, and default, only using XSLT1 syntax -->
1848
+ <!-- For more info see http://fgeorges.blogspot.com/2007/01/creating-namespace-nodes-in-xslt-10.html -->
1849
+ <xsl:choose>
1850
+ <!-- The following code workds for XSLT2 -->
1851
+ <xsl:when test="element-available('xsl:namespace')">
1852
+ <xsl:namespace name="{@prefix}" select="@uri" />
1853
+ </xsl:when>
1854
+
1855
+ <xsl:when use-when="not(element-available('xsl:namespace'))"
1856
+ test="function-available('exsl:node-set')">
1857
+ <xsl:variable name="ns-dummy-elements">
1858
+ <xsl:element name="{@prefix}:dummy" namespace="{@uri}"/>
1859
+ </xsl:variable>
1860
+ <xsl:variable name="p" select="@prefix"/>
1861
+ <xsl:copy-of select="exsl:node-set($ns-dummy-elements)
1862
+ /*/namespace::*[local-name()=$p]"/>
1863
+ </xsl:when>
1864
+
1865
+ <!-- end XSLT2 code -->
1866
+
1867
+
1868
+ <xsl:when test="@prefix = 'xsl' ">
1869
+ <!-- Do not generate dummy attributes with the xsl: prefix, as these
1870
+ are errors against XSLT, because we presume that the output
1871
+ stylesheet uses the xsl prefix. In any case, there would already
1872
+ be a namespace declaration for the XSLT namespace generated
1873
+ automatically, presumably using "xsl:".
1874
+ -->
1875
+ </xsl:when>
1876
+
1877
+ <xsl:when test="@uri = 'http://www.w3.org/1999/XSL/Transform'">
1878
+ <xsl:message terminate="yes">
1879
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">37a</xsl:with-param></xsl:call-template>
1880
+ <xsl:value-of select="system-property('xsl:vendor')"/>
1881
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">37b</xsl:with-param></xsl:call-template>
1882
+ </xsl:message>
1883
+ </xsl:when>
1884
+
1885
+ <xsl:otherwise>
1886
+ <xsl:attribute name="{concat(@prefix,':dummy-for-xmlns')}" namespace="{@uri}" />
1887
+
1888
+ </xsl:otherwise>
1889
+ </xsl:choose>
1890
+
1891
+
1892
+ </xsl:template>
1893
+
1894
+ <!-- ============================================================== -->
1895
+ <!-- UNEXPECTED ELEMENTS -->
1896
+ <!-- ============================================================== -->
1897
+
1898
+ <xsl:template match="iso:*" priority="-2">
1899
+ <xsl:message>
1900
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">38a</xsl:with-param></xsl:call-template>
1901
+ <xsl:value-of select="name(.)"/>
1902
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">38b</xsl:with-param></xsl:call-template>
1903
+ </xsl:message>
1904
+ </xsl:template>
1905
+
1906
+
1907
+ <!-- Swallow old namespace elements: there is an upfront test for them elsewhere -->
1908
+ <xsl:template match="schold:*" priority="-2" />
1909
+
1910
+ <xsl:template match="*" priority="-3">
1911
+ <xsl:choose>
1912
+ <xsl:when test=" $allow-foreign = 'false' ">
1913
+ <xsl:message>
1914
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">39a</xsl:with-param></xsl:call-template>
1915
+ <xsl:value-of select="name(.)"/>
1916
+ <xsl:call-template name="outputLocalizedMessage" ><xsl:with-param name="number">39b</xsl:with-param></xsl:call-template>
1917
+ </xsl:message>
1918
+ </xsl:when>
1919
+ <xsl:otherwise>
1920
+ <xsl:copy-of select="." />
1921
+ </xsl:otherwise>
1922
+ </xsl:choose>
1923
+ </xsl:template>
1924
+
1925
+ <xsl:template match="iso:*" mode="text" priority="-2" />
1926
+ <xsl:template match="*" mode="text" priority="-3">
1927
+ <xsl:if test=" not( $allow-foreign = 'false') ">
1928
+ <xsl:copy-of select="." />
1929
+ </xsl:if>
1930
+ </xsl:template>
1931
+
1932
+ <!-- ============================================================== -->
1933
+ <!-- DEFAULT NAMED TEMPLATES -->
1934
+ <!-- These are the actions that are performed unless overridden -->
1935
+ <!-- ============================================================== -->
1936
+
1937
+ <xsl:template name="process-prolog"/>
1938
+ <!-- no params -->
1939
+
1940
+ <xsl:template name="process-root">
1941
+ <xsl:param name="contents"/>
1942
+ <xsl:param name="id" />
1943
+ <xsl:param name="version" />
1944
+ <xsl:param name="schemaVersion" />
1945
+ <xsl:param name="queryBinding" />
1946
+ <xsl:param name="title" />
1947
+
1948
+
1949
+ <!-- "Rich" parameters -->
1950
+ <xsl:param name="fpi" />
1951
+ <xsl:param name="icon" />
1952
+ <xsl:param name="lang" />
1953
+ <xsl:param name="see" />
1954
+ <xsl:param name="space" />
1955
+
1956
+ <xsl:copy-of select="$contents"/>
1957
+ </xsl:template>
1958
+
1959
+ <xsl:template name="process-assert">
1960
+
1961
+ <xsl:param name="test"/>
1962
+ <xsl:param name="diagnostics" />
1963
+ <xsl:param name="id" />
1964
+ <xsl:param name="flag" />
1965
+ <xsl:param name="properties" />
1966
+
1967
+ <!-- "Linkable" parameters -->
1968
+ <xsl:param name="role"/>
1969
+ <xsl:param name="subject"/>
1970
+
1971
+ <!-- "Rich" parameters -->
1972
+ <xsl:param name="fpi" />
1973
+ <xsl:param name="icon" />
1974
+ <xsl:param name="lang" />
1975
+ <xsl:param name="see" />
1976
+ <xsl:param name="space" />
1977
+
1978
+
1979
+ <xsl:call-template name="process-message">
1980
+ <xsl:with-param name="pattern" select="$test"/>
1981
+ <xsl:with-param name="role" select="$role"/>
1982
+ </xsl:call-template>
1983
+
1984
+ <xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
1985
+ <axsl:message terminate="yes">TERMINATING</axsl:message>
1986
+ </xsl:if>
1987
+ <xsl:if test=" $terminate = 'assert' ">
1988
+ <axsl:message terminate="yes">TERMINATING</axsl:message>
1989
+ </xsl:if>
1990
+
1991
+ </xsl:template>
1992
+
1993
+ <xsl:template name="process-report">
1994
+ <xsl:param name="test"/>
1995
+ <xsl:param name="diagnostics" />
1996
+ <xsl:param name="id" />
1997
+ <xsl:param name="flag" />
1998
+ <xsl:param name="properties" />
1999
+
2000
+ <!-- "Linkable" parameters -->
2001
+ <xsl:param name="role"/>
2002
+ <xsl:param name="subject"/>
2003
+
2004
+ <!-- "Rich" parameters -->
2005
+ <xsl:param name="fpi" />
2006
+ <xsl:param name="icon" />
2007
+ <xsl:param name="lang" />
2008
+ <xsl:param name="see" />
2009
+ <xsl:param name="space" />
2010
+
2011
+ <xsl:call-template name="process-message">
2012
+ <xsl:with-param name="pattern" select="$test"/>
2013
+ <xsl:with-param name="role" select="$role"/>
2014
+ </xsl:call-template>
2015
+
2016
+ <xsl:if test=" $terminate = 'yes' or $terminate = 'true' ">
2017
+ <axsl:message terminate="yes">TERMINATING</axsl:message>
2018
+ </xsl:if>
2019
+ </xsl:template>
2020
+
2021
+ <xsl:template name="process-diagnostic">
2022
+ <xsl:param name="id" />
2023
+
2024
+ <!-- "Rich" parameters -->
2025
+ <xsl:param name="fpi" />
2026
+ <xsl:param name="icon" />
2027
+ <xsl:param name="lang" />
2028
+ <xsl:param name="see" />
2029
+ <xsl:param name="space" />
2030
+
2031
+ <!-- We generate too much whitespace rather than risking concatenation -->
2032
+ <axsl:text> </axsl:text>
2033
+ <xsl:apply-templates mode="text"/>
2034
+ <axsl:text> </axsl:text>
2035
+ </xsl:template>
2036
+
2037
+ <xsl:template name="process-dir">
2038
+ <xsl:param name="value" />
2039
+
2040
+ <!-- We generate too much whitespace rather than risking concatenation -->
2041
+ <axsl:text> </axsl:text>
2042
+ <xsl:apply-templates mode="inline-text"/>
2043
+ <axsl:text> </axsl:text>
2044
+ </xsl:template>
2045
+
2046
+ <xsl:template name="process-emph">
2047
+ <!-- We generate too much whitespace rather than risking concatenation -->
2048
+ <axsl:text> </axsl:text>
2049
+ <xsl:apply-templates mode="inline-text"/>
2050
+ <axsl:text> </axsl:text>
2051
+ </xsl:template>
2052
+
2053
+ <xsl:template name="process-name">
2054
+ <xsl:param name="name"/>
2055
+
2056
+ <!-- We generate too much whitespace rather than risking concatenation -->
2057
+ <axsl:text> </axsl:text>
2058
+ <axsl:value-of select="{$name}"/>
2059
+ <axsl:text> </axsl:text>
2060
+
2061
+ </xsl:template>
2062
+
2063
+ <xsl:template name="process-ns" >
2064
+ <!-- Note that process-ns is for reporting. The iso:ns elements are
2065
+ independently used in the iso:schema template to provide namespace bindings -->
2066
+ <xsl:param name="prefix"/>
2067
+ <xsl:param name="uri" />
2068
+ </xsl:template>
2069
+
2070
+ <xsl:template name="process-p">
2071
+ <xsl:param name="id" />
2072
+ <xsl:param name="class" />
2073
+ <xsl:param name="icon" />
2074
+ <xsl:param name="lang" />
2075
+ </xsl:template>
2076
+
2077
+ <xsl:template name="process-pattern">
2078
+ <xsl:param name="id" />
2079
+ <xsl:param name="name" />
2080
+ <xsl:param name="is-a" />
2081
+
2082
+ <!-- "Rich" parameters -->
2083
+ <xsl:param name="fpi" />
2084
+ <xsl:param name="icon" />
2085
+ <xsl:param name="lang" />
2086
+ <xsl:param name="see" />
2087
+ <xsl:param name="space" />
2088
+ </xsl:template>
2089
+
2090
+
2091
+ <xsl:template name="process-rule">
2092
+ <xsl:param name="context" />
2093
+
2094
+ <xsl:param name="id" />
2095
+ <xsl:param name="flag" />
2096
+ <xsl:param name="properties" />
2097
+
2098
+ <!-- "Linkable" parameters -->
2099
+ <xsl:param name="role"/>
2100
+ <xsl:param name="subject"/>
2101
+
2102
+ <!-- "Rich" parameters -->
2103
+ <xsl:param name="fpi" />
2104
+ <xsl:param name="icon" />
2105
+ <xsl:param name="lang" />
2106
+ <xsl:param name="see" />
2107
+ <xsl:param name="space" />
2108
+ </xsl:template>
2109
+
2110
+ <xsl:template name="process-span" >
2111
+ <xsl:param name="class" />
2112
+
2113
+ <!-- We generate too much whitespace rather than risking concatenation -->
2114
+ <axsl:text> </axsl:text>
2115
+ <xsl:apply-templates mode="inline-text"/>
2116
+ <axsl:text> </axsl:text>
2117
+ </xsl:template>
2118
+
2119
+ <xsl:template name="process-title" >
2120
+ <xsl:param name="class" />
2121
+ <xsl:call-template name="process-p">
2122
+ <xsl:with-param name="class">title</xsl:with-param>
2123
+ </xsl:call-template>
2124
+ </xsl:template>
2125
+
2126
+ <xsl:template name="process-schema-title" >
2127
+ <xsl:param name="class" />
2128
+ <xsl:call-template name="process-title">
2129
+ <xsl:with-param name="class">schema-title</xsl:with-param>
2130
+ </xsl:call-template>
2131
+ </xsl:template>
2132
+
2133
+ <xsl:template name="process-value-of">
2134
+ <xsl:param name="select"/>
2135
+
2136
+ <!-- We generate too much whitespace rather than risking concatenation -->
2137
+ <axsl:text> </axsl:text>
2138
+ <axsl:value-of select="{$select}"/>
2139
+ <axsl:text> </axsl:text>
2140
+ </xsl:template>
2141
+
2142
+ <!-- default output action: the simplest customization is to just override this -->
2143
+ <xsl:template name="process-message">
2144
+ <xsl:param name="pattern" />
2145
+ <xsl:param name="role" />
2146
+
2147
+ <xsl:apply-templates mode="text"/>
2148
+ <xsl:if test=" $message-newline = 'true'" >
2149
+ <axsl:value-of select="string('&#10;')"/>
2150
+ </xsl:if>
2151
+
2152
+ </xsl:template>
2153
+
2154
+
2155
+ <!-- ===================================================== -->
2156
+ <!-- Extension API: default rules -->
2157
+ <!-- This allows the transmission of extra attributes on -->
2158
+ <!-- rules, asserts, reports, diagnostics. -->
2159
+ <!-- ===================================================== -->
2160
+
2161
+
2162
+
2163
+ <xsl:template name="process-property">
2164
+ <xsl:param name="id" />
2165
+
2166
+ <xsl:param name="name"/>
2167
+ <xsl:param name="value"/>
2168
+ <xsl:param name="contents"/>
2169
+
2170
+ </xsl:template>
2171
+
2172
+
2173
+ <!-- ===================================================== -->
2174
+ <!-- Localization -->
2175
+ <!-- ===================================================== -->
2176
+ <!--
2177
+ All messages generated by the skeleton during processing are localized.
2178
+ (This does not apply to the text that comes from Schematron schemas
2179
+ themselves, of course. Nor does it apply to messages in metastylesheets.)
2180
+
2181
+ Stylesheets have a parameter $langCode which can be used to select the
2182
+ language code (e.g. from the command line)
2183
+
2184
+ The default value of $langCode is "default". When this is used, the
2185
+ message text is taken from the strings below. We use XHTML, to provide
2186
+ the namespace.
2187
+
2188
+ If the $langCode is somethign else, then the XSLT engine will try to
2189
+ find a file called sch-messages-$langCode.xhtml in the same directory
2190
+ as this stylesheet. Expect a fatal error if the file does not exist.
2191
+
2192
+ The file should contain XHTML elements, with the text translated.
2193
+ The strings are located by using ids on each xhtml:p element.
2194
+ The ids are formed by sch-message-$number-$langCode such as
2195
+ sch-message-1-en
2196
+
2197
+ If there is no match in a localization file for a message, then the
2198
+ default will be used. This allows this XSLT to be developed with new
2199
+ messages added without requiring that any localization files be updated.
2200
+
2201
+ In many cases, there are actually two localization strings per message.
2202
+ This happens whenever a message has an embedded value that is dynamically
2203
+ generated (using <value-of>). Having two strings, preceding and following,
2204
+ allows the translator to make idiomatic error messages. When there are
2205
+ two message for a single message, they have numbers like 30a and 30b:
2206
+ translators should check the reference to them in the XSLT above to
2207
+ see what the dynamically generated information is.
2208
+ -->
2209
+ <xsl:template name="outputLocalizedMessage">
2210
+ <xsl:param name="number" />
2211
+
2212
+ <xsl:choose>
2213
+ <xsl:when test="string-length( $langCode ) = 0 or $langCode = 'default'" >
2214
+ <xsl:value-of select='document("")//xhtml:p[@id=concat("sch-message-", $number)]/text()' />
2215
+ </xsl:when>
2216
+ <xsl:otherwise>
2217
+ <xsl:variable name="localizationDocumentFilename" >
2218
+ <xsl:value-of select="concat('sch-messages-', $langCode, '.xhtml')" />
2219
+ </xsl:variable>
2220
+ <xsl:variable name="theLocalizedMessage" >
2221
+ <xsl:value-of select=
2222
+ 'document( $localizationDocumentFilename, /)//xhtml:p[@id=concat("sch-message-", $number, "-", $langCode)]/text()' />
2223
+ </xsl:variable>
2224
+
2225
+ <xsl:choose>
2226
+ <!-- if we found any external message with that id, use it -->
2227
+ <xsl:when test=" string-length($theLocalizedMessage) &gt; 0">
2228
+ <xsl:value-of select="$theLocalizedMessage" />
2229
+ </xsl:when>
2230
+ <xsl:otherwise>
2231
+ <!-- otherwise use the default strings -->
2232
+ <xsl:value-of select='document("")//xhtml:p[@id=concat("sch-message-", $number)]/text()' />
2233
+ </xsl:otherwise>
2234
+ </xsl:choose>
2235
+
2236
+
2237
+ </xsl:otherwise>
2238
+ </xsl:choose>
2239
+ </xsl:template>
2240
+
2241
+ <xhtml:div class="ErrorMessages">
2242
+ <!-- Where the error message contains dynamic information, the message has been split into an "a" and a "b" section.
2243
+ This has been done even when the English does not require it, in order to accomodate different language grammars
2244
+ that might position the dynamic information differently.
2245
+ -->
2246
+ <xhtml:p id="sch-message-1">Schema error: Schematron elements in old and new namespaces found</xhtml:p>
2247
+ <xhtml:p id="sch-message-2">Schema error: in the queryBinding attribute, use 'xslt'</xhtml:p>
2248
+ <xhtml:p id="sch-message-3a">Fail: This implementation of ISO Schematron does not work with schemas using the query language </xhtml:p>
2249
+ <xhtml:p id="sch-message-3b"/>
2250
+ <xhtml:p id="sch-message-4a">Phase Error: no phase has been defined with name </xhtml:p>
2251
+ <xhtml:p id="sch-message-4b" />
2252
+ <xhtml:p id="sch-message-5">Markup Error: no pattern attribute in &lt;active></xhtml:p>
2253
+ <xhtml:p id="sch-message-6a">Reference Error: the pattern "</xhtml:p>
2254
+ <xhtml:p id="sch-message-6b">" has been activated but is not declared</xhtml:p>
2255
+ <xhtml:p id="sch-message-7">Markup Error: no test attribute in &lt;assert</xhtml:p>
2256
+ <xhtml:p id="sch-message-8">Markup Error: no test attribute in &lt;report></xhtml:p>
2257
+ <xhtml:p id="sch-message-9">Markup Error: no id attribute in &lt;diagnostic></xhtml:p>
2258
+ <xhtml:p id="sch-message-10">Markup Error: no rule attribute in &lt;extends></xhtml:p>
2259
+ <xhtml:p id="sch-message-11a">Reference Error: the abstract rule "</xhtml:p>
2260
+ <xhtml:p id="sch-message-11b">" has been referenced but is not declared</xhtml:p>
2261
+ <xhtml:p id="sch-message-12">Markup Error: no name attribute in &lt;key></xhtml:p>
2262
+ <xhtml:p id="sch-message-13">Markup Error: no path or use attribute in &lt;key></xhtml:p>
2263
+ <xhtml:p id="sch-message-14">Markup Error: no path or use attribute in &lt;key></xhtml:p>
2264
+ <xhtml:p id="sch-message-15">Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace.</xhtml:p>
2265
+ <xhtml:p id="sch-message-16">Markup Error: no name attribute in &lt;function></xhtml:p>
2266
+ <xhtml:p id="sch-message-17">Schema error: The function element is not in the ISO Schematron namespace. Use the XSLT namespace.</xhtml:p>
2267
+ <xhtml:p id="sch-message-18">Schema error: Empty href= attribute for include directive.</xhtml:p>
2268
+ <xhtml:p id="sch-message-19">Error: Impossible URL in Schematron include</xhtml:p>
2269
+ <xhtml:p id="sch-message-20a">Unable to open referenced included file: </xhtml:p>
2270
+ <xhtml:p id="sch-message-20b" />
2271
+ <xhtml:p id="sch-message-21">Schema error: Use include to include fragments, not a whole schema</xhtml:p>
2272
+ <xhtml:p id="sch-message-22">Schema error: XSD schemas may only be imported if you are using the 'xslt2' query language binding</xhtml:p>
2273
+ <xhtml:p id="sch-message-23">Schema error: The import-schema element is not available in the ISO Schematron namespace. Use the XSLT namespace.</xhtml:p>
2274
+ <xhtml:p id="sch-message-24">Warning: Variables should not be used with the "xpath" query language binding.</xhtml:p>
2275
+ <xhtml:p id="sch-message-25">Warning: Variables should not be used with the "xpath2" query language binding.</xhtml:p>
2276
+ <xhtml:p id="sch-message-26">Markup Error: no uri attribute in &lt;ns></xhtml:p>
2277
+ <xhtml:p id="sch-message-27">Markup Error: no prefix attribute in &lt;ns></xhtml:p>
2278
+ <xhtml:p id="sch-message-28">Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already</xhtml:p>
2279
+ <xhtml:p id="sch-message-29">Markup Error: no id attribute in &lt;phase></xhtml:p>
2280
+ <xhtml:p id="sch-message-30">Markup Error: no context attribute in &lt;rule></xhtml:p>
2281
+ <xhtml:p id="sch-message-31">Markup Error: no id attribute on abstract &lt;rule></xhtml:p>
2282
+ <xhtml:p id="sch-message-32">Markup Error: (2) context attribute on abstract &lt;rule></xhtml:p>
2283
+ <xhtml:p id="sch-message-33">Markup Error: context attribute on abstract &lt;rule></xhtml:p>
2284
+ <xhtml:p id="sch-message-34">Markup Error: no select attribute in &lt;value-of></xhtml:p>
2285
+ <xhtml:p id="sch-message-35a">Warning: </xhtml:p>
2286
+ <xhtml:p id="sch-message-35b"> must not contain any child elements</xhtml:p>
2287
+ <xhtml:p id="sch-message-36a">Reference error: A diagnostic "</xhtml:p>
2288
+ <xhtml:p id="sch-message-36b">" has been referenced but is not declared</xhtml:p>
2289
+ <xhtml:p id="sch-message-37a">Using the XSLT namespace with a prefix other than "xsl" in Schematron rules is not supported in this processor:</xhtml:p>
2290
+ <xhtml:p id="sch-message-37b" />
2291
+ <xhtml:p id="sch-message-38a">Error: unrecognized element in ISO Schematron namespace: check spelling and capitalization</xhtml:p>
2292
+ <xhtml:p id="sch-message-38b" />
2293
+ <xhtml:p id="sch-message-39a">Warning: unrecognized element </xhtml:p>
2294
+ <xhtml:p id="sch-message-39b" />
2295
+ </xhtml:div>
2296
+ </xsl:stylesheet>
2297
+
2298
+
2299
+