simple-xspec-wrapper 0.1.0-java

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