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,152 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ===================================================================== -->
3
+ <!-- File: generate-query-helper.xsl -->
4
+ <!-- Author: Jeni Tennsion -->
5
+ <!-- URL: http://github.com/xspec/xspec -->
6
+ <!-- Tags: -->
7
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) -->
8
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
9
+
10
+
11
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
13
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
14
+ xmlns:test="http://www.jenitennison.com/xslt/unit-test"
15
+ xmlns:pkg="http://expath.org/ns/pkg"
16
+ extension-element-prefixes="test"
17
+ exclude-result-prefixes="xs xhtml"
18
+ version="2.0">
19
+
20
+ <pkg:import-uri>http://www.jenitennison.com/xslt/xspec/generate-query-helper.xsl</pkg:import-uri>
21
+
22
+ <xsl:key name="functions"
23
+ match="xsl:function"
24
+ use="resolve-QName(@name, .)"/>
25
+
26
+ <xsl:key name="named-templates"
27
+ match="xsl:template[@name]"
28
+ use="if ( contains(@name, ':') ) then
29
+ resolve-QName(@name, .)
30
+ else
31
+ QName('', @name)"/>
32
+
33
+ <xsl:key name="matching-templates"
34
+ match="xsl:template[@match]"
35
+ use="concat('match=', normalize-space(@match), '+',
36
+ 'mode=', normalize-space(@mode))"/>
37
+
38
+ <xsl:template match="*" mode="test:generate-variable-declarations">
39
+ <xsl:param name="var" as="xs:string" required="yes"/>
40
+ <xsl:param name="global" as="xs:boolean" select="false()"/>
41
+ <xsl:choose>
42
+ <xsl:when test="$global">
43
+ <xsl:text>declare variable $</xsl:text>
44
+ </xsl:when>
45
+ <xsl:otherwise>
46
+ <xsl:text> let $</xsl:text>
47
+ </xsl:otherwise>
48
+ </xsl:choose>
49
+ <xsl:value-of select="$var"/>
50
+ <xsl:if test="@as">
51
+ <xsl:text> as </xsl:text>
52
+ <xsl:value-of select="@as"/>
53
+ </xsl:if>
54
+ <xsl:choose>
55
+ <xsl:when test="@href">
56
+ <xsl:text> := doc('</xsl:text>
57
+ <xsl:value-of select="resolve-uri(@href, base-uri(.))"/>
58
+ <xsl:text>')</xsl:text>
59
+ <xsl:if test="@select">/( <xsl:value-of select="@select"/> )</xsl:if>
60
+ </xsl:when>
61
+ <xsl:when test="node()">
62
+ <xsl:text> := ( </xsl:text>
63
+ <xsl:for-each select="node() except text()[not(normalize-space(.))]">
64
+ <xsl:apply-templates select="." mode="test:create-xslt-generator"/>
65
+ <xsl:if test="position() ne last()">
66
+ <xsl:text>, </xsl:text>
67
+ </xsl:if>
68
+ </xsl:for-each>
69
+ <xsl:text> )</xsl:text>
70
+ <xsl:if test="@select">/( <xsl:value-of select="@select"/> )</xsl:if>
71
+ </xsl:when>
72
+ <xsl:when test="@select">
73
+ <xsl:text> := ( </xsl:text>
74
+ <xsl:value-of select="@select"/>
75
+ <xsl:text> )</xsl:text>
76
+ </xsl:when>
77
+ <xsl:otherwise>
78
+ <xsl:text> := ()</xsl:text>
79
+ </xsl:otherwise>
80
+ </xsl:choose>
81
+ <xsl:if test="$global">
82
+ <xsl:text>;</xsl:text>
83
+ </xsl:if>
84
+ <xsl:text>&#10;</xsl:text>
85
+ </xsl:template>
86
+
87
+ <xsl:template match="*" mode="test:create-xslt-generator">
88
+ <!--xsl:copy>
89
+ <xsl:copy-of select="@*"/>
90
+ <xsl:apply-templates mode="test:create-xslt-generator"/>
91
+ </xsl:copy-->
92
+ <xsl:copy-of select="."/>
93
+ </xsl:template>
94
+
95
+ <!-- FIXME: Escape the quoted string... -->
96
+ <xsl:template match="text()" mode="test:create-xslt-generator">
97
+ <xsl:text>text { "</xsl:text>
98
+ <xsl:value-of select="."/>
99
+ <xsl:text>" }</xsl:text>
100
+ </xsl:template>
101
+
102
+ <xsl:template match="comment()" mode="test:create-xslt-generator">
103
+ <xsl:text>comment { </xsl:text>
104
+ <xsl:value-of select="."/>
105
+ <xsl:text> }</xsl:text>
106
+ </xsl:template>
107
+
108
+ <xsl:template match="processing-instruction()" mode="test:create-xslt-generator">
109
+ <xsl:text>processing-instruction { </xsl:text>
110
+ <xsl:value-of select="name(.)"/>
111
+ <xsl:text> } { </xsl:text>
112
+ <xsl:value-of select="."/>
113
+ <xsl:text> }</xsl:text>
114
+ </xsl:template>
115
+
116
+ <xsl:function name="test:matching-xslt-elements" as="element()*">
117
+ <xsl:param name="element-kind" as="xs:string" />
118
+ <xsl:param name="element-id" as="item()" />
119
+ <xsl:param name="stylesheet" as="document-node()" />
120
+ <xsl:sequence select="key($element-kind, $element-id, $stylesheet)" />
121
+ </xsl:function>
122
+
123
+ </xsl:stylesheet>
124
+
125
+
126
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
127
+ <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. -->
128
+ <!-- -->
129
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion -->
130
+ <!-- -->
131
+ <!-- The contents of this file are subject to the MIT License (see the URI -->
132
+ <!-- http://www.opensource.org/licenses/mit-license.php for details). -->
133
+ <!-- -->
134
+ <!-- Permission is hereby granted, free of charge, to any person obtaining -->
135
+ <!-- a copy of this software and associated documentation files (the -->
136
+ <!-- "Software"), to deal in the Software without restriction, including -->
137
+ <!-- without limitation the rights to use, copy, modify, merge, publish, -->
138
+ <!-- distribute, sublicense, and/or sell copies of the Software, and to -->
139
+ <!-- permit persons to whom the Software is furnished to do so, subject to -->
140
+ <!-- the following conditions: -->
141
+ <!-- -->
142
+ <!-- The above copyright notice and this permission notice shall be -->
143
+ <!-- included in all copies or substantial portions of the Software. -->
144
+ <!-- -->
145
+ <!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -->
146
+ <!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
147
+ <!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.-->
148
+ <!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -->
149
+ <!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -->
150
+ <!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -->
151
+ <!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
152
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@@ -0,0 +1,473 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ===================================================================== -->
3
+ <!-- File: generate-query-tests.xsl -->
4
+ <!-- Author: Jeni Tennsion -->
5
+ <!-- URL: http://github.com/xspec/xspec -->
6
+ <!-- Tags: -->
7
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) -->
8
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
9
+
10
+
11
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
13
+ xmlns:test="http://www.jenitennison.com/xslt/unit-test"
14
+ xmlns:x="http://www.jenitennison.com/xslt/xspec"
15
+ xmlns:pkg="http://expath.org/ns/pkg"
16
+ exclude-result-prefixes="xs test x"
17
+ version="2.0">
18
+
19
+ <xsl:import href="generate-common-tests.xsl"/>
20
+ <xsl:import href="generate-query-helper.xsl"/>
21
+
22
+ <pkg:import-uri>http://www.jenitennison.com/xslt/xspec/generate-query-tests.xsl</pkg:import-uri>
23
+
24
+ <xsl:output omit-xml-declaration="yes"/>
25
+
26
+ <!--
27
+ The URI to use in the "at" clause of the import statement (aka
28
+ the "location hint") for the library generate-query-utils.xql.
29
+ The special value '#none' is used to generate no "at" clause at
30
+ all.
31
+
32
+ By defaut, the URI is generated as a file relative to this
33
+ stylesheet (because it comes with it in the XSpec release, but
34
+ accessing the module on the file system is not always the best
35
+ option, for instance for XML databases like eXist or
36
+ MarkLogic).
37
+ -->
38
+ <xsl:param name="utils-library-at" select="
39
+ resolve-uri('generate-query-utils.xql', static-base-uri())"/>
40
+
41
+ <xsl:variable name="xspec-prefix" as="xs:string">
42
+ <xsl:variable name="e" select="/*"/>
43
+ <xsl:variable name="u" select="xs:anyURI('http://www.jenitennison.com/xslt/xspec')"/>
44
+ <xsl:sequence select="
45
+ in-scope-prefixes($e)[namespace-uri-for-prefix(., $e) eq $u][1]"/>
46
+ </xsl:variable>
47
+
48
+ <!-- TODO: The at hint should not be always resolved (e.g. for MarkLogic). -->
49
+ <xsl:param name="query-at" as="xs:string?" select="
50
+ /x:description/@query-at/resolve-uri(., base-uri(..))"/>
51
+ <!--xsl:param name="query-at" as="xs:string?" select="
52
+ /x:description/@query-at"/-->
53
+
54
+ <xsl:template match="/">
55
+ <xsl:call-template name="x:generate-tests"/>
56
+ </xsl:template>
57
+
58
+ <xsl:template match="x:description" mode="x:decl-ns">
59
+ <xsl:param name="except" as="xs:string"/>
60
+ <xsl:variable name="e" as="element()" select="."/>
61
+ <xsl:for-each select="in-scope-prefixes($e)[not(. = ('xml', $except))]">
62
+ <xsl:text>declare namespace </xsl:text>
63
+ <xsl:value-of select="."/>
64
+ <xsl:text> = "</xsl:text>
65
+ <xsl:value-of select="namespace-uri-for-prefix(., $e)"/>
66
+ <xsl:text>";&#10;</xsl:text>
67
+ </xsl:for-each>
68
+ </xsl:template>
69
+
70
+ <!-- *** x:generate-tests *** -->
71
+ <!-- Does the generation of the test stylesheet -->
72
+
73
+ <xsl:template match="x:description" mode="x:generate-tests">
74
+ <xsl:variable name="this" select="."/>
75
+ <!-- A prefix has to be defined for the target namespace on x:description. -->
76
+ <!-- TODO: If not, we should generate one. -->
77
+ <xsl:variable name="prefix" select="
78
+ in-scope-prefixes($this)[
79
+ namespace-uri-for-prefix(., $this) eq xs:anyURI($this/@query)
80
+ ][1]"/>
81
+ <xsl:text>import module namespace </xsl:text>
82
+ <xsl:value-of select="$prefix"/>
83
+ <xsl:text> = "</xsl:text>
84
+ <xsl:value-of select="@query"/>
85
+ <xsl:if test="exists($query-at)">
86
+ <xsl:text>"&#10; at "</xsl:text>
87
+ <xsl:value-of select="$query-at"/>
88
+ </xsl:if>
89
+ <xsl:text>";&#10;</xsl:text>
90
+ <!-- prevent double import in case we are testing this file in the compiled suite... -->
91
+ <xsl:if test="@query ne 'http://www.jenitennison.com/xslt/unit-test'">
92
+ <xsl:text>import module namespace test = </xsl:text>
93
+ <xsl:text>"http://www.jenitennison.com/xslt/unit-test"</xsl:text>
94
+ <xsl:if test="not($utils-library-at eq '#none')">
95
+ <xsl:text>&#10; at "</xsl:text>
96
+ <xsl:value-of select="$utils-library-at"/>
97
+ <xsl:text>"</xsl:text>
98
+ </xsl:if>
99
+ <xsl:text>;&#10;</xsl:text>
100
+ </xsl:if>
101
+ <xsl:apply-templates select="." mode="x:decl-ns">
102
+ <xsl:with-param name="except" select="$prefix"/>
103
+ </xsl:apply-templates>
104
+ <!-- Compile the test suite params (aka global params). -->
105
+ <xsl:call-template name="x:compile-params"/>
106
+ <!-- Compile the top-level scenarios. -->
107
+ <xsl:call-template name="x:compile-scenarios"/>
108
+ <xsl:text>&#10;</xsl:text>
109
+ <xsl:element name="{ $xspec-prefix }:report"
110
+ namespace="http://www.jenitennison.com/xslt/xspec">
111
+ <xsl:attribute name="date" select="current-dateTime()"/>
112
+ <xsl:attribute name="query" select="$this/@query"/>
113
+ <xsl:if test="exists($query-at)">
114
+ <xsl:attribute name="query-at" select="$query-at"/>
115
+ </xsl:if>
116
+ <xsl:text> {&#10;</xsl:text>
117
+ <!-- Generate calls to the compiled top-level scenarios. -->
118
+ <xsl:call-template name="x:call-scenarios"/>
119
+ <xsl:text>&#10;}&#10;</xsl:text>
120
+ </xsl:element>
121
+ </xsl:template>
122
+
123
+ <!-- *** x:output-call *** -->
124
+ <!-- Generates a call to the function compiled from a scenario or an expect element. -->
125
+
126
+ <xsl:template name="x:output-call">
127
+ <xsl:param name="name" as="xs:string"/>
128
+ <xsl:param name="last" as="xs:boolean"/>
129
+ <xsl:param name="params" as="element(param)*"/>
130
+ <xsl:if test="exists(preceding-sibling::x:*[1][self::x:pending])">
131
+ <xsl:text>,&#10;</xsl:text>
132
+ </xsl:if>
133
+ <xsl:text> let $</xsl:text>
134
+ <xsl:value-of select="$xspec-prefix"/>
135
+ <xsl:text>:tmp := local:</xsl:text>
136
+ <xsl:value-of select="$name"/>
137
+ <xsl:text>(</xsl:text>
138
+ <xsl:for-each select="$params">
139
+ <xsl:value-of select="@select"/>
140
+ <xsl:if test="position() ne last()">
141
+ <xsl:text>, </xsl:text>
142
+ </xsl:if>
143
+ </xsl:for-each>
144
+ <xsl:text>) return (&#10;</xsl:text>
145
+ <xsl:text> $</xsl:text>
146
+ <xsl:value-of select="$xspec-prefix"/>
147
+ <xsl:text>:tmp</xsl:text>
148
+ <xsl:if test="not($last)">
149
+ <xsl:text>,</xsl:text>
150
+ </xsl:if>
151
+ <xsl:text>&#10;</xsl:text>
152
+ <!-- Continue compiling calls. -->
153
+ <xsl:call-template name="x:continue-call-scenarios"/>
154
+ <xsl:text> )&#10;</xsl:text>
155
+ </xsl:template>
156
+
157
+ <!-- *** x:compile *** -->
158
+ <!-- Generates the functions that perform the tests -->
159
+ <!--
160
+ TODO: Add the $params parameter as in the x:output-scenario for XSLT.
161
+ -->
162
+
163
+ <xsl:template name="x:output-scenario">
164
+ <xsl:param name="pending" select="()" tunnel="yes" as="node()?"/>
165
+ <xsl:param name="context" select="()" tunnel="yes" as="element(x:context)?"/>
166
+ <xsl:param name="call" select="()" tunnel="yes" as="element(x:call)?"/>
167
+ <xsl:param name="variables" as="element(x:variable)*"/>
168
+ <xsl:param name="params" as="element(param)*"/>
169
+ <xsl:variable name="pending-p" select="exists($pending) and empty(ancestor-or-self::*/@focus)"/>
170
+ <!-- x:context and x:call/@template not supported for XQuery -->
171
+ <xsl:if test="exists($context)">
172
+ <xsl:variable name="msg" select="
173
+ concat('x:context not supported for XQuery (scenario ', x:label(.), ')')"/>
174
+ <xsl:sequence select="error(xs:QName('x:XSPEC003'), $msg)"/>
175
+ </xsl:if>
176
+ <xsl:if test="exists($call/@template)">
177
+ <xsl:variable name="msg" select="
178
+ concat('x:call/@template not supported for XQuery (scenario ', x:label(.), ')')"/>
179
+ <xsl:sequence select="error(xs:QName('x:XSPEC004'), $msg)"/>
180
+ </xsl:if>
181
+ <!-- x:call required if there are x:expect -->
182
+ <xsl:if test="x:expect and not($call)">
183
+ <xsl:variable name="msg" select="
184
+ concat('there are x:expect but no x:call in scenario ''', x:label(.), '''')"/>
185
+ <xsl:sequence select="error(xs:QName('x:XSPEC005'), $msg)"/>
186
+ </xsl:if>
187
+ <!--
188
+ declare function local:...(...)
189
+ {
190
+ -->
191
+ <xsl:text>&#10;declare function local:</xsl:text>
192
+ <xsl:value-of select="generate-id()"/>
193
+ <xsl:text>(</xsl:text>
194
+ <xsl:value-of select="$params/concat('$', @name)" separator=", "/>
195
+ <xsl:text>)&#10;{&#10;</xsl:text>
196
+ <x:scenario>
197
+ <xsl:if test="$pending-p">
198
+ <xsl:attribute name="pending" select="$pending"/>
199
+ </xsl:if>
200
+ <x:label>
201
+ <xsl:value-of select="x:label(.)"/>
202
+ </x:label>
203
+ <!-- Generate a seq ctor to generate x:context or x:call in the report. -->
204
+ <xsl:apply-templates select="x:context|x:call" mode="x:report"/>
205
+ <xsl:text> &#10;{&#10;</xsl:text>
206
+ <xsl:choose>
207
+ <xsl:when test="not($pending-p)">
208
+ <xsl:for-each select="$variables">
209
+ <xsl:apply-templates select="." mode="test:generate-variable-declarations">
210
+ <xsl:with-param name="var" select="@name"/>
211
+ </xsl:apply-templates>
212
+ </xsl:for-each>
213
+ <!--
214
+ let $xxx-param1 := ...
215
+ let $xxx-param2 := ...
216
+ let $t:result := ...($xxx-param1, $xxx-param2)
217
+ return (
218
+ test:report-value($t:result, 'x:result'),
219
+ -->
220
+ <xsl:apply-templates select="$call/x:param[1]" mode="x:compile"/>
221
+ <xsl:text> let $</xsl:text>
222
+ <xsl:value-of select="$xspec-prefix"/>
223
+ <xsl:text>:result := </xsl:text>
224
+ <xsl:value-of select="$call/@function"/>
225
+ <xsl:text>(</xsl:text>
226
+ <xsl:for-each select="$call/x:param">
227
+ <xsl:sort select="xs:integer(@position)"/>
228
+ <xsl:text>$</xsl:text>
229
+ <xsl:value-of select="( @name, generate-id() )[1]"/>
230
+ <xsl:if test="position() != last()">, </xsl:if>
231
+ </xsl:for-each>
232
+ <xsl:text>)&#10;</xsl:text>
233
+ <xsl:text> return (&#10;</xsl:text>
234
+ <xsl:text> test:report-value($</xsl:text>
235
+ <xsl:value-of select="$xspec-prefix"/>
236
+ <xsl:text>:result, '</xsl:text>
237
+ <xsl:value-of select="$xspec-prefix"/>
238
+ <xsl:text>:result'),&#10;</xsl:text>
239
+ </xsl:when>
240
+ <xsl:otherwise>
241
+ <!--
242
+ let $t:result := ()
243
+ return (
244
+ -->
245
+ <xsl:text> let $</xsl:text>
246
+ <xsl:value-of select="$xspec-prefix"/>
247
+ <xsl:text>:result := ()&#10;</xsl:text>
248
+ <xsl:text> return (&#10;</xsl:text>
249
+ </xsl:otherwise>
250
+ </xsl:choose>
251
+ <xsl:call-template name="x:call-scenarios"/>
252
+ <xsl:text> )&#10;</xsl:text>
253
+ <xsl:text>}&#10;</xsl:text>
254
+ </x:scenario>
255
+ <xsl:text>&#10;};&#10;</xsl:text>
256
+ <xsl:call-template name="x:compile-scenarios"/>
257
+ </xsl:template>
258
+
259
+ <!--
260
+ Generate an XQuery function from the expect element.
261
+
262
+ This function, when called, checks the expectation against the
263
+ actual result of the test and return the corresponding t:test
264
+ element for the XML report.
265
+ -->
266
+ <xsl:template name="x:output-expect">
267
+ <xsl:param name="pending" select="()" tunnel="yes" as="node()?"/>
268
+ <xsl:param name="call" required="yes" tunnel="yes" as="element(x:call)?"/>
269
+ <xsl:param name="params" required="yes" as="element(param)*"/>
270
+ <xsl:variable name="pending-p" select="exists($pending) and empty(ancestor::*/@focus)"/>
271
+ <!--
272
+ declare function local:...($t:result as item()*)
273
+ {
274
+ -->
275
+ <xsl:text>&#10;declare function local:</xsl:text>
276
+ <xsl:value-of select="generate-id()"/>
277
+ <xsl:text>(</xsl:text>
278
+ <xsl:for-each select="$params">
279
+ <xsl:text>$</xsl:text>
280
+ <xsl:value-of select="@name"/>
281
+ <xsl:if test="position() ne last()">
282
+ <xsl:text>, </xsl:text>
283
+ </xsl:if>
284
+ </xsl:for-each>
285
+ <xsl:text>)&#10;{&#10;</xsl:text>
286
+ <xsl:if test="not($pending-p)">
287
+ <!--
288
+ let $local:expected :=
289
+ ( ... )
290
+ -->
291
+ <xsl:text> let $local:expected := (: expected result :)&#10;</xsl:text>
292
+ <!-- FIXME: Not correct, the x:expect model is more complex than
293
+ a simple variable... (see how the original stylesheet, for
294
+ XSLT, handles that...) Factorize with the XSLT version...
295
+ The value of $local:expected depends on x:expect's depends
296
+ on content, @href and @select. -->
297
+ <xsl:text> ( </xsl:text>
298
+ <xsl:value-of select="@select"/>
299
+ <xsl:copy-of select="node()"/>
300
+ <xsl:text> )&#10;</xsl:text>
301
+ <!--
302
+ let $local:test-result :=
303
+ if ( $t:result instance of node()+ ) then
304
+ document { $t:result }/( ... )
305
+ else
306
+ ( ... )
307
+ -->
308
+ <!--xsl:text> let $local:test-result := (: evaluate the predicate :)&#10;</xsl:text>
309
+ <xsl:text> if ( $</xsl:text>
310
+ <xsl:value-of select="$xspec-prefix"/>
311
+ <xsl:text>:result instance of node()+ ) then&#10;</xsl:text>
312
+ <xsl:text> document { $</xsl:text>
313
+ <xsl:value-of select="$xspec-prefix"/>
314
+ <xsl:text>:result }/( </xsl:text>
315
+ <xsl:value-of select="@test"/>
316
+ <xsl:text> )&#10;</xsl:text>
317
+ <xsl:text> else&#10;</xsl:text>
318
+ <xsl:text> ( </xsl:text>
319
+ <xsl:value-of select="@test"/>
320
+ <xsl:text> )&#10;</xsl:text>
321
+ <!- -
322
+ let $local:successful :=
323
+ if ( $local:test-result instance of xs:boolean ) then
324
+ $local:test-result
325
+ else
326
+ test:deep-equal($local:expected, $local:test-result)
327
+ - ->
328
+ <xsl:text> let $local:successful := (: did the test pass?:)&#10;</xsl:text>
329
+ <xsl:text> if ( $local:test-result instance of xs:boolean ) then&#10;</xsl:text>
330
+ <xsl:text> $local:test-result&#10;</xsl:text>
331
+ <xsl:text> else&#10;</xsl:text>
332
+ <xsl:text> test:deep-equal($local:expected, $local:test-result)&#10;</xsl:text-->
333
+ <!--
334
+ IF @test ==>
335
+ let $local:successful :=
336
+ ( ...)
337
+
338
+ ELSE ==>
339
+ let $local:successful :=
340
+ test:deep-equal($local:expected, $x:result)
341
+ -->
342
+ <xsl:text> let $local:successful as xs:boolean := (: did the test pass?:)&#10;</xsl:text>
343
+ <xsl:choose>
344
+ <xsl:when test="exists(@test) and exists(node())">
345
+ <xsl:text> test:deep-equal($local:expected, </xsl:text>
346
+ <xsl:value-of select="@test"/>
347
+ <xsl:text>)&#10;</xsl:text>
348
+ </xsl:when>
349
+ <xsl:when test="exists(@test)">
350
+ <xsl:text> ( </xsl:text>
351
+ <xsl:value-of select="@test"/>
352
+ <xsl:text> )&#10;</xsl:text>
353
+ </xsl:when>
354
+ <xsl:otherwise>
355
+ <xsl:text> test:deep-equal($local:expected, $</xsl:text>
356
+ <xsl:value-of select="$xspec-prefix"/>
357
+ <xsl:text>:result)&#10;</xsl:text>
358
+ </xsl:otherwise>
359
+ </xsl:choose>
360
+ <xsl:text> return&#10; </xsl:text>
361
+ </xsl:if>
362
+ <!--
363
+ return the x:test element for the report
364
+ -->
365
+ <x:test>
366
+ <xsl:choose>
367
+ <xsl:when test="$pending-p">
368
+ <xsl:attribute name="pending" select="$pending"/>
369
+ </xsl:when>
370
+ <xsl:otherwise>
371
+ <xsl:attribute name="successful" select="'{ $local:successful }'"/>
372
+ </xsl:otherwise>
373
+ </xsl:choose>
374
+ <xsl:sequence select="x:label(.)"/>
375
+ <xsl:if test="not($pending-p)">
376
+ <!--xsl:if test="@test">
377
+ <xsl:text>&#10; { if ( $local:test-result instance of xs:boolean ) then () else test:report-value($local:test-result, '</xsl:text>
378
+ <xsl:value-of select="$xspec-prefix"/>
379
+ <xsl:text>:result') }</xsl:text>
380
+ </xsl:if-->
381
+ <xsl:text>&#10; { test:report-value($local:expected, '</xsl:text>
382
+ <xsl:value-of select="$xspec-prefix"/>
383
+ <xsl:text>:expect') }</xsl:text>
384
+ </xsl:if>
385
+ </x:test>
386
+ <xsl:text>&#10;};&#10;</xsl:text>
387
+ </xsl:template>
388
+
389
+ <!-- *** x:generate-declarations *** -->
390
+ <!-- Code to generate parameter declarations -->
391
+ <!--
392
+ TODO: For x:param, define external variable (which can have a
393
+ default value in XQuery 1.1, but not in 1.0, so we will need to
394
+ generate an error for global x:param with default value...)
395
+ -->
396
+ <xsl:template match="x:param|x:variable" mode="x:generate-declarations">
397
+ <xsl:apply-templates select="." mode="test:generate-variable-declarations">
398
+ <xsl:with-param name="var" select="@name" />
399
+ <xsl:with-param name="global" select="true()"/>
400
+ </xsl:apply-templates>
401
+ </xsl:template>
402
+
403
+ <xsl:template match="x:space" mode="test:create-xslt-generator">
404
+ <text>
405
+ <xsl:value-of select="."/>
406
+ </text>
407
+ </xsl:template>
408
+
409
+ <xsl:template match="x:param" mode="x:report">
410
+ <xsl:element name="x:{local-name()}">
411
+ <xsl:apply-templates select="@*" mode="x:report"/>
412
+ <xsl:apply-templates mode="test:create-xslt-generator"/>
413
+ </xsl:element>
414
+ </xsl:template>
415
+
416
+ <xsl:template match="x:call" mode="x:report">
417
+ <x:call>
418
+ <xsl:copy-of select="@*"/>
419
+ <xsl:apply-templates mode="x:report"/>
420
+ </x:call>
421
+ </xsl:template>
422
+
423
+ <xsl:template match="@select" mode="x:report">
424
+ <xsl:attribute name="select" select="
425
+ replace(replace(., '\{', '{{'), '\}', '}}')"/>
426
+ </xsl:template>
427
+
428
+ <xsl:template match="@*" mode="x:report">
429
+ <xsl:sequence select="."/>
430
+ </xsl:template>
431
+
432
+ <xsl:function name="x:label" as="node()?">
433
+ <xsl:param name="labelled" as="element()"/>
434
+ <xsl:choose>
435
+ <xsl:when test="exists($labelled/x:label)">
436
+ <xsl:sequence select="$labelled/x:label"/>
437
+ </xsl:when>
438
+ <xsl:otherwise>
439
+ <x:label><xsl:value-of select="$labelled/@label"/></x:label>
440
+ </xsl:otherwise>
441
+ </xsl:choose>
442
+ </xsl:function>
443
+
444
+ </xsl:stylesheet>
445
+
446
+
447
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
448
+ <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. -->
449
+ <!-- -->
450
+ <!-- Copyright (c) 2008, 2010 Jeni Tennsion -->
451
+ <!-- -->
452
+ <!-- The contents of this file are subject to the MIT License (see the URI -->
453
+ <!-- http://www.opensource.org/licenses/mit-license.php for details). -->
454
+ <!-- -->
455
+ <!-- Permission is hereby granted, free of charge, to any person obtaining -->
456
+ <!-- a copy of this software and associated documentation files (the -->
457
+ <!-- "Software"), to deal in the Software without restriction, including -->
458
+ <!-- without limitation the rights to use, copy, modify, merge, publish, -->
459
+ <!-- distribute, sublicense, and/or sell copies of the Software, and to -->
460
+ <!-- permit persons to whom the Software is furnished to do so, subject to -->
461
+ <!-- the following conditions: -->
462
+ <!-- -->
463
+ <!-- The above copyright notice and this permission notice shall be -->
464
+ <!-- included in all copies or substantial portions of the Software. -->
465
+ <!-- -->
466
+ <!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -->
467
+ <!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
468
+ <!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.-->
469
+ <!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -->
470
+ <!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -->
471
+ <!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -->
472
+ <!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -->
473
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->