simple-xspec-wrapper 0.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/xspec +16 -0
- data/lib/xspec/version.rb +3 -0
- data/lib/xspec.rb +256 -0
- data/simple-xspec-wrapper.gemspec +28 -0
- data/spec-test.xml +1125 -0
- data/vendor/xspec-1.0.0/.gitignore +7 -0
- data/vendor/xspec-1.0.0/.travis.yml +57 -0
- data/vendor/xspec-1.0.0/LICENSE +21 -0
- data/vendor/xspec-1.0.0/README.md +26 -0
- data/vendor/xspec-1.0.0/appveyor.yml +77 -0
- data/vendor/xspec-1.0.0/bin/xspec.bat +620 -0
- data/vendor/xspec-1.0.0/bin/xspec.sh +403 -0
- data/vendor/xspec-1.0.0/build.xml +369 -0
- data/vendor/xspec-1.0.0/editors/emacs/README +31 -0
- data/vendor/xspec-1.0.0/editors/emacs/schemas.xml +6 -0
- data/vendor/xspec-1.0.0/editors/oxygen/.cvsignore +2 -0
- data/vendor/xspec-1.0.0/editors/oxygen/README +11 -0
- data/vendor/xspec-1.0.0/editors/oxygen/build.xml +38 -0
- data/vendor/xspec-1.0.0/editors/oxygen/templates/xspec.xml +17 -0
- data/vendor/xspec-1.0.0/editors/oxygen/xspec.framework +175 -0
- data/vendor/xspec-1.0.0/find-examples.xml +37 -0
- data/vendor/xspec-1.0.0/find-examples.xsl +615 -0
- data/vendor/xspec-1.0.0/graphics/3angle-down.gif +0 -0
- data/vendor/xspec-1.0.0/graphics/3angle-right.gif +0 -0
- data/vendor/xspec-1.0.0/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class +0 -0
- data/vendor/xspec-1.0.0/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java +209 -0
- data/vendor/xspec-1.0.0/src/ant/find-test-failure.xsl +17 -0
- data/vendor/xspec-1.0.0/src/ant/get-schematron-phase.xsl +17 -0
- data/vendor/xspec-1.0.0/src/ant/locate-schematron.xsl +28 -0
- data/vendor/xspec-1.0.0/src/ant/make-path.js +4 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-common-tests.xsl +604 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-query-helper.xsl +152 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-query-tests.xsl +473 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-query-utils.xql +263 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-tests-helper.xsl +169 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-tests-utils.xsl +479 -0
- data/vendor/xspec-1.0.0/src/compiler/generate-xspec-tests.xsl +503 -0
- data/vendor/xspec-1.0.0/src/harnesses/basex/basex-standalone-xquery-harness.xproc +135 -0
- data/vendor/xspec-1.0.0/src/harnesses/basex/basex-xquery-harness.xproc +133 -0
- data/vendor/xspec-1.0.0/src/harnesses/exist/exist-xquery-harness.xproc +161 -0
- data/vendor/xspec-1.0.0/src/harnesses/harness-lib.xpl +327 -0
- data/vendor/xspec-1.0.0/src/harnesses/marklogic/ml-xquery-harness.xproc +143 -0
- data/vendor/xspec-1.0.0/src/harnesses/saxon/saxon-xquery-harness.xproc +108 -0
- data/vendor/xspec-1.0.0/src/harnesses/saxon/saxon-xslt-harness.xproc +85 -0
- data/vendor/xspec-1.0.0/src/harnesses/zorba/zorba-xquery-harness.xproc +134 -0
- data/vendor/xspec-1.0.0/src/reporter/coverage-report.xsl +378 -0
- data/vendor/xspec-1.0.0/src/reporter/format-utils.xsl +220 -0
- data/vendor/xspec-1.0.0/src/reporter/format-xspec-report-folding.xsl +164 -0
- data/vendor/xspec-1.0.0/src/reporter/format-xspec-report.xsl +410 -0
- data/vendor/xspec-1.0.0/src/reporter/junit-report.xsl +93 -0
- data/vendor/xspec-1.0.0/src/reporter/test-report.css +469 -0
- data/vendor/xspec-1.0.0/src/schemas/find-examples.rnc +90 -0
- data/vendor/xspec-1.0.0/src/schemas/xspec.rnc +304 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_abstract_expand.xsl +313 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_dsdl_include.xsl +1519 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_message.xsl +64 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_message_xslt2.xsl +64 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_skeleton_for_saxon.xsl +2306 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_schematron_skeleton_for_xslt1.xsl +1851 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_svrl_for_xslt1.xsl +614 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl +692 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/readme.txt +101 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-cs.xhtml +56 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-de.xhtml +55 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-en.xhtml +57 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-fr.xhtml +54 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-ja.xhtml +53 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/sch-messages-nl.xhtml +58 -0
- data/vendor/xspec-1.0.0/src/schematron/iso-schematron/schematron-skeleton-api.htm +723 -0
- data/vendor/xspec-1.0.0/src/schematron/sch-location-compare.xsl +139 -0
- data/vendor/xspec-1.0.0/src/schematron/schut-to-xspec.xsl +179 -0
- data/vendor/xspec-1.0.0/test/Makefile +117 -0
- data/vendor/xspec-1.0.0/test/README +5 -0
- data/vendor/xspec-1.0.0/test/catalog/xspec-160_catalog.xml +4 -0
- data/vendor/xspec-1.0.0/test/catalog/xspec-160_schematron.xspec +6 -0
- data/vendor/xspec-1.0.0/test/catalog/xspec-160_xslt.xspec +5 -0
- data/vendor/xspec-1.0.0/test/end-to-end/README.md +42 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/.gitignore +1 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/.gitignore +3 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-50-result-norm.html +74 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-55-result-norm.html +112 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-focus-1-result-norm.html +109 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-function-result-norm.html +118 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-import-result-norm.html +163 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-imported-result-norm.html +95 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-pending-result-norm.html +123 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-rule-result-norm.html +109 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/expected/xspec-three-dots-result-norm.html +1237 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-50.xsl +7 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-50.xspec +10 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-55.xsl +2 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-55.xspec +18 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-focus-1.xspec +71 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-function.xspec +50 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-import.xspec +50 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-imported.xspec +48 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-pending.xspec +89 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-rule.xspec +76 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-three-dots.xsl +49 -0
- data/vendor/xspec-1.0.0/test/end-to-end/cases/xspec-three-dots.xspec +527 -0
- data/vendor/xspec-1.0.0/test/end-to-end/generate-expected.cmd +51 -0
- data/vendor/xspec-1.0.0/test/end-to-end/generate-expected.sh +25 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/_deserializer.xsl +53 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/_normalizer.xsl +192 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/_serializer.xsl +15 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/_util.xsl +35 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/compare.xsl +88 -0
- data/vendor/xspec-1.0.0/test/end-to-end/processor/normalize.xsl +28 -0
- data/vendor/xspec-1.0.0/test/end-to-end/run-e2e-tests.cmd +61 -0
- data/vendor/xspec-1.0.0/test/end-to-end/run-e2e-tests.sh +28 -0
- data/vendor/xspec-1.0.0/test/generate-tests-utils.xspec +636 -0
- data/vendor/xspec-1.0.0/test/generate-x-utils.xspec +173 -0
- data/vendor/xspec-1.0.0/test/generate-xspec-tests.xspec +64 -0
- data/vendor/xspec-1.0.0/test/run-xspec-tests.cmd +83 -0
- data/vendor/xspec-1.0.0/test/run-xspec-tests.sh +42 -0
- data/vendor/xspec-1.0.0/test/sch-location-compare.xspec +179 -0
- data/vendor/xspec-1.0.0/test/schematron/data/standards.xml +7 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-017.sch +9 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-018.sch +17 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-019.sch +13 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-020-01.sch +35 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-020.sch +32 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-021.sch +28 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-022.sch +18 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-compile.xsl +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-expand.xsl +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schematron-xslt-include.xsl +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-001-in.xspec +5 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-001-out.xspec +7 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002-in.xspec +5 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002-out.xspec +7 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-002.sch +4 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-003-in.xspec +7 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-003-out.xspec +9 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-004-in.xspec +20 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-004-out.xspec +22 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-005-in.xspec +6 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-005-out.xspec +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-006-in.xspec +11 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-006-out.xspec +13 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007-in.xspec +7 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007-out.xspec +9 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-007.xml +2 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-008-in.xspec +9 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-008-out.xspec +9 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-import-in.xspec +5 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-in.xspec +6 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-009-out.xspec +10 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-import.xspec +5 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-in.xspec +6 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-010-out.xspec +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-011-in.xspec +6 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-011-out.xspec +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-01.xml +4 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-02.xml +13 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-012-out.xspec +81 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-013-in.xspec +6 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-013-out.xspec +8 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-test.sch +4 -0
- data/vendor/xspec-1.0.0/test/schematron/schut-to-xspec-test.sch.xsl +4 -0
- data/vendor/xspec-1.0.0/test/schematron-01.sch +17 -0
- data/vendor/xspec-1.0.0/test/schematron-01.xml +14 -0
- data/vendor/xspec-1.0.0/test/schematron-01.xspec +14 -0
- data/vendor/xspec-1.0.0/test/schematron-012.xspec +83 -0
- data/vendor/xspec-1.0.0/test/schematron-014-01.xml +10 -0
- data/vendor/xspec-1.0.0/test/schematron-014.sch +16 -0
- data/vendor/xspec-1.0.0/test/schematron-014.xspec +11 -0
- data/vendor/xspec-1.0.0/test/schematron-015.sch +16 -0
- data/vendor/xspec-1.0.0/test/schematron-015.xspec +11 -0
- data/vendor/xspec-1.0.0/test/schematron-016.sch +19 -0
- data/vendor/xspec-1.0.0/test/schematron-016.xspec +171 -0
- data/vendor/xspec-1.0.0/test/schematron-017.xspec +26 -0
- data/vendor/xspec-1.0.0/test/schematron-018.xspec +120 -0
- data/vendor/xspec-1.0.0/test/schematron-019.xspec +16 -0
- data/vendor/xspec-1.0.0/test/schematron-020.xspec +53 -0
- data/vendor/xspec-1.0.0/test/schematron-021.xspec +27 -0
- data/vendor/xspec-1.0.0/test/schematron-022.xspec +15 -0
- data/vendor/xspec-1.0.0/test/schematron-param-001.xspec +50 -0
- data/vendor/xspec-1.0.0/test/schut-to-xspec-012.sch +27 -0
- data/vendor/xspec-1.0.0/test/schut-to-xspec.xspec +85 -0
- data/vendor/xspec-1.0.0/test/unit-expect-xsl.xspec +28 -0
- data/vendor/xspec-1.0.0/test/xspec-26.xsl +19 -0
- data/vendor/xspec-1.0.0/test/xspec-26.xspec +17 -0
- data/vendor/xspec-1.0.0/test/xspec-30.xml +2 -0
- data/vendor/xspec-1.0.0/test/xspec-30.xsl +6 -0
- data/vendor/xspec-1.0.0/test/xspec-30.xspec +8 -0
- data/vendor/xspec-1.0.0/test/xspec-33.xsl +7 -0
- data/vendor/xspec-1.0.0/test/xspec-33.xspec +15 -0
- data/vendor/xspec-1.0.0/test/xspec-46.xsl +7 -0
- data/vendor/xspec-1.0.0/test/xspec-46.xspec +9 -0
- data/vendor/xspec-1.0.0/test/xspec-72.xsl +13 -0
- data/vendor/xspec-1.0.0/test/xspec-72.xspec +19 -0
- data/vendor/xspec-1.0.0/test/xspec-bat.cmd +757 -0
- data/vendor/xspec-1.0.0/test/xspec-focus-2.xspec +91 -0
- data/vendor/xspec-1.0.0/test/xspec-junit.xspec +78 -0
- data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xml +1003 -0
- data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xslt +10 -0
- data/vendor/xspec-1.0.0/test/xspec-result-naming-collision.xspec +13 -0
- data/vendor/xspec-1.0.0/test/xspec-tested.xql +44 -0
- data/vendor/xspec-1.0.0/test/xspec-tested.xsl +64 -0
- data/vendor/xspec-1.0.0/test/xspec-variable.xml +3 -0
- data/vendor/xspec-1.0.0/test/xspec-variable.xspec +58 -0
- data/vendor/xspec-1.0.0/test/xspec-xslt3.xsl +13 -0
- data/vendor/xspec-1.0.0/test/xspec-xslt3.xspec +12 -0
- data/vendor/xspec-1.0.0/test/xspec.bats +420 -0
- data/vendor/xspec-1.0.0/tutorial/escape-for-regex.xslt +40 -0
- data/vendor/xspec-1.0.0/tutorial/escape-for-regex.xspec +75 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.sch +17 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.xml +11 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-01.xspec +14 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-PhaseA.xspec +11 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-PhaseB.xspec +12 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import1.xspec +10 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import2.xspec +8 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02-import3.xspec +10 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02.sch +58 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-02.xml +19 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-03-doc1.xml +6 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-03-doc2.xml +7 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-03.sch +29 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-03.xspec +63 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-04.sch +20 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/demo-04.xspec +33 -0
- data/vendor/xspec-1.0.0/tutorial/schematron/quickfix.sch +81 -0
- data/vendor/xspec-1.0.0/tutorial/xquery-tutorial.xq +8 -0
- data/vendor/xspec-1.0.0/tutorial/xquery-tutorial.xspec +16 -0
- data/vendor/xspec-1.0.0/xproject/project.xml +8 -0
- data/vendor/xspec-1.0.0/xproject/release-project.xsl +41 -0
- 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> </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>"; </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>" at "</xsl:text>
|
87
|
+
<xsl:value-of select="$query-at"/>
|
88
|
+
</xsl:if>
|
89
|
+
<xsl:text>"; </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> at "</xsl:text>
|
96
|
+
<xsl:value-of select="$utils-library-at"/>
|
97
|
+
<xsl:text>"</xsl:text>
|
98
|
+
</xsl:if>
|
99
|
+
<xsl:text>; </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> </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> { </xsl:text>
|
117
|
+
<!-- Generate calls to the compiled top-level scenarios. -->
|
118
|
+
<xsl:call-template name="x:call-scenarios"/>
|
119
|
+
<xsl:text> } </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>, </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 ( </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> </xsl:text>
|
152
|
+
<!-- Continue compiling calls. -->
|
153
|
+
<xsl:call-template name="x:continue-call-scenarios"/>
|
154
|
+
<xsl:text> ) </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> 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>) { </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> { </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>) </xsl:text>
|
233
|
+
<xsl:text> return ( </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'), </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 := () </xsl:text>
|
248
|
+
<xsl:text> return ( </xsl:text>
|
249
|
+
</xsl:otherwise>
|
250
|
+
</xsl:choose>
|
251
|
+
<xsl:call-template name="x:call-scenarios"/>
|
252
|
+
<xsl:text> ) </xsl:text>
|
253
|
+
<xsl:text>} </xsl:text>
|
254
|
+
</x:scenario>
|
255
|
+
<xsl:text> }; </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> 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>) { </xsl:text>
|
286
|
+
<xsl:if test="not($pending-p)">
|
287
|
+
<!--
|
288
|
+
let $local:expected :=
|
289
|
+
( ... )
|
290
|
+
-->
|
291
|
+
<xsl:text> let $local:expected := (: expected result :) </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> ) </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 :) </xsl:text>
|
309
|
+
<xsl:text> if ( $</xsl:text>
|
310
|
+
<xsl:value-of select="$xspec-prefix"/>
|
311
|
+
<xsl:text>:result instance of node()+ ) then </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> ) </xsl:text>
|
317
|
+
<xsl:text> else </xsl:text>
|
318
|
+
<xsl:text> ( </xsl:text>
|
319
|
+
<xsl:value-of select="@test"/>
|
320
|
+
<xsl:text> ) </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?:) </xsl:text>
|
329
|
+
<xsl:text> if ( $local:test-result instance of xs:boolean ) then </xsl:text>
|
330
|
+
<xsl:text> $local:test-result </xsl:text>
|
331
|
+
<xsl:text> else </xsl:text>
|
332
|
+
<xsl:text> test:deep-equal($local:expected, $local:test-result) </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?:) </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>) </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> ) </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) </xsl:text>
|
358
|
+
</xsl:otherwise>
|
359
|
+
</xsl:choose>
|
360
|
+
<xsl:text> return </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> { 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> { 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> }; </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
|
+
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|