simple-xspec-wrapper 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +11 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +37 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +49 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/exe/xspec +16 -0
  15. data/lib/xspec/version.rb +3 -0
  16. data/lib/xspec.rb +256 -0
  17. data/simple-xspec-wrapper.gemspec +28 -0
  18. data/spec-test.xml +1125 -0
  19. data/vendor/xspec-1.0.0/.gitignore +7 -0
  20. data/vendor/xspec-1.0.0/.travis.yml +57 -0
  21. data/vendor/xspec-1.0.0/LICENSE +21 -0
  22. data/vendor/xspec-1.0.0/README.md +26 -0
  23. data/vendor/xspec-1.0.0/appveyor.yml +77 -0
  24. data/vendor/xspec-1.0.0/bin/xspec.bat +620 -0
  25. data/vendor/xspec-1.0.0/bin/xspec.sh +403 -0
  26. data/vendor/xspec-1.0.0/build.xml +369 -0
  27. data/vendor/xspec-1.0.0/editors/emacs/README +31 -0
  28. data/vendor/xspec-1.0.0/editors/emacs/schemas.xml +6 -0
  29. data/vendor/xspec-1.0.0/editors/oxygen/.cvsignore +2 -0
  30. data/vendor/xspec-1.0.0/editors/oxygen/README +11 -0
  31. data/vendor/xspec-1.0.0/editors/oxygen/build.xml +38 -0
  32. data/vendor/xspec-1.0.0/editors/oxygen/templates/xspec.xml +17 -0
  33. data/vendor/xspec-1.0.0/editors/oxygen/xspec.framework +175 -0
  34. data/vendor/xspec-1.0.0/find-examples.xml +37 -0
  35. data/vendor/xspec-1.0.0/find-examples.xsl +615 -0
  36. data/vendor/xspec-1.0.0/graphics/3angle-down.gif +0 -0
  37. data/vendor/xspec-1.0.0/graphics/3angle-right.gif +0 -0
  38. data/vendor/xspec-1.0.0/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class +0 -0
  39. data/vendor/xspec-1.0.0/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java +209 -0
  40. data/vendor/xspec-1.0.0/src/ant/find-test-failure.xsl +17 -0
  41. data/vendor/xspec-1.0.0/src/ant/get-schematron-phase.xsl +17 -0
  42. data/vendor/xspec-1.0.0/src/ant/locate-schematron.xsl +28 -0
  43. data/vendor/xspec-1.0.0/src/ant/make-path.js +4 -0
  44. data/vendor/xspec-1.0.0/src/compiler/generate-common-tests.xsl +604 -0
  45. data/vendor/xspec-1.0.0/src/compiler/generate-query-helper.xsl +152 -0
  46. data/vendor/xspec-1.0.0/src/compiler/generate-query-tests.xsl +473 -0
  47. data/vendor/xspec-1.0.0/src/compiler/generate-query-utils.xql +263 -0
  48. data/vendor/xspec-1.0.0/src/compiler/generate-tests-helper.xsl +169 -0
  49. data/vendor/xspec-1.0.0/src/compiler/generate-tests-utils.xsl +479 -0
  50. data/vendor/xspec-1.0.0/src/compiler/generate-xspec-tests.xsl +503 -0
  51. data/vendor/xspec-1.0.0/src/harnesses/basex/basex-standalone-xquery-harness.xproc +135 -0
  52. data/vendor/xspec-1.0.0/src/harnesses/basex/basex-xquery-harness.xproc +133 -0
  53. data/vendor/xspec-1.0.0/src/harnesses/exist/exist-xquery-harness.xproc +161 -0
  54. data/vendor/xspec-1.0.0/src/harnesses/harness-lib.xpl +327 -0
  55. data/vendor/xspec-1.0.0/src/harnesses/marklogic/ml-xquery-harness.xproc +143 -0
  56. data/vendor/xspec-1.0.0/src/harnesses/saxon/saxon-xquery-harness.xproc +108 -0
  57. data/vendor/xspec-1.0.0/src/harnesses/saxon/saxon-xslt-harness.xproc +85 -0
  58. data/vendor/xspec-1.0.0/src/harnesses/zorba/zorba-xquery-harness.xproc +134 -0
  59. data/vendor/xspec-1.0.0/src/reporter/coverage-report.xsl +378 -0
  60. data/vendor/xspec-1.0.0/src/reporter/format-utils.xsl +220 -0
  61. data/vendor/xspec-1.0.0/src/reporter/format-xspec-report-folding.xsl +164 -0
  62. data/vendor/xspec-1.0.0/src/reporter/format-xspec-report.xsl +410 -0
  63. data/vendor/xspec-1.0.0/src/reporter/junit-report.xsl +93 -0
  64. data/vendor/xspec-1.0.0/src/reporter/test-report.css +469 -0
  65. data/vendor/xspec-1.0.0/src/schemas/find-examples.rnc +90 -0
  66. data/vendor/xspec-1.0.0/src/schemas/xspec.rnc +304 -0
  67. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_abstract_expand.xsl +313 -0
  68. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_dsdl_include.xsl +1519 -0
  69. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_message.xsl +64 -0
  70. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_message_xslt2.xsl +64 -0
  71. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_skeleton_for_saxon.xsl +2306 -0
  72. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_skeleton_for_xslt1.xsl +1851 -0
  73. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_svrl_for_xslt1.xsl +614 -0
  74. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl +692 -0
  75. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/readme.txt +101 -0
  76. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-cs.xhtml +56 -0
  77. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-de.xhtml +55 -0
  78. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-en.xhtml +57 -0
  79. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-fr.xhtml +54 -0
  80. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-ja.xhtml +53 -0
  81. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-nl.xhtml +58 -0
  82. data/vendor/xspec-1.0.0/src/schematron/iso-schematron/schematron-skeleton-api.htm +723 -0
  83. data/vendor/xspec-1.0.0/src/schematron/sch-location-compare.xsl +139 -0
  84. data/vendor/xspec-1.0.0/src/schematron/schut-to-xspec.xsl +179 -0
  85. data/vendor/xspec-1.0.0/test/Makefile +117 -0
  86. data/vendor/xspec-1.0.0/test/README +5 -0
  87. data/vendor/xspec-1.0.0/test/catalog/xspec-160_catalog.xml +4 -0
  88. data/vendor/xspec-1.0.0/test/catalog/xspec-160_schematron.xspec +6 -0
  89. data/vendor/xspec-1.0.0/test/catalog/xspec-160_xslt.xspec +5 -0
  90. data/vendor/xspec-1.0.0/test/end-to-end/README.md +42 -0
  91. data/vendor/xspec-1.0.0/test/end-to-end/cases/.gitignore +1 -0
  92. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/.gitignore +3 -0
  93. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-50-result-norm.html +74 -0
  94. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-55-result-norm.html +112 -0
  95. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-focus-1-result-norm.html +109 -0
  96. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-function-result-norm.html +118 -0
  97. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-import-result-norm.html +163 -0
  98. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-imported-result-norm.html +95 -0
  99. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-pending-result-norm.html +123 -0
  100. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-rule-result-norm.html +109 -0
  101. data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-three-dots-result-norm.html +1237 -0
  102. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-50.xsl +7 -0
  103. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-50.xspec +10 -0
  104. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-55.xsl +2 -0
  105. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-55.xspec +18 -0
  106. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-focus-1.xspec +71 -0
  107. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-function.xspec +50 -0
  108. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-import.xspec +50 -0
  109. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-imported.xspec +48 -0
  110. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-pending.xspec +89 -0
  111. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-rule.xspec +76 -0
  112. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-three-dots.xsl +49 -0
  113. data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-three-dots.xspec +527 -0
  114. data/vendor/xspec-1.0.0/test/end-to-end/generate-expected.cmd +51 -0
  115. data/vendor/xspec-1.0.0/test/end-to-end/generate-expected.sh +25 -0
  116. data/vendor/xspec-1.0.0/test/end-to-end/processor/_deserializer.xsl +53 -0
  117. data/vendor/xspec-1.0.0/test/end-to-end/processor/_normalizer.xsl +192 -0
  118. data/vendor/xspec-1.0.0/test/end-to-end/processor/_serializer.xsl +15 -0
  119. data/vendor/xspec-1.0.0/test/end-to-end/processor/_util.xsl +35 -0
  120. data/vendor/xspec-1.0.0/test/end-to-end/processor/compare.xsl +88 -0
  121. data/vendor/xspec-1.0.0/test/end-to-end/processor/normalize.xsl +28 -0
  122. data/vendor/xspec-1.0.0/test/end-to-end/run-e2e-tests.cmd +61 -0
  123. data/vendor/xspec-1.0.0/test/end-to-end/run-e2e-tests.sh +28 -0
  124. data/vendor/xspec-1.0.0/test/generate-tests-utils.xspec +636 -0
  125. data/vendor/xspec-1.0.0/test/generate-x-utils.xspec +173 -0
  126. data/vendor/xspec-1.0.0/test/generate-xspec-tests.xspec +64 -0
  127. data/vendor/xspec-1.0.0/test/run-xspec-tests.cmd +83 -0
  128. data/vendor/xspec-1.0.0/test/run-xspec-tests.sh +42 -0
  129. data/vendor/xspec-1.0.0/test/sch-location-compare.xspec +179 -0
  130. data/vendor/xspec-1.0.0/test/schematron/data/standards.xml +7 -0
  131. data/vendor/xspec-1.0.0/test/schematron/schematron-017.sch +9 -0
  132. data/vendor/xspec-1.0.0/test/schematron/schematron-018.sch +17 -0
  133. data/vendor/xspec-1.0.0/test/schematron/schematron-019.sch +13 -0
  134. data/vendor/xspec-1.0.0/test/schematron/schematron-020-01.sch +35 -0
  135. data/vendor/xspec-1.0.0/test/schematron/schematron-020.sch +32 -0
  136. data/vendor/xspec-1.0.0/test/schematron/schematron-021.sch +28 -0
  137. data/vendor/xspec-1.0.0/test/schematron/schematron-022.sch +18 -0
  138. data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-compile.xsl +8 -0
  139. data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-expand.xsl +8 -0
  140. data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-include.xsl +8 -0
  141. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-001-in.xspec +5 -0
  142. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-001-out.xspec +7 -0
  143. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002-in.xspec +5 -0
  144. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002-out.xspec +7 -0
  145. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002.sch +4 -0
  146. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-003-in.xspec +7 -0
  147. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-003-out.xspec +9 -0
  148. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-004-in.xspec +20 -0
  149. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-004-out.xspec +22 -0
  150. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-005-in.xspec +6 -0
  151. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-005-out.xspec +8 -0
  152. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-006-in.xspec +11 -0
  153. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-006-out.xspec +13 -0
  154. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007-in.xspec +7 -0
  155. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007-out.xspec +9 -0
  156. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007.xml +2 -0
  157. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-008-in.xspec +9 -0
  158. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-008-out.xspec +9 -0
  159. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-import-in.xspec +5 -0
  160. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-in.xspec +6 -0
  161. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-out.xspec +10 -0
  162. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-import.xspec +5 -0
  163. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-in.xspec +6 -0
  164. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-out.xspec +8 -0
  165. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-011-in.xspec +6 -0
  166. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-011-out.xspec +8 -0
  167. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-01.xml +4 -0
  168. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-02.xml +13 -0
  169. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-out.xspec +81 -0
  170. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-013-in.xspec +6 -0
  171. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-013-out.xspec +8 -0
  172. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-test.sch +4 -0
  173. data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-test.sch.xsl +4 -0
  174. data/vendor/xspec-1.0.0/test/schematron-01.sch +17 -0
  175. data/vendor/xspec-1.0.0/test/schematron-01.xml +14 -0
  176. data/vendor/xspec-1.0.0/test/schematron-01.xspec +14 -0
  177. data/vendor/xspec-1.0.0/test/schematron-012.xspec +83 -0
  178. data/vendor/xspec-1.0.0/test/schematron-014-01.xml +10 -0
  179. data/vendor/xspec-1.0.0/test/schematron-014.sch +16 -0
  180. data/vendor/xspec-1.0.0/test/schematron-014.xspec +11 -0
  181. data/vendor/xspec-1.0.0/test/schematron-015.sch +16 -0
  182. data/vendor/xspec-1.0.0/test/schematron-015.xspec +11 -0
  183. data/vendor/xspec-1.0.0/test/schematron-016.sch +19 -0
  184. data/vendor/xspec-1.0.0/test/schematron-016.xspec +171 -0
  185. data/vendor/xspec-1.0.0/test/schematron-017.xspec +26 -0
  186. data/vendor/xspec-1.0.0/test/schematron-018.xspec +120 -0
  187. data/vendor/xspec-1.0.0/test/schematron-019.xspec +16 -0
  188. data/vendor/xspec-1.0.0/test/schematron-020.xspec +53 -0
  189. data/vendor/xspec-1.0.0/test/schematron-021.xspec +27 -0
  190. data/vendor/xspec-1.0.0/test/schematron-022.xspec +15 -0
  191. data/vendor/xspec-1.0.0/test/schematron-param-001.xspec +50 -0
  192. data/vendor/xspec-1.0.0/test/schut-to-xspec-012.sch +27 -0
  193. data/vendor/xspec-1.0.0/test/schut-to-xspec.xspec +85 -0
  194. data/vendor/xspec-1.0.0/test/unit-expect-xsl.xspec +28 -0
  195. data/vendor/xspec-1.0.0/test/xspec-26.xsl +19 -0
  196. data/vendor/xspec-1.0.0/test/xspec-26.xspec +17 -0
  197. data/vendor/xspec-1.0.0/test/xspec-30.xml +2 -0
  198. data/vendor/xspec-1.0.0/test/xspec-30.xsl +6 -0
  199. data/vendor/xspec-1.0.0/test/xspec-30.xspec +8 -0
  200. data/vendor/xspec-1.0.0/test/xspec-33.xsl +7 -0
  201. data/vendor/xspec-1.0.0/test/xspec-33.xspec +15 -0
  202. data/vendor/xspec-1.0.0/test/xspec-46.xsl +7 -0
  203. data/vendor/xspec-1.0.0/test/xspec-46.xspec +9 -0
  204. data/vendor/xspec-1.0.0/test/xspec-72.xsl +13 -0
  205. data/vendor/xspec-1.0.0/test/xspec-72.xspec +19 -0
  206. data/vendor/xspec-1.0.0/test/xspec-bat.cmd +757 -0
  207. data/vendor/xspec-1.0.0/test/xspec-focus-2.xspec +91 -0
  208. data/vendor/xspec-1.0.0/test/xspec-junit.xspec +78 -0
  209. data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xml +1003 -0
  210. data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xslt +10 -0
  211. data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xspec +13 -0
  212. data/vendor/xspec-1.0.0/test/xspec-tested.xql +44 -0
  213. data/vendor/xspec-1.0.0/test/xspec-tested.xsl +64 -0
  214. data/vendor/xspec-1.0.0/test/xspec-variable.xml +3 -0
  215. data/vendor/xspec-1.0.0/test/xspec-variable.xspec +58 -0
  216. data/vendor/xspec-1.0.0/test/xspec-xslt3.xsl +13 -0
  217. data/vendor/xspec-1.0.0/test/xspec-xslt3.xspec +12 -0
  218. data/vendor/xspec-1.0.0/test/xspec.bats +420 -0
  219. data/vendor/xspec-1.0.0/tutorial/escape-for-regex.xslt +40 -0
  220. data/vendor/xspec-1.0.0/tutorial/escape-for-regex.xspec +75 -0
  221. data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.sch +17 -0
  222. data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.xml +11 -0
  223. data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.xspec +14 -0
  224. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-PhaseA.xspec +11 -0
  225. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-PhaseB.xspec +12 -0
  226. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import1.xspec +10 -0
  227. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import2.xspec +8 -0
  228. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import3.xspec +10 -0
  229. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02.sch +58 -0
  230. data/vendor/xspec-1.0.0/tutorial/schematron/demo-02.xml +19 -0
  231. data/vendor/xspec-1.0.0/tutorial/schematron/demo-03-doc1.xml +6 -0
  232. data/vendor/xspec-1.0.0/tutorial/schematron/demo-03-doc2.xml +7 -0
  233. data/vendor/xspec-1.0.0/tutorial/schematron/demo-03.sch +29 -0
  234. data/vendor/xspec-1.0.0/tutorial/schematron/demo-03.xspec +63 -0
  235. data/vendor/xspec-1.0.0/tutorial/schematron/demo-04.sch +20 -0
  236. data/vendor/xspec-1.0.0/tutorial/schematron/demo-04.xspec +33 -0
  237. data/vendor/xspec-1.0.0/tutorial/schematron/quickfix.sch +81 -0
  238. data/vendor/xspec-1.0.0/tutorial/xquery-tutorial.xq +8 -0
  239. data/vendor/xspec-1.0.0/tutorial/xquery-tutorial.xspec +16 -0
  240. data/vendor/xspec-1.0.0/xproject/project.xml +8 -0
  241. data/vendor/xspec-1.0.0/xproject/release-project.xsl +41 -0
  242. metadata +341 -0
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ===================================================================== -->
3
+ <!-- File: find-examples.xml -->
4
+ <!-- Author: Jeni Tennsion -->
5
+ <!-- Tags: -->
6
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) -->
7
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
8
+ <x:scan xmlns:x="http://www.jenitennison.com/xslt/xspec">
9
+ <x:collection>?select=*.xml&amp;recurse=yes&amp;strip-space=yes</x:collection>
10
+ </x:scan>
11
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
12
+ <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. -->
13
+ <!-- -->
14
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion -->
15
+ <!-- -->
16
+ <!-- The contents of this file are subject to the MIT License (see the URI -->
17
+ <!-- http://www.opensource.org/licenses/mit-license.php for details). -->
18
+ <!-- -->
19
+ <!-- Permission is hereby granted, free of charge, to any person obtaining -->
20
+ <!-- a copy of this software and associated documentation files (the -->
21
+ <!-- "Software"), to deal in the Software without restriction, including -->
22
+ <!-- without limitation the rights to use, copy, modify, merge, publish, -->
23
+ <!-- distribute, sublicense, and/or sell copies of the Software, and to -->
24
+ <!-- permit persons to whom the Software is furnished to do so, subject to -->
25
+ <!-- the following conditions: -->
26
+ <!-- -->
27
+ <!-- The above copyright notice and this permission notice shall be -->
28
+ <!-- included in all copies or substantial portions of the Software. -->
29
+ <!-- -->
30
+ <!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -->
31
+ <!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
32
+ <!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.-->
33
+ <!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -->
34
+ <!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -->
35
+ <!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -->
36
+ <!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
37
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@@ -0,0 +1,615 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ===================================================================== -->
3
+ <!-- File: find-examples.xsl -->
4
+ <!-- Author: Jeni Tennsion -->
5
+ <!-- Tags: -->
6
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) -->
7
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
8
+
9
+
10
+ <!-- See find-examples.rnc for a schema for the source for this transformation -->
11
+ <xsl:stylesheet version="2.0"
12
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
14
+ xmlns:x="http://www.jenitennison.com/xslt/xspec"
15
+ xmlns:saxon="http://saxon.sf.net/"
16
+ xmlns="http://www.w3.org/1999/XSL/TransformAlias"
17
+ exclude-result-prefixes="xs saxon">
18
+
19
+ <xsl:param name="select" as="element(x:find)">
20
+ <xsl:choose>
21
+ <xsl:when test="exists(/x:scan/x:find)">
22
+ <xsl:sequence select="/x:scan/x:find" />
23
+ </xsl:when>
24
+ <xsl:otherwise>
25
+ <x:find>//(*|processing-instruction())</x:find>
26
+ </xsl:otherwise>
27
+ </xsl:choose>
28
+ </xsl:param>
29
+
30
+ <xsl:variable name="examples" as="node()*">
31
+ <xsl:for-each select="$collection">
32
+ <xsl:variable name="annotated" as="document-node()">
33
+ <xsl:document>
34
+ <xsl:for-each select="*">
35
+ <xsl:copy>
36
+ <xsl:attribute name="xml:base" select="base-uri(.)" />
37
+ <xsl:copy-of select="@*" />
38
+ <xsl:copy-of select="$select" />
39
+ <xsl:copy-of select="node()" />
40
+ </xsl:copy>
41
+ </xsl:for-each>
42
+ </xsl:document>
43
+ </xsl:variable>
44
+ <xsl:apply-templates select="$annotated" mode="find-examples" />
45
+ </xsl:for-each>
46
+ </xsl:variable>
47
+
48
+ <!-- Note: This is sensitive code; moving it into a <xsl:for-each> messes it
49
+ up -->
50
+ <xsl:template match="/" mode="find-examples">
51
+ <xsl:variable name="expr" as="element(x:find)"
52
+ select="*/x:find" />
53
+ <xsl:sequence select="saxon:evaluate-node($expr) except $expr" />
54
+ </xsl:template>
55
+
56
+ <xsl:param name="collection-uri" as="xs:anyURI"
57
+ select="resolve-uri(/x:scan/x:collection, base-uri(/x:scan/x:collection))" />
58
+ <xsl:param name="collection" as="document-node()+"
59
+ select="collection($collection-uri)[not(x:*)]" />
60
+
61
+ <xsl:param name="global-id-atts" as="xs:string"
62
+ select="if (exists(/x:scan/x:global-id-atts))
63
+ then /x:scan/x:global-id-atts
64
+ else 'id xml:id'" />
65
+
66
+ <xsl:param name="local-id-atts" as="xs:string"
67
+ select="if (exists(/x:scan/x:local-id-atts))
68
+ then /x:scan/x:local-id-atts
69
+ else ''" />
70
+
71
+ <xsl:param name="enum-atts" as="xs:string"
72
+ select="if (exists(/x:scan/x:enum-atts))
73
+ then /x:scan/x:enum-atts
74
+ else ''" />
75
+
76
+ <xsl:param name="max-examples" as="xs:integer"
77
+ select="if (exists(/x:scan/x:max-examples))
78
+ then xs:integer(/x:scan/x:max-examples)
79
+ else 10" />
80
+
81
+ <xsl:param name="ns-map" as="xs:string">
82
+ <xsl:choose>
83
+ <xsl:when test="exists(/x:scan)">
84
+ <xsl:value-of>
85
+ <xsl:for-each select="/x:scan/namespace::*[name()]">
86
+ <xsl:sequence select="concat(name(), '={', ., '}')" />
87
+ </xsl:for-each>
88
+ </xsl:value-of>
89
+ </xsl:when>
90
+ <xsl:otherwise>
91
+ <xsl:text>xml={http://www.w3.org/XML/1998/namespace};dc={http://purl.org/dc/elements/1.1/}</xsl:text>
92
+ </xsl:otherwise>
93
+ </xsl:choose>
94
+ </xsl:param>
95
+
96
+ <xsl:variable name="global-ids" as="xs:string*" select="tokenize($global-id-atts, '\s')" />
97
+ <xsl:variable name="local-ids" as="xs:string*" select="tokenize($local-id-atts, '\s')" />
98
+ <xsl:variable name="enums" as="xs:string*" select="tokenize($enum-atts, '\s')" />
99
+
100
+ <xsl:variable name="ns-map-regex" as="xs:string">
101
+ (\i\c*) <!-- 1: prefix -->
102
+ =\{
103
+ ([^}]+) <!-- 2: URL -->
104
+ \};?
105
+ </xsl:variable>
106
+
107
+ <xsl:variable name="provided-nsmap" as="element(ns)*">
108
+ <xsl:analyze-string select="$ns-map" regex="{$ns-map-regex}" flags="x">
109
+ <xsl:matching-substring>
110
+ <ns prefix="{regex-group(1)}" xmlns="">
111
+ <xsl:sequence select="regex-group(2)" />
112
+ </ns>
113
+ </xsl:matching-substring>
114
+ </xsl:analyze-string>
115
+ </xsl:variable>
116
+
117
+ <xsl:variable name="nsmap" as="element(ns)*">
118
+ <xsl:copy-of select="$provided-nsmap" />
119
+ <xsl:for-each-group group-by="."
120
+ select="$collection//namespace::*[not(name() = $provided-nsmap/@prefix or . = $provided-nsmap)]">
121
+ <xsl:variable name="prefix" as="xs:string">
122
+ <xsl:choose>
123
+ <xsl:when test="exists(current-group()[name() != ''])">
124
+ <xsl:value-of select="name(current-group()[name() != ''][1])" />
125
+ </xsl:when>
126
+ <xsl:otherwise>
127
+ <xsl:value-of select="replace(., '^.+?([\i-[:]][\c-[:]]*)/?$', '$1')" />
128
+ </xsl:otherwise>
129
+ </xsl:choose>
130
+ </xsl:variable>
131
+ <xsl:if test="not(matches($prefix, '^[\i-[:]][\c-[:]]*$'))">
132
+ <xsl:message terminate="yes">
133
+ <xsl:text>ERROR: Couldn't identify prefix for namespace "</xsl:text>
134
+ <xsl:value-of select="."/>
135
+ <xsl:text>".&#10;</xsl:text>
136
+ <xsl:text> See for instance "</xsl:text>
137
+ <xsl:value-of select="document-uri(/)"/>
138
+ <xsl:text>".&#10;</xsl:text>
139
+ <xsl:text> Declare it with a prefix in the scanning XML document.</xsl:text>
140
+ </xsl:message>
141
+ </xsl:if>
142
+ <ns prefix="{$prefix}" xmlns="">
143
+ <xsl:value-of select="." />
144
+ </ns>
145
+ </xsl:for-each-group>
146
+ </xsl:variable>
147
+
148
+ <xsl:template match="/" name="main">
149
+ <x:description>
150
+ <xsl:for-each select="$nsmap">
151
+ <xsl:namespace name="{@prefix}">
152
+ <xsl:value-of select="." />
153
+ </xsl:namespace>
154
+ </xsl:for-each>
155
+ <xsl:for-each-group select="$examples[self::*]" group-by="node-name(.)">
156
+ <xsl:sort select="x:expanded-QName(current-grouping-key())" />
157
+ <xsl:variable name="name" as="xs:string" select="x:node-name(.)" />
158
+ <x:scenario label="when processing a {$name} element">
159
+ <xsl:for-each-group select="current-group()"
160
+ group-by="x:content-model(.)">
161
+ <xsl:sort select="current-grouping-key()" />
162
+ <xsl:variable name="test-id" as="xs:string" select="concat($name, '.', position())" />
163
+ <xsl:choose>
164
+ <xsl:when test="current-grouping-key() = '(text)'">
165
+ <xsl:variable name="all-vals" as="xs:string+" select="distinct-values(current-group())" />
166
+ <xsl:message>all-vals: <xsl:value-of select="count($all-vals)" /></xsl:message>
167
+ <xsl:choose>
168
+ <xsl:when test="count($all-vals) > $max-examples">
169
+ <x:scenario label="with the content model (text)">
170
+ <xsl:apply-templates select="current-group()[position() &lt;= $max-examples]" />
171
+ </x:scenario>
172
+ </xsl:when>
173
+ <xsl:otherwise>
174
+ <xsl:for-each-group select="current-group()"
175
+ group-by=".">
176
+ <xsl:sort select="." />
177
+ <x:scenario label="with the value '{current-grouping-key()}'">
178
+ <xsl:apply-templates select="current-group()[position() &lt;= $max-examples]">
179
+ <xsl:with-param name="enum-value" select="true()" />
180
+ </xsl:apply-templates>
181
+ </x:scenario>
182
+ </xsl:for-each-group>
183
+ </xsl:otherwise>
184
+ </xsl:choose>
185
+ </xsl:when>
186
+ <xsl:otherwise>
187
+ <x:scenario label="with the content model {current-grouping-key()}">
188
+ <xsl:apply-templates select="current-group()[position() &lt;= $max-examples]" />
189
+ </x:scenario>
190
+ </xsl:otherwise>
191
+ </xsl:choose>
192
+ </xsl:for-each-group>
193
+ </x:scenario>
194
+ </xsl:for-each-group>
195
+ <xsl:for-each-group select="$examples[self::processing-instruction()]" group-by="name()">
196
+ <xsl:sort select="name()" />
197
+ <x:scenario label="when processing a {name()} PI">
198
+ <xsl:for-each-group select="current-group()" group-by="x:pi-content-model(.)">
199
+ <xsl:sort select="current-grouping-key()" />
200
+ <x:scenario label="with content like {current-grouping-key()}">
201
+ <xsl:apply-templates select="current-group()[position() &lt;= $max-examples]" />
202
+ </x:scenario>
203
+ </xsl:for-each-group>
204
+ </x:scenario>
205
+ </xsl:for-each-group>
206
+ </x:description>
207
+ </xsl:template>
208
+
209
+ <xsl:template match="*">
210
+ <xsl:param name="enum-value" as="xs:boolean" select="false()" />
211
+ <xsl:choose>
212
+ <xsl:when test="position() = 1">
213
+ <x:context select="{x:xpath(.)}"
214
+ href="{base-uri(.)}" />
215
+ <x:expect label="it should ...">
216
+ <xsl:apply-templates select="." mode="x:shallow-copy">
217
+ <xsl:with-param name="full-text" tunnel="yes" select="true()" />
218
+ </xsl:apply-templates>
219
+ </x:expect>
220
+ </xsl:when>
221
+ <xsl:otherwise>
222
+ <xsl:comment>
223
+ <xsl:text>&lt;x:context select="</xsl:text>
224
+ <xsl:value-of select="x:xpath(.)" />
225
+ <xsl:text>" href="</xsl:text>
226
+ <xsl:value-of select="base-uri(.)" />
227
+ <xsl:text>" /></xsl:text>
228
+ </xsl:comment>
229
+ <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
230
+ </xsl:otherwise>
231
+ </xsl:choose>
232
+ </xsl:template>
233
+
234
+ <xsl:template match="processing-instruction()">
235
+ <xsl:choose>
236
+ <xsl:when test="position() = 1">
237
+ <x:context select="{x:xpath(.)}" href="{base-uri(.)}" />
238
+ <x:expect label="it should ...">
239
+ <xsl:copy-of select="." />
240
+ </x:expect>
241
+ </xsl:when>
242
+ <xsl:otherwise>
243
+ <xsl:comment>
244
+ <xsl:text>&lt;x:context select="</xsl:text>
245
+ <xsl:value-of select="x:xpath(.)" />
246
+ <xsl:text>" href="</xsl:text>
247
+ <xsl:value-of select="base-uri(.)" />
248
+ <xsl:text>" /></xsl:text>
249
+ </xsl:comment>
250
+ <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
251
+ </xsl:otherwise>
252
+ </xsl:choose>
253
+ </xsl:template>
254
+
255
+ <xsl:template match="*" mode="x:shallow-copy" priority="2">
256
+ <xsl:param name="level" select="0" />
257
+ <xsl:param name="full-text" select="false()" tunnel="yes" />
258
+ <xsl:copy>
259
+ <xsl:copy-of select="@*" />
260
+ <xsl:choose>
261
+ <xsl:when test="text() and *">
262
+ <xsl:choose>
263
+ <xsl:when test="$level = 0 or $full-text">
264
+ <xsl:copy-of select="node()" />
265
+ </xsl:when>
266
+ <xsl:otherwise>
267
+ <xsl:text>...</xsl:text>
268
+ </xsl:otherwise>
269
+ </xsl:choose>
270
+ </xsl:when>
271
+ <xsl:when test="*">
272
+ <xsl:choose>
273
+ <xsl:when test="$level = 0">
274
+ <xsl:apply-templates select="node()" mode="x:shallow-copy">
275
+ <xsl:with-param name="level" select="1" />
276
+ </xsl:apply-templates>
277
+ </xsl:when>
278
+ <xsl:otherwise>
279
+ <xsl:text>...</xsl:text>
280
+ </xsl:otherwise>
281
+ </xsl:choose>
282
+ </xsl:when>
283
+ <xsl:otherwise>
284
+ <xsl:choose>
285
+ <xsl:when test="$full-text or string-length(.) > 15">
286
+ <xsl:text>...</xsl:text>
287
+ </xsl:when>
288
+ <xsl:otherwise>
289
+ <xsl:apply-templates select="node()" mode="x:shallow-copy">
290
+ <xsl:with-param name="level" select="1" />
291
+ </xsl:apply-templates>
292
+ </xsl:otherwise>
293
+ </xsl:choose>
294
+ </xsl:otherwise>
295
+ </xsl:choose>
296
+ </xsl:copy>
297
+ </xsl:template>
298
+
299
+ <xsl:template match="node()" mode="x:shallow-copy">
300
+ <xsl:copy-of select="." />
301
+ </xsl:template>
302
+
303
+ <xsl:function name="x:content-model" as="xs:string">
304
+ <xsl:param name="element" as="element()" />
305
+ <xsl:apply-templates select="$element" mode="x:content-model" />
306
+ </xsl:function>
307
+
308
+ <xsl:template match="*[text() and *]" mode="x:content-model" as="xs:string"
309
+ priority="5">
310
+ <xsl:value-of>
311
+ <xsl:text>mixed{</xsl:text>
312
+ <xsl:next-match />
313
+ <xsl:text>}</xsl:text>
314
+ </xsl:value-of>
315
+ </xsl:template>
316
+
317
+ <xsl:variable name="content-model-keywords" as="xs:string+"
318
+ select="('text', 'empty', 'mixed')" />
319
+
320
+ <xsl:template match="*[*]" mode="x:content-model" as="xs:string"
321
+ priority="4">
322
+ <xsl:value-of>
323
+ <xsl:text>(</xsl:text>
324
+ <xsl:apply-templates select="." mode="x:attribute-model" />
325
+ <xsl:if test="@*">,</xsl:if>
326
+ <xsl:for-each-group select="*" group-adjacent="node-name(.)">
327
+ <xsl:variable name="name" as="xs:string" select="x:node-name(.)" />
328
+ <xsl:value-of select="if ($name = $content-model-keywords) then concat('\', $name) else $name" />
329
+ <xsl:if test="count(current-group()) > 1">+</xsl:if>
330
+ <xsl:if test="position() != last()">,</xsl:if>
331
+ </xsl:for-each-group>
332
+ <xsl:text>)</xsl:text>
333
+ </xsl:value-of>
334
+ </xsl:template>
335
+
336
+ <xsl:template match="*[not(* or text())]" mode="x:content-model" as="xs:string"
337
+ priority="5">
338
+ <xsl:choose>
339
+ <xsl:when test="@*">
340
+ <xsl:value-of>
341
+ <xsl:text>(</xsl:text>
342
+ <xsl:apply-templates select="." mode="x:attribute-model" />
343
+ <xsl:text>)</xsl:text>
344
+ </xsl:value-of>
345
+ </xsl:when>
346
+ <xsl:otherwise>(empty)</xsl:otherwise>
347
+ </xsl:choose>
348
+ </xsl:template>
349
+
350
+ <xsl:template match="*" mode="x:content-model" as="xs:string"
351
+ priority="0">
352
+ <xsl:value-of>
353
+ <xsl:text>(</xsl:text>
354
+ <xsl:apply-templates select="." mode="x:attribute-model" />
355
+ <xsl:if test="@*">,</xsl:if>
356
+ <xsl:text>text)</xsl:text>
357
+ </xsl:value-of>
358
+ </xsl:template>
359
+
360
+ <xsl:template match="*" mode="x:attribute-model" as="xs:string">
361
+ <xsl:value-of>
362
+ <xsl:for-each select="@*">
363
+ <xsl:sort select="x:expanded-QName(node-name(.))" />
364
+ <xsl:text>@</xsl:text>
365
+ <xsl:value-of select="x:node-name(.)" />
366
+ <xsl:choose>
367
+ <xsl:when test="x:node-name(.) = $enums">
368
+ <xsl:sequence select="concat('{''', ., '''}')" />
369
+ </xsl:when>
370
+ <xsl:when test="x:node-name(.) = $global-ids">
371
+ <xsl:sequence select="'{xs:ID}'" />
372
+ </xsl:when>
373
+ <xsl:otherwise>
374
+ <xsl:variable name="value-model" select="x:value-model(.)" />
375
+ <xsl:if test="$value-model != 'text'">
376
+ <xsl:text>{</xsl:text>
377
+ <xsl:value-of select="$value-model" />
378
+ <xsl:text>}</xsl:text>
379
+ </xsl:if>
380
+ </xsl:otherwise>
381
+ </xsl:choose>
382
+ <xsl:if test="position() != last()">,</xsl:if>
383
+ </xsl:for-each>
384
+ </xsl:value-of>
385
+ </xsl:template>
386
+
387
+ <xsl:function name="x:value-model" as="xs:string">
388
+ <xsl:param name="text" as="xs:string" />
389
+ <xsl:choose>
390
+ <xsl:when test="$text = ''">
391
+ <xsl:sequence select="''''''" />
392
+ </xsl:when>
393
+ <!-- looks like a year -->
394
+ <xsl:when test="matches($text, '^(19|20)[0-9]{2}$')">
395
+ <xsl:sequence select="'xs:gYear'" />
396
+ </xsl:when>
397
+ <!-- looks like a date -->
398
+ <xsl:when test="matches($text, '^[0-9]{4}-[0-9]{2}-[0-9]{2}$')" >
399
+ <xsl:sequence select="'xs:date'" />
400
+ </xsl:when>
401
+ <!-- looks like a dateTime -->
402
+ <xsl:when test="matches($text, '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?$')" >
403
+ <xsl:sequence select="'xs:dateTime'" />
404
+ </xsl:when>
405
+ <!-- looks like an integer -->
406
+ <xsl:when test="matches($text, '^[0-9]+$')">
407
+ <xsl:sequence select="'xs:integer'" />
408
+ </xsl:when>
409
+ <!-- looks like a decimal -->
410
+ <xsl:when test="matches($text, '^[0-9]*\.[0-9]+$')">
411
+ <xsl:sequence select="'xs:decimal'" />
412
+ </xsl:when>
413
+ <!-- looks like a token -->
414
+ <xsl:when test="matches($text, '^\i\c*$')">
415
+ <xsl:choose>
416
+ <xsl:when test="matches($text, '^\i\c*:\i\c*$')">
417
+ <xsl:sequence select="'xs:QName'" />
418
+ </xsl:when>
419
+ <xsl:when test="matches($text, '^[\i-[:]][\c-[:]]*$')">
420
+ <xsl:sequence select="'xs:NCName'" />
421
+ </xsl:when>
422
+ <xsl:otherwise>
423
+ <xsl:sequence select="'xs:Name'" />
424
+ </xsl:otherwise>
425
+ </xsl:choose>
426
+ </xsl:when>
427
+ <!-- looks like a NMTOKEN -->
428
+ <xsl:when test="matches($text, '^\c+$')">
429
+ <xsl:sequence select="'xs:NMTOKEN'" />
430
+ </xsl:when>
431
+ <xsl:when test="contains($text, ' ')">
432
+ <xsl:variable name="value-types" as="xs:string+">
433
+ <xsl:for-each select="tokenize($text, '\s+')">
434
+ <xsl:sequence select="x:value-model(.)" />
435
+ </xsl:for-each>
436
+ </xsl:variable>
437
+ <xsl:choose>
438
+ <xsl:when test="count(distinct-values($value-types)) = 1">
439
+ <xsl:sequence select="concat($value-types[1], '+')" />
440
+ </xsl:when>
441
+ <xsl:otherwise>
442
+ <xsl:sequence select="'text'" />
443
+ </xsl:otherwise>
444
+ </xsl:choose>
445
+ </xsl:when>
446
+ <xsl:otherwise>
447
+ <xsl:sequence select="'text'" />
448
+ </xsl:otherwise>
449
+ </xsl:choose>
450
+ </xsl:function>
451
+
452
+ <xsl:variable name="pseudo-attribute-regex">
453
+ (\i\c*) <!-- 1: pseudo-attribute name -->
454
+ =
455
+ ( <!-- 2: quoted value -->
456
+ ('([^']*)') <!-- 3: single quoted value --><!-- 4: value -->
457
+ ("([^"]*)") <!-- 5: double quoted value --><!-- 6: value -->
458
+ )
459
+ </xsl:variable>
460
+
461
+ <xsl:function name="x:pi-content-model" as="xs:string">
462
+ <xsl:param name="pi" as="processing-instruction()" />
463
+ <xsl:choose>
464
+ <xsl:when test="matches($pi, $pseudo-attribute-regex, 'x')">
465
+ <xsl:variable name="atts" as="attribute()*">
466
+ <xsl:analyze-string select="$pi" regex="$psudo-attribute-regex" flags="x">
467
+ <xsl:matching-substring>
468
+ <xsl:attribute name="{regex-group(1)}"
469
+ select="if (regex-group(3)) then regex-group(4) else regex-group(5)" />
470
+ </xsl:matching-substring>
471
+ <xsl:non-matching-substring>
472
+ <xsl:message>WARNING: found a PI that holds text as well as pseudo-attributes</xsl:message>
473
+ </xsl:non-matching-substring>
474
+ </xsl:analyze-string>
475
+ </xsl:variable>
476
+ <xsl:value-of>
477
+ <xsl:text>(</xsl:text>
478
+ <xsl:for-each select="$atts">
479
+ <xsl:sort select="name()" />
480
+ <xsl:variable name="value-model" select="x:value-model(.)" />
481
+ <xsl:text>@</xsl:text>
482
+ <xsl:value-of select="name()" />
483
+ <xsl:if test="$value-model != 'text'">
484
+ <xsl:text>{</xsl:text>
485
+ <xsl:value-of select="$value-model" />
486
+ <xsl:text>}</xsl:text>
487
+ </xsl:if>
488
+ <xsl:if test="position() != last()">,</xsl:if>
489
+ </xsl:for-each>
490
+ <xsl:text>)</xsl:text>
491
+ </xsl:value-of>
492
+ </xsl:when>
493
+ <xsl:when test="normalize-space($pi)">
494
+ <xsl:sequence select="concat('(', x:value-model($pi), ')')" />
495
+ </xsl:when>
496
+ <xsl:otherwise>
497
+ <xsl:sequence select="'(empty)'" />
498
+ </xsl:otherwise>
499
+ </xsl:choose>
500
+ </xsl:function>
501
+
502
+ <xsl:function name="x:xpath" as="xs:string">
503
+ <xsl:param name="node" as="node()" />
504
+ <xsl:apply-templates select="$node" mode="x:xpath" />
505
+ </xsl:function>
506
+
507
+ <xsl:template match="processing-instruction()" mode="x:xpath" as="xs:string">
508
+ <xsl:variable name="name" select="name()" />
509
+ <xsl:variable name="predicate" as="xs:string"
510
+ select="if (count(../processing-instruction()[name() = $name]) > 1)
511
+ then concat('[', count(preceding-sibling::processing-instruction()[name() = $name]) + 1, ']')
512
+ else ''" />
513
+ <xsl:variable name="node-test" as="xs:string"
514
+ select="concat('processing-instruction(', name(), ')', $predicate)" />
515
+ <xsl:sequence select="concat(if (parent::*) then x:xpath(..) else '',
516
+ '/', $node-test)" />
517
+ </xsl:template>
518
+
519
+ <xsl:template match="*" mode="x:xpath" as="xs:string">
520
+ <xsl:variable name="name" as="xs:string" select="x:node-name(.)" />
521
+ <xsl:choose>
522
+ <xsl:when test="not(./parent::*)">
523
+ <xsl:sequence select="concat('/', $name)" />
524
+ </xsl:when>
525
+ <xsl:otherwise>
526
+ <xsl:variable name="global-id" as="attribute()?"
527
+ select="@*[x:node-name(.) = $global-ids][1]" />
528
+ <xsl:choose>
529
+ <xsl:when test="exists($global-id)">
530
+ <xsl:sequence select="concat('//', $name, '[@', name($global-id), '=''', $global-id, ''']')" />
531
+ </xsl:when>
532
+ <xsl:otherwise>
533
+ <xsl:variable name="base-path" as="xs:string"
534
+ select="concat(x:xpath(..), '/', $name)" />
535
+ <xsl:variable name="local-id" as="attribute()?"
536
+ select="@*[x:node-name(.) = $local-ids][1]" />
537
+ <xsl:choose>
538
+ <xsl:when test="exists($local-id)">
539
+ <xsl:sequence select="concat($base-path, '[@', name($local-id), '=''', $local-id, ''']')" />
540
+ </xsl:when>
541
+ <xsl:otherwise>
542
+ <xsl:choose>
543
+ <xsl:when test="count(../*[x:node-name(.) = $name]) > 1">
544
+ <xsl:sequence select="concat($base-path, '[', count(preceding-sibling::*[x:node-name(.) = $name]) + 1, ']')" />
545
+ </xsl:when>
546
+ <xsl:otherwise>
547
+ <xsl:sequence select="$base-path" />
548
+ </xsl:otherwise>
549
+ </xsl:choose>
550
+ </xsl:otherwise>
551
+ </xsl:choose>
552
+ </xsl:otherwise>
553
+ </xsl:choose>
554
+ </xsl:otherwise>
555
+ </xsl:choose>
556
+ </xsl:template>
557
+
558
+ <xsl:function name="x:expanded-QName" as="xs:string">
559
+ <xsl:param name="qname" as="xs:QName" />
560
+ <xsl:sequence select="concat('{', namespace-uri-from-QName($qname), '}', local-name-from-QName($qname))" />
561
+ </xsl:function>
562
+
563
+ <xsl:function name="x:node-name" as="xs:string">
564
+ <xsl:param name="node" as="node()" />
565
+ <xsl:choose>
566
+ <xsl:when test="namespace-uri($node)">
567
+ <xsl:variable name="prefix" select="x:prefix-for-ns(namespace-uri($node))" />
568
+ <xsl:sequence select="concat($prefix, ':', local-name($node))" />
569
+ </xsl:when>
570
+ <xsl:otherwise>
571
+ <xsl:value-of select="local-name($node)" />
572
+ </xsl:otherwise>
573
+ </xsl:choose>
574
+ </xsl:function>
575
+
576
+ <xsl:function name="x:prefix-for-ns" as="xs:string">
577
+ <xsl:param name="ns" as="xs:string" />
578
+ <xsl:sequence select="($nsmap[. = $ns]/@prefix)[1]" />
579
+ </xsl:function>
580
+
581
+ <xsl:strip-space elements="*" />
582
+ <xsl:output indent="yes" encoding="ASCII" />
583
+
584
+ <xsl:namespace-alias stylesheet-prefix="#default" result-prefix="xsl"/>
585
+
586
+ </xsl:stylesheet>
587
+
588
+
589
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
590
+ <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. -->
591
+ <!-- -->
592
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion -->
593
+ <!-- -->
594
+ <!-- The contents of this file are subject to the MIT License (see the URI -->
595
+ <!-- http://www.opensource.org/licenses/mit-license.php for details). -->
596
+ <!-- -->
597
+ <!-- Permission is hereby granted, free of charge, to any person obtaining -->
598
+ <!-- a copy of this software and associated documentation files (the -->
599
+ <!-- "Software"), to deal in the Software without restriction, including -->
600
+ <!-- without limitation the rights to use, copy, modify, merge, publish, -->
601
+ <!-- distribute, sublicense, and/or sell copies of the Software, and to -->
602
+ <!-- permit persons to whom the Software is furnished to do so, subject to -->
603
+ <!-- the following conditions: -->
604
+ <!-- -->
605
+ <!-- The above copyright notice and this permission notice shall be -->
606
+ <!-- included in all copies or substantial portions of the Software. -->
607
+ <!-- -->
608
+ <!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -->
609
+ <!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
610
+ <!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.-->
611
+ <!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -->
612
+ <!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -->
613
+ <!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -->
614
+ <!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
615
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->