health-data-standards 3.5.3 → 3.6.1

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