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,1519 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><?xar XSLT?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
OVERVIEW : iso_dsdl_include.xsl
|
5
|
+
|
6
|
+
This is an inclusion preprocessor for the non-smart text inclusions
|
7
|
+
of ISO DSDL. It handles
|
8
|
+
<relax:extRef> for ISO RELAX NG
|
9
|
+
<sch:include> for ISO Schematron and Schematron 1.n
|
10
|
+
<sch:extends> for 2009 draft ISO Schematron
|
11
|
+
<xi:xinclude> simple W3C XIncludes for ISO NVRL and DSRL
|
12
|
+
<crdl:ref> for draft ISO CRDL
|
13
|
+
<dtll:include> for draft ISO DTLL
|
14
|
+
<* @xlink:href> for simple W3C XLink 1.1 embedded links
|
15
|
+
|
16
|
+
|
17
|
+
This should be the first in any chain of processing. It only requires
|
18
|
+
XSLT 1. Each kind of inclusion can be turned off (or on) on the command line.
|
19
|
+
|
20
|
+
Ids in fragment identifiers or xpointers will be sought in the following
|
21
|
+
order:
|
22
|
+
* @xml:id
|
23
|
+
* id() for typed schemas (e.g. from DTD) [NOTE: XInclude does not support this]
|
24
|
+
* untyped @id
|
25
|
+
|
26
|
+
The proposed behaviour for the update to ISO Schematron has been implemented. If an
|
27
|
+
include points to an element with the same name as the parent, then that element's
|
28
|
+
contents will be included. This supports the merge style of inclusion.
|
29
|
+
|
30
|
+
When an inclusion is made, it is preceded by a PI with target DSDL_INCLUDE_START
|
31
|
+
and the href and closed by a PI with target DSDL_INCLUDE_START and the href. This is
|
32
|
+
to allow better location of problems, though only to the file level.
|
33
|
+
|
34
|
+
Limitations:
|
35
|
+
* No rebasing: relative paths will be interpreted based on the initial document's
|
36
|
+
path, not the including document. (Severe limitation!)
|
37
|
+
* No checking for circular references
|
38
|
+
* Not full xpointers: only ID matching
|
39
|
+
* <relax:include> not implemented
|
40
|
+
* XInclude handling of xml:base and xml:lang not implemented
|
41
|
+
-->
|
42
|
+
<!--
|
43
|
+
Open Source Initiative OSI - The MIT License:Licensing
|
44
|
+
[OSI Approved License]
|
45
|
+
|
46
|
+
This source code was previously available under the zlib/libpng license.
|
47
|
+
Attribution is polite.
|
48
|
+
|
49
|
+
The MIT License
|
50
|
+
|
51
|
+
Copyright (c) 2008-2010 Rick Jelliffe
|
52
|
+
|
53
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
54
|
+
of this software and associated documentation files (the "Software"), to deal
|
55
|
+
in the Software without restriction, including without limitation the rights
|
56
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
57
|
+
copies of the Software, and to permit persons to whom the Software is
|
58
|
+
furnished to do so, subject to the following conditions:
|
59
|
+
|
60
|
+
The above copyright notice and this permission notice shall be included in
|
61
|
+
all copies or substantial portions of the Software.
|
62
|
+
|
63
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
64
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
65
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
66
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
67
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
68
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
69
|
+
THE SOFTWARE.
|
70
|
+
-->
|
71
|
+
|
72
|
+
<!--
|
73
|
+
VERSION INFORMATION
|
74
|
+
2010-07-10
|
75
|
+
* Move to MIT license
|
76
|
+
2010-04-21
|
77
|
+
* Add basic syntax checks on XPaths belonging to Schematron elements only
|
78
|
+
* Unlocalized messages are put out using xsl:message. The intent is to allow
|
79
|
+
* problems to be caught at compile time.
|
80
|
+
2009-02-25
|
81
|
+
* Update DSDL namespace to use schematron.com
|
82
|
+
* Tested with SAXON9, Xalan 2.7.1, IE7,
|
83
|
+
* IE does not like multiple variables in same template with same name: rename.
|
84
|
+
2008-09-18
|
85
|
+
* Remove new behaviour for include, because it conflicts with existing usage [KH]
|
86
|
+
* Add extends[@href] element with that merge functionality
|
87
|
+
* Generate PIs to notate source of inclusions for potential better diagnostics
|
88
|
+
|
89
|
+
2008-09-16
|
90
|
+
* Fix for XSLT1
|
91
|
+
|
92
|
+
2008-08-28
|
93
|
+
* New behaviour for schematron includes: if the pointed to element is the same as the current,
|
94
|
+
include the children. [Note: this has been removed: use sch:extends with @href.]
|
95
|
+
|
96
|
+
2008-08-20
|
97
|
+
* Fix bug: in XSLT1 cannot do $document/id('x') but need to use for-each
|
98
|
+
|
99
|
+
2008-08-04
|
100
|
+
* Add support for inclusions in old namespace
|
101
|
+
|
102
|
+
2008-08-03
|
103
|
+
* Fix wrong param name include-relaxng & include-crdl (KH, PH)
|
104
|
+
* Allow inclusion of XSLT and XHTML (KH)
|
105
|
+
* Fix inclusion of fragments (KH)
|
106
|
+
|
107
|
+
2008-07-25
|
108
|
+
* Add selectable input parameter
|
109
|
+
|
110
|
+
2008-07-24
|
111
|
+
* RJ New
|
112
|
+
-->
|
113
|
+
|
114
|
+
<xslt:stylesheet version="1.0"
|
115
|
+
xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
|
116
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
117
|
+
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
|
118
|
+
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
|
119
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
120
|
+
xmlns:schold="http://www.ascc.net/xml/schematron"
|
121
|
+
xmlns:crdl="http://purl.oclc.org/dsdl/crepdl/ns/structure/1.0"
|
122
|
+
xmlns:xi="http://www.w3.org/2001/XInclude"
|
123
|
+
xmlns:dtll="http://www.jenitennison.com/datatypes"
|
124
|
+
xmlns:dsdl="http://www.schematron.com/namespace/dsdl"
|
125
|
+
xmlns:relax="http://relaxng.org/ns/structure/1.0"
|
126
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
127
|
+
|
128
|
+
|
129
|
+
xmlns:sch-check="http://www.schematron.com/namespace/sch-check"
|
130
|
+
>
|
131
|
+
<!-- Note: The URL for the dsdl namespace is not official -->
|
132
|
+
|
133
|
+
|
134
|
+
<xsl:param name="include-schematron">true</xsl:param>
|
135
|
+
<xsl:param name="include-crdl">true</xsl:param>
|
136
|
+
<xsl:param name="include-xinclude">true</xsl:param>
|
137
|
+
<xsl:param name="include-dtll">true</xsl:param>
|
138
|
+
<xsl:param name="include-relaxng">true</xsl:param>
|
139
|
+
<xsl:param name="include-xlink">true</xsl:param>
|
140
|
+
|
141
|
+
|
142
|
+
<!-- ========================================================== -->
|
143
|
+
<!-- Output and process contents, check Schematron XPaths too -->
|
144
|
+
<!-- ========================================================== -->
|
145
|
+
|
146
|
+
<xsl:template match="/">
|
147
|
+
<xsl:apply-templates select="." mode="dsdl:go" />
|
148
|
+
</xsl:template>
|
149
|
+
|
150
|
+
<!-- output everything else unchanged. But check Xpaths here. -->
|
151
|
+
|
152
|
+
<xslt:template match="iso:rule[@context]" mode="dsdl:go">
|
153
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
154
|
+
<xsl:with-param name="string" select=" @context " />
|
155
|
+
<xsl:with-param name="subject" select=" 'Bad rule: ' " />
|
156
|
+
</xsl:call-template>
|
157
|
+
|
158
|
+
<xslt:copy>
|
159
|
+
<xslt:copy-of select="@*" />
|
160
|
+
<xslt:apply-templates mode="dsdl:go" />
|
161
|
+
</xslt:copy>
|
162
|
+
</xslt:template>
|
163
|
+
|
164
|
+
<xslt:template match="iso:assert[@test]" mode="dsdl:go">
|
165
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
166
|
+
<xsl:with-param name="string" select=" @test " />
|
167
|
+
<xsl:with-param name="subject" select=" 'Bad assert: ' " />
|
168
|
+
</xsl:call-template>
|
169
|
+
|
170
|
+
<xslt:copy>
|
171
|
+
<xslt:copy-of select="@*" />
|
172
|
+
<xslt:apply-templates mode="dsdl:go" />
|
173
|
+
</xslt:copy>
|
174
|
+
</xslt:template>
|
175
|
+
|
176
|
+
<xslt:template match="iso:report[@test]" mode="dsdl:go">
|
177
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
178
|
+
<xsl:with-param name="string" select=" @test " />
|
179
|
+
<xsl:with-param name="subject" select=" 'Bad report: ' " />
|
180
|
+
</xsl:call-template>
|
181
|
+
|
182
|
+
<xslt:copy>
|
183
|
+
<xslt:copy-of select="@*" />
|
184
|
+
<xslt:apply-templates mode="dsdl:go" />
|
185
|
+
</xslt:copy>
|
186
|
+
</xslt:template>
|
187
|
+
|
188
|
+
<xslt:template match="iso:let[@value]" mode="dsdl:go">
|
189
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
190
|
+
<xsl:with-param name="string" select=" @value " />
|
191
|
+
<xsl:with-param name="subject" select=" 'Bad let: ' " />
|
192
|
+
</xsl:call-template>
|
193
|
+
|
194
|
+
<xslt:copy>
|
195
|
+
<xslt:copy-of select="@*" />
|
196
|
+
<xslt:apply-templates mode="dsdl:go" />
|
197
|
+
</xslt:copy>
|
198
|
+
</xslt:template>
|
199
|
+
|
200
|
+
|
201
|
+
<xslt:template match="iso:value-of[@select]" mode="dsdl:go">
|
202
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
203
|
+
<xsl:with-param name="string" select=" @select " />
|
204
|
+
<xsl:with-param name="subject" select=" 'Bad value-of: ' " />
|
205
|
+
</xsl:call-template>
|
206
|
+
|
207
|
+
<xslt:copy>
|
208
|
+
<xslt:copy-of select="@*" />
|
209
|
+
<xslt:apply-templates mode="dsdl:go" />
|
210
|
+
</xslt:copy>
|
211
|
+
</xslt:template>
|
212
|
+
|
213
|
+
<xslt:template match="iso:name[@path]" mode="dsdl:go">
|
214
|
+
<xsl:call-template name="sch-check:xpath-wf-message">
|
215
|
+
<xsl:with-param name="string" select=" @select " />
|
216
|
+
<xsl:with-param name="subject" select=" 'Bad name element: ' " />
|
217
|
+
</xsl:call-template>
|
218
|
+
|
219
|
+
<xslt:copy>
|
220
|
+
<xslt:copy-of select="@*" />
|
221
|
+
<xslt:apply-templates mode="dsdl:go" />
|
222
|
+
</xslt:copy>
|
223
|
+
</xslt:template>
|
224
|
+
|
225
|
+
<!-- output everything else unchanged -->
|
226
|
+
<xslt:template match="node()" priority="-1" mode="dsdl:go">
|
227
|
+
<xslt:copy>
|
228
|
+
<xslt:copy-of select="@*" />
|
229
|
+
<xslt:apply-templates mode="dsdl:go" />
|
230
|
+
</xslt:copy>
|
231
|
+
</xslt:template>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<!-- =========================================================== -->
|
236
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
237
|
+
<!-- Part 2 - Regular grammar-based validation - RELAX NG -->
|
238
|
+
<!-- This only implements relax:extRef not relax:include which -->
|
239
|
+
<!-- is complex. -->
|
240
|
+
<!-- =========================================================== -->
|
241
|
+
<xslt:template match="relax:extRef" mode="dsdl:go">
|
242
|
+
|
243
|
+
|
244
|
+
<!-- Insert subschema -->
|
245
|
+
|
246
|
+
<xsl:variable name="document-uri"
|
247
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
248
|
+
<xsl:variable name="fragment-id"
|
249
|
+
select="substring-after(@href, '#')" />
|
250
|
+
|
251
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
252
|
+
<xsl:value-of select="@href" />
|
253
|
+
</xsl:processing-instruction>
|
254
|
+
<xsl:choose>
|
255
|
+
<xsl:when test="not( $include-relaxng = 'true' )">
|
256
|
+
<xslt:copy>
|
257
|
+
<xslt:copy-of select="@*" />
|
258
|
+
<xslt:apply-templates mode="dsdl:go" />
|
259
|
+
</xslt:copy>
|
260
|
+
</xsl:when>
|
261
|
+
<xsl:otherwise>
|
262
|
+
|
263
|
+
<xsl:choose>
|
264
|
+
|
265
|
+
<xsl:when
|
266
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
267
|
+
<xsl:message>
|
268
|
+
Error: Impossible URL in RELAX NG extRef
|
269
|
+
include
|
270
|
+
</xsl:message>
|
271
|
+
</xsl:when>
|
272
|
+
|
273
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
274
|
+
<xslt:when
|
275
|
+
test="string-length( $document-uri ) = 0">
|
276
|
+
<xslt:apply-templates mode="dsdl:go"
|
277
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id) | //*[@id= $fragment-id ]" />
|
278
|
+
</xslt:when>
|
279
|
+
|
280
|
+
<xsl:when
|
281
|
+
test="string-length( $fragment-id ) > 0">
|
282
|
+
<xsl:variable name="theDocument_1"
|
283
|
+
select="document( $document-uri,/ )" />
|
284
|
+
|
285
|
+
<xsl:if test="not($theDocument_1)">
|
286
|
+
<xsl:message terminate="no">
|
287
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
288
|
+
<xsl:value-of select="@href" />
|
289
|
+
</xsl:message>
|
290
|
+
</xsl:if>
|
291
|
+
<!-- use a for-each so that the id() function works correctly on the external document -->
|
292
|
+
<xsl:for-each select="$theDocument_1">
|
293
|
+
<xsl:variable name="theFragment_1"
|
294
|
+
select="$theDocument_1//*[@xml:id= $fragment-id ]
|
295
|
+
| id( $fragment-id)
|
296
|
+
| $theDocument_1//*[@id= $fragment-id ]" />
|
297
|
+
<xsl:if test="not($theFragment_1)">
|
298
|
+
<xsl:message terminate="no">
|
299
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
300
|
+
<xsl:value-of select="@href" />
|
301
|
+
</xsl:message>
|
302
|
+
</xsl:if>
|
303
|
+
<xsl:apply-templates
|
304
|
+
select=" $theFragment_1[1]" mode="dsdl:go" />
|
305
|
+
</xsl:for-each>
|
306
|
+
</xsl:when>
|
307
|
+
|
308
|
+
<xsl:otherwise>
|
309
|
+
<xsl:variable name="theDocument_2"
|
310
|
+
select="document( $document-uri,/ )" />
|
311
|
+
<xsl:variable name="theFragment_2"
|
312
|
+
select="$theDocument_2/*" />
|
313
|
+
<xsl:if test="not($theDocument_2)">
|
314
|
+
<xsl:message terminate="no">
|
315
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
316
|
+
<xsl:value-of select="@href" />
|
317
|
+
</xsl:message>
|
318
|
+
</xsl:if>
|
319
|
+
|
320
|
+
<xsl:if test="not($theFragment_2)">
|
321
|
+
<xsl:message terminate="no">
|
322
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
323
|
+
<xsl:value-of select="@href" />
|
324
|
+
</xsl:message>
|
325
|
+
</xsl:if>
|
326
|
+
<xsl:apply-templates select="$theFragment_2 "
|
327
|
+
mode="dsdl:go" />
|
328
|
+
</xsl:otherwise>
|
329
|
+
</xsl:choose>
|
330
|
+
|
331
|
+
</xsl:otherwise>
|
332
|
+
</xsl:choose>
|
333
|
+
|
334
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
335
|
+
<xsl:value-of select="@href" />
|
336
|
+
</xsl:processing-instruction>
|
337
|
+
</xslt:template>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
<!-- =========================================================== -->
|
342
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
343
|
+
<!-- Part 3 - Rule-based validation - Schematron -->
|
344
|
+
<!-- =========================================================== -->
|
345
|
+
|
346
|
+
|
347
|
+
<!-- Extend the URI syntax to allow # references -->
|
348
|
+
<!-- Add experimental support for simple containers like /xxx:xxx/iso:pattern to allow better includes -->
|
349
|
+
<xsl:template match="iso:include" mode="dsdl:go">
|
350
|
+
|
351
|
+
<xsl:variable name="document-uri"
|
352
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
353
|
+
<xsl:variable name="fragment-id"
|
354
|
+
select="substring-after(@href, '#')" />
|
355
|
+
|
356
|
+
|
357
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
358
|
+
<xsl:value-of select="@href" />
|
359
|
+
</xsl:processing-instruction>
|
360
|
+
|
361
|
+
<xsl:choose>
|
362
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
363
|
+
<xslt:copy>
|
364
|
+
<xslt:copy-of select="@*" />
|
365
|
+
<xslt:apply-templates mode="dsdl:go" />
|
366
|
+
</xslt:copy>
|
367
|
+
</xsl:when>
|
368
|
+
<xsl:otherwise>
|
369
|
+
|
370
|
+
<xsl:choose>
|
371
|
+
|
372
|
+
<xsl:when
|
373
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
374
|
+
<xsl:message>
|
375
|
+
Error: Impossible URL in Schematron include
|
376
|
+
</xsl:message>
|
377
|
+
</xsl:when>
|
378
|
+
|
379
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
380
|
+
<xslt:when
|
381
|
+
test="string-length( $document-uri ) = 0">
|
382
|
+
<xslt:apply-templates mode="dsdl:go"
|
383
|
+
select="//iso:*[@xml:id= $fragment-id ]
|
384
|
+
|id( $fragment-id)
|
385
|
+
| //iso:*[@id= $fragment-id ]" />
|
386
|
+
</xslt:when>
|
387
|
+
|
388
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
389
|
+
<!-- There are three cases for includes with fragment:
|
390
|
+
0) No href file or no matching id - error!
|
391
|
+
1) REMOVED
|
392
|
+
|
393
|
+
2) The linked-to element is sch:schema however the parent of the include
|
394
|
+
is not a schema. In this case, it is an error. (Actually, it should
|
395
|
+
be an error for other kinds of containment problems, but we won't
|
396
|
+
check for them in this version.)
|
397
|
+
|
398
|
+
3) Otherwise, include the pointed-to element
|
399
|
+
-->
|
400
|
+
|
401
|
+
<xsl:when
|
402
|
+
test="string-length( $fragment-id ) > 0">
|
403
|
+
<xsl:variable name="theDocument_1"
|
404
|
+
select="document( $document-uri,/ )" />
|
405
|
+
<xsl:variable name="originalParent" select=".." />
|
406
|
+
|
407
|
+
<!-- case 0 -->
|
408
|
+
<xsl:if test="not($theDocument_1)">
|
409
|
+
<xsl:message terminate="no">
|
410
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
411
|
+
<xsl:value-of select="@href" />
|
412
|
+
</xsl:message>
|
413
|
+
</xsl:if>
|
414
|
+
<!-- use for-each to rebase id() to external document -->
|
415
|
+
<xsl:for-each select="$theDocument_1">
|
416
|
+
<xsl:variable name="theFragment_1"
|
417
|
+
select=" $theDocument_1//iso:*[@xml:id= $fragment-id ] |
|
418
|
+
id($fragment-id) |
|
419
|
+
$theDocument_1//iso:*[@id= $fragment-id ]" />
|
420
|
+
|
421
|
+
|
422
|
+
<xsl:choose>
|
423
|
+
<!-- case 0 -->
|
424
|
+
<xsl:when test="not($theFragment_1)">
|
425
|
+
<xsl:message terminate="no">
|
426
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
427
|
+
<xsl:value-of select="@href" />
|
428
|
+
</xsl:message>
|
429
|
+
</xsl:when>
|
430
|
+
|
431
|
+
|
432
|
+
<!-- case 1 REMOVED -->
|
433
|
+
|
434
|
+
<!-- case 2 -->
|
435
|
+
<xsl:when
|
436
|
+
test=" $theFragment_1/self::iso:schema ">
|
437
|
+
<xsl:message>
|
438
|
+
Schema error: Use include to
|
439
|
+
include fragments, not a whole
|
440
|
+
schema
|
441
|
+
</xsl:message>
|
442
|
+
</xsl:when>
|
443
|
+
|
444
|
+
<!-- case 3 -->
|
445
|
+
<xsl:otherwise>
|
446
|
+
<xsl:apply-templates
|
447
|
+
select=" $theFragment_1[1]" mode="dsdl:go" />
|
448
|
+
</xsl:otherwise>
|
449
|
+
</xsl:choose>
|
450
|
+
</xsl:for-each>
|
451
|
+
</xsl:when>
|
452
|
+
|
453
|
+
<!-- Case where there is no ID so we include the whole document -->
|
454
|
+
<!-- Experimental addition: include fragments of children -->
|
455
|
+
<xsl:otherwise>
|
456
|
+
<xsl:variable name="theDocument_2"
|
457
|
+
select="document( $document-uri,/ )" />
|
458
|
+
<xsl:variable name="theFragment_2"
|
459
|
+
select="$theDocument_2/iso:*" />
|
460
|
+
<xsl:variable name="theContainedFragments"
|
461
|
+
select="$theDocument_2/*/iso:* | $theDocument_2/*/xsl:* | $theDocument_2/*/xhtml:*" />
|
462
|
+
<xsl:if test="not($theDocument_2)">
|
463
|
+
<xsl:message terminate="no">
|
464
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
465
|
+
<xsl:value-of select="@href" />
|
466
|
+
</xsl:message>
|
467
|
+
</xsl:if>
|
468
|
+
|
469
|
+
<!-- There are three cases for includes:
|
470
|
+
0) No text specified- error!
|
471
|
+
|
472
|
+
1) REMOVED
|
473
|
+
|
474
|
+
2) The linked-to element is sch:schema however the parent of the include
|
475
|
+
is not a schema. In this case, it is an error. (Actually, it should
|
476
|
+
be an error for other kinds of containment problems, but we won't
|
477
|
+
check for them in this version.)
|
478
|
+
|
479
|
+
3) Otherwise, include the pointed-to element
|
480
|
+
-->
|
481
|
+
<xsl:choose>
|
482
|
+
<!-- case 0 -->
|
483
|
+
<xsl:when
|
484
|
+
test="not($theFragment_2) and not ($theContainedFragments)">
|
485
|
+
<xsl:message terminate="no">
|
486
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
487
|
+
<xsl:value-of select="@href" />
|
488
|
+
</xsl:message>
|
489
|
+
</xsl:when>
|
490
|
+
|
491
|
+
<!-- case 1 removed -->
|
492
|
+
|
493
|
+
<!-- case 2 -->
|
494
|
+
<xsl:when
|
495
|
+
test=" $theFragment_2/self::iso:schema or $theContainedFragments/self::iso:schema">
|
496
|
+
<xsl:message>
|
497
|
+
Schema error: Use include to include
|
498
|
+
fragments, not a whole schema
|
499
|
+
</xsl:message>
|
500
|
+
</xsl:when>
|
501
|
+
|
502
|
+
<!-- If this were XLST 2, we could use
|
503
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
504
|
+
here (thanks to KN)
|
505
|
+
-->
|
506
|
+
<!-- case 3 -->
|
507
|
+
<xsl:otherwise>
|
508
|
+
<xsl:apply-templates
|
509
|
+
select="$theFragment_2 " mode="dsdl:go" />
|
510
|
+
</xsl:otherwise>
|
511
|
+
</xsl:choose>
|
512
|
+
</xsl:otherwise>
|
513
|
+
</xsl:choose>
|
514
|
+
</xsl:otherwise>
|
515
|
+
</xsl:choose>
|
516
|
+
|
517
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
518
|
+
<xsl:value-of select="@href" />
|
519
|
+
</xsl:processing-instruction>
|
520
|
+
</xsl:template>
|
521
|
+
|
522
|
+
|
523
|
+
<!-- WARNING sch:extends[@href] is experimental and non standard -->
|
524
|
+
<!-- Basically, it adds the children of the selected element, not the element itself. -->
|
525
|
+
<xsl:template match="iso:extends[@href]" mode="dsdl:go">
|
526
|
+
|
527
|
+
<xsl:variable name="document-uri"
|
528
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
529
|
+
<xsl:variable name="fragment-id"
|
530
|
+
select="substring-after(@href, '#')" />
|
531
|
+
|
532
|
+
|
533
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
534
|
+
<xsl:value-of select="@href" />
|
535
|
+
</xsl:processing-instruction>
|
536
|
+
|
537
|
+
<xsl:choose>
|
538
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
539
|
+
<xslt:copy>
|
540
|
+
<xslt:copy-of select="@*" />
|
541
|
+
<xslt:apply-templates mode="dsdl:go" />
|
542
|
+
</xslt:copy>
|
543
|
+
</xsl:when>
|
544
|
+
<xsl:otherwise>
|
545
|
+
|
546
|
+
<xsl:choose>
|
547
|
+
|
548
|
+
<xsl:when
|
549
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
550
|
+
<xsl:message>
|
551
|
+
Error: Impossible URL in Schematron include
|
552
|
+
</xsl:message>
|
553
|
+
</xsl:when>
|
554
|
+
|
555
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
556
|
+
<xslt:when
|
557
|
+
test="string-length( $document-uri ) = 0">
|
558
|
+
<xslt:apply-templates mode="dsdl:go"
|
559
|
+
select="//iso:*[@xml:id= $fragment-id ]/*
|
560
|
+
|id( $fragment-id)/*
|
561
|
+
| //iso:*[@id= $fragment-id ]/*" />
|
562
|
+
</xslt:when>
|
563
|
+
|
564
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
565
|
+
<!-- There are three cases for includes with fragment:
|
566
|
+
0) No href file or no matching id - error!
|
567
|
+
1) REMOVED
|
568
|
+
|
569
|
+
2) REMOVED
|
570
|
+
|
571
|
+
3) Otherwise, include the pointed-to element
|
572
|
+
-->
|
573
|
+
|
574
|
+
<xsl:when
|
575
|
+
test="string-length( $fragment-id ) > 0">
|
576
|
+
<xsl:variable name="theDocument_1"
|
577
|
+
select="document( $document-uri,/ )" />
|
578
|
+
<xsl:variable name="originalParent" select=".." />
|
579
|
+
|
580
|
+
<!-- case 0 -->
|
581
|
+
<xsl:if test="not($theDocument_1)">
|
582
|
+
<xsl:message terminate="no">
|
583
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
584
|
+
<xsl:value-of select="@href" />
|
585
|
+
</xsl:message>
|
586
|
+
</xsl:if>
|
587
|
+
<!-- use for-each to rebase id() to external document -->
|
588
|
+
<xsl:for-each select="$theDocument_1">
|
589
|
+
<xsl:variable name="theFragment_1"
|
590
|
+
select=" $theDocument_1//iso:*[@xml:id= $fragment-id ] |
|
591
|
+
id($fragment-id) |
|
592
|
+
$theDocument_1//iso:*[@id= $fragment-id ]" />
|
593
|
+
|
594
|
+
|
595
|
+
<xsl:choose>
|
596
|
+
<!-- case 0 -->
|
597
|
+
<xsl:when test="not($theFragment_1)">
|
598
|
+
<xsl:message terminate="no">
|
599
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
600
|
+
<xsl:value-of select="@href" />
|
601
|
+
</xsl:message>
|
602
|
+
</xsl:when>
|
603
|
+
|
604
|
+
|
605
|
+
<!-- case 1 REMOVED -->
|
606
|
+
|
607
|
+
<!-- case 2 REMOVED -->
|
608
|
+
|
609
|
+
|
610
|
+
<!-- case 3 -->
|
611
|
+
<xsl:otherwise>
|
612
|
+
|
613
|
+
<xsl:apply-templates
|
614
|
+
select=" $theFragment_1[1]/*" mode="dsdl:go" />
|
615
|
+
</xsl:otherwise>
|
616
|
+
</xsl:choose>
|
617
|
+
</xsl:for-each>
|
618
|
+
</xsl:when>
|
619
|
+
|
620
|
+
<!-- Case where there is no ID so we include the whole document -->
|
621
|
+
<!-- Experimental addition: include fragments of children -->
|
622
|
+
<xsl:otherwise>
|
623
|
+
<xsl:variable name="theDocument_2"
|
624
|
+
select="document( $document-uri,/ )" />
|
625
|
+
<xsl:variable name="theFragment_2"
|
626
|
+
select="$theDocument_2/iso:*" />
|
627
|
+
<xsl:variable name="theContainedFragments"
|
628
|
+
select="$theDocument_2/*/iso:* | $theDocument_2/*/xsl:* | $theDocument_2/*/xhtml:*" />
|
629
|
+
<xsl:if test="not($theDocument_2)">
|
630
|
+
<xsl:message terminate="no">
|
631
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
632
|
+
<xsl:value-of select="@href" />
|
633
|
+
</xsl:message>
|
634
|
+
</xsl:if>
|
635
|
+
|
636
|
+
<!-- There are three cases for includes:
|
637
|
+
0) No text specified- error!
|
638
|
+
|
639
|
+
1) REMOVED
|
640
|
+
|
641
|
+
2) REMOVED
|
642
|
+
|
643
|
+
3) Otherwise, include the pointed-to element
|
644
|
+
-->
|
645
|
+
<xsl:choose>
|
646
|
+
<!-- case 0 -->
|
647
|
+
<xsl:when
|
648
|
+
test="not($theFragment_2) and not ($theContainedFragments)">
|
649
|
+
<xsl:message terminate="no">
|
650
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
651
|
+
<xsl:value-of select="@href" />
|
652
|
+
</xsl:message>
|
653
|
+
</xsl:when>
|
654
|
+
|
655
|
+
<!-- case 1 removed -->
|
656
|
+
|
657
|
+
<!-- case 2 removed -->
|
658
|
+
|
659
|
+
<!-- If this were XLST 2, we could use
|
660
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
661
|
+
here (thanks to KN)
|
662
|
+
-->
|
663
|
+
<!-- case 3 -->
|
664
|
+
<xsl:otherwise>
|
665
|
+
<xsl:apply-templates
|
666
|
+
select="$theFragment_2/* " mode="dsdl:go" />
|
667
|
+
</xsl:otherwise>
|
668
|
+
</xsl:choose>
|
669
|
+
</xsl:otherwise>
|
670
|
+
</xsl:choose>
|
671
|
+
</xsl:otherwise>
|
672
|
+
</xsl:choose>
|
673
|
+
|
674
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
675
|
+
<xsl:value-of select="@href" />
|
676
|
+
</xsl:processing-instruction>
|
677
|
+
</xsl:template>
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
<!-- =========================================================== -->
|
682
|
+
<!-- Handle Schematron 1.6 inclusions: clone of ISO code above -->
|
683
|
+
<!-- =========================================================== -->
|
684
|
+
|
685
|
+
|
686
|
+
<!-- Extend the URI syntax to allow # references -->
|
687
|
+
<!-- Add experimental support for simple containers like /xxx:xxx/schold:pattern to allow better includes -->
|
688
|
+
<xsl:template match="schold:include" mode="dsdl:go">
|
689
|
+
<xsl:variable name="document-uri"
|
690
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
691
|
+
<xsl:variable name="fragment-id"
|
692
|
+
select="substring-after(@href, '#')" />
|
693
|
+
|
694
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
695
|
+
<xsl:value-of select="@href" />
|
696
|
+
</xsl:processing-instruction>
|
697
|
+
|
698
|
+
<xsl:choose>
|
699
|
+
<xsl:when test="not( $include-schematron = 'true' )">
|
700
|
+
<xslt:copy>
|
701
|
+
<xslt:copy-of select="@*" />
|
702
|
+
<xslt:apply-templates mode="dsdl:go" />
|
703
|
+
</xslt:copy>
|
704
|
+
</xsl:when>
|
705
|
+
<xsl:otherwise>
|
706
|
+
<xsl:choose>
|
707
|
+
|
708
|
+
<xsl:when
|
709
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
710
|
+
<xsl:message>
|
711
|
+
Error: Impossible URL in Schematron include
|
712
|
+
</xsl:message>
|
713
|
+
</xsl:when>
|
714
|
+
|
715
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
716
|
+
<xslt:when
|
717
|
+
test="string-length( $document-uri ) = 0">
|
718
|
+
<xslt:apply-templates mode="dsdl:go"
|
719
|
+
select="//schold:*[@xml:id= $fragment-id ]
|
720
|
+
|id( $fragment-id)
|
721
|
+
| //schold:*[@id= $fragment-id ]" />
|
722
|
+
</xslt:when>
|
723
|
+
|
724
|
+
<!-- case where there is a fragment in another document (should be an iso: element) -->
|
725
|
+
<xsl:when
|
726
|
+
test="string-length( $fragment-id ) > 0">
|
727
|
+
<xsl:variable name="theDocument_1"
|
728
|
+
select="document( $document-uri,/ )" />
|
729
|
+
<xsl:if test="not($theDocument_1)">
|
730
|
+
<xsl:message terminate="no">
|
731
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
732
|
+
<xsl:value-of select="@href" />
|
733
|
+
</xsl:message>
|
734
|
+
</xsl:if>
|
735
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
736
|
+
<xsl:for-each select="$theDocument_1">
|
737
|
+
<xsl:variable name="theFragment_1"
|
738
|
+
select=" $theDocument_1//schold:*[@xml:id= $fragment-id ] |
|
739
|
+
id($fragment-id) |
|
740
|
+
$theDocument_1//schold:*[@id= $fragment-id ]" />
|
741
|
+
<xsl:if
|
742
|
+
test=" $theFragment_1/self::schold:schema ">
|
743
|
+
<xsl:message>
|
744
|
+
Schema error: Use include to include
|
745
|
+
fragments, not a whole schema
|
746
|
+
</xsl:message>
|
747
|
+
</xsl:if>
|
748
|
+
<xsl:if test="not($theFragment_1)">
|
749
|
+
<xsl:message terminate="no">
|
750
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
751
|
+
<xsl:value-of select="@href" />
|
752
|
+
</xsl:message>
|
753
|
+
</xsl:if>
|
754
|
+
<xsl:apply-templates
|
755
|
+
select=" $theFragment_1[1]" mode="dsdl:go" />
|
756
|
+
</xsl:for-each>
|
757
|
+
</xsl:when>
|
758
|
+
|
759
|
+
<!-- Case where there is no ID so we include the whole document -->
|
760
|
+
<!-- Experimental addition: include fragments of children -->
|
761
|
+
<xsl:otherwise>
|
762
|
+
<xsl:variable name="theDocument_2"
|
763
|
+
select="document( $document-uri,/ )" />
|
764
|
+
<xsl:variable name="theFragment_2"
|
765
|
+
select="$theDocument_2/iso:*" />
|
766
|
+
<xsl:variable name="theContainedFragments"
|
767
|
+
select="$theDocument_2/*/schold:* | $theDocument_2/*/xsl:* | $theDocument_2/*/xhtml:*" />
|
768
|
+
<xsl:if test="not($theDocument_2)">
|
769
|
+
<xsl:message terminate="no">
|
770
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
771
|
+
<xsl:value-of select="@href" />
|
772
|
+
</xsl:message>
|
773
|
+
</xsl:if>
|
774
|
+
|
775
|
+
<xsl:if
|
776
|
+
test=" $theFragment_2/self::schold:schema or $theContainedFragments/self::schold:schema">
|
777
|
+
<xsl:message>
|
778
|
+
Schema error: Use include to include
|
779
|
+
fragments, not a whole schema
|
780
|
+
</xsl:message>
|
781
|
+
</xsl:if>
|
782
|
+
<xsl:if
|
783
|
+
test="not($theFragment_2) and not ($theContainedFragments)">
|
784
|
+
<xsl:message terminate="no">
|
785
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
786
|
+
<xsl:value-of select="@href" />
|
787
|
+
</xsl:message>
|
788
|
+
</xsl:if>
|
789
|
+
<!-- If this were XLST 2, we could use
|
790
|
+
if ($theFragment) then $theFragment else $theContainedFragments
|
791
|
+
here (thanks to KN)
|
792
|
+
-->
|
793
|
+
<xsl:choose>
|
794
|
+
<xsl:when test=" $theFragment_2 ">
|
795
|
+
<xsl:apply-templates
|
796
|
+
select="$theFragment_2 " mode="dsdl:go" />
|
797
|
+
</xsl:when>
|
798
|
+
<xsl:otherwise>
|
799
|
+
<!-- WARNING! EXPERIMENTAL! Use at your own risk. This may be discontinued! -->
|
800
|
+
<xsl:apply-templates
|
801
|
+
select=" $theContainedFragments " mode="dsdl:go" />
|
802
|
+
</xsl:otherwise>
|
803
|
+
</xsl:choose>
|
804
|
+
</xsl:otherwise>
|
805
|
+
</xsl:choose>
|
806
|
+
|
807
|
+
</xsl:otherwise>
|
808
|
+
</xsl:choose>
|
809
|
+
|
810
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
811
|
+
<xsl:value-of select="@href" />
|
812
|
+
</xsl:processing-instruction>
|
813
|
+
</xsl:template>
|
814
|
+
<!-- =========================================================== -->
|
815
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
816
|
+
<!-- Part 5 - DataType Library Language - DTLL -->
|
817
|
+
<!-- Committee Draft Experimental support only -->
|
818
|
+
<!-- The <include> element may well be replaced by XInclude in -->
|
819
|
+
<!-- any final version. -->
|
820
|
+
<!-- =========================================================== -->
|
821
|
+
<xslt:template match="dtll:include" mode="dsdl:go">
|
822
|
+
<!-- Insert subschema -->
|
823
|
+
|
824
|
+
<xsl:variable name="document-uri"
|
825
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
826
|
+
<xsl:variable name="fragment-id"
|
827
|
+
select="substring-after(@href, '#')" />
|
828
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
829
|
+
<xsl:value-of select="@href" />
|
830
|
+
</xsl:processing-instruction>
|
831
|
+
<xsl:choose>
|
832
|
+
<xsl:when test="not( $include-dtll = 'true' )">
|
833
|
+
<xslt:copy>
|
834
|
+
<xslt:copy-of select="@*" />
|
835
|
+
<xslt:apply-templates mode="dsdl:go" />
|
836
|
+
</xslt:copy>
|
837
|
+
</xsl:when>
|
838
|
+
<xsl:otherwise>
|
839
|
+
<xsl:choose>
|
840
|
+
|
841
|
+
<xsl:when
|
842
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
843
|
+
<xsl:message>
|
844
|
+
Error: Impossible URL in DTLL include
|
845
|
+
</xsl:message>
|
846
|
+
</xsl:when>
|
847
|
+
|
848
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
849
|
+
<xslt:when
|
850
|
+
test="string-length( $document-uri ) = 0">
|
851
|
+
<xslt:apply-templates mode="dsdl:go"
|
852
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
853
|
+
| //*[@id= $fragment-id ]" />
|
854
|
+
</xslt:when>
|
855
|
+
|
856
|
+
<xsl:when
|
857
|
+
test="string-length( $fragment-id ) > 0">
|
858
|
+
<xsl:variable name="theDocument_1"
|
859
|
+
select="document( $document-uri,/ )" />
|
860
|
+
<xsl:if test="not($theDocument_1)">
|
861
|
+
<xsl:message terminate="no">
|
862
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
863
|
+
<xsl:value-of select="@href" />
|
864
|
+
</xsl:message>
|
865
|
+
</xsl:if>
|
866
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
867
|
+
<xsl:for-each select="$theDocument_1">
|
868
|
+
<xsl:variable name="theFragment_1"
|
869
|
+
select="$theDocument_1//*[@xml:id= $fragment-id ]
|
870
|
+
| id( $fragment-id )
|
871
|
+
| $theDocument_1//*[@id= $fragment-id ]" />
|
872
|
+
<xsl:if test="not($theFragment_1)">
|
873
|
+
<xsl:message terminate="no">
|
874
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
875
|
+
<xsl:value-of select="@href" />
|
876
|
+
</xsl:message>
|
877
|
+
</xsl:if>
|
878
|
+
<xsl:apply-templates
|
879
|
+
select=" $theFragment_1[1]" mode="dsdl:go" />
|
880
|
+
</xsl:for-each>
|
881
|
+
</xsl:when>
|
882
|
+
|
883
|
+
<xsl:otherwise>
|
884
|
+
<xsl:variable name="theDocument_2"
|
885
|
+
select="document( $document-uri,/ )" />
|
886
|
+
<xsl:variable name="theFragment_2"
|
887
|
+
select="$theDocument_2/*" />
|
888
|
+
|
889
|
+
<xsl:if test="not($theDocument_2)">
|
890
|
+
<xsl:message terminate="no">
|
891
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
892
|
+
<xsl:value-of select="@href" />
|
893
|
+
</xsl:message>
|
894
|
+
</xsl:if>
|
895
|
+
|
896
|
+
<xsl:if test="not($theFragment_2)">
|
897
|
+
<xsl:message terminate="no">
|
898
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
899
|
+
<xsl:value-of select="@href" />
|
900
|
+
</xsl:message>
|
901
|
+
</xsl:if>
|
902
|
+
<xsl:apply-templates select="$theFragment_2 "
|
903
|
+
mode="dsdl:go" />
|
904
|
+
</xsl:otherwise>
|
905
|
+
</xsl:choose>
|
906
|
+
|
907
|
+
</xsl:otherwise>
|
908
|
+
</xsl:choose>
|
909
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
910
|
+
<xsl:value-of select="@href" />
|
911
|
+
</xsl:processing-instruction>
|
912
|
+
</xslt:template>
|
913
|
+
|
914
|
+
<!-- =========================================================== -->
|
915
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
916
|
+
<!-- Part 7 - Character Repertoire Description Language - CRDL -->
|
917
|
+
<!-- Final Committee Draft 2008-01-11 Experimental support only -->
|
918
|
+
<!-- =========================================================== -->
|
919
|
+
<xslt:template match="crdl:ref" mode="dsdl:go">
|
920
|
+
<!-- Insert subschema -->
|
921
|
+
|
922
|
+
<xsl:variable name="document-uri"
|
923
|
+
select="substring-before(concat(@href,'#'), '#')" />
|
924
|
+
<xsl:variable name="fragment-id"
|
925
|
+
select="substring-after(@href, '#')" />
|
926
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
927
|
+
<xsl:value-of select="@href" />
|
928
|
+
</xsl:processing-instruction>
|
929
|
+
<xsl:choose>
|
930
|
+
<xsl:when test="not( $include-crdl = 'true' )">
|
931
|
+
<xslt:copy>
|
932
|
+
<xslt:copy-of select="@*" />
|
933
|
+
<xslt:apply-templates mode="dsdl:go" />
|
934
|
+
</xslt:copy>
|
935
|
+
</xsl:when>
|
936
|
+
<xsl:otherwise>
|
937
|
+
<xsl:choose>
|
938
|
+
|
939
|
+
<xsl:when
|
940
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
941
|
+
<xsl:message>
|
942
|
+
Error: Impossible URL in CRDL include
|
943
|
+
</xsl:message>
|
944
|
+
</xsl:when>
|
945
|
+
|
946
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
947
|
+
<xslt:when
|
948
|
+
test="string-length( $document-uri ) = 0">
|
949
|
+
|
950
|
+
<xslt:apply-templates mode="dsdl:go"
|
951
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
952
|
+
| //*[@id= $fragment-id ]" />
|
953
|
+
</xslt:when>
|
954
|
+
|
955
|
+
<xsl:when
|
956
|
+
test="string-length( $fragment-id ) > 0">
|
957
|
+
<xsl:variable name="theDocument_1"
|
958
|
+
select="document( $document-uri,/ )" />
|
959
|
+
<xsl:if test="not($theDocument_1)">
|
960
|
+
<xsl:message terminate="no">
|
961
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
962
|
+
<xsl:value-of select="@href" />
|
963
|
+
</xsl:message>
|
964
|
+
</xsl:if>
|
965
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
966
|
+
<xsl:for-each select="$theDocument_1">
|
967
|
+
<xsl:variable name="theFragment_1"
|
968
|
+
select="$theDocument_1//*[@xml:id= $fragment-id ]
|
969
|
+
| id( $fragment-id )
|
970
|
+
| $theDocument_1//*[@id= $fragment-id ]" />
|
971
|
+
|
972
|
+
<xsl:if test="not($theFragment_1)">
|
973
|
+
<xsl:message terminate="no">
|
974
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
975
|
+
<xsl:value-of select="@href" />
|
976
|
+
</xsl:message>
|
977
|
+
</xsl:if>
|
978
|
+
<xsl:apply-templates select=" $theFragment_1 "
|
979
|
+
mode="dsdl:go" />
|
980
|
+
</xsl:for-each>
|
981
|
+
</xsl:when>
|
982
|
+
|
983
|
+
<xsl:otherwise>
|
984
|
+
<xsl:variable name="theDocument_2"
|
985
|
+
select="document( $document-uri,/ )" />
|
986
|
+
<xsl:variable name="theFragment_2"
|
987
|
+
select="$theDocument_2/*" />
|
988
|
+
|
989
|
+
<xsl:if test="not($theDocument_2)">
|
990
|
+
<xsl:message terminate="no">
|
991
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
992
|
+
<xsl:value-of select="@href" />
|
993
|
+
</xsl:message>
|
994
|
+
</xsl:if>
|
995
|
+
<xsl:if test="not($theFragment_2)">
|
996
|
+
<xsl:message terminate="no">
|
997
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
998
|
+
<xsl:value-of select="@href" />
|
999
|
+
</xsl:message>
|
1000
|
+
</xsl:if>
|
1001
|
+
|
1002
|
+
<xsl:apply-templates select="$theFragment_2"
|
1003
|
+
mode="dsdl:go" />
|
1004
|
+
</xsl:otherwise>
|
1005
|
+
</xsl:choose>
|
1006
|
+
|
1007
|
+
</xsl:otherwise>
|
1008
|
+
</xsl:choose>
|
1009
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
1010
|
+
<xsl:value-of select="@href" />
|
1011
|
+
</xsl:processing-instruction>
|
1012
|
+
</xslt:template>
|
1013
|
+
|
1014
|
+
|
1015
|
+
<!-- =========================================================== -->
|
1016
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
1017
|
+
<!-- Part 4 - Namespace-based Validation Dispatching Language - NVDL -->
|
1018
|
+
<!-- Note: This does not include schemas referenced for -->
|
1019
|
+
<!-- validation, it merely handles any simple XIncludes -->
|
1020
|
+
<!-- =========================================================== -->
|
1021
|
+
<!-- ISO/IEC 19757 - DSDL Document Schema Definition Languages -->
|
1022
|
+
<!-- Part 8 - Document Schema Renaming Language - DSRL -->
|
1023
|
+
<!-- Note: Final? Committee Draft Experimental support only -->
|
1024
|
+
<!-- =========================================================== -->
|
1025
|
+
<!-- XInclude support for id based references only, with 1 level -->
|
1026
|
+
<!-- of fallback. -->
|
1027
|
+
<!-- =========================================================== -->
|
1028
|
+
|
1029
|
+
<xslt:template mode="dsdl:go"
|
1030
|
+
match="xi:include[@href][not(@parseType) or @parseType ='xml']">
|
1031
|
+
<!-- Simple inclusions only here -->
|
1032
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
1033
|
+
<xsl:value-of select="@href" />
|
1034
|
+
</xsl:processing-instruction>
|
1035
|
+
<xsl:choose>
|
1036
|
+
<xsl:when test="not( $include-xinclude = 'true' )">
|
1037
|
+
<xslt:copy>
|
1038
|
+
<xslt:copy-of select="@*" />
|
1039
|
+
<xslt:apply-templates mode="dsdl:go" />
|
1040
|
+
</xslt:copy>
|
1041
|
+
</xsl:when>
|
1042
|
+
<xsl:otherwise>
|
1043
|
+
<xsl:choose>
|
1044
|
+
|
1045
|
+
<xsl:when test="contains( @href, '#')">
|
1046
|
+
<xsl:message terminate="yes">
|
1047
|
+
Fatal error: Xinclude href contains fragment
|
1048
|
+
identifier #
|
1049
|
+
</xsl:message>
|
1050
|
+
</xsl:when>
|
1051
|
+
|
1052
|
+
|
1053
|
+
<xsl:when test="contains( @xpointer, '(')">
|
1054
|
+
<xsl:message terminate="yes">
|
1055
|
+
Fatal error: Sorry, this software only
|
1056
|
+
supports simple ids in XInclude xpointers
|
1057
|
+
</xsl:message>
|
1058
|
+
</xsl:when>
|
1059
|
+
|
1060
|
+
<xsl:when
|
1061
|
+
test="string-length( @href ) = 0 and string-length( @xpointer ) = 0">
|
1062
|
+
|
1063
|
+
<xsl:message terminate="yes">
|
1064
|
+
Fatal Error: Impossible URL in XInclude
|
1065
|
+
include
|
1066
|
+
</xsl:message>
|
1067
|
+
</xsl:when>
|
1068
|
+
|
1069
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
1070
|
+
<xslt:when test="string-length( @href ) = 0">
|
1071
|
+
|
1072
|
+
<xslt:apply-templates mode="dsdl:go"
|
1073
|
+
select="//*[@xml:id= current()/@xpointer ] | id( @xpointer)
|
1074
|
+
| //*[@id= current()/@xpointer ]" />
|
1075
|
+
</xslt:when>
|
1076
|
+
|
1077
|
+
<xsl:when
|
1078
|
+
test="string-length( @xpointer ) > 0">
|
1079
|
+
<xsl:variable name="theDocument_1"
|
1080
|
+
select="document( @href,/ )" />
|
1081
|
+
<xsl:variable name="theFragment_1"
|
1082
|
+
select="$theDocument_1//*[@xml:id= current()/@xpointer ]
|
1083
|
+
|
1084
|
+
| $theDocument_1//*[@id= current()/@xpointer ]" />
|
1085
|
+
<!-- removed
|
1086
|
+
| $theDocument_1/id( @xpointer)
|
1087
|
+
because it requires rebasing in XSLT1 and that would mess up the use of current()
|
1088
|
+
-->
|
1089
|
+
|
1090
|
+
|
1091
|
+
<!-- Allow one level of fallback, to another XInclude -->
|
1092
|
+
<xsl:if test="not($theDocument_1)">
|
1093
|
+
<xsl:choose>
|
1094
|
+
<xsl:when test="xi:fallback">
|
1095
|
+
<xsl:variable name="theDocument_2"
|
1096
|
+
select="document( xi:fallback[1]/xi:include[not(@parseType)
|
1097
|
+
or @parseType='xml']/@href,/ )" />
|
1098
|
+
<xsl:variable name="theFragment_2"
|
1099
|
+
select="$theDocument_2//*[@xml:id= current()/xi:fallback[1]/xi:include/@xpointer ]
|
1100
|
+
| $theDocument_2//*[@id= current()/xi:fallback[1]/xi:include/@xpointer ]" />
|
1101
|
+
<!-- removed
|
1102
|
+
| $theDocument_2/id( xi:fallback[1]/xi:include/@xpointer)
|
1103
|
+
because it id() would need rebasing in XSLT1 and that would mess up use of current()
|
1104
|
+
-->
|
1105
|
+
|
1106
|
+
<xsl:if
|
1107
|
+
test="not($theDocument_2)">
|
1108
|
+
|
1109
|
+
<xsl:message terminate="no">
|
1110
|
+
<xsl:text>Unable to open referenced included file and fallback
|
1111
|
+
file: </xsl:text>
|
1112
|
+
<xsl:value-of
|
1113
|
+
select="@href" />
|
1114
|
+
</xsl:message>
|
1115
|
+
</xsl:if>
|
1116
|
+
</xsl:when>
|
1117
|
+
<xsl:otherwise>
|
1118
|
+
<xsl:message terminate="no">
|
1119
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
1120
|
+
<xsl:value-of select="@href" />
|
1121
|
+
</xsl:message>
|
1122
|
+
</xsl:otherwise>
|
1123
|
+
</xsl:choose>
|
1124
|
+
</xsl:if>
|
1125
|
+
<xsl:apply-templates select=" $theFragment_1"
|
1126
|
+
mode="dsdl:go" />
|
1127
|
+
</xsl:when>
|
1128
|
+
|
1129
|
+
<!-- Document but no fragment specified -->
|
1130
|
+
<xsl:otherwise>
|
1131
|
+
<xsl:variable name="theDocument_3"
|
1132
|
+
select="document( @href,/ )" />
|
1133
|
+
<xsl:variable name="theFragment_3"
|
1134
|
+
select="$theDocument_3/*" />
|
1135
|
+
|
1136
|
+
<xsl:if test="not($theDocument_3)">
|
1137
|
+
<xsl:message terminate="no">
|
1138
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
1139
|
+
<xsl:value-of select="@href" />
|
1140
|
+
</xsl:message>
|
1141
|
+
</xsl:if>
|
1142
|
+
|
1143
|
+
<xsl:apply-templates select="$theFragment_3 "
|
1144
|
+
mode="dsdl:go" />
|
1145
|
+
</xsl:otherwise>
|
1146
|
+
</xsl:choose>
|
1147
|
+
|
1148
|
+
</xsl:otherwise>
|
1149
|
+
</xsl:choose>
|
1150
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
1151
|
+
<xsl:value-of select="@href" />
|
1152
|
+
</xsl:processing-instruction>
|
1153
|
+
</xslt:template>
|
1154
|
+
|
1155
|
+
<!-- =========================================================== -->
|
1156
|
+
<!-- W3C XLink 1.1 embedded simple links -->
|
1157
|
+
<!-- =========================================================== -->
|
1158
|
+
<xslt:template
|
1159
|
+
match="*[@xlink:href][not(parent::*[@xlink:type='complex'])]
|
1160
|
+
[not(@xlink:type) or (@xlink:type='simple')]
|
1161
|
+
[@xlink:show='embed']
|
1162
|
+
[not(@xlink:actuate) or (@xlink:actuate='onLoad')]"
|
1163
|
+
mode="dsdl:go" priority="1">
|
1164
|
+
|
1165
|
+
<xsl:variable name="document-uri"
|
1166
|
+
select="substring-before(concat(@xlink:href,'#'), '#')" />
|
1167
|
+
<xsl:variable name="fragment-id"
|
1168
|
+
select="substring-after(@xlink:href, '#')" />
|
1169
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_START">
|
1170
|
+
<xsl:value-of select="@xlink:href" />
|
1171
|
+
</xsl:processing-instruction>
|
1172
|
+
<xsl:choose>
|
1173
|
+
<xsl:when test="not( $include-xlink = 'true' )">
|
1174
|
+
<xslt:copy>
|
1175
|
+
<xslt:copy-of select="@*" />
|
1176
|
+
<xslt:apply-templates mode="dsdl:go" />
|
1177
|
+
</xslt:copy>
|
1178
|
+
</xsl:when>
|
1179
|
+
<xsl:otherwise>
|
1180
|
+
<xsl:choose>
|
1181
|
+
|
1182
|
+
<xsl:when
|
1183
|
+
test="string-length( $document-uri ) = 0 and string-length( $fragment-id ) = 0">
|
1184
|
+
<xsl:message>
|
1185
|
+
Error: Impossible URL in XLink embedding
|
1186
|
+
link
|
1187
|
+
</xsl:message>
|
1188
|
+
</xsl:when>
|
1189
|
+
|
1190
|
+
<!-- this case is when there is in embedded schema in the same document elsewhere -->
|
1191
|
+
<xslt:when
|
1192
|
+
test="string-length( $document-uri ) = 0">
|
1193
|
+
<xslt:apply-templates mode="dsdl:go"
|
1194
|
+
select="//*[@xml:id= $fragment-id ] | id( $fragment-id)
|
1195
|
+
| //*[@id= $fragment-id ]" />
|
1196
|
+
</xslt:when>
|
1197
|
+
|
1198
|
+
<xsl:when
|
1199
|
+
test="string-length( $fragment-id ) > 0">
|
1200
|
+
<xsl:variable name="theDocument_1"
|
1201
|
+
select="document( $document-uri,/ )" />
|
1202
|
+
<xsl:if test="not($theDocument_1)">
|
1203
|
+
<xsl:message terminate="no">
|
1204
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
1205
|
+
<xsl:value-of select="@xlink:href" />
|
1206
|
+
</xsl:message>
|
1207
|
+
</xsl:if>
|
1208
|
+
<!-- use for-each to rebase id() to $theDocument -->
|
1209
|
+
<xsl:for-each select="$theDocument_1">
|
1210
|
+
<xsl:variable name="theFragment_1"
|
1211
|
+
select="$theDocument_1//*[@xml:id= $fragment-id ]
|
1212
|
+
| id( $fragment-id )
|
1213
|
+
| $theDocument_1//*[@id= $fragment-id ]" />
|
1214
|
+
<xsl:if test="not($theFragment_1)">
|
1215
|
+
<xsl:message terminate="no">
|
1216
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
1217
|
+
<xsl:value-of select="@xlink:href" />
|
1218
|
+
</xsl:message>
|
1219
|
+
</xsl:if>
|
1220
|
+
<xsl:apply-templates
|
1221
|
+
select=" $theFragment_1[1]" mode="dsdl:go" />
|
1222
|
+
</xsl:for-each>
|
1223
|
+
</xsl:when>
|
1224
|
+
|
1225
|
+
<xsl:otherwise>
|
1226
|
+
<xsl:variable name="theDocument_2"
|
1227
|
+
select="document( $document-uri,/ )" />
|
1228
|
+
<xsl:variable name="theFragment_2"
|
1229
|
+
select="$theDocument_2/*" />
|
1230
|
+
|
1231
|
+
<xsl:if test="not($theDocument_2)">
|
1232
|
+
<xsl:message terminate="no">
|
1233
|
+
<xsl:text>Unable to open referenced included file: </xsl:text>
|
1234
|
+
<xsl:value-of select="@xlink:href" />
|
1235
|
+
</xsl:message>
|
1236
|
+
</xsl:if>
|
1237
|
+
|
1238
|
+
<xsl:if test="not($theFragment_2)">
|
1239
|
+
<xsl:message terminate="no">
|
1240
|
+
<xsl:text>Unable to locate id attribute: </xsl:text>
|
1241
|
+
<xsl:value-of select="@xlink:href" />
|
1242
|
+
</xsl:message>
|
1243
|
+
</xsl:if>
|
1244
|
+
<xsl:apply-templates select="$theFragment_2 "
|
1245
|
+
mode="dsdl:go" />
|
1246
|
+
</xsl:otherwise>
|
1247
|
+
</xsl:choose>
|
1248
|
+
|
1249
|
+
</xsl:otherwise>
|
1250
|
+
</xsl:choose>
|
1251
|
+
|
1252
|
+
<xsl:processing-instruction name="DSDL_INCLUDE_END">
|
1253
|
+
<xsl:value-of select="@xlink:href" />
|
1254
|
+
</xsl:processing-instruction>
|
1255
|
+
</xslt:template>
|
1256
|
+
|
1257
|
+
<!-- ================================================================= -->
|
1258
|
+
<!-- UTILITY TEMPLATES -->
|
1259
|
+
<!-- ================================================================= -->
|
1260
|
+
|
1261
|
+
<!-- MESSAGE WHEN XPATH NOT WELL FORMED -->
|
1262
|
+
|
1263
|
+
<xsl:template name="sch-check:xpath-wf-message" >
|
1264
|
+
<xsl:param name="string" />
|
1265
|
+
<xsl:param name="subject" />
|
1266
|
+
<xsl:variable name="xpath-wf-result">
|
1267
|
+
<xsl:call-template name="sch-check:xpath-wf">
|
1268
|
+
<xsl:with-param name="string" select=" $string " />
|
1269
|
+
</xsl:call-template>
|
1270
|
+
</xsl:variable>
|
1271
|
+
|
1272
|
+
<xsl:if test="string-length($xpath-wf-result) > 0">
|
1273
|
+
<xsl:message><xsl:value-of select="$subject"/><xsl:value-of select="$xpath-wf-result" /></xsl:message>
|
1274
|
+
</xsl:if>
|
1275
|
+
</xsl:template>
|
1276
|
+
|
1277
|
+
<!-- XPATH WELL FORMED -->
|
1278
|
+
|
1279
|
+
<xsl:template name="sch-check:xpath-wf" >
|
1280
|
+
<xsl:param name="string" />
|
1281
|
+
<!-- This does some minimal checks to see if a string is well-formed XPath.
|
1282
|
+
It checks
|
1283
|
+
1) String is not empty,
|
1284
|
+
2) equal number of open and close parens
|
1285
|
+
3) equal number of left and right square brackets
|
1286
|
+
4) if there is a predicate open immediately following a step separator
|
1287
|
+
It does not check balancing. It does not check inside string literals in XPaths.
|
1288
|
+
|
1289
|
+
If there is no error, empty content is returned. If there is an error, it is given
|
1290
|
+
as an error message. This is not localized yet.
|
1291
|
+
-->
|
1292
|
+
|
1293
|
+
|
1294
|
+
<xsl:variable name="stripped-contents">
|
1295
|
+
<xsl:call-template name="sch-check:strip-strings" >
|
1296
|
+
<xsl:with-param name="string" select=" $string " />
|
1297
|
+
<xsl:with-param name="mode" select=" 0" />
|
1298
|
+
</xsl:call-template>
|
1299
|
+
</xsl:variable>
|
1300
|
+
|
1301
|
+
|
1302
|
+
<xsl:variable name="paren-result">
|
1303
|
+
<xsl:call-template name="sch-check:test-paren" >
|
1304
|
+
<xsl:with-param name="string" select="$stripped-contents" />
|
1305
|
+
<xsl:with-param name="count" select=" 0" />
|
1306
|
+
</xsl:call-template>
|
1307
|
+
</xsl:variable>
|
1308
|
+
|
1309
|
+
|
1310
|
+
<xsl:variable name="sqb-result">
|
1311
|
+
<xsl:call-template name="sch-check:test-sqb" >
|
1312
|
+
<xsl:with-param name="string" select="$stripped-contents" />
|
1313
|
+
<xsl:with-param name="count" select=" 0" />
|
1314
|
+
</xsl:call-template>
|
1315
|
+
</xsl:variable>
|
1316
|
+
|
1317
|
+
|
1318
|
+
<xsl:choose>
|
1319
|
+
<xsl:when test="string-length( normalize-space($string)) = 0"
|
1320
|
+
>XPath error. No XPath.</xsl:when>
|
1321
|
+
<xsl:when test="contains( $stripped-contents, '/[' )"
|
1322
|
+
>XPath error. Missing location step. Suggestion: remove '/' before '['.
|
1323
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1324
|
+
<!-- not implemented yet
|
1325
|
+
<xsl:when test=" count () mod 2 = 1"
|
1326
|
+
>XPath syntax error. Odd number of apostrophe characters. Suggestion: check string termination and delimiting.
|
1327
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1328
|
+
<xsl:when test=" count ( ) mod 2 = 1"
|
1329
|
+
>XPath syntax error. Odd number of quote characters. Suggestion: check string termination and delimiting.
|
1330
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1331
|
+
-->
|
1332
|
+
<xsl:when test=" $paren-result > 0 "
|
1333
|
+
>XPath syntax error. Unclosed parenthesis. Suggestion: add ')'.
|
1334
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1335
|
+
<xsl:when test=" $paren-result < 0 "
|
1336
|
+
>XPath syntax error. Extra close parenthesis. Suggestion: remove ')'.
|
1337
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1338
|
+
|
1339
|
+
<xsl:when test=" $sqb-result > 0 "
|
1340
|
+
>XPath syntax error. Unclosed left square bracket. Suggestion: add ']'.
|
1341
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1342
|
+
<xsl:when test=" $sqb-result < 0 "
|
1343
|
+
>XPath syntax error. Extra right square bracket. Suggestion: remove ']'.
|
1344
|
+
<xsl:value-of select=" normalize-space($string)"/></xsl:when>
|
1345
|
+
|
1346
|
+
</xsl:choose>
|
1347
|
+
|
1348
|
+
|
1349
|
+
|
1350
|
+
</xsl:template>
|
1351
|
+
|
1352
|
+
|
1353
|
+
<!-- STRIP XPATH STRINGS -->
|
1354
|
+
<xsl:template name="sch-check:strip-strings">
|
1355
|
+
<xsl:param name="string" />
|
1356
|
+
<xsl:param name="mode" />
|
1357
|
+
|
1358
|
+
<!--
|
1359
|
+
mode 0 = outside string
|
1360
|
+
mode 1 = in double quote string
|
1361
|
+
mode 2 = in single quote string
|
1362
|
+
-->
|
1363
|
+
<xsl:choose>
|
1364
|
+
<xsl:when test=" string-length( $string) = 0" />
|
1365
|
+
<xsl:when test="$mode = 1 ">
|
1366
|
+
<xsl:choose>
|
1367
|
+
|
1368
|
+
|
1369
|
+
<xsl:when test="starts-with( $string, '""') " >
|
1370
|
+
|
1371
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1372
|
+
<xsl:with-param name="string" select=" substring ( $string, 3 )"/>
|
1373
|
+
<xsl:with-param name="mode" select=" $mode" />
|
1374
|
+
</xsl:call-template>
|
1375
|
+
</xsl:when>
|
1376
|
+
<xsl:when test="starts-with( $string, '"') " >
|
1377
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1378
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1379
|
+
<xsl:with-param name="mode" select=" 0 " />
|
1380
|
+
</xsl:call-template>
|
1381
|
+
</xsl:when>
|
1382
|
+
|
1383
|
+
<xsl:otherwise>
|
1384
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1385
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1386
|
+
<xsl:with-param name="mode" select=" $mode " />
|
1387
|
+
</xsl:call-template>
|
1388
|
+
</xsl:otherwise>
|
1389
|
+
</xsl:choose>
|
1390
|
+
</xsl:when>
|
1391
|
+
|
1392
|
+
<xsl:when test="$mode = 2 ">
|
1393
|
+
<xsl:choose>
|
1394
|
+
|
1395
|
+
<!-- doubled double quote or double apos is an escape -->
|
1396
|
+
<xsl:when test="starts-with( $string, "''") " >
|
1397
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1398
|
+
<xsl:with-param name="string" select=" substring ( $string, 3 )"/>
|
1399
|
+
<xsl:with-param name="mode" select=" $mode" />
|
1400
|
+
</xsl:call-template>
|
1401
|
+
</xsl:when>
|
1402
|
+
<xsl:when test="starts-with( $string, "'" )" >
|
1403
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1404
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1405
|
+
<xsl:with-param name="mode" select=" 0 " />
|
1406
|
+
</xsl:call-template>
|
1407
|
+
</xsl:when>
|
1408
|
+
<xsl:otherwise>
|
1409
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1410
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1411
|
+
<xsl:with-param name="mode" select=" $mode " />
|
1412
|
+
</xsl:call-template>
|
1413
|
+
</xsl:otherwise>
|
1414
|
+
</xsl:choose>
|
1415
|
+
</xsl:when>
|
1416
|
+
|
1417
|
+
<xsl:otherwise> <!-- mode = 0 -->
|
1418
|
+
<xsl:choose>
|
1419
|
+
<xsl:when test="starts-with( $string, '"')" >
|
1420
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1421
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1422
|
+
<xsl:with-param name="mode" select=" 1 " />
|
1423
|
+
</xsl:call-template>
|
1424
|
+
</xsl:when>
|
1425
|
+
|
1426
|
+
<xsl:when test="starts-with( $string, "'" )" >
|
1427
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1428
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1429
|
+
<xsl:with-param name="mode" select=" 2 " />
|
1430
|
+
</xsl:call-template>
|
1431
|
+
</xsl:when>
|
1432
|
+
<xsl:otherwise>
|
1433
|
+
<xsl:value-of select="substring( $string, 1, 1)" />
|
1434
|
+
<xsl:call-template name="sch-check:strip-strings">
|
1435
|
+
|
1436
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1437
|
+
<xsl:with-param name="mode" select=" $mode " />
|
1438
|
+
</xsl:call-template>
|
1439
|
+
</xsl:otherwise>
|
1440
|
+
</xsl:choose>
|
1441
|
+
</xsl:otherwise>
|
1442
|
+
</xsl:choose>
|
1443
|
+
|
1444
|
+
|
1445
|
+
</xsl:template>
|
1446
|
+
|
1447
|
+
<!-- COUNT THE NUMBER OF UNMATCHED PARENTHESES -->
|
1448
|
+
<!-- Limitation: Does not check balancing. -->
|
1449
|
+
|
1450
|
+
<xsl:template name="sch-check:test-paren">
|
1451
|
+
<xsl:param name="string" />
|
1452
|
+
<xsl:param name="count" />
|
1453
|
+
|
1454
|
+
<xsl:choose>
|
1455
|
+
<xsl:when test=" string-length( $string) = 0">
|
1456
|
+
<xsl:value-of select=" $count " />
|
1457
|
+
</xsl:when>
|
1458
|
+
<xsl:when test=" starts-with( $string, '(') ">
|
1459
|
+
<xsl:call-template name="sch-check:test-paren">
|
1460
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )" />
|
1461
|
+
<xsl:with-param name="count" select=" $count + 1 " />
|
1462
|
+
</xsl:call-template>
|
1463
|
+
</xsl:when>
|
1464
|
+
<xsl:when test=" starts-with( $string, ')') ">
|
1465
|
+
<xsl:call-template name="sch-check:test-paren">
|
1466
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1467
|
+
<xsl:with-param name="count" select="$count - 1 " />
|
1468
|
+
</xsl:call-template>
|
1469
|
+
</xsl:when>
|
1470
|
+
<xsl:otherwise>
|
1471
|
+
<xsl:call-template name="sch-check:test-paren">
|
1472
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1473
|
+
<xsl:with-param name="count" select=" $count " />
|
1474
|
+
</xsl:call-template>
|
1475
|
+
</xsl:otherwise>
|
1476
|
+
</xsl:choose>
|
1477
|
+
|
1478
|
+
|
1479
|
+
</xsl:template>
|
1480
|
+
|
1481
|
+
|
1482
|
+
<!-- COUNT THE NUMBER OF SQUARE BRACKETS -->
|
1483
|
+
<!-- Limitation: Does not check balancing. -->
|
1484
|
+
<xsl:template name="sch-check:test-sqb">
|
1485
|
+
<xsl:param name="string" />
|
1486
|
+
<xsl:param name="count" />
|
1487
|
+
|
1488
|
+
<xsl:choose>
|
1489
|
+
<xsl:when test=" string-length( $string) = 0">
|
1490
|
+
<xsl:value-of select=" $count " />
|
1491
|
+
</xsl:when>
|
1492
|
+
<xsl:when test=" starts-with( $string, '[') ">
|
1493
|
+
<xsl:call-template name="sch-check:test-sqb">
|
1494
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )" />
|
1495
|
+
<xsl:with-param name="count" select=" $count + 1 " />
|
1496
|
+
</xsl:call-template>
|
1497
|
+
</xsl:when>
|
1498
|
+
<xsl:when test=" starts-with( $string, ']') ">
|
1499
|
+
<xsl:call-template name="sch-check:test-sqb">
|
1500
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1501
|
+
<xsl:with-param name="count" select="$count - 1 " />
|
1502
|
+
</xsl:call-template>
|
1503
|
+
</xsl:when>
|
1504
|
+
<xsl:otherwise>
|
1505
|
+
<xsl:call-template name="sch-check:test-sqb">
|
1506
|
+
<xsl:with-param name="string" select=" substring ( $string, 2 )"/>
|
1507
|
+
<xsl:with-param name="count" select=" $count " />
|
1508
|
+
</xsl:call-template>
|
1509
|
+
</xsl:otherwise>
|
1510
|
+
</xsl:choose>
|
1511
|
+
|
1512
|
+
|
1513
|
+
</xsl:template>
|
1514
|
+
|
1515
|
+
|
1516
|
+
|
1517
|
+
|
1518
|
+
|
1519
|
+
</xslt:stylesheet>
|