diff --git a/.circleci/config.yml b/.circleci/config.yml index 39d0029a0..e454947f4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: machine: - image: ubuntu-1604:202004-01 + image: ubuntu-2004:202111-02 resource_class: xlarge working_directory: ~/repo @@ -31,6 +31,13 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- + - run: | + if [ -z "$SAXPASSPHRASE" ]; then + echo "No secrets available, will run with Saxon-HE" + else + gpg --batch --yes --passphrase $SAXPASSPHRASE -d tools/saxon.enc | tar zxf - + fi + - run: ./gradlew dependencies - save_cache: diff --git a/build.gradle b/build.gradle index 5ecda885f..f33562f47 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ plugins { id "maven-publish" id "signing" //id 'com.github.eerohele.saxon-gradle' version '0.9.0-beta3' - id 'com.nwalsh.saxon-gradle' version '0.9.1-beta4' + id 'com.nwalsh.gradle.saxon.saxon-gradle' version '0.9.6' id 'com.nwalsh.gradle.relaxng.validate' version '0.0.6' id 'com.nwalsh.gradle.relaxng.translate' version '0.0.6' id "de.undercouch.download" version "4.0.4" @@ -47,7 +47,7 @@ sourceSets { } //import com.github.eerohele.SaxonXsltTask -import com.nwalsh.SaxonXsltTask +import com.nwalsh.gradle.saxon.SaxonXsltTask import com.nwalsh.gradle.relaxng.validate.RelaxNGValidateTask import com.nwalsh.gradle.relaxng.translate.RelaxNGTranslateTask @@ -97,19 +97,9 @@ dependencies { defaultTasks 'report' saxon.configure { - classpath configurations.validateRuntime - entityResolverClass "org.xmlresolver.Resolver" - uriResolverClass "org.xmlresolver.Resolver" - sourceSaxParser "org.xmlresolver.tools.ResolvingXMLReader" - stylesheetSaxParser "org.xmlresolver.tools.ResolvingXMLReader" } saxon.configure("docbook") { - classpath configurations.validateRuntime - entityResolverClass "org.xmlresolver.Resolver" - uriResolverClass "org.xmlresolver.Resolver" - sourceSaxParser "org.xmlresolver.tools.ResolvingXMLReader" - stylesheetSaxParser "org.xmlresolver.tools.ResolvingXMLReader" initializer 'org.docbook.xsltng.extensions.Register' } @@ -233,6 +223,8 @@ configurations.compileClasspath.each { it -> System.setProperty("org.docbook.xsltng.extensions.verbose", verbose) System.setProperty("org.docbook.extensions.pygmentize", pygmentize) +println("Building with Java version ${System.getProperty('java.version')}") + task configureEnvironment() { def envVars = [:] envVars['TEST_DIR'] = buildDir @@ -259,18 +251,17 @@ task setupXSpec(type: Download) { doLast { copy { from "${projectDir}/src/test/resources/xspec" - into "${buildDir}/xspec-${xspecVersion}/bin" - include "xspec.sh" + into "${buildDir}/xspec-${xspecVersion}/src/common" + include "uri-utils.xsl" } } doLast { copy { from "${projectDir}/src/test/resources/xspec" - into "${buildDir}/xspec-${xspecVersion}/src/compiler" - include "generate-tests-utils.xsl" + into "${buildDir}/xspec-${xspecVersion}/bin" + include "xspec.sh" } } - onlyIf { !file("${buildDir}/xspec-${xspecVersion}/README.md").exists() } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a94e4ca38..9e04f86a8 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -34,7 +34,7 @@ dependencies { sourceSets { main { java { - srcDirs = ['src', 'build/generated/sources/buildconfig'] + srcDirs = ['src/main/java', 'build/generated/sources/buildconfig'] } } } diff --git a/gradle.properties b/gradle.properties index be46b894f..d448938a8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ systemProp.javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactor verbose=false -xspecVersion=1.6.0 +xspecVersion=2.2.4 xsltExplorerVersion=0.1.10 pdftool=antennahouse diff --git a/properties.gradle b/properties.gradle index adaf98419..4c1789598 100644 --- a/properties.gradle +++ b/properties.gradle @@ -2,13 +2,13 @@ ext { xslTNGtitle = 'DocBook xslTNG' xslTNGbaseName = 'docbook-xslTNG' - xslTNGversion = '1.6.2' - guideVersion = '1.6.2' + xslTNGversion = '1.7.0-11' + guideVersion = '1.7.0-11' - docbookVersion = '5.2b12' - publishersVersion = '5.2b12' + docbookVersion = '5.2b13' + publishersVersion = '5.2b13' - saxonVersion = '10.6' + saxonVersion = '11.3' saxonGroup = 'net.sf.saxon' saxonEdition = 'Saxon-HE' //saxonGroup = 'com.saxonica' @@ -17,6 +17,6 @@ ext { metadataExtractorVersion = '2.15.0' jingVersion = '20181222' xmlresolverVersion = '4.2.0' - sincludeVersion = '4.0.0' + sincludeVersion = '4.0.0-11' slf4jVersion = '1.7.30' } diff --git a/src/bin/docbook.py b/src/bin/docbook.py index 792856ed6..316a5dd1d 100755 --- a/src/bin/docbook.py +++ b/src/bin/docbook.py @@ -39,14 +39,23 @@ def __init__(self, args): # environment because that version may not be published yet. # Instead, we rely on the fact that we can get the # docbook-xslTNG package from the distribution environment and - # we seed with its dependencies. + # we seed with its dependencies. These must all be in the + # DocBook distribution (in libs/lib). self.seeds = set(["@@PACKAGE_LIST@@"]) self.config = { "maven-local": str(Path.home()) + "/.m2/repository", "maven-packages": [], "pinned-packages": ["xml-apis:xml-apis:1.4.01"], - "excluded-packages": ["xml-resolver:xml-resolver:1.2"], + "excluded-packages": ["xml-resolver:xml-resolver:1.2", + "org.jdom:jdom:*", + "org.jdom:jdom2:*", + "xom:xom:*", + "dom4j:dom4j:*", + "jline:jline:*", + "org.apache.ws.commons.axiom:axiom:*", + "org.apache.ws.commons.axiom:axiom-dom:*", + "org.apache.ws.commons.axiom:axiom-impl:*"], "args": [], "classpath": [], "class": "net.sf.saxon.Transform", @@ -80,7 +89,14 @@ def __init__(self, args): try: with open(self.config_file, "r") as depfile: + # There's a real potential for this to become a nest of hacks. + # I want the excluded files to be a union of what the user + # might have suggested and what the script suggests. + excluded = self.config['excluded-packages'] self.config = json.load(depfile) + for package in excluded: + if package not in self.config['excluded-packages']: + self.config['excluded-packages'].append(package) except FileNotFoundError: with open(self.config_file, "w") as depfile: depfile.write(json.dumps(self.config, indent=2, sort_keys=True)) @@ -360,12 +376,25 @@ def compute_dependencies(self): """Find all the (transitive closure) of available dependencies among the packages that we're going to use. """ + required_list = [] for package in self.seeds: - group, artifact, version = package.split(":") - self._update_dependencies(group, artifact, version) + required_list.append(package) for package in self.config["pinned-packages"]: + required_list.append(package) + + found = True + for package in required_list: group, artifact, version = package.split(":") self._update_dependencies(group, artifact, version) + if group not in self.depends \ + or artifact not in self.depends[group] \ + or version not in self.depends[group][artifact] \ + or self.depends[group][artifact][version] is None: + print(f"Required package not found: {group}:{artifact}:{version}; download with Maven") + found = False + + if not found: + sys.exit(1) def _higher_version(self, curver, newver): if curver == newver: @@ -512,10 +541,7 @@ def args(self): if key not in argset: args.append(arg) - for arg in ["-x:org.xmlresolver.tools.ResolvingXMLReader", - "-y:org.xmlresolver.tools.ResolvingXMLReader", - "-r:org.xmlresolver.Resolver", - "-init:org.docbook.xsltng.extensions.Register"]: + for arg in ["-init:org.docbook.xsltng.extensions.Register"]: if ":" in arg: key = arg[0:arg.index(":")] else: @@ -535,7 +561,7 @@ def run(self): print(self._java) for item in jopt: print(f"\t{item}") - print("-cp") + print("-cp (in addition to libs/lib/*.jar)") for item in cp.split(os.pathsep): print(f"\t{item}") print(self.config["class"]) diff --git a/src/main/java/org/docbook/xsltng/Main.java b/src/main/java/org/docbook/xsltng/Main.java index 4ab64acd1..6452d8519 100644 --- a/src/main/java/org/docbook/xsltng/Main.java +++ b/src/main/java/org/docbook/xsltng/Main.java @@ -62,9 +62,6 @@ public void run() { } System.setProperty("xml.catalog.files", catBuilder.toString()); - userArgs.add("-x:org.xmlresolver.tools.ResolvingXMLReader"); - userArgs.add("-y:org.xmlresolver.tools.ResolvingXMLReader"); - userArgs.add("-r:org.xmlresolver.Resolver"); userArgs.add("-init:org.docbook.xsltng.extensions.Register"); if (!userStylesheet) { userArgs.add("-xsl:https://cdn.docbook.org/release/xsltng/current/xslt/docbook.xsl"); diff --git a/src/test/resources/xml/fixed.xml b/src/test/resources/xml/fixed.xml new file mode 100644 index 000000000..9bd54dfa1 --- /dev/null +++ b/src/test/resources/xml/fixed.xml @@ -0,0 +1,48 @@ +
+content + + + + + + + + + + +content +content +content +content + + + + +content +content +content + + + +content +content + + + +content +content +content + + + +content +content +content + + + + + + +
diff --git a/src/test/resources/xspec/generate-tests-utils.xsl b/src/test/resources/xspec/generate-tests-utils.xsl deleted file mode 100644 index 359bb3362..000000000 --- a/src/test/resources/xspec/generate-tests-utils.xsl +++ /dev/null @@ -1,699 +0,0 @@ - - - - - - - - - - - - -http://www.jenitennison.com/xslt/xspec/generate-tests-utils.xsl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* - - - - - - - - / - - ( - - - - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - xs:ID - xs:IDREF - xs:ENTITY - xs:NCName - - xs:language - xs:Name - xs:NMTOKEN - xs:token - xs:normalizedString - xs:negativeInteger - xs:nonPositiveInteger - xs:byte - xs:short - xs:int - xs:long - xs:unsignedByte - xs:unsignedShort - xs:unsignedInt - xs:unsignedLong - xs:positiveInteger - xs:nonNegativeInteger - - - - - - xs:yearMonthDuration - xs:dayTimeDuration - - - xs:untypedAtomic - - - - - - xs:integer - - - xs:string - xs:boolean - xs:decimal - xs:double - xs:float - xs:date - xs:time - xs:dateTime - xs:duration - xs:QName - xs:anyURI - xs:gDay - xs:gMonthDay - xs:gMonth - xs:gYearMonth - xs:gYear - xs:base64Binary - xs:hexBinary - - xs:anyAtomicType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/xspec/uri-utils.xsl b/src/test/resources/xspec/uri-utils.xsl new file mode 100644 index 000000000..82ee028e3 --- /dev/null +++ b/src/test/resources/xspec/uri-utils.xsl @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/xspec/xspec.sh b/src/test/resources/xspec/xspec.sh index bb282fdcd..d1b4adaa2 100755 --- a/src/test/resources/xspec/xspec.sh +++ b/src/test/resources/xspec/xspec.sh @@ -20,7 +20,7 @@ ## and used instead. You just have to ensure it is visible from here ## (aka "ensure it is in the $PATH"). Even without packaging support, ## this script is a useful way to launch Saxon from the shell. -## +## ## TODO: With the Packaging System, there should be no need to set the ## XSPEC_HOME, as we could use absolute public URIs for the public ## components... @@ -34,9 +34,9 @@ usage() { if test -n "$1"; then echo "$1" - echo; + echo fi - echo "Usage: xspec [-t|-q|-s|-c|-j|-catalog file|-h] file" + echo "Usage: xspec [-t|-q|-s|-c|-j|-catalog file|-e|-h] file" echo echo " file the XSpec document" echo " -t test an XSLT stylesheet (the default)" @@ -45,12 +45,13 @@ usage() { echo " -c output test coverage report (XSLT only)" echo " -j output JUnit report" echo " -catalog file use XML Catalog file to locate resources" + echo " -e treat failed tests as error" echo " -h display this help message" } die() { echo - echo "*** $@" >&2 + echo "*** $*" >&2 exit 1 } @@ -59,46 +60,40 @@ die() { # script for Saxon [1]. If it is present, that means the user already # configured it, so there is no point to duplicate the logic here. # Just use it. +# [1]http://code.google.com/p/expath-pkg/source/browse/trunk/saxon/pkg-saxon/src/shell/saxon -if which saxon > /dev/null 2>&1 && saxon --help | grep "EXPath Packaging" > /dev/null 2>&1; then +if command -v saxon > /dev/null 2>&1 && saxon --help | grep "EXPath Packaging" > /dev/null 2>&1; then echo Saxon script found, use it. echo xslt() { saxon \ --java -Dxspec.coverage.ignore="${TEST_DIR}" \ --java -Dxspec.coverage.xml="${COVERAGE_XML}" \ + --java -Dxspec.home="${XSPEC_HOME}" \ --java -Dxspec.xspecfile="${XSPEC}" \ --add-cp "${XSPEC_HOME}/java/" ${CATALOG:+"$CATALOG"} --xsl "$@" } xquery() { - saxon \ - --java -Dxspec.coverage.ignore="${TEST_DIR}" \ - --java -Dxspec.coverage.xml="${COVERAGE_XML}" \ - --java -Dxspec.xspecfile="${XSPEC}" \ - --add-cp "${XSPEC_HOME}/java/" ${CATALOG:+"$CATALOG"} --xq "$@" + saxon --add-cp "${XSPEC_HOME}/java/" ${CATALOG:+"$CATALOG"} --xq "$@" } else - echo Saxon script not found, invoking JVM directly instead. - echo xslt() { java \ -Dxspec.coverage.ignore="${TEST_DIR}" \ -Dxspec.coverage.xml="${COVERAGE_XML}" \ + -Dxspec.home="${XSPEC_HOME}" \ -Dxspec.xspecfile="${XSPEC}" \ -Dorg.docbook.xsltng.extensions.pygmentize=${PYGMENTIZE} \ -Dorg.docbook.xsltng.verbose=${VERBOSE} \ -cp "$CP" net.sf.saxon.Transform ${CATALOG:+"$CATALOG"} \ - -init:org.docbook.xsltng.extensions.Register "$@" + -init:org.docbook.xsltng.extensions.Register "$@" } xquery() { java \ - -Dxspec.coverage.ignore="${TEST_DIR}" \ - -Dxspec.coverage.xml="${COVERAGE_XML}" \ - -Dxspec.xspecfile="${XSPEC}" \ -Dorg.docbook.xsltng.extensions.pygmentize=${PYGMENTIZE} \ -Dorg.docbook.xsltng.verbose=${VERBOSE} \ -cp "$CP" net.sf.saxon.Query ${CATALOG:+"$CATALOG"} \ - -init:org.docbook.xsltng.extensions.Register "$@" + -init:org.docbook.xsltng.extensions.Register "$@" } fi @@ -107,14 +102,14 @@ fi ## # the command to use to open the final HTML report -if [ `uname` = "Darwin" ]; then - OPEN=open -else - OPEN=see -fi +#if [ $(uname) = "Darwin" ]; then +# OPEN=open +#else +# OPEN=see +#fi # the classpath delimiter (aka ':', except ';' on Cygwin) -if uname | grep -i cygwin >/dev/null 2>&1; then +if uname | grep -i cygwin > /dev/null 2>&1; then CP_DELIM=";" else CP_DELIM=":" @@ -123,17 +118,17 @@ fi # set XSPEC_HOME if it has not been set by the user (set it to the # parent dir of this script) if test -z "$XSPEC_HOME"; then - XSPEC_HOME=`dirname $0`; - XSPEC_HOME=`dirname $XSPEC_HOME`; + XSPEC_HOME=$(dirname "$0") + XSPEC_HOME=$(dirname "$XSPEC_HOME") fi # safety checks if test \! -d "${XSPEC_HOME}"; then echo "ERROR: XSPEC_HOME is not a directory: ${XSPEC_HOME}" - exit 1; + exit 1 fi -if test \! -f "${XSPEC_HOME}/src/compiler/generate-common-tests.xsl"; then +if test \! -f "${XSPEC_HOME}/src/compiler/base/main.xsl"; then echo "ERROR: XSPEC_HOME seems to be corrupted: ${XSPEC_HOME}" - exit 1; + exit 1 fi # set SAXON_CP (either it has been by the user, or set it from SAXON_HOME) @@ -143,13 +138,12 @@ unset USE_SAXON_HOME if test -z "$SAXON_CP"; then if test -z "$SAXON_HOME"; then echo "SAXON_CP and SAXON_HOME both not set!" -# die "SAXON_CP and SAXON_HOME both not set!" + # die "SAXON_CP and SAXON_HOME both not set!" else USE_SAXON_HOME=1 for f in \ "${SAXON_HOME}"/saxon9?e.jar \ - "${SAXON_HOME}"/saxon-?e-??.?*.jar - do + "${SAXON_HOME}"/saxon-?e-??.?*.jar; do [ -f "${f}" ] && SAXON_CP="${f}" done fi @@ -158,10 +152,10 @@ fi if [ -n "${USE_SAXON_HOME}" ]; then if [ -z "${SAXON_CP}" ]; then echo "Saxon jar cannot be found in SAXON_HOME: $SAXON_HOME" -# die "Saxon jar cannot be found in SAXON_HOME: $SAXON_HOME" + # die "Saxon jar cannot be found in SAXON_HOME: $SAXON_HOME" else if test -f "${SAXON_HOME}/xml-resolver-1.2.jar"; then - SAXON_CP="${SAXON_CP}${CP_DELIM}${SAXON_HOME}/xml-resolver-1.2.jar"; + SAXON_CP="${SAXON_CP}${CP_DELIM}${SAXON_HOME}/xml-resolver-1.2.jar" fi fi fi @@ -172,7 +166,8 @@ CP="${SAXON_CP}${CP_DELIM}${XSPEC_HOME}/java/" ## options ################################################################### ## -while echo "$1" | grep -- ^- >/dev/null 2>&1; do +# Use printf instead of echo: https://stackoverflow.com/a/3657061/11853330 +while printf "%s\n" "$1" | grep -- ^- > /dev/null 2>&1; do case "$1" in # XSLT -t) @@ -184,7 +179,8 @@ while echo "$1" | grep -- ^- >/dev/null 2>&1; do usage "-s and -t are mutually exclusive" exit 1 fi - XSLT=1;; + XSLT=1 + ;; # XQuery -q) if test -n "$XSLT"; then @@ -195,7 +191,8 @@ while echo "$1" | grep -- ^- >/dev/null 2>&1; do usage "-s and -q are mutually exclusive" exit 1 fi - XQUERY=1;; + XQUERY=1 + ;; # Schematron -s) if test -n "$XQUERY"; then @@ -206,27 +203,37 @@ while echo "$1" | grep -- ^- >/dev/null 2>&1; do usage "-s and -t are mutually exclusive" exit 1 fi - SCHEMATRON=1;; + SCHEMATRON=1 + ;; # Coverage -c) - COVERAGE=1;; + COVERAGE=1 + ;; # JUnit report -j) - JUNIT=1;; + JUNIT=1 + ;; # Catalog -catalog) shift - XML_CATALOG="$1";; + XML_CATALOG="$1" + ;; + # Error on test failure + -e) + ERROR_ON_TEST_FAILURE=1 + ;; # Help! -h) usage - exit 0;; + exit 0 + ;; # Unknown option! -*) usage "Error: Unknown option: $1" - exit 1;; + exit 1 + ;; esac - shift; + shift done # Coverage is only for XSLT @@ -244,7 +251,7 @@ fi # set XSLT if XQuery has not been set (that's the default) if test -z "$XQUERY"; then - XSLT=1; + XSLT=1 fi XSPEC=$1 @@ -263,8 +270,7 @@ fi ## # TEST_DIR (may be relative, may not exist) -if [ -z "$TEST_DIR" ] -then +if [ -z "$TEST_DIR" ]; then TEST_DIR=$(dirname "$XSPEC")/xspec fi @@ -277,7 +283,9 @@ else COMPILED="${COMPILED}.xq" fi COVERAGE_XML=$TEST_DIR/$TARGET_FILE_NAME-coverage.xml -COVERAGE_HTML=$TEST_DIR/$TARGET_FILE_NAME-coverage.html +if [ -z "${COVERAGE_HTML}" ]; then + COVERAGE_HTML="${TEST_DIR}/${TARGET_FILE_NAME}-coverage.html" +fi RESULT=$TEST_DIR/$TARGET_FILE_NAME-result.xml HTML=$TEST_DIR/$TARGET_FILE_NAME-result.html JUNIT_RESULT=$TEST_DIR/$TARGET_FILE_NAME-junit.xml @@ -287,92 +295,60 @@ if [ ! -d "$TEST_DIR" ]; then echo "Creating XSpec Directory at $TEST_DIR..." mkdir "$TEST_DIR" echo -fi +fi ## ## compile the suite ######################################################### ## if test -n "$SCHEMATRON"; then - echo "Setting up Schematron preprocessors..." - - if test -z "$SCHEMATRON_XSLT_INCLUDE"; then - SCHEMATRON_XSLT_INCLUDE="$XSPEC_HOME/src/schematron/iso-schematron/iso_dsdl_include.xsl"; + SCH_PREPROCESSED_XSPEC="${TEST_DIR}/${TARGET_FILE_NAME}-sch-preprocessed.xspec" + SCH_PREPROCESSED_XSL="${TEST_DIR}/${TARGET_FILE_NAME}-sch-preprocessed.xsl" + + SCHUT_TO_XSLT_PARAMS=() + if [ -n "${SCHEMATRON_XSLT_INCLUDE}" ]; then + if [ "${SCHEMATRON_XSLT_INCLUDE}" = "#none" ]; then + SCHUT_TO_XSLT_PARAMS+=("STEP1-PREPROCESSOR-URI=${SCHEMATRON_XSLT_INCLUDE}") + else + SCHUT_TO_XSLT_PARAMS+=("+STEP1-PREPROCESSOR-DOC=${SCHEMATRON_XSLT_INCLUDE}") + fi fi - if test -z "$SCHEMATRON_XSLT_EXPAND"; then - SCHEMATRON_XSLT_EXPAND="$XSPEC_HOME/src/schematron/iso-schematron/iso_abstract_expand.xsl"; + if [ -n "${SCHEMATRON_XSLT_EXPAND}" ]; then + if [ "${SCHEMATRON_XSLT_EXPAND}" = "#none" ]; then + SCHUT_TO_XSLT_PARAMS+=("STEP2-PREPROCESSOR-URI=${SCHEMATRON_XSLT_EXPAND}") + else + SCHUT_TO_XSLT_PARAMS+=("+STEP2-PREPROCESSOR-DOC=${SCHEMATRON_XSLT_EXPAND}") + fi fi - if test -n "${SCHEMATRON_XSLT_COMPILE}"; then - # Absolute SCHEMATRON_XSLT_COMPILE - SCHEMATRON_XSLT_COMPILE_ABS="$(cd "$(dirname "${SCHEMATRON_XSLT_COMPILE}")" && pwd)/$(basename "${SCHEMATRON_XSLT_COMPILE}")" + if [ -n "${SCHEMATRON_XSLT_COMPILE}" ]; then + SCHUT_TO_XSLT_PARAMS+=("+STEP3-PREPROCESSOR-DOC=${SCHEMATRON_XSLT_COMPILE}") fi - - # Get Schematron file URI - xslt -o:"${TEST_DIR}/${TARGET_FILE_NAME}-var.txt" \ - -s:"${XSPEC}" \ - -xsl:"${XSPEC_HOME}/src/schematron/locate-schematron-uri.xsl" \ - || die "Error getting Schematron location" - SCH_URI=`cat "${TEST_DIR}/${TARGET_FILE_NAME}-var.txt"` - - # Generate Step 3 wrapper XSLT - if test -n "${SCHEMATRON_XSLT_COMPILE}"; then - SCHEMATRON_XSLT_COMPILE_URI="file:${SCHEMATRON_XSLT_COMPILE_ABS}" - fi - SCH_STEP3_WRAPPER="${TEST_DIR}/${TARGET_FILE_NAME}-sch-step3-wrapper.xsl" - xslt -o:"${SCH_STEP3_WRAPPER}" \ - -s:"${XSPEC}" \ - -xsl:"${XSPEC_HOME}/src/schematron/generate-step3-wrapper.xsl" \ - "ACTUAL-PREPROCESSOR-URI=${SCHEMATRON_XSLT_COMPILE_URI}" \ - || die "Error generating Step 3 wrapper XSLT" - - SCH_PREPROCESSED_XSPEC="${TEST_DIR}/${TARGET_FILE_NAME}-sch-preprocessed.xspec" - SCH_PREPROCESSED_XSL="${TEST_DIR}/${TARGET_FILE_NAME}-sch-preprocessed.xsl" - - # Absolute SCH_PREPROCESSED_XSL - SCH_PREPROCESSED_XSL_ABS="$(cd "$(dirname "${SCH_PREPROCESSED_XSL}")" && pwd)/$(basename "${SCH_PREPROCESSED_XSL}")" - + echo echo "Converting Schematron into XSLT..." - xslt -o:"$TEST_DIR/$TARGET_FILE_NAME-step1.sch" \ - -s:"${SCH_URI}" \ - -xsl:"$SCHEMATRON_XSLT_INCLUDE" \ - -versionmsg:off \ - || die "Error preprocessing Schematron on step 1" - xslt -o:"$TEST_DIR/$TARGET_FILE_NAME-step2.sch" \ - -s:"$TEST_DIR/$TARGET_FILE_NAME-step1.sch" \ - -xsl:"$SCHEMATRON_XSLT_EXPAND" \ - -versionmsg:off \ - || die "Error preprocessing Schematron on step 2" - xslt -o:"${SCH_PREPROCESSED_XSL}" \ - -s:"${TEST_DIR}/${TARGET_FILE_NAME}-step2.sch" \ - -xsl:"${SCH_STEP3_WRAPPER}" \ - -versionmsg:off \ - || die "Error preprocessing Schematron on step 3" - - # use XQuery to get full URI to preprocessed Schematron XSLT - # xquery -qs:"declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:method 'text'; replace(iri-to-uri(document-uri(/)), concat(codepoints-to-string(94), 'file:/'), '')" \ - # -s:"$SCH_PREPROCESSED_XSL" \ - # -o:"$TEST_DIR/$TARGET_FILE_NAME-var.txt" \ - # || die "Error getting preprocessed Schematron XSLT location" - # SCH_PREPROCESSED_XSL_URI=`cat "$TEST_DIR/$TARGET_FILE_NAME-var.txt"` - SCH_PREPROCESSED_XSL_URI="file:${SCH_PREPROCESSED_XSL_ABS}" - - echo + xslt \ + -o:"${SCH_PREPROCESSED_XSL}" \ + -s:"${XSPEC}" \ + -xsl:"${XSPEC_HOME}/src/schematron/schut-to-xslt.xsl" \ + "${SCHUT_TO_XSLT_PARAMS[@]}" \ + || die "Error converting Schematron into XSLT" + + echo echo "Converting Schematron XSpec into XSLT XSpec..." xslt -o:"${SCH_PREPROCESSED_XSPEC}" \ -s:"${XSPEC}" \ -xsl:"${XSPEC_HOME}/src/schematron/schut-to-xspec.xsl" \ - stylesheet-uri="${SCH_PREPROCESSED_XSL_URI}" \ + +stylesheet-doc="${SCH_PREPROCESSED_XSL}" \ || die "Error converting Schematron XSpec into XSLT XSpec" XSPEC="${SCH_PREPROCESSED_XSPEC}" - - echo + + echo fi if test -n "$XSLT"; then - COMPILE_SHEET=generate-xspec-tests.xsl + COMPILE_SHEET=compile-xslt-tests.xsl else - COMPILE_SHEET=generate-query-tests.xsl + COMPILE_SHEET=compile-xquery-tests.xsl fi echo "Creating Test Stylesheet..." xslt -o:"$COMPILED" -s:"$XSPEC" \ @@ -384,6 +360,11 @@ echo ## run the suite ############################################################# ## +# Init otherwise SC2154 +saxon_custom_options_array=() + +# Split options taking quotes into account (like command arguments) +# https://superuser.com/q/1066455 declare -a "saxon_custom_options_array=(${SAXON_CUSTOM_OPTIONS})" echo "Running Tests..." @@ -394,27 +375,19 @@ if test -n "$XSLT"; then xslt "${saxon_custom_options_array[@]}" \ -T:$COVERAGE_CLASS \ -o:"$RESULT" -xsl:"$COMPILED" \ - -it:{http://www.jenitennison.com/xslt/xspec}main \ + -it:"{http://www.jenitennison.com/xslt/xspec}main" \ || die "Error collecting test coverage data" else xslt "${saxon_custom_options_array[@]}" \ -o:"$RESULT" -xsl:"$COMPILED" \ - -it:{http://www.jenitennison.com/xslt/xspec}main \ + -it:"{http://www.jenitennison.com/xslt/xspec}main" \ || die "Error running the test suite" fi else # for XQuery - if test -n "$COVERAGE"; then - echo "Collecting test coverage data..." - xquery "${saxon_custom_options_array[@]}" \ - -T:$COVERAGE_CLASS \ - -o:"$RESULT" -q:"$COMPILED" \ - || die "Error collecting test coverage data" - else - xquery "${saxon_custom_options_array[@]}" \ - -o:"$RESULT" -q:"$COMPILED" \ - || die "Error running the test suite" - fi + xquery "${saxon_custom_options_array[@]}" \ + -o:"$RESULT" -q:"$COMPILED" \ + || die "Error running the test suite" fi ## @@ -460,15 +433,14 @@ else fi ## -## cleanup +## error on test failure ##################################################### ## -if test -n "$SCHEMATRON"; then - rm -f "$SCH_PREPROCESSED_XSPEC" - rm -f "$TEST_DIR/$TARGET_FILE_NAME-var.txt" - rm -f "$TEST_DIR/$TARGET_FILE_NAME-step1.sch" - rm -f "$TEST_DIR/$TARGET_FILE_NAME-step2.sch" - rm -f "$SCH_STEP3_WRAPPER" - rm -f "$SCH_PREPROCESSED_XSL" + +if [ -n "${ERROR_ON_TEST_FAILURE}" ]; then + xslt \ + -s:"${RESULT}" \ + -xsl:"${XSPEC_HOME}/src/cli/terminate-on-test-failure.xsl" 2> /dev/null \ + || die "Found a test failure" fi echo "Done." diff --git a/tools/saxon.enc b/tools/saxon.enc index d97156900..fbc44c9bc 100644 Binary files a/tools/saxon.enc and b/tools/saxon.enc differ diff --git a/tools/xform-10-tng.xsl b/tools/xform-10-tng.xsl index e06aa1792..0fbe495aa 100644 --- a/tools/xform-10-tng.xsl +++ b/tools/xform-10-tng.xsl @@ -6,7 +6,7 @@ xmlns:l="http://docbook.org/ns/docbook/l10n" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:xs="http://www.w3.org/2001/XMLSchema" - exclude-result-prefixes="doc f l map xs" + exclude-result-prefixes="#all" version="3.0">