simple-xspec-wrapper 0.1.0-java

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