diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..94cb4752b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +target/ +.idea/ +*.iml +test/result.log +**/xspec/* +*-result.html +*-report.html diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..3d20c2f1b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,57 @@ +language: generic +env: + global: + # full path to Saxon jar + - SAXON_CP=/tmp/xspec/saxon/saxon9he.jar + # Ant version used in oXygen + - ANT_VERSION=1.9.8 + # full path to XML Resolver jar + - XML_RESOLVER_CP=/tmp/xspec/xml-resolver/xml-resolver.jar + matrix: + # latest Saxon 9.8 version + - SAXON_VERSION=9.8.0-7 + # latest Saxon 9.7 version + - SAXON_VERSION=9.7.0-21 + XMLCALABASH_VERSION=1.1.16-97 + BASEX_VERSION=8.6.4 + # Saxon version used in oXygen + - SAXON_VERSION=9.7.0-19 + +before_install: + - unset _JAVA_OPTIONS + +before_script: + # install Saxon + - curl -fsSL --create-dirs -o ${SAXON_CP} http://central.maven.org/maven2/net/sf/saxon/Saxon-HE/${SAXON_VERSION}/Saxon-HE-${SAXON_VERSION}.jar + # install XML Calabash + - if [ -z ${XMLCALABASH_VERSION} ]; then + echo "XMLCalabash will not be installed as it uses a higher version of Saxon"; + else + curl -fsSL --create-dirs -o /tmp/xspec/xmlcalabash/xmlcalabash.zip https://github.com/ndw/xmlcalabash1/releases/download/${XMLCALABASH_VERSION}/xmlcalabash-${XMLCALABASH_VERSION}.zip; + unzip /tmp/xspec/xmlcalabash/xmlcalabash.zip -d /tmp/xspec/xmlcalabash; + export XMLCALABASH_CP=/tmp/xspec/xmlcalabash/xmlcalabash-${XMLCALABASH_VERSION}/xmlcalabash-${XMLCALABASH_VERSION}.jar; + fi + # install BaseX + - if [[ -z ${XMLCALABASH_VERSION} && -z ${BASEX_VERSION} ]]; then + echo "BaseX will not be installed as it requires to run XMLCalabash with a higher version of Saxon"; + else + export BASEX_CP=/tmp/xspec/basex/basex.jar; + curl -fsSL --create-dirs -o ${BASEX_CP} http://files.basex.org/maven/org/basex/basex/${BASEX_VERSION}/basex-${BASEX_VERSION}.jar; + fi + # install Ant + - curl -fsSL --create-dirs -o /tmp/xspec/ant/ant.tar.gz http://archive.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz + - tar xf /tmp/xspec/ant/ant.tar.gz -C /tmp/xspec/ant; + - export PATH=/tmp/xspec/ant/apache-ant-${ANT_VERSION}/bin:{$PATH} + # install XML Resolver + - curl -fsSL --create-dirs -o ${XML_RESOLVER_CP} http://central.maven.org/maven2/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar + +script: + - ant -version + - cd test + - echo "execute bats unit tests" + - bats --tap xspec.bats + - echo "execute XSpec unit tests" + - ./run-xspec-tests.sh + - echo "execute XSpec end-to-end tests" + - cd end-to-end + - ./run-e2e-tests.sh diff --git a/LICENSE b/LICENSE index 3765d7449..c8073d063 100755 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2008, 2010 Jeni Tennison +Copyright (c) 2008-2017 Jeni Tennison Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/README.md b/README.md index f93118cf2..9aa028f97 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,26 @@ -## XSpec +[![Travis Build Status](https://api.travis-ci.org/xspec/xspec.svg?branch=master "Travis Build Status")](https://travis-ci.org/xspec/xspec) +[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/github/xspec/xspec?branch=master&svg=true "AppVeyor Build Status")](https://ci.appveyor.com/project/xspec/xspec/branch/master) -Version 0.4.0. +## XSpec [![Release](https://img.shields.io/github/release/xspec/xspec.svg)](https://github.com/xspec/xspec/releases/latest) -XSpec is a [Behaviour Driven Development](http://en.wikipedia.org/wiki/Behavior_Driven_Development) -(BDD) framework for XSLT and XQuery. It is based on the Spec -framework of [RSpec](http://rspec.info/), which is a BDD framework for -Ruby. +XSpec is a unit test and [behaviour driven development](http://en.wikipedia.org/wiki/Behavior_Driven_Development) (BDD) framework for XSLT and XQuery. It is based on the Spec framework of [RSpec](http://rspec.info/), which is a BDD framework for Ruby. -XSpec consists of a syntax for describing the behaviour of your XSLT -or XQuery code, and some code that enables you to test your code -against those descriptions. +XSpec consists of a syntax for describing the behaviour of XSLT or XQuery code and some code that enables to test the code against those descriptions. -Maven plugins for running XSpec tests as part of a build are available from [adamretter](http://github.com/adamretter/xspec-maven-plugin) and [daisy](http://github.com/daisy/xspec-maven-plugin). +## Getting Started -An external project, [jxsl](http://code.google.com/p/jxsl/), provides -a Maven archetype for XSpec (Ant is expected soon). The goal is to -provide everything needed to integrate with Continuous Integration -tools for Java (like Hudson, Cruise Control, etc.) See Benoit's -[presentation at Balisage 2011](http://www.balisage.net/Proceedings/vol7/html/Mercier01/BalisageVol7-Mercier01.html) -in Montreal for more info. +To get started, check out the installation instructions for [MacOS/Linux](https://github.com/xspec/xspec/wiki/Installation-on-Mac-and-Linux) and [Windows](https://github.com/xspec/xspec/wiki/Installation-on-Windows) and how to [write your first XSpec test](https://github.com/xspec/xspec/wiki/Getting-Started). -The project owners are Jeni Tennison and Florent Georges. +## Support -### Usage: +Check out the XSpec documentation in the [wiki](https://github.com/xspec/xspec/wiki) before raising an issue or ask a question. If you have any question which is not answered in the wiki, feel free to [raise an issue](https://github.com/xspec/xspec/issues) or post it in the [XSpec discussion list](http://groups.google.com/group/xspec-users). -For more information about using XSpec, visit the project wiki at -. If you have any questions, -you can also join (or search the archives of) the XSpec discussion -list: . +## Contribute +XSpec is an open source project originally written by [Jeni Tennison](https://github.com/JeniT). It was maintained in the past years by [Florent Georges](https://github.com/fgeorges). Active development of XSpec restarted in 2016 and the project is currently maintained by [Sandro Cirulli](https://github.com/cirulls) with the help of the XSpec community. -### License: +If you wish to contribute to XSpec, [raise or pick up an issue](https://github.com/xspec/xspec/issues) and [send us your pull requests](https://github.com/xspec/xspec/pulls). Please document any issue with examples of your XSpec code. -XSpec is released under the MIT license. For a copy of this license, -see [LICENSE](LICENSE), or go to . +## License + +XSpec is released under the [MIT License](LICENSE). [Few parts of the codebase](https://github.com/xspec/xspec/blob/master/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java) are released under the [Mozilla Public License](http://www.mozilla.org/MPL/). diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..0319ebdac --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,77 @@ +environment: + global: + # full path to Saxon jar + SAXON_CP: '%TEMP%\xspec\saxon\saxon9he.jar' + # Ant version used in oXygen + ANT_VERSION: 1.9.8 + # full path to XML Resolver jar + XML_RESOLVER_CP: '%TEMP%\xspec\xml-resolver\xml-resolver.jar' + matrix: + # latest Saxon 9.8 version + - SAXON_VERSION: 9.8.0-7 + # latest Saxon 9.7 version + - SAXON_VERSION: 9.7.0-21 + XMLCALABASH_VERSION: 1.1.16-97 + # Saxon version used in oXygen + - SAXON_VERSION: 9.7.0-19 + +install: +- ps: >- + # install Saxon + + curl.exe -fsSL --create-dirs -o "${env:SAXON_CP}" "http://central.maven.org/maven2/net/sf/saxon/Saxon-HE/${env:SAXON_VERSION}/Saxon-HE-${env:SAXON_VERSION}.jar" + + + # install XML Calabash + + if( -Not( Test-Path -Path env:\XMLCALABASH_VERSION ) ) { + echo "XMLCalabash will not be installed as it uses a higher version of Saxon" + } + + else { + curl.exe -fsSL --create-dirs -o "${env:TEMP}\xspec\xmlcalabash\xmlcalabash.zip" "https://github.com/ndw/xmlcalabash1/releases/download/${env:XMLCALABASH_VERSION}/xmlcalabash-${env:XMLCALABASH_VERSION}.zip" + 7z x "${env:TEMP}\xspec\xmlcalabash\xmlcalabash.zip" -o"${env:TEMP}\xspec\xmlcalabash" + ${env:XMLCALABASH_CP} = "${env:TEMP}\xspec\xmlcalabash\xmlcalabash-${env:XMLCALABASH_VERSION}\xmlcalabash-${env:XMLCALABASH_VERSION}.jar" + } + + + # install Ant without installing JDK + + choco install ant --ignore-dependencies --no-progress --version "${env:ANT_VERSION}" + + + # install XML Resolver + + curl.exe -fsSL --create-dirs -o "${env:XML_RESOLVER_CP}" "http://central.maven.org/maven2/xml-resolver/xml-resolver/1.2/xml-resolver-1.2.jar" +build: off +test_script: +- cmd: >- + rem Print Java version + + java -version + + + rem Print Ant version + + ant -version + + + rem Print Saxon version + + java -cp "%SAXON_CP%" net.sf.saxon.Transform 2>&1 | find /i "saxon-" + + + rem execute xspec.bat unit tests + + test\xspec-bat.cmd + + + rem execute XSpec unit tests + + test\run-xspec-tests.cmd + + + rem execute XSpec end-to-end tests + + test\end-to-end\run-e2e-tests.cmd +deploy: off diff --git a/bin/xspec.bat b/bin/xspec.bat index 4e249caad..bff3e7bb7 100644 --- a/bin/xspec.bat +++ b/bin/xspec.bat @@ -1,95 +1,621 @@ @echo off -SET CP=C:\Program Files (x86)\Oxygen XML Editor\lib\saxon9sa.jar - -SET XSPEC=%1 - -REM ========================================== -REM Check if a parameter was passed -REM ========================================== -IF %XSPEC%x == x GOTO notfound - -REM ========================================== -REM Check if xspec document exists -REM ========================================== -IF NOT EXIST %XSPEC% GOTO notfound -GOTO endif1 - -:notfound -echo File not found. -echo Usage: -echo xspec filename [coverage] -echo filename should specify an XSpec document -echo if coverage is specified, outputs test coverage report -GOTO end -:endif1 - - -SET COVERAGE=%2 - -SET TEST_DIR=%~dp1xspec -SET TARGET_FILE_NAME=%~n1 - -SET TEST_STYLESHEET="%TEST_DIR%\%TARGET_FILE_NAME%.xsl" -SET COVERAGE_XML="%TEST_DIR%\%TARGET_FILE_NAME%-coverage.xml" -SET COVERAGE_HTML="%TEST_DIR%\%TARGET_FILE_NAME%-coverage.html" -SET RESULT="%TEST_DIR%\%TARGET_FILE_NAME%-result.xml" -SET HTML="%TEST_DIR%\%TARGET_FILE_NAME%-result.html" - -REM ================================================ -REM Create xspec subdirectory for running the tests -REM ================================================ -IF NOT EXIST "%TEST_DIR%" GOTO notestdir -GOTO endif2 -:notestdir -echo Creating XSpec Directory at "%TEST_DIR%" ... -mkdir "%TEST_DIR%" -echo. -:endif2 +rem +rem ############################################################################## +rem ## +rem ## This script is used to compile a test suite to XSLT, run it, format +rem ## the report and open it in a browser. +rem ## +rem ## It relies on the environment variable SAXON_HOME to be set to the +rem ## dir Saxon has been installed to (i.e. the containing the Saxon JAR +rem ## file), or on SAXON_CP to be set to a full classpath containing +rem ## Saxon (and maybe more). The latter has precedence over the former. +rem ## +rem ## It also uses the environment variable XSPEC_HOME. It must be set +rem ## to the XSpec install directory. By default, it uses this script's +rem ## parent dir. +rem ## +rem ## TODO: Not aware of the EXPath Packaging System +rem ## +rem ############################################################################## +rem +rem Comments (rem) +rem Comments starting with '#' are derived from xspec.sh (possibly with +rem some modifications). +rem +rem Environment variables (%FOO%) +rem Environment variables are tried to be on parity with xspec.sh, +rem except that those starting with 'WIN_' are only for this batch +rem file. +rem +rem Labels (:foo) +rem Labels are tried to be on parity with functions in xspec.sh, except +rem that those starting with 'win_' are only for this batch file. +rem +rem +rem Skip over "utility functions" +rem +goto :win_main_enter + +rem ## +rem ## utility functions ######################################################### +rem ## + +:usage + if not "%~1"=="" ( + call :win_echo %1 + echo: + ) + echo Usage: xspec [-t^|-q^|-s^|-c^|-j^|-h] filename [coverage] + echo: + echo filename the XSpec document + echo -t test an XSLT stylesheet (the default) + echo -q test an XQuery module (mutually exclusive with -t and -s) + echo -s test a Schematron schema (mutually exclusive with -t and -q) + echo -c output test coverage report + echo -j output JUnit report + echo -h display this help message + echo coverage deprecated, use -c instead + goto :EOF + +:die + echo: + echo *** %~1 >&2 + rem + rem Now, to exit the batch file, you must go to :win_main_error_exit from + rem the main code flow. + rem + goto :EOF + +:xslt + java -cp "%CP%" net.sf.saxon.Transform %* + goto :EOF + +:win_xslt_trace + rem + rem Inner Redirect: + rem By swapping stdout and stderr, send stderr to pipe (as stdout) + rem while allowing original stdout to survive (as stderr) + rem + rem Pipe: + rem To keep the output XML well-formed, remove the stdout lines + rem that don't look like XML element, assuming %COVERAGE_CLASS% + rem emits every required line in this format + rem + rem Outer Redirect: + rem To restore the original direction, swap stdout and stderr again + rem + ( java -cp "%CP%" net.sf.saxon.Transform %* 3>&2 2>&1 1>&3 | findstr /r /c:"^<..*>$" ) 3>&2 2>&1 1>&3 + goto :EOF + +:xquery + java -cp "%CP%" net.sf.saxon.Query %* + goto :EOF + +:win_xquery_trace + rem + rem As for redirect and pipe, see :win_xslt_trace + rem + ( java -cp "%CP%" net.sf.saxon.Query %* 3>&2 2>&1 1>&3 | findstr /r /c:"^<..*>$" ) 3>&2 2>&1 1>&3 + goto :EOF + +:win_reset_options + set XSLT= + set XQUERY= + set SCHEMATRON= + set SCH_PARAMS= + set COVERAGE= + set JUNIT= + set WIN_HELP= + set WIN_UNKNOWN_OPTION= + set WIN_DEPRECATED_COVERAGE= + set WIN_EXTRA_OPTION= + set XSPEC= + goto :EOF + +:win_get_options + set WIN_ARGV=%~1 + + if not defined WIN_ARGV ( + goto :EOF + ) else if "%WIN_ARGV%"=="-t" ( + set XSLT=1 + ) else if "%WIN_ARGV%"=="-q" ( + set XQUERY=1 + ) else if "%WIN_ARGV%"=="-s" ( + set SCHEMATRON=1 + ) else if "%WIN_ARGV%"=="-c" ( + set COVERAGE=1 + ) else if "%WIN_ARGV%"=="-j" ( + set JUNIT=1 + ) else if "%WIN_ARGV%"=="-h" ( + set WIN_HELP=1 + ) else if "%WIN_ARGV:~0,1%"=="-" ( + set "WIN_UNKNOWN_OPTION=%WIN_ARGV%" + ) else if defined XSPEC ( + if "%WIN_ARGV%"=="coverage" ( + set WIN_DEPRECATED_COVERAGE=1 + ) else ( + set "WIN_EXTRA_OPTION=%WIN_ARGV%" + goto :EOF + ) + ) else ( + set "XSPEC=%WIN_ARGV%" + ) + + shift + + rem + rem %* doesn't reflect shift. Pass %n individually. + rem + call :win_get_options %1 %2 %3 %4 %5 %6 %7 %8 %9 + goto :EOF + + +:schematron_compile + echo Setting up Schematron... + + if not defined SCHEMATRON_XSLT_INCLUDE set SCHEMATRON_XSLT_INCLUDE="%XSPEC_HOME%\src\schematron\iso-schematron\iso_dsdl_include.xsl" + if not defined SCHEMATRON_XSLT_EXPAND set SCHEMATRON_XSLT_EXPAND="%XSPEC_HOME%\src\schematron\iso-schematron\iso_abstract_expand.xsl" + if not defined SCHEMATRON_XSLT_COMPILE set SCHEMATRON_XSLT_COMPILE="%XSPEC_HOME%\src\schematron\iso-schematron\iso_svrl_for_xslt2.xsl" + + rem # get URI to Schematron file and phase/parameters from the XSpec file + call :xquery -qs:"declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:method 'text'; replace(iri-to-uri(concat(replace(document-uri(/), '(.*)/.*$', '$1'), '/', /*[local-name() = 'description']/@schematron)), concat(codepoints-to-string(94), 'file:/'), '')" ^ + -s:"%XSPEC%" >"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" ^ + || ( call :die "Error getting Schematron location" & goto :win_main_error_exit ) + set /P SCH=<"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" + + call :xquery -qs:"declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:method 'text'; declare function local:escape($v) { let $w := if (matches($v,codepoints-to-string((91,92,115,34,93)))) then codepoints-to-string(34) else '' return concat($w, replace($v,codepoints-to-string(34),codepoints-to-string((34,34))), $w)}; string-join(for $p in /*/*[local-name() = 'param'] return if ($p/@select) then concat('?',$p/@name,'=',local:escape($p/@select)) else concat($p/@name,'=',local:escape($p/string())),' ')" ^ + -s:"%XSPEC%" >"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" ^ + || ( call :die "Error getting Schematron phase and parameters" & goto :win_main_error_exit ) + set /P SCH_PARAMS=<"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" + echo Paramaters: %SCH_PARAMS% + set SCHUT=%XSPEC%-compiled.xspec + set SCH_COMPILED=%SCH%-compiled.xsl + + echo: + echo Compiling the Schematron... + call :xslt -o:"%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp1.xml" -s:"%SCH%" ^ + -xsl:"%SCHEMATRON_XSLT_INCLUDE%" -versionmsg:off ^ + || ( call :die "Error compiling the Schematron on step 1" & goto :win_main_error_exit ) + call :xslt -o:"%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp2.xml" -s:"%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp1.xml" ^ + -xsl:"%SCHEMATRON_XSLT_EXPAND%" -versionmsg:off ^ + || ( call :die "Error compiling the Schematron on step 2" & goto :win_main_error_exit ) + call :xslt -o:"%SCH_COMPILED%" -s:"%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp2.xml" ^ + -xsl:"%SCHEMATRON_XSLT_COMPILE%" -versionmsg:off ^ + %SCH_PARAMS% ^ + || ( call :die "Error compiling the Schematron on step 3" & goto :win_main_error_exit ) + + rem use XQuery to get full URI to compiled Schematron + rem echo SCH_COMPILED %SCH_COMPILED% + rem call :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:/'), '')" ^ + rem -s:"%SCH_COMPILED%" >"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" ^ + rem || ( call :die "Error getting compiled Schematron location" & goto :win_main_error_exit ) + rem set /P SCH_COMPILED=<"%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" + rem echo SCH_COMPILED %SCH_COMPILED% + + echo: + echo Compiling the Schematron tests... + set TEST_DIR_URI=file:///%TEST_DIR:\=/% + call :xslt -o:"%SCHUT%" -s:"%XSPEC%" ^ + -xsl:"%XSPEC_HOME%\src\schematron\schut-to-xspec.xsl" ^ + stylesheet="%SCH_COMPILED%" ^ + test_dir="%TEST_DIR_URI%" ^ + || ( call :die "Error compiling the Schematron tests" & goto :win_main_error_exit ) + set XSPEC=%SCHUT% + echo: + goto :EOF + +:cleanup + if defined SCHEMATRON ( + del /q "%SCHUT%" 2>nul + del /q "%TEST_DIR%\context-*.xml" 2>nul + del /q "%TEST_DIR%\%TARGET_FILE_NAME%-var.txt" 2>nul + del /q "%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp1.xml" 2>nul + del /q "%TEST_DIR%\%TARGET_FILE_NAME%-sch-temp2.xml" 2>nul + del /q "%SCH_COMPILED:/=\%" 2>nul + ) + goto :EOF + +:win_echo + rem + rem Prints a message removing its surrounding quotes (") + rem + echo %~1 + goto :EOF + +rem +rem Main ######################################################################### +rem +:win_main_enter + +rem +rem Begin localization of environment changes. +rem Also make sure the command processor extensions are enabled. +rem +verify other 2> NUL +setlocal enableextensions +if errorlevel 1 ( + echo Unable to enable extensions + exit /b %ERRORLEVEL% +) + +rem +rem To be compatible with xspec.sh, do not omit this message. It makes the +rem test automation easier. +rem +echo Saxon script not found, invoking JVM directly instead. +echo: + +rem +rem ## +rem ## some variables ############################################################ +rem ## +rem + +rem +rem # the command to use to open the final HTML report +rem +rem Include the command line options (and consequently the double quotes) +rem if necessary. +rem +set OPEN=start "XSpec Report" + +rem +rem # set XSPEC_HOME if it has not been set by the user (set it to the +rem # parent dir of this script) +rem +if not defined XSPEC_HOME set XSPEC_HOME=%~dp0.. + +rem +rem # safety checks +rem +for %%I in ("%XSPEC_HOME%") do echo "%%~aI" | find "d" > NUL +if errorlevel 1 ( + call :win_echo "ERROR: XSPEC_HOME is not a directory: %XSPEC_HOME%" + exit /b 1 +) +if not exist "%XSPEC_HOME%\src\compiler\generate-common-tests.xsl" ( + call :win_echo "ERROR: XSPEC_HOME seems to be corrupted: %XSPEC_HOME%" + exit /b 1 +) + +rem +rem # set SAXON_CP (either it has been by the user, or set it from SAXON_HOME) +rem + +rem +rem # Set this variable in your environment or here, if you don't set SAXON_CP +rem # set SAXON_HOME=C:\path\to\saxon\dir +rem +rem Since we don't use the delayed environment variable expansion, +rem SAXON_HOME must be set outside 'if' scope. +rem + +if not defined SAXON_CP ( + if not defined SAXON_HOME ( + echo SAXON_CP and SAXON_HOME both not set! + ) + if exist "%SAXON_HOME%\saxon9ee.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon9ee.jar" + ) else if exist "%SAXON_HOME%\saxon9pe.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon9pe.jar" + ) else if exist "%SAXON_HOME%\saxon9he.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon9he.jar" + ) else if exist "%SAXON_HOME%\saxon9sa.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon9sa.jar" + ) else if exist "%SAXON_HOME%\saxon9.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon9.jar" + ) else if exist "%SAXON_HOME%\saxonb9-1-0-8.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxonb9-1-0-8.jar" + ) else if exist "%SAXON_HOME%\saxon8sa.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon8sa.jar" + ) else if exist "%SAXON_HOME%\saxon8.jar" ( + set "SAXON_CP=%SAXON_HOME%\saxon8.jar" + ) else ( + call :win_echo "Saxon jar cannot be found in SAXON_HOME: %SAXON_HOME%" + ) +) + +set CP=%SAXON_CP%;%XSPEC_HOME%\java + +rem +rem ## +rem ## options ################################################################### +rem ## +rem + +rem +rem JAR filename +rem +for %%I in ("%SAXON_CP%") do set WIN_SAXON_CP_N=%%~nI + +rem +rem Parse command line +rem +call :win_reset_options +call :win_get_options %* + +rem +rem # Schematron +rem # XSLT +rem +if defined SCHEMATRON if defined XSLT ( + call :usage "-s and -t are mutually exclusive" + exit /b 1 +) + +rem +rem # Schematron +rem # XQuery +rem +if defined SCHEMATRON if defined XQUERY ( + call :usage "-s and -q are mutually exclusive" + exit /b 1 +) + +rem +rem # XSLT +rem # XQuery +rem +if defined XSLT if defined XQUERY ( + call :usage "-t and -q are mutually exclusive" + exit /b 1 +) + +rem +rem # Coverage +rem +if defined COVERAGE ( + if /i not "%WIN_SAXON_CP_N%"=="saxon9pe" if /i not "%WIN_SAXON_CP_N%"=="saxon9ee" ( + echo Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE. + exit /b 1 + ) +) + +rem +rem # JUnit report +rem +if defined JUNIT ( + if /i "%WIN_SAXON_CP_N:~0,6%"=="saxon8" ( + echo Saxon8 detected. JUnit report requires Saxon9. + exit /b 1 + ) +) + +rem +rem # Help! +rem +if defined WIN_HELP ( + call :usage + exit /b 0 +) + +rem +rem # Unknown option! +rem +if defined WIN_UNKNOWN_OPTION ( + call :usage "Error: Unknown option: %WIN_UNKNOWN_OPTION%" + exit /b 1 +) + +rem +rem # set XSLT if XQuery has not been set (that's the default) +rem +if not defined XSLT if not defined XQUERY set XSLT=1 + +if not exist "%XSPEC%" ( + call :usage "Error: File not found." + exit /b 1 +) + +rem +rem Extra option +rem +if defined WIN_EXTRA_OPTION ( + call :usage "Error: Extra option: %WIN_EXTRA_OPTION%" + exit /b 1 +) + +rem +rem Deprecated 'coverage' option +rem +if defined WIN_DEPRECATED_COVERAGE ( + echo Long-form option 'coverage' deprecated, use '-c' instead. + if /i not "%WIN_SAXON_CP_N%"=="saxon9pe" if /i not "%WIN_SAXON_CP_N%"=="saxon9ee" ( + echo Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE. + exit /b 1 + ) + set COVERAGE=1 +) + +rem +rem Env var no longer necessary +rem +set WIN_SAXON_CP_N= + +rem +rem ## +rem ## files and dirs ############################################################ +rem ## +rem + +if not defined TEST_DIR for %%I in ("%XSPEC%") do set TEST_DIR=%%~dpIxspec +for %%I in ("%XSPEC%") do set TARGET_FILE_NAME=%%~nI + +if defined XSLT ( + set "COMPILED=%TEST_DIR%\%TARGET_FILE_NAME%.xsl" +) else ( + set "COMPILED=%TEST_DIR%\%TARGET_FILE_NAME%.xq" +) +set COVERAGE_XML=%TEST_DIR%\%TARGET_FILE_NAME%-coverage.xml +set COVERAGE_HTML=%TEST_DIR%\%TARGET_FILE_NAME%-coverage.html +set RESULT=%TEST_DIR%\%TARGET_FILE_NAME%-result.xml +set HTML=%TEST_DIR%\%TARGET_FILE_NAME%-result.html +set JUNIT_RESULT=%TEST_DIR%\%TARGET_FILE_NAME%-junit.xml +set COVERAGE_CLASS=com.jenitennison.xslt.tests.XSLTCoverageTraceListener + +if not exist "%TEST_DIR%" ( + call :win_echo "Creating XSpec Directory at %TEST_DIR%..." + mkdir "%TEST_DIR%" + echo: +) + +rem +rem ## +rem ## compile the suite ######################################################### +rem ## +rem + +if defined SCHEMATRON call :schematron_compile || goto :win_main_error_exit + +if defined XSLT ( + set COMPILE_SHEET=generate-xspec-tests.xsl +) else ( + set COMPILE_SHEET=generate-query-tests.xsl +) echo Creating Test Stylesheet... -echo %TEST_STYLESHEET% -echo %XSPEC% -java -cp "%CP%" net.sf.saxon.Transform -o:%TEST_STYLESHEET% -s:%XSPEC% -xsl:"%~dp0\..\src\compiler\generate-xspec-tests.xsl" -echo. +call :xslt -o:"%COMPILED%" -s:"%XSPEC%" ^ + -xsl:"%XSPEC_HOME%\src\compiler\%COMPILE_SHEET%" ^ + || ( call :die "Error compiling the test suite" & goto :win_main_error_exit ) +echo: + +rem +rem ## +rem ## run the suite ############################################################# +rem ## +rem echo Running Tests... +if defined XSLT ( + rem + rem # for XSLT + rem + if defined COVERAGE ( + echo Collecting test coverage data; suppressing progress report... + call :win_xslt_trace -T:%COVERAGE_CLASS% ^ + -o:"%RESULT%" -s:"%XSPEC%" -xsl:"%COMPILED%" ^ + -it:{http://www.jenitennison.com/xslt/xspec}main 2> "%COVERAGE_XML%" ^ + || ( call :die "Error collecting test coverage data" & goto :win_main_error_exit ) + ) else ( + call :xslt -o:"%RESULT%" -s:"%XSPEC%" -xsl:"%COMPILED%" ^ + -it:{http://www.jenitennison.com/xslt/xspec}main ^ + || ( call :die "Error running the test suite" & goto :win_main_error_exit ) + ) +) else ( + rem + rem # for XQuery + rem + if defined COVERAGE ( + echo Collecting test coverage data; suppressing progress report... + call :win_xquery_trace -T:%COVERAGE_CLASS% ^ + -o:"%RESULT%" -s:"%XSPEC%" "%COMPILED%" 2> "%COVERAGE_XML%" ^ + || ( call :die "Error collecting test coverage data" & goto :win_main_error_exit ) + ) else ( + call :xquery -o:"%RESULT%" -s:"%XSPEC%" "%COMPILED%" ^ + || ( call :die "Error running the test suite" & goto :win_main_error_exit ) + ) +) + +rem +rem ## +rem ## format the report ######################################################### +rem ## +rem -REM ======================================= -REM Check if coverage parameter was passed -REM ======================================= -IF %COVERAGE%x == coveragex GOTO coverage -GOTO endif3 -:coverage -echo Collecting test coverage data; suppressing progress report... - java -cp "%CP%" net.sf.saxon.Transform -T:com.jenitennison.xslt.tests.XSLTCoverageTraceListener \ - -o:%RESULT% -s:%XSPEC% -xsl:%TEST_STYLESHEET% -it:{http://www.jenitennison.com/xslt/xspec}main 2> %COVERAGE_XML% - -:endif3 - -REM ======================================= -REM Run the tests -REM ======================================= -java -cp "%CP%" net.sf.saxon.Transform -o:%RESULT% -s:%XSPEC% -xsl:%TEST_STYLESHEET% -it:{http://www.jenitennison.com/xslt/xspec}main - -echo. +echo: echo Formatting Report... -java -cp "%CP%" net.sf.saxon.Transform -o:%HTML% -s:%RESULT% -xsl:"%~dp0\..\src\reporter\format-xspec-report.xsl" - -REM ======================================= -REM Check if coverage parameter was passed -REM ======================================= -IF %COVERAGE%x == coveragex GOTO coverage2 -GOTO endif4 -:coverage2 - java -cp "%CP%" net.sf.saxon.Transform -l:on "-o:%COVERAGE_HTML%" "-s:%COVERAGE_XML%" "-xsl:%~dp0\..\src\reporter\coverage-report.xsl" "tests=%XSPEC%" "pwd=file:///%~dp0" - %COVERAGE_HTML% -:endif4 - -REM ============= -REM Output report -REM ============= -%HTML% +call :xslt -o:"%HTML%" ^ + -s:"%RESULT%" ^ + -xsl:"%XSPEC_HOME%\src\reporter\format-xspec-report.xsl" ^ + inline-css=true ^ + || ( call :die "Error formatting the report" & goto :win_main_error_exit ) + +rem +rem Absolute path of the XSPEC env var +rem +for %%I in ("%XSPEC%") do set WIN_XSPEC_ABS=%%~fI + +if defined COVERAGE ( + rem + rem For $tests and $pwd, convert the native file path to a wannabe- + rem URI. The peculiar implementation of Java prefers the following + rem forms (if it's absolute). + rem + rem For drive: file:/c:/dir/file + rem For UNC: file:////host/share/dir/file + rem + rem Note that in terms of the native file path, coverage-report.xsl + rem handles $tests and $pwd differently. + rem + rem Scheme ('file:') + rem + rem $tests + rem The XSPEC env var may be absolute or relative. If + rem relative, we need to omit 'file:' from $tests. + rem For simplicity, we always obtain the absolute path of + rem the XSPEC env var and prefix it with 'file:'. + rem + rem $pwd + rem The CD env var is always absolute. So we always prefix + rem it with 'file:'. + rem + rem '\' character + rem + rem $tests + rem coverage-report.xsl replaces '\' with '/'. You can + rem leave '\' intact here. + rem + rem $pwd + rem coverage-report.xsl does nothing. You have to replace + rem '\' with '/' here. + rem + rem UNC + rem + rem $tests + rem You have to care about UNC. + rem + rem $pwd + rem You don't have to care about UNC. By default CMD.EXE + rem does not accept UNC as the current directory. + rem + rem We don't escape any characters here. Too much for this simple + rem batch script. Fortunately Saxon 9.7 seems to be more tolerant of + rem space chars than 9.6. + rem + call :xslt -l:on ^ + -o:"%COVERAGE_HTML%" ^ + -s:"%COVERAGE_XML%" ^ + -xsl:"%XSPEC_HOME%\src\reporter\coverage-report.xsl" ^ + tests="file:/%WIN_XSPEC_ABS:\\=/\\%" ^ + pwd="file:/%CD:\=/%/" ^ + inline-css=true ^ + || ( call :die "Error formating the coverage report" & goto :win_main_error_exit ) + call :win_echo "Report available at %COVERAGE_HTML%" + rem %OPEN% "%COVERAGE_HTML%" +) else if defined JUNIT ( + call :xslt -o:"%JUNIT_RESULT%" ^ + -s:"%RESULT%" ^ + -xsl:"%XSPEC_HOME%\src\reporter\junit-report.xsl" ^ + || ( call :die "Error formating the JUnit report" & goto :win_main_error_exit ) + call :win_echo "Report available at %JUNIT_RESULT%" +) else ( + call :win_echo "Report available at %HTML%" + rem %OPEN% "%HTML%" +) + +call :cleanup echo Done. -:end +exit /b + +rem +rem Error exit ################################################################### +rem +:win_main_error_exit +if errorlevel 1 ( + exit /b %ERRORLEVEL% +) else ( + exit /b 1 +) diff --git a/bin/xspec.sh b/bin/xspec.sh index 541f3d52a..ff731a5d7 100755 --- a/bin/xspec.sh +++ b/bin/xspec.sh @@ -36,12 +36,14 @@ usage() { echo "$1" echo; fi - echo "Usage: xspec [-t|-q|-c|-h] filename [coverage]" + echo "Usage: xspec [-t|-q|-s|-c|-j|-h] filename [coverage]" echo echo " filename the XSpec document" echo " -t test an XSLT stylesheet (the default)" - echo " -q test an XQuery module (mutually exclusive with -t)" + echo " -q test an XQuery module (mutually exclusive with -t and -s)" + echo " -s test a Schematron schema (mutually exclusive with -t and -q)" echo " -c output test coverage report" + echo " -j output JUnit report" echo " -h display this help message" echo " coverage deprecated, use -c instead" } @@ -57,9 +59,8 @@ 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; then +if which saxon > /dev/null 2>&1 && saxon --help | grep "EXPath Packaging" > /dev/null 2>&1; then echo Saxon script found, use it. echo xslt() { @@ -132,6 +133,8 @@ if test -z "$SAXON_CP"; then SAXON_CP="${SAXON_HOME}/saxon9sa.jar"; elif test -f "${SAXON_HOME}/saxon9.jar"; then SAXON_CP="${SAXON_HOME}/saxon9.jar"; + elif test -f "${SAXON_HOME}/saxonb9-1-0-8.jar"; then + SAXON_CP="${SAXON_HOME}/saxonb9-1-0-8.jar"; elif test -f "${SAXON_HOME}/saxon8sa.jar"; then SAXON_CP="${SAXON_HOME}/saxon8sa.jar"; elif test -f "${SAXON_HOME}/saxon8.jar"; then @@ -156,6 +159,10 @@ while echo "$1" | grep -- ^- >/dev/null 2>&1; do usage "-t and -q are mutually exclusive" exit 1 fi + if test -n "$SCHEMATRON"; then + usage "-s and -t are mutually exclusive" + exit 1 + fi XSLT=1;; # XQuery -q) @@ -163,10 +170,36 @@ while echo "$1" | grep -- ^- >/dev/null 2>&1; do usage "-t and -q are mutually exclusive" exit 1 fi + if test -n "$SCHEMATRON"; then + usage "-s and -q are mutually exclusive" + exit 1 + fi XQUERY=1;; + # Schematron + -s) + if test -n "$XQUERY"; then + usage "-s and -q are mutually exclusive" + exit 1 + fi + if test -n "$XSLT"; then + usage "-s and -t are mutually exclusive" + exit 1 + fi + SCHEMATRON=1;; # Coverage -c) + if [[ ${SAXON_CP} != *"saxon9pe"* && ${SAXON_CP} != *"saxon9ee"* ]]; then + echo "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + exit 1 + fi COVERAGE=1;; + # JUnit report + -j) + if [[ ${SAXON_CP} == *"saxon8"* || ${SAXON_CP} == *"saxon8sa"* ]]; then + echo "Saxon8 detected. JUnit report requires Saxon9." + exit 1 + fi + JUNIT=1;; # Help! -h) usage @@ -195,8 +228,12 @@ if [ -n "$2" ]; then usage "Error: Extra option: $2" exit 1 fi - echo "Long-form option 'coverage' deprecated, use '-c' instead." - COVERAGE=1 + echo "Long-form option 'coverage' deprecated, use '-c' instead." + if [[ ${SAXON_CP} != *"saxon9pe"* && ${SAXON_CP} != *"saxon9ee"* ]]; then + echo "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + exit 1 + fi + COVERAGE=1 if [ -n "$3" ]; then usage "Error: Extra option: $3" exit 1 @@ -207,8 +244,11 @@ fi ## files and dirs ############################################################ ## -TEST_DIR=$(dirname "$XSPEC")/xspec -TARGET_FILE_NAME=$(basename "$XSPEC" | sed 's:\...*$::') +if [ -z "$TEST_DIR" ] +then + TEST_DIR=$(dirname "$XSPEC")/xspec +fi +TARGET_FILE_NAME=$(basename "$XSPEC" | sed 's:\.[^.]*$::') if test -n "$XSLT"; then COMPILED=$TEST_DIR/$TARGET_FILE_NAME.xsl @@ -219,6 +259,7 @@ COVERAGE_XML=$TEST_DIR/$TARGET_FILE_NAME-coverage.xml COVERAGE_HTML=$TEST_DIR/$TARGET_FILE_NAME-coverage.html 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 COVERAGE_CLASS=com.jenitennison.xslt.tests.XSLTCoverageTraceListener if [ ! -d "$TEST_DIR" ]; then @@ -231,6 +272,48 @@ fi ## compile the suite ######################################################### ## +if test -n "$SCHEMATRON"; then + echo "Setting up Schematron..." + + if test -z "$SCHEMATRON_XSLT_INCLUDE"; then + SCHEMATRON_XSLT_INCLUDE="$XSPEC_HOME/src/schematron/iso-schematron/iso_dsdl_include.xsl"; + fi + if test -z "$SCHEMATRON_XSLT_EXPAND"; then + SCHEMATRON_XSLT_EXPAND="$XSPEC_HOME/src/schematron/iso-schematron/iso_abstract_expand.xsl"; + fi + if test -z "$SCHEMATRON_XSLT_COMPILE"; then + SCHEMATRON_XSLT_COMPILE="$XSPEC_HOME/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl"; + fi + + # get URI to Schematron file and phase/parameters from the XSpec file + # Need to escape for sh in XQuery: dollar sign as \$ + xquery -qs:"declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:method 'text'; iri-to-uri(concat(replace(document-uri(/), '(.*)/.*\$', '\$1'), '/', /*[local-name() = 'description']/@schematron))" -s:"$XSPEC" >"$TEST_DIR/$TARGET_FILE_NAME-var.txt" || die "Error getting Schematron location" + SCH=`cat "$TEST_DIR/$TARGET_FILE_NAME-var.txt"` + + xquery -qs:"declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization'; declare option output:method 'text'; declare function local:escape(\$v) { let \$w := if (matches(\$v,codepoints-to-string((91,92,115,93)))) then codepoints-to-string(34) else '' return concat(\$w, replace(\$v,codepoints-to-string((40,91,36,92,92,96,93,41)),codepoints-to-string((92,92,36,49))), \$w)}; string-join(for \$p in /*/*[local-name() = 'param'] return if (\$p/@select) then concat('?',\$p/@name,'=',local:escape(\$p/@select)) else concat(\$p/@name,'=',local:escape(\$p/string())),' ')" -s:"$XSPEC" >"$TEST_DIR/$TARGET_FILE_NAME-var.txt" || die "Error getting Schematron phase and parameters" + SCH_PARAMS=`cat "$TEST_DIR/$TARGET_FILE_NAME-var.txt"` + echo Parameters: $SCH_PARAMS + SCHUT=$XSPEC-compiled.xspec + SCH_COMPILED=$(echo "$SCH" | sed 's:^file\:::')-compiled.xsl + + echo + echo "Compiling the Schematron..." + xslt -o:"$TEST_DIR/$TARGET_FILE_NAME-sch-temp1.xml" -s:"$SCH" -xsl:"$SCHEMATRON_XSLT_INCLUDE" -versionmsg:off || die "Error compiling the Schematron on step 1" + xslt -o:"$TEST_DIR/$TARGET_FILE_NAME-sch-temp2.xml" -s:"$TEST_DIR/$TARGET_FILE_NAME-sch-temp1.xml" -xsl:"$SCHEMATRON_XSLT_EXPAND" -versionmsg:off || die "Error compiling the Schematron on step 2" + xslt -o:"$SCH_COMPILED" -s:"$TEST_DIR/$TARGET_FILE_NAME-sch-temp2.xml" -xsl:"$SCHEMATRON_XSLT_COMPILE" -versionmsg:off $SCH_PARAMS || die "Error compiling the Schematron on step 3" + + # use XQuery to get full URI to compiled Schematron + # 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_COMPILED" >"$TEST_DIR/$TARGET_FILE_NAME-var.txt" || die "Error getting compiled Schematron location" + # SCH_COMPILED=`cat "$TEST_DIR/$TARGET_FILE_NAME-var.txt"` + + echo + echo "Compiling the Schematron tests..." + xslt -o:"$SCHUT" -s:"$XSPEC" -xsl:"$XSPEC_HOME/src/schematron/schut-to-xspec.xsl" stylesheet="$SCH_COMPILED" || die "Error compiling the Schematron tests" + XSPEC=$SCHUT + + echo +fi + if test -n "$XSLT"; then COMPILE_SHEET=generate-xspec-tests.xsl else @@ -282,6 +365,7 @@ echo "Formatting Report..." xslt -o:"$HTML" \ -s:"$RESULT" \ -xsl:"$XSPEC_HOME/src/reporter/format-xspec-report.xsl" \ + inline-css=true \ || die "Error formating the report" if test -n "$COVERAGE"; then xslt -l:on \ @@ -290,12 +374,31 @@ if test -n "$COVERAGE"; then -xsl:"$XSPEC_HOME/src/reporter/coverage-report.xsl" \ "tests=$XSPEC" \ "pwd=file:`pwd`/" \ + inline-css=true \ || die "Error formating the coverage report" echo "Report available at $COVERAGE_HTML" #$OPEN "$COVERAGE_HTML" +elif test -n "$JUNIT"; then + xslt -o:"$JUNIT_RESULT" \ + -s:"$RESULT" \ + -xsl:"$XSPEC_HOME/src/reporter/junit-report.xsl" \ + || die "Error formating the JUnit report" + echo "Report available at $JUNIT_RESULT" else echo "Report available at $HTML" #$OPEN "$HTML" fi +## +## cleanup +## +if test -n "$SCHEMATRON"; then + rm -f "$SCHUT" + rm -f "$TEST_DIR"/context-*.xml + rm -f "$TEST_DIR/$TARGET_FILE_NAME-var.txt" + rm -f "$TEST_DIR/$TARGET_FILE_NAME-sch-temp1.xml" + rm -f "$TEST_DIR/$TARGET_FILE_NAME-sch-temp2.xml" + rm -f "$SCH_COMPILED" +fi + echo "Done." diff --git a/build.xml b/build.xml index 63cda7c13..fc5602af9 100644 --- a/build.xml +++ b/build.xml @@ -2,54 +2,77 @@ - - - XSpec is a Behavior Driven Development (BDD) framework for XSLT and XQuery. - -Usage: - -ant -Dxspec.xml=filename - -where: - - filename XSpec tests XML file - - - + + XSpec is a Behavior Driven Development (BDD) framework for XSLT and XQuery. + + Usage (command-line): + + ant -Dxspec.xml=/path/to/xspec/file + -Dtest.type=t|s + -Dxspec.project.dir=/path/to/folder/where/xspec/is/installed + -Dxspec.phase=#ALL + -lib /path/to/saxon.jar + -lib /path/to/xml-resolver.jar + -Dclean.output.dir=true|false + -Dxspec.fail=true|false + where: + + xspec.xml XSpec test file + test.type Value "t" if XSpec describes an XSLT file, "s" if XSpec describes a Schematron file + [Optional; the default value is "t"] + xspec.project.dir Folder in which XSpec is installed + [Optional; the default is the folder containing this build file] + xspec.phase Schematron phase. Used only for testing Schematron. Can be "#ALL". + [Optional; the default is taken from "phase" parameter in XSpec file] + lib Additional jar libraries (saxon, xml-resolver) + or folder where they are located + clean.output.dir Value true to delete temporary files, value false to keep them + [Optional; the default is false] + xspec.fail Value true makes the build fail when one or more tests failed + [Optional; the default is true] + + --- + + Usage (Oxygen XSLT transformation scenario): + + This file is an updated copy of Oxygen's ${frameworksDir}/xspec/build.xml + + Setup: + + - Duplicate Oxygen's default XSpec scenario + - Under Options tab: + - Build file: [this file] + - Under Parameters tab: + - New parameters if required (See the usage above): + - test.type + - xspec.phase + - xspec.fail + - Parameter xspec.project.dir value C:\Git\xspec + - If parameter catalog uses ${pdu}, replace it with ${pd} + + + - + - - - - - - - - - - - - - - - + + - + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - + style="${format.xspec.report}"> + + + + + + + + + + + + + + + + - + + + - - - - - + + + + + + + + Clean up + + + + + + + + + + diff --git a/find-examples.xml b/find-examples.xml index 08e6d22aa..2b9c75eec 100644 --- a/find-examples.xml +++ b/find-examples.xml @@ -2,18 +2,12 @@ - - - - ?select=*.xml&recurse=yes&strip-space=yes - - diff --git a/find-examples.xsl b/find-examples.xsl index 6487cf9b0..706ad83f8 100644 --- a/find-examples.xsl +++ b/find-examples.xsl @@ -2,7 +2,6 @@ - diff --git a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class index aecafafbf..43561e7b3 100644 Binary files a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class and b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class differ diff --git a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java index b95de46b5..e5c05744b 100644 --- a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java +++ b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java @@ -1,17 +1,18 @@ /****************************************************************************/ /* File: XSLTCoverageTraceListener.java */ -/* Author: Jeni Tennsion */ -/* URI: http://xspec.googlecode.com/ */ +/* Author: Jeni Tennison */ +/* URI: https://github.com/expath/xspec/ */ /* Tags: */ -/* Copyright (c) 2008, 2010 (see end of file.) */ +/* Copyright (c) 2008-2016 (see end of file.) */ /* ------------------------------------------------------------------------ */ package com.jenitennison.xslt.tests; -import net.sf.saxon.trace.TraceListener; +import net.sf.saxon.lib.TraceListener; import net.sf.saxon.trace.InstructionInfo; -import net.sf.saxon.trace.Location; +import net.sf.saxon.trace.LocationKind; +import net.sf.saxon.Controller; import net.sf.saxon.expr.XPathContext; import net.sf.saxon.om.Item; import net.sf.saxon.om.StandardNames; @@ -19,6 +20,7 @@ import java.util.HashMap; import java.util.HashSet; import java.io.PrintStream; +import net.sf.saxon.lib.Logger; /** * A Simple trace listener for XSLT that writes messages (by default) to System.err @@ -29,16 +31,27 @@ public class XSLTCoverageTraceListener implements TraceListener { private PrintStream out = System.err; private String xspecStylesheet = null; private String utilsStylesheet = null; - private HashMap modules = new HashMap(); - private HashSet constructs = new HashSet(); + private HashMap modules = new HashMap(); + private HashSet constructs = new HashSet(); private int moduleCount = 0; + + public XSLTCoverageTraceListener() { + System.out.println("****************************************"); + } /** * Method called at the start of execution, that is, when the run-time transformation starts */ - public void open() { + public void open(Controller c) { out.println(""); + System.out.println("controller="+c); + } + + /** + * Method that implements the output destination for SaxonEE/PE 9.7 + */ + public void setOutputDestination(Logger logger) { } /** @@ -85,40 +98,37 @@ public void enter(InstructionInfo info, XPathContext context) { construct = StandardNames.getClarkName(constructType); } else { switch (constructType) { - case Location.LITERAL_RESULT_ELEMENT: + case LocationKind.LITERAL_RESULT_ELEMENT: construct = "LITERAL_RESULT_ELEMENT"; break; - case Location.LITERAL_RESULT_ATTRIBUTE: + case LocationKind.LITERAL_RESULT_ATTRIBUTE: construct = "LITERAL_RESULT_ATTRIBUTE"; break; - case Location.EXTENSION_INSTRUCTION: + case LocationKind.EXTENSION_INSTRUCTION: construct = "EXTENSION_INSTRUCTION"; break; - case Location.TEMPLATE: + case LocationKind.TEMPLATE: construct = "TEMPLATE"; break; - case Location.FUNCTION_CALL: + case LocationKind.FUNCTION_CALL: construct = "FUNCTION_CALL"; break; - case Location.BUILT_IN_TEMPLATE: - construct = "BUILT_IN_TEMPLATE"; - break; - case Location.XPATH_IN_XSLT: + case LocationKind.XPATH_IN_XSLT: construct = "XPATH_IN_XSLT"; break; - case Location.LET_EXPRESSION: + case LocationKind.LET_EXPRESSION: construct = "LET_EXPRESSION"; break; - case Location.TRACE_CALL: + case LocationKind.TRACE_CALL: construct = "TRACE_CALL"; break; - case Location.SAXON_EVALUATE: + case LocationKind.SAXON_EVALUATE: construct = "SAXON_EVALUATE"; break; - case Location.FUNCTION: + case LocationKind.FUNCTION: construct = "FUNCTION"; break; - case Location.XPATH_EXPRESSION: + case LocationKind.XPATH_EXPRESSION: construct = "XPATH_EXPRESSION"; break; default: @@ -196,4 +206,4 @@ public void endCurrentItem(Item currentItem) { // // Contributor(s): Heavily modified by Michael Kay // Methods implemented by Jeni Tennison -// +// Extended for Saxon 9.7 by Sandro Cirulli, github.com/cirulls diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..bee995fb4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,203 @@ + + 4.0.0 + io.xspec + xspec + 1.0.0 + + XSpec implementation + A unit test framework for Xsl, XQuery and Schematron + 2008 + https://github.com/xspec/xspec + + + + The MIT License + repo | manually + https://opensource.org/licenses/MIT + Copyright (c) 2008-2017 Jeni Tennison + + + + + + Jeni Tennison + jeni@jenitennison.com + + creator + + + + Sandro Cirulli + sandro.cirulli@oup.com + + current maintainer + + + + Florent George + fgeorges@fgeorges.org + + former maintainer + + + + Christophe Marchand + christophe@marchand.top + + maven maintainer + + + + + + scm:git:https://github.com/xspec/xspec.git + scm:git:https://github.com/xspec/xspec.git + scm:git:https://github.com/xspec/xspec.git + HEAD + + + + + xspec-io.ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + xspec-io.ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + src + + harnesses/** + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.7 + 1.7 + + + + com.code54.mojo + buildversion-plugin + 1.0.3 + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + org.apache.maven.plugins + maven-release-plugin + 2.5.2 + + + + + + com.code54.mojo + buildversion-plugin + + + validate + + set-properties + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + ${build-tag} + ${build-commit} + ${build-commit-abbrev} + ${build-version} + ${build-tstamp} + ${project.scm.connection} + ${project.description} + ${project.url} + + + + + + org.apache.maven.plugins + maven-release-plugin + + + + + + + release + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + xspec-io.ossrh + https://oss.sonatype.org/ + true + + + + + + + + + diff --git a/src/ant/find-test-failure.xsl b/src/ant/find-test-failure.xsl new file mode 100644 index 000000000..5ff93b0ed --- /dev/null +++ b/src/ant/find-test-failure.xsl @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/src/ant/get-schematron-phase.xsl b/src/ant/get-schematron-phase.xsl new file mode 100644 index 000000000..dc6006897 --- /dev/null +++ b/src/ant/get-schematron-phase.xsl @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/src/ant/locate-schematron.xsl b/src/ant/locate-schematron.xsl new file mode 100644 index 000000000..cff30d057 --- /dev/null +++ b/src/ant/locate-schematron.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ant/make-path.js b/src/ant/make-path.js new file mode 100644 index 000000000..6a1b6e46a --- /dev/null +++ b/src/ant/make-path.js @@ -0,0 +1,4 @@ +var javaURL = new java.net.URL(attributes.get("url")); +var javaFile = new java.io.File(javaURL.toURI()); +var path = javaFile.toString(); +self.project.setProperty(attributes.get("property"), path); diff --git a/src/compiler/generate-common-tests.xsl b/src/compiler/generate-common-tests.xsl index 9b95cf844..17f5cf4e2 100644 --- a/src/compiler/generate-common-tests.xsl +++ b/src/compiler/generate-common-tests.xsl @@ -2,7 +2,7 @@ - + @@ -19,6 +19,10 @@ http://www.jenitennison.com/xslt/xspec/generate-common-tests.xsl + + + + - + diff --git a/src/compiler/generate-query-tests.xsl b/src/compiler/generate-query-tests.xsl index 58088e175..5cdb387ff 100644 --- a/src/compiler/generate-query-tests.xsl +++ b/src/compiler/generate-query-tests.xsl @@ -2,7 +2,7 @@ - + @@ -113,6 +113,7 @@ + { diff --git a/src/compiler/generate-query-utils.xql b/src/compiler/generate-query-utils.xql index dbf981d0e..aef158e59 100644 --- a/src/compiler/generate-query-utils.xql +++ b/src/compiler/generate-query-utils.xql @@ -3,7 +3,7 @@ module namespace test = "http://www.jenitennison.com/xslt/unit-test"; (::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::) (: File: generate-query-utils.xql :) (: Author: Jeni Tennsion :) -(: URI: http://xspec.googlecode.com/ :) +(: URL: http://github.com/xspec/xspec :) (: Tags: :) (: Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) :) (: ------------------------------------------------------------------------ :) @@ -64,7 +64,7 @@ declare function test:node-deep-equal($node1 as node(), $node2 as node()) as xs: let $atts2 as attribute()* := test:sort-named-nodes($node2/@*) return if ( test:deep-equal($atts1, $atts2) ) then - if ( $node1/text() = '...' and fn:count($node1/node()) = 1 ) then + if ( fn:count($node1/node()) = 1 and $node1/text() = '...' ) then fn:true() else test:deep-equal(test:sorted-children($node1), test:sorted-children($node2)) @@ -80,9 +80,9 @@ declare function test:node-deep-equal($node1 as node(), $node2 as node()) as xs: or ( $node1 instance of processing-instruction() and $node2 instance of processing-instruction()) ) then fn:node-name($node1) eq fn:node-name($node2) - and ( $node1 = '...' or fn:string($node1) eq fn:string($node2) ) + and ( fn:string($node1) eq fn:string($node2) or fn:string($node1) = '...' ) else if ( $node1 instance of comment() and $node2 instance of comment() ) then - $node1 = '...' or fn:string($node1) eq fn:string($node2) + fn:string($node1) eq fn:string($node2) or fn:string($node1) = '...' else fn:false() }; diff --git a/src/compiler/generate-tests-helper.xsl b/src/compiler/generate-tests-helper.xsl index c315b594e..f9d0ed7d1 100644 --- a/src/compiler/generate-tests-helper.xsl +++ b/src/compiler/generate-tests-helper.xsl @@ -2,7 +2,7 @@ - + diff --git a/src/compiler/generate-tests-utils.xsl b/src/compiler/generate-tests-utils.xsl index 2ad485cdf..40122b70e 100644 --- a/src/compiler/generate-tests-utils.xsl +++ b/src/compiler/generate-tests-utils.xsl @@ -2,7 +2,7 @@ - + @@ -76,48 +76,6 @@ - - test:deep-equal function - - Identical Sequences - - - - - - Non-Identical Sequences - - - - - - Sequences with Same Items in Different Orders - - - - - - Empty Sequences - - - - - - One empty sequence - - - - - - A text node and several text nodes - foobar - - foo - bar - - - - @@ -204,27 +162,6 @@ - - test:item-deep-equal function - - Identical Integers - - - - - - Non-Identical Strings - - - - - - String and Integer - - - - - @@ -243,133 +180,6 @@ - - test:node-deep-equal function - - Identical Elements - - - - - - - - - - Elements with Identical Attributes in Different Orders - - - - - - - - - - Elements with Identical Children - - - - - - - - - - Identical Attributes - - - - - - - - - - Identical Document Nodes - - - - - - - - - - Identical Text Nodes - - Test - - - Test - - - - - Identical Comments - - - - - - - - - - - - Identical Processing Instructions - - - - - - - - - - - - Using "..." to indicate missing text - - ... - - - foo - - - - - Using "..." to indicate missing mixed content - - ... - - - foofoo - - - - - Using "..." to indicate missing attribute values - - - - - - - - - - Using "..." to indicate missing empty content - - ... - - - - - - - @@ -450,11 +260,12 @@ ($node1 instance of processing-instruction() and $node2 instance of processing-instruction())"> + (string($node1) eq string($node2) or string($node1) = '...')" /> + - + @@ -462,18 +273,6 @@ - - test:sorted-children function - - Original order preserved - - - - - - - - - - test:report-value function - - Integer - - - - - - - Empty Sequence - - - - - - - String - - - - - - - URI - - - - - - - QName - - - - - - - Attributes - - - - - - - - - - - Attributes and content - - - - - - - - - - - - - - @@ -568,18 +302,22 @@ /node() - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -614,14 +352,6 @@ - - test:report-atomic-value function - - String Containing Single Quotes - - - - @@ -630,11 +360,25 @@ replace($value, '''', ''''''), '''')" /> - + + + + + + + + + + + + + + + + + + + xs:yearMonthDuration + xs:dayTimeDuration + + + xs:untypedAtomic + + + + + + xs:integer + + xs:string xs:boolean + xs:decimal xs:double - xs:anyURI - xs:dateTime + 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/compiler/generate-xspec-tests.xsl b/src/compiler/generate-xspec-tests.xsl index bf7e50239..cd716674a 100644 --- a/src/compiler/generate-xspec-tests.xsl +++ b/src/compiler/generate-xspec-tests.xsl @@ -2,7 +2,6 @@ - @@ -33,8 +32,9 @@ +' + select="resolve-uri(/x:description/@stylesheet, replace(base-uri(/x:description), $apostrophe, '%27'))" /> @@ -48,11 +48,12 @@ - + @@ -80,6 +81,8 @@ test stylesheet, which can then be picked up by stylesheets that process *that* to generate a coverage report --> + + @@ -208,7 +211,7 @@ - + @@ -285,123 +288,8 @@ - - + + @@ -438,9 +326,14 @@ Have to experiment a bit to see if that really is the case. TODO: To remove. Use directly $x:result instead. See issue 14. --> - - - + + + + + @@ -464,7 +357,7 @@ @@ -508,248 +401,6 @@ - - - - - - - - diff --git a/src/harnesses/basex/basex-server-xquery-harness.xproc b/src/harnesses/basex/basex-server-xquery-harness.xproc deleted file mode 100644 index d038cfb59..000000000 --- a/src/harnesses/basex/basex-server-xquery-harness.xproc +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - -

This pipeline executes an XSpec test suite on a BaseX server instance.

-

Primary input: A XSpec test suite document.

-

Primary output: A formatted HTML XSpec report.

-

The XQuery library module to test must already be on the BaseX instance - (its URI is passed through the option 'query-at'). The instance endpoint - is passed in the option 'endpoint'. The runtime utils library (also known - as generate-query-utils.xql) must also be on the instance (its location - hint, that is the 'at' clause to use) is passed in the option 'utils-lib'. - The dir where you unzipped the XSpec archive on your filesystem is passed - in the option 'xspec-home'. User credentials are passed through options - 'username' and 'password'.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/harnesses/basex/basex-standalone-xquery-harness.xproc b/src/harnesses/basex/basex-standalone-xquery-harness.xproc index 663a5556c..ff4ebcf1e 100644 --- a/src/harnesses/basex/basex-standalone-xquery-harness.xproc +++ b/src/harnesses/basex/basex-standalone-xquery-harness.xproc @@ -9,27 +9,22 @@ - +

This pipeline executes an XSpec test suite with BaseX standalone.

Primary input: A XSpec test suite document.

Primary output: A formatted HTML XSpec report.

-

The dir where you unzipped the XSpec archive on your filesystem is passed - in the option 'xspec-home'. The compiled test suite (the XQuery file to be - actually evaluated) is saved on the filesystem to be passed to BaseX. The - name of this file is passed in the option 'compiled-file' (it defaults to a - file in /tmp). The BaseX JAR file is passed through 'basex-jar'.

+

The dir where you unzipped the XSpec archive on your filesystem is passed in the option + 'xspec-home'. The compiled test suite (the XQuery file to be actually evaluated) is saved + on the filesystem to be passed to BaseX. The name of this file is passed in the option + 'compiled-file' (it defaults to a file in /tmp). The BaseX JAR file is passed through + 'basex-jar'.

@@ -39,27 +34,25 @@ - + - + - - + - + @@ -84,7 +77,8 @@ - @@ -112,8 +106,6 @@
- - diff --git a/src/harnesses/basex/basex-xquery-harness.xproc b/src/harnesses/basex/basex-xquery-harness.xproc new file mode 100644 index 000000000..38421afc3 --- /dev/null +++ b/src/harnesses/basex/basex-xquery-harness.xproc @@ -0,0 +1,133 @@ + + + + + + + + + + + +

This pipeline executes an XSpec test suite with BaseX standalone.

+

Primary input: A XSpec test suite document.

+

Primary output: A formatted HTML XSpec report.

+

The dir where you unzipped the XSpec archive on your filesystem is passed + in the option 'xspec-home'. The compiled test suite (the XQuery file to be + actually evaluated) is saved on the filesystem to be passed to BaseX. The + name of this file is passed in the option 'compiled-file' (it defaults to a + file in /tmp).

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/harnesses/exist/exist-xquery-harness.xproc b/src/harnesses/exist/exist-xquery-harness.xproc index c5b98d35a..8b448f41a 100644 --- a/src/harnesses/exist/exist-xquery-harness.xproc +++ b/src/harnesses/exist/exist-xquery-harness.xproc @@ -7,104 +7,135 @@ - - - - - -

This pipeline executes an XSpec test suite on an eXist instance.

-

Primary input: A XSpec test suite document.

-

Primary output: A formatted HTML XSpec report.

-

The XQuery library module to test must already be on the eXist instance - (its URI is passed through the option 'query-at'). The instance endpoint - is passed in the option 'endpoint'. The runtime utils library (also known - as generate-query-utils.xql) must also be on the instance (its location - hint, that is the 'at' clause to use) is passed in the option 'utils-lib'. - The dir where you unzipped the XSpec archive on your filesystem is passed - in the option 'xspec-home'.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +

This pipeline executes an XSpec test suite on an eXist instance.

+

Primary input: A XSpec test suite document.

+

Primary output: A formatted HTML XSpec report.

+

The XQuery library module to test must already be on the eXist instance. + The instance endpoint is passed in the option 'endpoint'. The runtime + utils library (also known as generate-query-utils.xql) must also be on + the instance (its location hint, that is the 'at' clause to use) is + passed in the option 'utils-lib'. The dir where you unzipped the XSpec + archive on your filesystem is passed in the option 'xspec-home'.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - + diff --git a/src/harnesses/harness-lib.xpl b/src/harnesses/harness-lib.xpl index 4e7f87cce..1afc5380a 100644 --- a/src/harnesses/harness-lib.xpl +++ b/src/harnesses/harness-lib.xpl @@ -237,42 +237,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Not a t:report document + + + + + + diff --git a/src/harnesses/marklogic/ml-xquery-harness.xproc b/src/harnesses/marklogic/ml-xquery-harness.xproc index b71e9e1fa..cf96defdc 100644 --- a/src/harnesses/marklogic/ml-xquery-harness.xproc +++ b/src/harnesses/marklogic/ml-xquery-harness.xproc @@ -7,104 +7,117 @@ - - - - - -

This pipeline executes an XSpec test suite on a MarkLogic instance.

-

Primary input: A XSpec test suite document.

-

Primary output: A formatted HTML XSpec report.

-

The XQuery library module to test must already be on the MarkLogic - instance. The instance endpoint is passed in the option 'endpoint'. The - runtime utils library (also known as generate-query-utils.xql) must also - be on the instance (its location hint, that is the 'at' clause to use) is - passed in the option 'utils-lib'. The dir where you unzipped the XSpec - archive on your filesystem is passed in the option 'xspec-home'.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +

This pipeline executes an XSpec test suite on a MarkLogic instance.

+

Primary input: A XSpec test suite document.

+

Primary output: A formatted HTML XSpec report.

+

The XQuery library module to test must already be on the MarkLogic + instance. The instance endpoint is passed in the option 'endpoint'. The + runtime utils library (also known as generate-query-utils.xql) must also + be on the instance (its location hint, that is the 'at' clause to use) is + passed in the option 'utils-lib'. The dir where you unzipped the XSpec + archive on your filesystem is passed in the option 'xspec-home'.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - -
- +
+ + + + + + + + + + + + + + + + + + + + + + + +
- - - + diff --git a/src/harnesses/saxon/saxon-xslt-harness.xproc b/src/harnesses/saxon/saxon-xslt-harness.xproc index c63a56efa..a57c34797 100644 --- a/src/harnesses/saxon/saxon-xslt-harness.xproc +++ b/src/harnesses/saxon/saxon-xslt-harness.xproc @@ -26,7 +26,8 @@

Primary output: A formatted HTML XSpec report.

- + diff --git a/src/harnesses/zorba/zorba-xquery-harness.xproc b/src/harnesses/zorba/zorba-xquery-harness.xproc index 81ed7e0f3..aeb3cbef2 100644 --- a/src/harnesses/zorba/zorba-xquery-harness.xproc +++ b/src/harnesses/zorba/zorba-xquery-harness.xproc @@ -7,119 +7,108 @@ - - - - - -

This pipeline executes an XSpec test suite with Zorba.

-

Primary input: A XSpec test suite document.

-

Primary output: A formatted HTML XSpec report.

-

The dir where you unzipped the XSpec archive on your filesystem is passed - in the option 'xspec-home'. The compiled test suite (the XQuery file to be - actually evaluated) is saved on the filesystem to be passed to Zorba. The - name of this file is passed in the option 'compiled-file' (it defaults to a - file in /tmp). It relies on a script called 'zorba' being available in the - system's $PATH.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +

This pipeline executes an XSpec test suite with Zorba.

+

Primary input: A XSpec test suite document.

+

Primary output: A formatted HTML XSpec report.

+

The dir where you unzipped the XSpec archive on your filesystem is passed + in the option 'xspec-home'. The compiled test suite (the XQuery file to be + actually evaluated) is saved on the filesystem to be passed to Zorba. The + name of this file is passed in the option 'compiled-file' (it defaults to a + file in /tmp). It relies on a script called 'zorba' being available in the + system's $PATH.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - -
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - + diff --git a/src/reporter/coverage-report.xsl b/src/reporter/coverage-report.xsl index be46dab8d..e880a0395 100644 --- a/src/reporter/coverage-report.xsl +++ b/src/reporter/coverage-report.xsl @@ -2,7 +2,6 @@ - @@ -23,6 +22,12 @@ +false + + + + @@ -64,8 +69,15 @@ Test Coverage Report for <xsl:value-of select="test:format-URI($stylesheet-uri)" /> - + + + + + +

Test Coverage Report

diff --git a/src/reporter/format-utils.xsl b/src/reporter/format-utils.xsl index 2a08a6e4e..21f3b92d8 100644 --- a/src/reporter/format-utils.xsl +++ b/src/reporter/format-utils.xsl @@ -2,7 +2,6 @@ - @@ -15,7 +14,7 @@ xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns="http://www.w3.org/1999/xhtml" xmlns:pkg="http://expath.org/ns/pkg" - exclude-result-prefixes="test xs"> + exclude-result-prefixes="test xs x pkg"> diff --git a/src/reporter/format-xspec-report-folding.xsl b/src/reporter/format-xspec-report-folding.xsl index 228ce6574..fa54e600c 100755 --- a/src/reporter/format-xspec-report-folding.xsl +++ b/src/reporter/format-xspec-report-folding.xsl @@ -2,7 +2,6 @@ - diff --git a/src/reporter/format-xspec-report.xsl b/src/reporter/format-xspec-report.xsl index 290c0f20b..418be5ef0 100644 --- a/src/reporter/format-xspec-report.xsl +++ b/src/reporter/format-xspec-report.xsl @@ -2,7 +2,6 @@ - @@ -21,6 +20,8 @@ http://www.jenitennison.com/xslt/xspec/format-xspec-report.xsl +false + @@ -53,12 +54,13 @@ + - - + + @@ -102,6 +105,7 @@ @@ -124,14 +128,22 @@ <xsl:text>Test Report for </xsl:text> - <xsl:value-of select="x:report/test:format-URI(@stylesheet|@query)"/> + <xsl:value-of select="x:report/test:format-URI((@schematron,@stylesheet,@query)[1])"/> <xsl:text> (</xsl:text> <xsl:call-template name="x:totals"> <xsl:with-param name="tests" select="//x:scenario/x:test"/> + <xsl:with-param name="labels" select="true()"/> </xsl:call-template> <xsl:text>)</xsl:text> - + + + + + + @@ -147,27 +159,36 @@

- - - + + +

+

+ XSpec: + + + +

Tested:

Contents

@@ -68,6 +70,7 @@ +
+
- - + + + + + - - + + + + + @@ -183,11 +204,11 @@ - + + + + + @@ -334,25 +355,34 @@ - - - + passed: - + / pending: - + / failed: - + / total: - + + + + + + + + + + + + diff --git a/src/reporter/junit-report.xsl b/src/reporter/junit-report.xsl new file mode 100644 index 000000000..f466b6ece --- /dev/null +++ b/src/reporter/junit-report.xsl @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + skipped + passed + failed + + + + + + + + + + + + + + + Expected: + + + + + + + + + + + + diff --git a/src/reporter/test-report.css b/src/reporter/test-report.css index d91e3b91b..529a9be10 100644 --- a/src/reporter/test-report.css +++ b/src/reporter/test-report.css @@ -1,7 +1,6 @@ /****************************************************************************/ /* File: test-report.css */ /* Author: Jeni Tennsion */ -/* URI: http://xspec.googlecode.com/ */ /* Tags: */ /* Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) */ /* ------------------------------------------------------------------------ */ @@ -12,8 +11,8 @@ /* box model */ body { - margin-right: 1em; - margin-left: 10%; + margin-right: 5%; + margin-left: 5%; } h1 { @@ -145,7 +144,7 @@ dd pre, li pre { /* fonts */ body { - font-family: Verdana, arial, sans-serif; + font-family: arial, helvetica, sans-serif; font-size: small; } @@ -160,7 +159,7 @@ h1 { h2 { font-size: 144%; - font-weight: normal; + font-weight: bold; } h3 { @@ -319,11 +318,11 @@ a.img:hover, a.img:active { } .same { - background-color: #9F9; + background-color: rgb(206, 239, 174); } .diff { - background-color: #F99; + background-color: #FCC; } .whitespace { @@ -351,10 +350,6 @@ ol ol li { list-style: lower-alpha; } -th { - text-align: left; - } - td { vertical-align: top; } @@ -363,10 +358,6 @@ h1 { text-transform: uppercase; } -h2, h3 { - text-transform: capitalize; - } - .question { text-indent: -33px; } @@ -383,18 +374,53 @@ a { text-decoration: none; } -table { width: 85%; +body > h2:first-of-type { + background: inherit; + margin-bottom: 0; +} + +table { width: 95%; /* border: collapse; */ } th { text-align: left; } +th.totals { text-align: center; font-weight: normal; } + +div > table > tbody > tr > th:first-child { + font-weight:bold; + color: #474747; +} + .xspec tbody th { font-weight: normal; font-size: 0.8em; border-top: 1px #666 solid; } -.xspec tbody td { font-size: 0.8em; color: #666; } +.xspec tbody td { font-size: 0.8em; color: #262626; } .successful { background-color: #CFC; } .pending { background-color: #EEE; color: #666; } .failed { background-color: #FCC; } +.successful td:first-child:before, +body > table:first-of-type tr.successful th:first-child:before +{ +margin-right: 5px; +content:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpCQjU0NjU4QjIyQTNFMTExQkI5Rjk5QkQ4RkQ5RUJFQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpEMDVBNThBQUEzRDUxMUUxQjdCQkM2QUNBMTNBMDExNiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpEMDVBNThBOUEzRDUxMUUxQjdCQkM2QUNBMTNBMDExNiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjQ4MTZDRTNCRDVBM0UxMTFBQTI2QTBCMjZENzg1Qzg5IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkJCNTQ2NThCMjJBM0UxMTFCQjlGOTlCRDhGRDlFQkVCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+xJ3YrgAAAYBJREFUeNpsUrtKA1EQPZtdY4gEQiD4QCsLEVGX4CP4AykEq1hYiGghCDZ+gBZWVtrZ+EAjaGOhfoAkNiaKhYWICilMEQNqoYjZ5O4d5+6ucQuLM3funDNzD7OrLe229YBwSKAEnyAP/pyIbL5fcz5rcNiLtuqJSEz3ickn5ruE/vFmJ9/LYjvAldGWqA7bJkgPtoAHQrS5G6NdiwhFWCoxHOCgKUL+iurkCBVawyamE8d4qmSZ51clBZUlh+RG14JzEsJNcaTNLVwWd1B6vXXqkmGoYNeVUPnW3JNr4+YarPoncvebEAKNekAlokaY6N/A1NA+SBgY6Eijtz2Fs5sVWNWawysorWNJsO+q9QWzaxLTYwfojA3isZzDfSnrWvTsNiyp7pOrZURC7ejrTDEpcVpY9ab+NSioLZEiapZA5nwBxZcC8g9HeK7ccYM7TDnwmoU2vx6/NIJaUjc0b0u8YvJNle5HdJvlhbI0Y31ThqsjTGr0/+8hOOQ5nfsRYACtHiy+FDd82wAAAABJRU5ErkJggg==') +} + +.failed td:first-child:before, +body > table:first-of-type tr.failed th:first-child:before +{ +margin-right: 5px; +content:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpCQjU0NjU4QjIyQTNFMTExQkI5Rjk5QkQ4RkQ5RUJFQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpEQTUyOTdBQUEzRDUxMUUxQTQwN0YzMUI0Nzg3NDU1RSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpEQTUyOTdBOUEzRDUxMUUxQTQwN0YzMUI0Nzg3NDU1RSIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjQ4MTZDRTNCRDVBM0UxMTFBQTI2QTBCMjZENzg1Qzg5IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkJCNTQ2NThCMjJBM0UxMTFCQjlGOTlCRDhGRDlFQkVCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+aHNJrgAAAZ1JREFUeNpsUssrRGEU/907985YMDPNYlh4hbKZPMdgR3aysrGSSFIeKyUKpewoRTYkmcgCf4MsMI2FPDYGKeUZSoru4/uc82VC+W7fOeee+zvn/M45V1uuyCmVwDogq0hDklD6jy1dspNkdxokVrIzPFUh0/MD5OdXoJDwPFtu3d2ns6TTp9oggTlFZlmN0o4AHMmXfJGo0lmGzoE1OgmNHf5YA8rmN5HfM6wADmUuHphA9cIW/JX1yiek9DIlyijxkNjBzXYche19gNcHzfShoLUdVxtLuD/cYzCoMAzCwqYrhMDx9Chs20JRWzf4nMcXcDI3pYAqQHIAtWUJbpKursMMhpA+RiAEGzpc4X5XkDB4GjaHmiZik/PIa2rBEWVlSuW9Q+T3YndskBi46QpQFcLltchtbEZyZhxna4uKhmV9Ito/gtPNOG4P99WItdlIWARNXWOAv6AEr9cplel7/ggUleDlMqUSvNnCobHKxDsNnqs8XaWUZopp/XhxTkOR+HDVOveYUge9rNLyY9SU9v+vwXuUB2R0fQkwABfn/VKSjTLBAAAAAElFTkSuQmCC') +} + +.pending td:first-child:before, +body > table:first-of-type tr.pending th:first-child:before +{ +margin-right: 5px; +content:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDpCQjU0NjU4QjIyQTNFMTExQkI5Rjk5QkQ4RkQ5RUJFQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpDODdDM0Y0QUEzRDUxMUUxQjk5N0MzQjVFRDMyQUE1MiIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpDODdDM0Y0OUEzRDUxMUUxQjk5N0MzQjVFRDMyQUE1MiIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M2IChXaW5kb3dzKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjQ4MTZDRTNCRDVBM0UxMTFBQTI2QTBCMjZENzg1Qzg5IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkJCNTQ2NThCMjJBM0UxMTFCQjlGOTlCRDhGRDlFQkVCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+yj6RYgAAAPZJREFUeNp0kM8KgkAQxmc1E0Wfo3vQn5eRSDx4EUHwbTpEhx4lil7DiydBQUFXp5nAMNsGhpnd/X77za4Iw3CFiFcAWFMFDkXtKZ/UHhfUnB3HWdu2/REpAL2u631ZlicGdpZlwTAMSmBM0zS5bhgQLB5FU3AOUS4XvNn3vVKgAACCIMA0TbFpGsyyDJMkefdFUWAcx1hVFeZ5jlEUoed5qPEI7KDrOhiG8e6llNC27Zcz77FW+L6Pruv+WKtGIzfgR39umv/UHOJgAMlO/BPOXCQDD5p3r2ma8lvHNU9BcWPg0HXdhRZbOhRT8aSXVO9U/ZcAAwAsmjsSQcM0lwAAAABJRU5ErkJggg==') +} + + + .xspecResult { width: 95%; table-layout: fixed; } .xspecResult td, @@ -407,8 +433,12 @@ th { text-align: left; } border: 1px #999 dotted; } -span.scenario-totals {float: right; width: 22.5%; text-align: left} +span.scenario-totals {float: right; text-align: right} +/* highlight the link target */ +*:target { + box-shadow: -0.5rem 0 0 0 #FC511D; +} /* ------------------------------------------------------------------------ */ /* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. */ diff --git a/src/schemas/find-examples.rnc b/src/schemas/find-examples.rnc index 671d5ac15..96339abc0 100644 --- a/src/schemas/find-examples.rnc +++ b/src/schemas/find-examples.rnc @@ -1,7 +1,6 @@ # ========================================================================== # # File: find-examples.rnc # # Author: Jeni Tennsion # -# URI: http://xspec.googlecode.com/ # # Tags: # # Copyright (c) 2008, 2010 Jeni Tennsion (see end of file.) # # -------------------------------------------------------------------------- # diff --git a/src/schemas/xspec.rnc b/src/schemas/xspec.rnc index 245b76874..68f4d19fd 100644 --- a/src/schemas/xspec.rnc +++ b/src/schemas/xspec.rnc @@ -19,6 +19,7 @@ description = attribute query-at { xs:anyURI }?, attribute version { xs:NMTOKEN }?, attribute preserve-space { xs:NMTOKENS }?, + attribute schematron { xs:anyURI }?, (global-param | import | scenario | pending)+ } import = @@ -27,7 +28,9 @@ import = ## XSpec will be run on the stylesheet that this XSpec document describes. ## Importing is recursive and may be circular (although only one copy of a given ## imported document will actually be imported). - element import { common-attributes, attribute href { xs:anyURI } } + element import { common-attributes, + ## The document URI (location) of the imported document. + attribute href { xs:anyURI } } pending = ## Anything that is within a element will remain untested, but will be @@ -38,7 +41,7 @@ pending = ## ## An optional label attribute can be used to describe why the scenario or ## assertion should not be tested. - element pending { common-attributes, label?, (scenario | assertion)* } + element pending { common-attributes, label?, (scenario | assertion | schematron-assertion)* } scenario = ## A scenario defines the environment in which a piece of processing takes place. @@ -56,10 +59,21 @@ scenario = label, ( matching-scenario | function-scenario | - named-scenario ) } + named-scenario | + schematron-scenario ) } common-scenario-attributes = common-attributes, + ## Anything which has the @pending attribute will remain untested, but will be + ## reported as (eventual) desired behaviour. This is a good way of commenting out + ## a set of behaviours that haven't been implemented yet, or scenarios whose + ## desired behaviour hasn't been determined, or tests for code that you're not + ## currently working on, to make the testing process faster. + ## + ## The attribute value can be used to describe why the scenario or + ## assertion should not be tested. attribute pending { text }?, + ## If any scenario has a focus attribute, any scenarios without a focus + ## attribute will be classed as pending. attribute focus { text }? label = @@ -113,7 +127,8 @@ function-scenario = function-call?, ## element defines the template call and the parameters passed to it and the ## elements test the result of the template call. Child scenarios ## can override the parameters in the template call. -named-scenario = template-call?, +named-scenario = context?, + template-call?, like*, (pending | assertion)*, (pending | @@ -125,6 +140,7 @@ context = ## are applied to it, and any parameters included in the apply templates. element context { common-attributes, + ## The mode in which templates are applied to it, and any parameters included in the apply templates. attribute mode { xs:QName }?, template-param*, node-selection @@ -135,6 +151,7 @@ function-call = ## parameters passed to it. element call { common-attributes, + ## The qualified name of the function which should get called. attribute function { xs:QName }?, function-param* } @@ -144,6 +161,7 @@ template-call = ## parameters passed to it. element call { common-attributes, + ## The qualified name of the template which should get called. attribute template { xs:QName }?, template-param* } @@ -169,11 +187,16 @@ as = attribute as { text } selection = node-selection | value-selection -node-selection = attribute href { xs:anyURI }?, +node-selection = + ## The document URI (location) of the imported document. + attribute href { xs:anyURI }?, + ## The XPath expression to access the selected node. attribute select { xpath }?, any-content -value-selection = attribute select { xpath } +value-selection = + ## The XPath expression to access the selected node. + attribute select { xpath } xpath = text @@ -190,4 +213,92 @@ test = attribute test { xpath } common-attributes = attribute xml:* { text }* any-content = mixed { any-element* } -any-element = element * { attribute * { text }*, any-content } \ No newline at end of file +any-element = element * { attribute * { text }*, any-content } + +schematron-scenario = context?, + like*, + (pending | schematron-assertion | assertion)*, + (pending | + element scenario { common-scenario-attributes, + label, schematron-scenario })* + +schematron-assertion = + expect-assert | expect-not-assert | + expect-report | expect-not-report | + expect-valid | expect-rule + +expect-valid = + ## In a Schematron test, verify that the Schematron is executed and the XML + ## that is provided as context passes validation. + ## + ## In the Schematron an or can have a attribute + ## specifying that it is a warning or informational message and these are + ## considered to be allowed for a passing validation. + element expect-valid { empty } + +expect-assert = + ## In a Schematron test, verify that an is thrown. + ## + ## The attributes id, role, and location can be used in combination to + ## identify a specific . + element expect-assert { + schematron-common-expect, + schematron-count-expect +} +expect-report = + ## In a Schematron test, verify that a is thrown. + ## + ## The attributes id, role, and location can be used in combination to + ## identify a specific . + element expect-report { + schematron-common-expect, + schematron-count-expect +} + +expect-not-assert = + ## In a Schematron test, verify that an is not thrown. + ## + ## The attributes id, role, and location can be used in combination to + ## identify a specific . + element expect-not-assert { + schematron-common-expect +} +expect-not-report = + ## In a Schematron test, verify that a is not thrown. + ## + ## The attributes id, role, and location can be used in combination to + ## identify a specific . + element expect-not-report { + schematron-common-expect +} + +expect-rule = + ## In a Schematron test, verify that a is fired. + element expect-rule { + ## Optional label to describe the expectation. + attribute label { text }?, + ## Identify a specific using its id attribute. + attribute id { xs:NCName }?, + ## Match a specific context attribute value of a . + attribute context { text }?, + schematron-count-expect +} + +schematron-common-expect = + ## Optional label to describe the expectation. + attribute label { text }?, + ## Identify a specific or using its id attribute or + ## the id attribute of the parent . + attribute id { xs:NCName }?, + ## Match a specific role attribute value of an or or + ## the parent . Role attribute values are often used to specify + ## 'error', 'fatal', 'warn', 'warning', 'info', 'information'. + attribute role { text }?, + ## XPath of a location in the context XML that the or + ## is expected to find. Namespace prefixes that are defined in Schematron + ## using ns elements can be used. + attribute location { xpath }? + +schematron-count-expect = + ## Number of times an or is expected to be thrown. + attribute count { xs:nonNegativeInteger }? diff --git a/src/schematron/iso-schematron/iso_abstract_expand.xsl b/src/schematron/iso-schematron/iso_abstract_expand.xsl new file mode 100644 index 000000000..501839523 --- /dev/null +++ b/src/schematron/iso-schematron/iso_abstract_expand.xsl @@ -0,0 +1,313 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Suppressed abstract pattern was here + + + + + + + Start pattern based on abstract + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/schematron/iso-schematron/iso_dsdl_include.xsl b/src/schematron/iso-schematron/iso_dsdl_include.xsl new file mode 100644 index 000000000..f345b2d97 --- /dev/null +++ b/src/schematron/iso-schematron/iso_dsdl_include.xsl @@ -0,0 +1,1519 @@ + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in RELAX NG extRef + include + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in Schematron include + + + + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + Schema error: Use include to + include fragments, not a whole + schema + + + + + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + Schema error: Use include to include + fragments, not a whole schema + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in Schematron include + + + + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in Schematron include + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + Schema error: Use include to include + fragments, not a whole schema + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + Schema error: Use include to include + fragments, not a whole schema + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in DTLL include + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in CRDL include + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fatal error: Xinclude href contains fragment + identifier # + + + + + + + Fatal error: Sorry, this software only + supports simple ids in XInclude xpointers + + + + + + + Fatal Error: Impossible URL in XInclude + include + + + + + + + + + + + + + + + + + + + + + + + + + + + Unable to open referenced included file and fallback + file: + + + + + + + Unable to open referenced included file: + + + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: Impossible URL in XLink embedding + link + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + Unable to open referenced included file: + + + + + + + Unable to locate id attribute: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + XPath error. No XPath. + XPath error. Missing location step. Suggestion: remove '/' before '['. + + + XPath syntax error. Unclosed parenthesis. Suggestion: add ')'. + + XPath syntax error. Extra close parenthesis. Suggestion: remove ')'. + + + XPath syntax error. Unclosed left square bracket. Suggestion: add ']'. + + XPath syntax error. Extra right square bracket. Suggestion: remove ']'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/schematron/iso-schematron/iso_schematron_message.xsl b/src/schematron/iso-schematron/iso_schematron_message.xsl new file mode 100644 index 000000000..33ed50971 --- /dev/null +++ b/src/schematron/iso-schematron/iso_schematron_message.xsl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + ( + / + ) + + + \ No newline at end of file diff --git a/src/schematron/iso-schematron/iso_schematron_message_xslt2.xsl b/src/schematron/iso-schematron/iso_schematron_message_xslt2.xsl new file mode 100644 index 000000000..b3ade50fb --- /dev/null +++ b/src/schematron/iso-schematron/iso_schematron_message_xslt2.xsl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + ( + / + ) + + + \ No newline at end of file diff --git a/src/schematron/iso-schematron/iso_schematron_skeleton_for_saxon.xsl b/src/schematron/iso-schematron/iso_schematron_skeleton_for_saxon.xsl new file mode 100644 index 000000000..d18f21626 --- /dev/null +++ b/src/schematron/iso-schematron/iso_schematron_skeleton_for_saxon.xsl @@ -0,0 +1,2306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #ALL + + + +false + +true + + + + + true + false + + + + + + + true + false + + + + + + + + + @*| + + * + node() + *|comment()|processing-instruction() + + + + + + + + + + +false + + +default + + +1 + +false + + + + + + 1 + + + + + + + + + + + + + + + + + 2 + + + + + + 1.0 + + + + + + + + + This XSLT was automatically generated from a Schematron schema. + + + + + 1.0 + + + + + + + + + + + + 2.0 + + + + + + + + + + 3a + + 3b + + + + + Implementers: please note that overriding process-prolog or process-root is + the preferred method for meta-stylesheets to use where possible. + + + + + + + + + + + + PHASES + + PROLOG + + XSD TYPES FOR XSLT2 + + KEYS AND FUNCTIONS + + DEFAULT RULES + + SCHEMA SETUP + + SCHEMATRON PATTERNS + + + + + + + + + + + + + + + + + + + + + + + + 4a + + 4b + + + + + + + MODE: SCHEMATRON-SELECT-FULL-PATH + This mode can be used to generate an ugly though full XPath for locators + + + + + + + + + + + + + + + + + + + + + + + + + MODE: SCHEMATRON-FULL-PATH + This mode can be used to generate an ugly though full XPath for locators + + + + + + / + + + + *: + + [namespace-uri()=' + + '] + + + + [ + + ] + + + + + + / + + + + + + [] + + + + *[local-name()=' + + '] + + + [] + + + + + + + + + + + + + + + / + + @ + + @*[local-name()=' + + ' and namespace-uri()=' + + '] + + + + + + + / + + @ + + @*[local-name()=' + + ' and namespace-uri()=' + + '] + + + + + + + + + + MODE: SCHEMATRON-FULL-PATH-2 + + This mode can be used to generate prefixed XPath for humans + + + + + + / + + + [ + + ] + + + + + /@ + + + + + MODE: SCHEMATRON-FULL-PATH-3 + + + This mode can be used to generate prefixed XPath for humans + (Top-level element has index) + + + + + + / + + + [ + + ] + + + + + /@ + + + + + MODE: GENERATE-ID-FROM-PATH + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + MODE: GENERATE-ID-2 + + + U + + + U + + + + + U. + + n + + + + + U. + + _ + + _ + + + + + Strip characters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + 6a + + 6b + + + + + + + + 7 + + + ASSERT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8 + + + + REPORT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 + + + + 11a + + 11b + + + + + + + + + + + + + + + + + + + + + + 12 + + + 13 + + + + + + + + + + + + + + + + 14 + + + + + + + + + + + + 15 + + + + + + 16 + + + + + + + + 17 + + + + + + + + + 18 + + + + + + + + + + + + + + 19 + + + + + + + + 20a + + 20b + + + + 21 + + + + + + + + + + + + 20a + + 20b + + + + 21 + + + + + + + + + + + + + + + 19 + + + + + + + 21 + + + + + + + + + + + 21 + + + + + + + + + + + + + + + + 22 + + + + + + + + + 23 + + + + + + 24 + + + 25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 26 + + + 27 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //( + + ( + + ) + | + + ) + [not(self::text())] + + + + + + + + + //( + + ( + + ) + | + + ) + [not(self::text())] + + + + + + + + + + + + + + + + + + + + + + + 28 + + + + + + + + PATTERN + + + + + + + + + + + + + + + + + + + + 29 + + + + + + + + + + No property found with that ID + + + + + + + + + + + + + + + + + + + + + + + + + + 30 + + + + + RULE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 31 + + + 32 + + + + + + 33 + + + + + + + + + + + + + + + + + + + + + + + + + + + 34 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 35a + + 35b + + + + + + + + + + + + + + + + + + + + + + + + + 36a + + 36b + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 36a + + 36b + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 37a + + 37b + + + + + + + + + + + + + + + + + + + 38a + + 38b + + + + + + + + + + + + 39a + + 39b + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + + + + + schema-title + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Schema error: Schematron elements in old and new namespaces found + Schema error: in the queryBinding attribute, use 'xslt' + Fail: This implementation of ISO Schematron does not work with schemas using the query language + + Phase Error: no phase has been defined with name + + Markup Error: no pattern attribute in <active> + Reference Error: the pattern " + " has been activated but is not declared + Markup Error: no test attribute in <assert + Markup Error: no test attribute in <report> + Markup Error: no id attribute in <diagnostic> + Markup Error: no rule attribute in <extends> + Reference Error: the abstract rule " + " has been referenced but is not declared + Markup Error: no name attribute in <key> + Markup Error: no path or use attribute in <key> + Markup Error: no path or use attribute in <key> + Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace. + Markup Error: no name attribute in <function> + Schema error: The function element is not in the ISO Schematron namespace. Use the XSLT namespace. + Schema error: Empty href= attribute for include directive. + Error: Impossible URL in Schematron include + Unable to open referenced included file: + + Schema error: Use include to include fragments, not a whole schema + Schema error: XSD schemas may only be imported if you are using the 'xslt2' query language binding + Schema error: The import-schema element is not available in the ISO Schematron namespace. Use the XSLT namespace. + Warning: Variables should not be used with the "xpath" query language binding. + Warning: Variables should not be used with the "xpath2" query language binding. + Markup Error: no uri attribute in <ns> + Markup Error: no prefix attribute in <ns> + Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already + Markup Error: no id attribute in <phase> + Markup Error: no context attribute in <rule> + Markup Error: no id attribute on abstract <rule> + Markup Error: (2) context attribute on abstract <rule> + Markup Error: context attribute on abstract <rule> + Markup Error: no select attribute in <value-of> + Warning: + must not contain any child elements + Reference error: A diagnostic " + " has been referenced but is not declared + Using the XSLT namespace with a prefix other than "xsl" in Schematron rules is not supported in this processor: + + Error: unrecognized element in ISO Schematron namespace: check spelling and capitalization + + Warning: unrecognized element + + + + + + diff --git a/src/schematron/iso-schematron/iso_schematron_skeleton_for_xslt1.xsl b/src/schematron/iso-schematron/iso_schematron_skeleton_for_xslt1.xsl new file mode 100644 index 000000000..9a764dfe2 --- /dev/null +++ b/src/schematron/iso-schematron/iso_schematron_skeleton_for_xslt1.xsl @@ -0,0 +1,1851 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #ALL + + + +false + +true + + + + + true + false + + + + + + + true + false + + + + + + + + + @*| + + * + node() + *|comment()|processing-instruction() + + + + + + + + + +false + + + + + +default + +false + + + +1 + + + + + Schema error: Schematron elements in old and new namespaces found + + + + + + + + + + + + + + + + + Schema error: in the queryBinding attribute, use 'xslt' + + + + + 1.0 + + + + + + + + + This XSLT was automatically generated from a Schematron schema. + + + + + 1.0 + + + + + + + + + + Fail: This implementation of ISO Schematron does not work with + schemas using the "" query language. + + + + + Implementers: please note that overriding process-prolog or process-root is + the preferred method for meta-stylesheets to use where possible. + + + + + + + + + + PHASES + + PROLOG + + KEYS + + DEFAULT RULES + + SCHEMA METADATA + + SCHEMATRON PATTERNS + + + + + + + + + + + + + + + + + + + + + + + Phase Error: no phase with name has been defined. + + + + + + + MODE: SCHEMATRON-SELECT-FULL-PATH + This mode can be used to generate an ugly though full XPath for locators + + + + + + + + + + + + + + + + + + + + + + + + + MODE: SCHEMATRON-FULL-PATH + This mode can be used to generate an ugly though full XPath for locators + + + + + + / + + + + + + [] + + + + *[local-name()=' + ' and namespace-uri()=' + + '] + + + [] + + + + + + + + + + / + + @ + + @*[local-name()=' + + ' and namespace-uri()=' + + '] + + + + + + + + + MODE: SCHEMATRON-FULL-PATH-2 + + This mode can be used to generate prefixed XPath for humans + + + + + + / + + + [ + + ] + + + + + /@ + + + + + MODE: GENERATE-ID-FROM-PATH + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + MODE: SCHEMATRON-FULL-PATH-3 + + + This mode can be used to generate prefixed XPath for humans + (Top-level element has index) + + + + + + / + + + [ + + ] + + + + + /@ + + + + + MODE: GENERATE-ID-2 + + + U + + + U + + + + + U. + + n + + + + + U. + + _ + + _ + + + + + Strip characters + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no pattern attribute in <active> + + + + Reference Error: the pattern "" has been activated but is not declared + + + + + + + + Markup Error: no test attribute in <assert + + + ASSERT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no test attribute in <report> + + + + REPORT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no id attribute in <diagnostic> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no rule attribute in <extends> + + + Reference Error: the abstract rule "" has been referenced but is not declared + + + + + + + + + + + + + + Markup Error: no name attribute in <key> + + + Markup Error: no path or use attribute in <key> + + + + + + + + + + + + + + + + Markup Error: no path or use attribute in <key> + + + + + + + + + + + + Schema error: The key element is not in the ISO Schematron namespace. Use the XSLT namespace. + + + + + + + + Schema error: Empty href= attribute for include directive. + + + + + + + + + + + + + + Error: Impossible URL in Schematron include + + + + + + + Schema error: Use include to include fragments, not a whole schema + + + + + + + + + + Schema error: Use include to include fragments, not a whole schema + + + + + + + + + + + + + + + Error: Impossible URL in Schematron include + + + + + + + Schema error: Use include to include fragments, not a whole schema + + + + + + + + + + + Schema error: Use include to include fragments, not a whole schema + + + + + + + + + + Warning: Variables should not be used with the "xpath" query language binding. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no uri attribute in <ns> + + + Markup Error: no prefix attribute in <ns> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //( + + ( + + ) + | + + ) + [not(self::text())] + + + + + + + + + + + + + Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already + + + + + + + + + + PATTERN + + + + + + + + + + + + + + + + + + + + Markup Error: no id attribute in <phase> + + + + + + + + Markup Error: no context attribute in <rule> + + + RULE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no id attribute on abstract <rule> + + + Markup Error: (2) context attribute on abstract <rule> + + + + + + Markup Error: context attribute on abstract <rule> + + + + + + + + + + + + + + + + + + + + + + + + + + + Markup Error: no select attribute in <value-of> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Warning: + + must not contain any child elements + + + + + + + + + + + + + + + + + + + + + + + + + Reference error: A diagnostic "" has been referenced but is not declared + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Using the XSLT namespace with a prefix other than "xsl" in + Schematron rules is not supported + in this processor: + + + + + + + + + + + + + + + + + + + + Error: unrecognized element in ISO Schematron namespace: check spelling + and capitalization + + + + + + + + + + + + + Warning: unrecognized element + + + + + + + + + + + + + + + Warning: unrecognized element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + title + + + + + + + schema-title + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schematron/iso-schematron/iso_svrl_for_xslt1.xsl b/src/schematron/iso-schematron/iso_svrl_for_xslt1.xsl new file mode 100644 index 000000000..069ea0294 --- /dev/null +++ b/src/schematron/iso-schematron/iso_svrl_for_xslt1.xsl @@ -0,0 +1,614 @@ + + + + + + + + + + + + + + + + + +true + + + + + + + + + + + #ALL + + +false +true +true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + xslt1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +   +   +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl b/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl new file mode 100644 index 000000000..373270d00 --- /dev/null +++ b/src/schematron/iso-schematron/iso_svrl_for_xslt2.xsl @@ -0,0 +1,692 @@ + + + + + + + + + + + + + + + +true +true + + + + + + + + + + + #ALL + + +false +true +true + + + + +false + + +default + + + + +1 + + + + + + + + + + + + + + + + + + + + + + + + xslt1 + + + + + + + + + + + + + + + + + +   +   +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TERMINATING + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schematron/iso-schematron/readme.txt b/src/schematron/iso-schematron/readme.txt new file mode 100644 index 000000000..685c92e39 --- /dev/null +++ b/src/schematron/iso-schematron/readme.txt @@ -0,0 +1,101 @@ +

ISO SCHEMATRON 2010

+ +XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist. + +2010-04-21 + +Two distributions are available. One is for XSLT1 engines. +The other is for XSLT2 engines, such as SAXON 9. + + +This version of Schematron splits the process into a pipeline of several different XSLT stages. + +1) First, preprocess your Schematron schema with iso_dsdl_include.xsl. +This is a macro processor to assemble the schema from various parts. +If your schema is not in separate parts, you can skip this stage. +This stage also generates error messages for some common XPath syntax problems. + +2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl. +This is a macro processor to convert abstract patterns to real patterns. +If your schema does not use abstract patterns, you can skip this +stage. + +3) Third, compile the Schematron schema into an XSLT script. +This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl +(which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl) +However, other "meta-styleseets" are also in common use; the principle of operation is the same. +If your schema uses Schematron phases, supply these as command line/invocation parameters +to this process. + +4) Fourth, run the script generated by stage 3 against the document being validated. +If you are using the SVRL script, then the output of validation will be an XML document. +If your schema uses Schematron parameters, supply these as command line/invocation parameters +to this process. + + +The XSLT2 distribution also features several next generation features, +such as validating multiple documents. See the source code for details. + +Schematron assertions can be written in any language, of course; the file +sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton +in English, and this can be used as template to localize the skeleton's +error messages. Note that typically programming errors in Schematron are XPath +errors, which requires localized messages from the XSLT engine. + +ANT +--- +To give an example of how to process a document, here is a sample ANT task. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EXTRACTION SCHEMATRON FROM XSD OR RELAX NG + +The following files allow extracting of embedded schematron patterns +in XML Schemas or RELAX NG schemas. For details, see the at + article http://www.topologi.com/resources/schtrn_xsd_paper.html + +The following files are provided: + ExtractSchFromRNG.xsl Generate a Schematron schema from patterns + embedded in a RELAX NG schema. The schema uses XSLT1. + ExtractSchFromXSD.xsl Generate a Schematron schema from patterns + embedded in a W3C XML Schemas schema. The schema uses XSLT1. + + ExtractSchFromRNG-2.xsl Generate a Schematron schema from patterns + embedded in a RELAX NG schema. The schema uses XSLT2. + ExtractSchFromXSD-2.xsl Generate a Schematron schema from patterns + embedded in a W3C XML Schemas schema. The schema uses XSLT2. \ No newline at end of file diff --git a/src/schematron/iso-schematron/sch-messages-cs.xhtml b/src/schematron/iso-schematron/sch-messages-cs.xhtml new file mode 100644 index 000000000..93e181c8b --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-cs.xhtml @@ -0,0 +1,56 @@ + + + Chyba ve schématu: nalezeny elementy Schematronu ve starém i novém jmenném prostoru + Chyba ve schématu: v atributu queryBinding použijte 'xslt' + Porucha: Tato implementace ISO Schematronu nefunguje se schématy, která používají dotazovací jazyk + + Fázová chyba: fáze jménem + není definována. + Chybný markup: v elementu <active> chybí atribut pattern + Chybný odkaz: vzor " + " byl aktivován, ne však deklarován + Chybný markup: v elementu <assert> chybí atribut test + Chybný markup: v elementu <report> chybí atribut test + Chybný markup: v elementu <diagnostic> chybí atribut id + Chybný markup: v elementu <extends> chybí atribut rule + Chybný odkaz: abstraktní pravidlo " + " není definováno, ačkoli se na ně odkazuje + Chybný markup: v elementu <key> chybí atribut name + Chybný markup: v elementu <key> chybí atribut path nebo use + Chybný markup: v elementu <key> chybí atribut path nebo use + Chyba ve schématu: element <key> není ve jmenném prostoru ISO Schematronu. Použijte jmenný prostor XSLT. + Chybný markup: v elementu <function> chybí atribut name + Chyba ve schématu: element <function> není ve jmenném prostoru ISO Schematronu. Použijte jmenný prostor XSLT. + Chyba ve schématu: direktiva <include> má prázdný atribut href + Chyba: Nesprávné URL v direktivě <include> + Chyba: Nelze otevřít vkládaný soubor + + Chyba ve schématu: <include> používejte ke vkládání fragmentů, ne celého schématu + Chyba ve schématu: Schémata XSD lze importovat pouze pokud používáte dotazovací jazyk "xslt2" + Chyba ve schématu: element <import-schema> není ve jmenném prostoru ISO Schematronu. Použijte jmenný prostor XSLT. + Varování: S dotazovacím jazykem "xpath" by se neměly používat proměnné + Varování: S dotazovacím jazykem "xpath2" by se neměly používat proměnné + Chybný markup: v elementu <ns> chybí atribut uri + Chybný markup: v elementu <ns> chybí atribut prefix + Chyba v implementaci schématu: toto schéma obsahuje abstraktní vzory, které však již měly být předchozím zpracováním odstraněny + Chybný markup: v elementu <phase> chybí atribut id + Chybný markup: v elementu <rule> chybí atribut context + Chybný markup: v abstraktním pravidlu chybí atribut id + Chybný markup: (2) Abstraktní pravidlo nesmí mít atribut context + Chybný markup: Abstraktní pravidlo nesmí mít atribut context + Chybný markup: v elementu <value-of> chybí atribut select + Varování: + nesmí obsahovat žádné podelementy + Chybný odkaz: Diagnostika " + " nebyla deklarována, ačkoli se na ni odkazuje + Chyba: procesor + nepodporuje použití jmenného prostoru XSLT s jiným prefixem než "xsl" + Chyba: neznámý element + ve jmenném prostoru ISO Schematronu: zkontrolujte, je-li správně zapsán + Varování: neznámý element + + + diff --git a/src/schematron/iso-schematron/sch-messages-de.xhtml b/src/schematron/iso-schematron/sch-messages-de.xhtml new file mode 100644 index 000000000..00e33e6db --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-de.xhtml @@ -0,0 +1,55 @@ + + + Fehler im Schema: Schematron Elemente sowohl im alten als auch neuen Namensraum gefunden + Fehler im Schema: Nutzen Sie 'xslt' als Wert für das 'queryBinding'-Attribut + Fehler: Diese Implementierung von ISO Schematron unterstützt keine Schemas, welche die Query Language + nutzen + Phasenfehler: Es gibt keine Phase mit Namen + + Fehler in der Annotation: Kein Attribut 'pattern' in <active> + Referenzierungsfehler: Der Ausdruck " + " wurde aktiviert, ist aber nicht deklariert + Fehler in der Annotation: Kein Attribut 'test' in <assert + Fehler in der Annotation: Kein Attribut 'test' in <report> + Fehler in der Annotation: Kein Attribut 'id' in <diagnostic> + Fehler in der Annotation: Kein Attribut 'rule' in <extends> + Referenzierungsfehler: Die abstrakte Regel " + " wurde referenziert, ist aber nicht deklariert + Fehler in der Annotation: Kein Attribut 'name' in <key> + Fehler in der Annotation: Kein Attribut 'path' oder 'use' in <key> + Fehler in der Annotation: Kein Attribut 'path' oder 'use' in <key> + Fehler im Schema: Das Element <key> ist im ISO Schematron-Namensraum nicht vorhanden. Benutzen Sie den XSLT-Namensraum. + Fehler in der Annotation: Kein Attribut 'name' in <function> + Fehler im Schema: Das Element <function> ist im ISO Schematron-Namensraum nicht vorhanden. Benutzen Sie den XSLT-Namensraum. + Fehler im Schema: Leeres Attribut 'href' für <include> Anweisung. + Fehler: Ungültige URL in <include> + Kann die referenzierte Datei nicht öffnen: + + Fehler im Schema: <include> darf nur zur Einbettung von Schemafragmenten genutzt werden, nicht für ganze Schemata + Fehler im Schema: XSD Schemata dürfen nur importiert werden, wenn das 'xslt2' Query Language Binding genutzt wird + Fehler im Schema: Das Element <import-schema> ist im ISO Schematron-Namensraum nicht vorhanden. Benutzen Sie den XSLT-Namensraum. + Warnung: Variablen sollten nicht zusammen mit dem 'xpath' Query Language Binding genutzt werden. + Warnung: Variablen sollten nicht zusammen mit dem 'xpath2' Query Language Binding genutzt werden. + Fehler in der Annotation: Fehlendes Attribut 'uri' in <ns> + Fehler in der Annotation: Fehlendes Attribut 'prefix' in <ns> + Fehler bei der Schemaimplementierung: Dieses Schema enthält abstrakte Mustervergleiche, die bereits vorverarbeitet sein sollten. + Fehler in der Annotation: Fehlendes Attribut 'id' in <phase> + Fehler in der Annotation: Fehlendes Attribut 'context' in <rule> + Fehler in der Annotation: Fehlendes Attribut 'id' an abstrakter <rule> + Fehler in der Annotation: (2) Kontext-Attribut an abstrakter <rule> + Fehler in der Annotation: Attribut 'context' an abstrakter <rule> + Fehler in der Annotation: Fehlendes Attribut 'select' in <value-of> + Warnung: + darf keine Kindelemente beinhalten + Referenzierungsfehler: Ein <diagnostic>-Element " + " wurde referenziert, ist aber nicht deklariert + Der Gebrauch des XSLT-Namensraums mit einem anderen Präfix als 'xsl' in Schematron-Regeln wird von diesem Prozessor nicht unterstützt: + + Fehler: Unbekanntes Element im ISO Schematron-Namensraum: Überprüfen Sie die Schreibweise (inkl. Groß- und Kleinschreibung) + + Warnung: Unbekanntes Element + + diff --git a/src/schematron/iso-schematron/sch-messages-en.xhtml b/src/schematron/iso-schematron/sch-messages-en.xhtml new file mode 100644 index 000000000..6f777ed2b --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-en.xhtml @@ -0,0 +1,57 @@ + + + + Schema error: Schematron elements in old and new namespaces found + Schema error: in the queryBinding attribute, use 'xslt' + Fail: This implementation of ISO Schematron does not work with schemas using the query language + + Phase Error: no phase has been defined with name + + Markup Error: no pattern attribute in <active> + Reference Error: the pattern " + " has been activated but is not declared + Markup Error: no test attribute in <assert> + Markup Error: no test attribute in <report> + Markup Error: no id attribute in <diagnostic> + Markup Error: no rule attribute in <extends> + Reference Error: the abstract rule " + " has been referenced but is not declared + Markup Error: no name attribute in <key> + Markup Error: no path or use attribute in <key> + Markup Error: no path or use attribute in <key> + Schema error: The <key> element is not in the ISO Schematron namespace. Use the XSLT namespace. + Markup Error: no name attribute in <function> + Schema error: The <function> element is not in the ISO Schematron namespace. Use the XSLT namespace. + Schema error: Empty href attribute for <include> directive. + Error: Impossible URL in Schematron <include> + Error: Unable to open referenced included file: + + Schema error: Use <include> to include fragments, not a whole schema + Schema error: XSD schemas may only be imported if you are using the 'xslt2' query language binding + Schema error: The <import-schema> element is not available in the ISO Schematron namespace. Use the XSLT namespace. + Warning: Variables should not be used with the "xpath" query language binding. + Warning: Variables should not be used with the "xpath2" query language binding. + Markup Error: no uri attribute in <ns> + Markup Error: no prefix attribute in <ns> + Schema implementation error: This schema has abstract patterns, yet they are supposed to be preprocessed out already + Markup Error: no id attribute in <phase> + Markup Error: no context attribute in <rule> + Markup Error: no id attribute on abstract <rule> + Markup Error: (2) context attribute on abstract <rule> + Markup Error: context attribute on abstract <rule> + Markup Error: no select attribute in <value-of> + Warning: + must not contain any child elements + Reference error: A diagnostic " + " has been referenced but is not declared + Warning: Using the XSLT namespace with a prefix other than "xsl" in Schematron rules is not supported in this processor: + + Error: unrecognized element in ISO Schematron namespace: check spelling and capitalization + + Warning: unrecognized element + + \ No newline at end of file diff --git a/src/schematron/iso-schematron/sch-messages-fr.xhtml b/src/schematron/iso-schematron/sch-messages-fr.xhtml new file mode 100644 index 000000000..a797db7bf --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-fr.xhtml @@ -0,0 +1,54 @@ + + + Erreur de schema: éléments Schematron à la fois dans l'ancien et le nouveau namespace + Erreur de schema: utilisez 'xslt' dans l'attribut queryBinding + Échec: Cette implémentation de Schematron ISO ne fonctionne pas avec des schemas utilisant le langage de query + + Erreur de phase: aucune phase n'a été définie avec le nom + + Erreur de balisage: pas d'attribut pattern dans <active> + Erreur de référence: le pattern " + " a été activé mais n'a pas été décalaré + Erreur de balisage: pas d'attribut test dans <assert> + Erreur de balisage: pas d'attribut test dans <report> + Erreur de balisage: pas d'attribut id dans <diagnostic> + Erreur de balisage: pas d'attribut rule dans <extends> + Erreur de référence: la règle abstraite " + " a été référencée mais pas déclarée + Erreur de balisage: pas d'attribut name dans <key> + Erreur de balisage: pas d'attribut path ou use dans <key> + Erreur de schema: L'élément key n'est pas dans le namespace Schematron ISO. Utilisez le namespace XSLT. + Erreur de balisage: pas d'attribut name dans <function> + Erreur de schema: L'élément function n'est pas dans le namespace Schematron ISO. Utilisez le namespace XSLT. + Erreur de schema: Attribut href vide sur a directive include. + Erreur: URL impossible dans la directive include de Schematron + Impossible d'ouvrir le fichier référencé pour l'inclusion: + + Erreur de schema: Utilisez include pour inclure des fragments et non un schema entier + Erreur de schema: Les schema XSD peuvent être importés seulement si vous utilisez the langage de query 'xslt2' + Erreur de schema: L'élément import-schema n'est pas disponible dans le namespace Schematron ISO. Utilisez le namespace XSLT. + Avertissement: Des variables ne devraient pas être utiliées avec le langage de query "xpath". + Avertissement: Des variables ne devraient pas être utiliées avec le langage de query "xpath2". + Erreur de balisage: pas d'attribut uri dans <ns> + Erreur de balisage: pas d'attribut prefix dans <ns> + Erreur d'implémentation de schema: Ce schema des patterns abstraits, bien qu'ils sont supposés avoir été préprocessés précédemment + Erreur de balisage: pas d'attribut id dans <phase> + Erreur de balisage: pas d'attribut context dans <rule> + Erreur de balisage: pas d'attribut id dans <rule> + Erreur de balisage: (2) attribut context dans une <rule> abstraite + Erreur de balisage: attribut context dans une <rule> abstraite + Erreur de balisage: pas d'attribut select dans <value-of> + Avertissement: + ne peut contenir aucun élément enfant + Erreur de référence: Un diagnostique " + " a été référencé mais n'est pas déclaré + Utiliser the namespace XSLT avec un autre préfixe que "xsl" dans les rules Schematron n'est pas supporté par ce processor: + + Erreur: élément inconnu dans le namespace Schematron ISO: vérifiez l'orthographe et la casse + + Avertissement: élément inconnu + + diff --git a/src/schematron/iso-schematron/sch-messages-ja.xhtml b/src/schematron/iso-schematron/sch-messages-ja.xhtml new file mode 100644 index 000000000..bedf32bed --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-ja.xhtml @@ -0,0 +1,53 @@ + + + スキーマエラー:古い名前空間と新しい名前空間にはSchematron 要素が見つかりました。 + スキーマエラー:検索結合属性では、 'xslt'を使用する。 + 失敗: ISO Schematron の 実行 は、スキーマが検索言語を使用してできない。 + + フェーズ エラー: フェーズは名前で定義されていない。 + + マークアップエラー: <active>にはパターンの属性がない + 参照エラー: パターン が " + " 活性化されているが宣言されていない。 + マークアップエラー: <assert> にはtestの属性がない + マークアップエラー: <report> にはtestの属性がない + マークアップエラー: <diagnostic> にはidの属性がない   + マークアップエラー:  <extends> にはruleの属性がない + 参照エラー: 抽象的な規則が " + " 参照されているが宣言されていない。 + マークアップエラー: <key>にはnameの属性がない + マークアップエラー: <key>にはpath か 又は useの 属性がない + マークアップエラー:  <key>には path か 又は useの 属性がない + スキーマエラー: <key> の要素はISO Schematronの 名前空間にはない. XSLTの名前空間を使用する。 + マークアップエラー: <function>にはnameの属性がない + スキーマエラー: <function> の要素はISO Schematronの 名前空間にはない. XSLTの名前空間を使用する。 + スキーマエラー: <include>のために空hrefの属性がある。 + エラー: Schematron <include>には不可能なURL がある + エラー: 参照したファイルが含まれて、開けない : + + スキーマエラー:全体のスキーマではなく、フラグメントを含む <include> を使用する。 + スキーマエラー: 'xslt2'の検索言語結合を使用している場合はXSDスキーマのみ読み込みできる。 + スキーマエラー:ISO Schematron の名前空間には <import-schema>の要素は無効です。 XSLTの 名前空間を使用する。 + 注意: 変数は、"xpath" 検索言語結合を使用すべきではない。 + 注意: 変数は、"xpath" 検索言語結合を使用すべきではない。 + マークアップエラー: <ns>にはuriの属性がない + マークアップエラー: <ns>にはprefixの属性がない + スキーマ実行 エラー: このスキーマは抽象的なパターンを持って、まだすでに前加工されることになっている。 + マークアップエラー: <phase>にはidの属性がない + マークアップエラー: <rule>にはcontextの要素がない + マークアップエラー: 抽象的な <rule>にはid属性がない。 + マークアップエラー: (2) 抽象的な <rule>にはcontext属性がない。 + マークアップエラー: 抽象的な <rule>にはcontext属性がない。 + マークアップエラー: <value-of>には selectの属性がない + 注意: + 子要素が含まれなくてはならない + 参照エラー: 診断は " + " 参照されているが宣言されていない。 + 注意: Schematron規則で"xsl"以外の接頭辞 XSLT 名前空間を使用することは、このプロセサーで サーポトしていない。 + + エラー: ISO Schematron 名前空間に不明な要素がある: 綴り字と大文字使用を確認する + + 注意: 不明な要素 + + diff --git a/src/schematron/iso-schematron/sch-messages-nl.xhtml b/src/schematron/iso-schematron/sch-messages-nl.xhtml new file mode 100644 index 000000000..5f055771c --- /dev/null +++ b/src/schematron/iso-schematron/sch-messages-nl.xhtml @@ -0,0 +1,58 @@ + + + Schema fout: er werden Schematron elementen uit de oude en nieuwe + namespace gevonden + Schema fout: gebruik 'xslt' in het queryBinding attribute + Faling: Deze implementatie van ISO Schematron werkt niet met + schemas die gebruik maken van de query language + + Fase fout: er is geen 'phase' gedefinieerd met naam + + Markup fout: er is geen 'pattern' attribuut in <active> + Referentie fout: het 'pattern' " + " is geactiveerd maar niet gedeclareerd + Markup fout: er is geen 'test' attribuut in <assert + Markup fout: er is geen 'test' attribuut in <report> + Markup fout: er is geen 'id' attribuut in <diagnostic> + Markup fout: er is geen 'rule' attribuut in <extends> + Referentie fout: de abstracte regel " + " werd gerefereerd maar niet gedeclareerd + Markup fout: er is geen 'name' attribuut in <key> + Markup fout: er is geen 'path' of 'use' attribuut in <key> + Markup fout: er is geen 'path' of 'use' attribuut in <key> + Schema fout: Het 'key' element zit niet in de ISO Schematron namespace. Gebruik de XSLT namespace. + Markup fout: er is geen 'name' attribuut in <function> + Schema fout: Het 'function' element zit niet in de ISO Schematron namespace. Gebruik de XSLT namespace. + Schema fout: Leeg 'href=' attribuut bij de include opdracht. + Fout: Onmogelijke URL gebruikt bij de Schematron include + Kan de gerefereerde 'include' file niet openen: + + Schema fout: Gebruik include om fragmenten op te nemen, niet een volledig schema + Schema fout: XSD schemas kunnen enkel geïmporteerd worden indien de 'xslt2' query language binding gebruikt is + Schema fout: Het 'import-schema' element is niet beschikbaar in the ISO Schematron namespace. Gebruik de XSLT namespace. + Waarschuwing: Variabelen niet gebruiken met de "xpath" query language binding. + Waarschuwing: Variabelen niet gebruiken met de "xpath2" query language binding. + Markup fout: er is geen 'uri' attribute in <ns> + Markup fout: er is geen 'prefix' attribute in <ns> + Schema implementatie fout: Dit schema heeft abstracte patronen, die al gepreprocessed zouden moeten zijn + Markup fout: er is geen 'id' attribuut in <phase> + Markup fout: er is geen 'context' attribuut in <rule> + Markup fout: er is geen 'id' attribuut op abstracte <rule> + Markup fout: (2) context attributen op abstracte <rule> + Markup fout: context attribuut op abstracte <rule> + Markup fout: er is geen 'select' attribute in <value-of> + Waarschuwing: + mag geen kind elementen bevatten + Referentie fout: Een diagnostic " + " werd gerefereerd maar is niet gedeclareerd. + Het gebruik van de XSLT namespace met een prefix verschillend + van "xsl" in Schematron regels wordt niet ondersteund in deze processor: + + Fout: een niet herkend element in de ISO Schematron namespace: check spelling en hoofdlettergebruik + + Waarschuwing: een niet herkend element + + diff --git a/src/schematron/iso-schematron/schematron-skeleton-api.htm b/src/schematron/iso-schematron/schematron-skeleton-api.htm new file mode 100644 index 000000000..af8137783 --- /dev/null +++ b/src/schematron/iso-schematron/schematron-skeleton-api.htm @@ -0,0 +1,723 @@ + + + + + The ISO Schematron Skeleton API + + + + + +

API for ISO Schematron Skeleton

+



+

+

Rick Jelliffe, 2010/04/14

+

This document provides documentation on the XSLT API available in +the implementation of Schematron called iso_schematron_skeleton.xsl. +(available in an XSLT1 and XSLT2 version). The API makes available as +much information from the schema, however there may be some edge +cases where it is not exhaustive. +

+

The skeleton is an XSLT script which provides all the basic +parsing and validating routines for compiling a Schematron schema +into XSLT. Schematron was designed to allow many different uses, and +the skeleton gives you a headstart in creating a customized +implementation. You just need to write XSLT templates to override the +default ones. (The program you write is sometimes called a +meta-stylesheet.) It is the meta-stylesheet that is called +as the XSLT script, not the skeleton. There are several +pre-processing stages which the Schematron schema should be processed +through first, to handle such things as include statements and +abstract patterns. +

+

Phases and error reporting for problems in the schema itself are +handled by the skeleton with no interaction with a “meta-stylesheet”. +Note that there is no guarantee that the context node is always the +element being handled: in most cases the only information available +is the information in the parameters. +

+

For an introductory tutorial on using this API, see Bob DuCharme's +Schematron 1.5: +Looking Under the Hood +

+

Superset of API for Schematron 1.5 and 1.6

+

(This is an updated version of the API for the Schematron 1.5 +implementation called skeleton1-5.xsl, which in turn comes +from the new architecture contributed by Oliver Becker for +Schematron 1.3.)

+

The current API contains only additions. Well-written +meta-stylesheets that use the new API will be be able to run on the +existing 1.5 and 1.6 skeletons. Similarly, it should be possible to +upgrade the skeleton from 1.5 or 1.6 to the iso-schematron-skeleton +only by correcting the import statement at the beginning of the +meta-stylsheet. Additions or re-groupings from the 1.5 schema are +shown in red. Deletions have overstrike.

+

Mooted addition: a parameter @action which for specifying +processing instructions on assertions and reports.

+
+

process-prolog

+

The process-prolog template gets called at the start of +the validation session. It has no parameters. The default +implementation is no action.

+
+

process-root

+

The process-root template processes the root element of +the schema (which is not the same thing as the root of the document / +and need not be the document element /*) .

+
+
node-list $contents +
+ string $schemaVersion +
+ The version of the schema, perhaps a datestamp. +
+ "xslt" | "xpath" | + "xslt2" | ... + $queryBinding +
+ The query language binding. +
+ string $title +
+ The title of this schema +
+ "iso" | "1.5" | + "1.6" | ... + $version +
+ The version of Schematron being used. +
+

+Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for the + schema + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this schema. +
+ IETF language + $lang +
+ The human language used in this schema, from + xml:lang +
+ URL + $see +
+ Link to documentation on WWW or file +
+ "preserve" | "default" + $space +
+ The value for xml:space +
+

+To print the documentation paragraphs, use <xsl:apply-templates +mode="do-schema-p" />

+

To output the results, use <xsl:copy-of select="$contents" +/>

+
+

process-assert

+

The process-assert template handles asserts whose test +has failed. +

+
+
XPath $test +
+ The test +
+ XML IDREFS $diagnostics +
+ A list of the idrefs diagnostic elements related to the current + assertion +
+ XML NMTOKEN + $flag +
+ The name of a flag that becomes true because + this assertion fails. The flag is true for the document if it is + flagged true on any assertion. For compatability, this parameter + should not be used with Schematron 1.5. +
+

+Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for the + assert + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this + assertion. +
+ IETF language + $lang +
+ The human language used in this assertion, + from xml:lang +
+ URL + $see +
+ Link to documentation on WWW or file +
+ "preserve" | "default" + $space +
+ The value for xml:space +
+

+Linking properties:

+
+
XML NMTOKEN + $role +
+ A name for the generic role of this assertion. + The schema creator would have their own vocabulary. +
+ XPath + $subject +
+ A path relative to the current context to some + interesting node considered the subject. +
+

+To print the text contents, use <xsl:apply-templates +mode="text" />

+
+

process-diagnostic

+

The process-diagnostic template handles diagnostic +messages for assert statements that have failed and report +statements that have succeeded. The diagnostics are evaluated in the +context of the rule.

+

Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for the + assert + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this + assertion. +
+ IETF language + $lang +
+ The human language used in this assertion, + from xml:lang +
+ URL + $see +
+ Link to documentation on WWW or file +
+ "preserve" | "default" + $space +
+ The value for xml:space +

+
+

process-dir

+

The process-dir template handles bi-directionality +markup, which is only needed by certain human scripts such as Arabic.

+
+
"ltr" or "rtl" or "" + $value +
+ Left-to-right or right-to-left or unspecified +

+
+

process-emph

+

The process-emph template handles the markup of +emphasized text in paragraphs, assertions and diagnostics. It has no +parameters.

+
+

process-message

+

The process-message handles default outputing of text.

+
+
string $pattern +
+ Some text that may be some kind of pattern +
+ string $role +
+ Some text that may be some kind of role +

+
+

process-name

+

The process-name templates handle name strings that can +be used in assertions. asssert and report only +provide name subelements rather than the more general +value-of elements to encourage plain language and generic +descriptions rather than specific diagnostics, for which purpose the +diagnostics elements are used.

+
+
string $name +
+ The name of the current element, or of the node specified by a name + element +

+
+

process-ns

+

The process-ns template reports on ns +declarations, which are used to transmit on namespace information by +the skeleton.

+
+
Namespace NCName $prefix +
+ The prefix of a namespace +
+ XML SystemId $uri +
+ The (internationalized) URI Reference of a namespace +

+
+

process-p

+

The process-p template handles paragraphs.

+
+
XML NMTOKEN $class +
+ An attribute that can be used for stylesheet style +
+ XML ID $id +
+ The unique identifier with the schema for the p element. +
+ XML SystemId $icon +
+ The URI of an icon +
+ IETF Language $lang +
+ The human language used in this paragraph +
+

+To print the text contents, use <xsl:apply-templates +mode="text" /> +

+
+

process-pattern

+

The process-pattern reports on the start of evaluation of +a pattern element.

+
+
string $name +
+ The title of the current pattern +
+ XML NCNAMES $is-a +
+ Empty or not provided if the pattern is not derived from an abstract + pattern. Otherwise the name of the abstract pattern. A list may be + used if there was a sequence of abstract patterns. +
+

+Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for the + pattern + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this pattern. + +
+ IETF language + $lang +
+ The human language used in this pattern, from + xml:lang +
+ URL + $see +
+ A (internationalized) URI reference to some + supporting or defining documentation +
+ "preserve" | "default" + $space +
+ The value for xml:space +
+

+To print the documentation contents, use <xsl:apply-templates +mode="do-pattern-p"/>

+
+

process-report

+

The process-report template handles report whose +test has succeeded. +

+
+
XPath $test +
+ The test +
+ XML IDREFS $diagnostics +
+ A list of the diagnostic elements related to the current assertion +
+ XML NMTOKEN + $flag +
+ The name of a flag that becomes true because + this assertion fails. The flag is true for the document if it is + flagged true on any assertion. For compatability, this parameter + should not be used with Schematron 1.5. +
+

+Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for the + report + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this report. +
+ IETF language + $lang +
+ The human language used in this report, from + xml:lang +
+ URL + $see +
+ Link to documentation on WWW or file +
+ "preserve" | "default" + $space +
+ The value for xml:space +
+

+Linking properties:

+
+
XML NMTOKEN + $role +
+ A name for the generic role of this assertion. + The schema creator would have their own vocabulary. +
+ XPath + $subject +
+ A path relative to the current context to some + interesting node considered the subject. +
+

+To print the text contents, use <xsl:apply-templates +mode="text" />

+
+

process-rule

+

The process-rule reports that a rule element has +fired: its context attribute matched some nodes. .

+
+
XSLT expression $context +
+ The expression that gives the context of the current +
+

+Rich properties:

+
+
XML SystemId + $icon +
+ The URI of an icon +
+ XML ID + $id +
+ The unique identifier with the schema for this + rule + element. +
+ SGML FPI + $fpi +
+ The Formal Public Identifier for this rule. +
+ IETF language + $lang +
+ The human language used in this rule, from + xml:lang +
+ URL + $see +
+ Link to documentation on WWW or file +
+ "preserve" | "default" + $space +
+ The value for xml:space +
+

+Linking properties:

+
+
XML NMTOKEN + $role +
+ A name for the generic role of this assertion. + The schema creator would have their own vocabulary. +
+ XPath + $subject +
+ A path relative to the current context to some + interesting node considered the subject. +

+
+

process-span

+

The process-span handles span elements, which are generic +elements for styling, like HTML's .

+
+
XML NMTOKEN $class +
+ An attribute that can be used for stylesheet style +

+
+

process-title

+

The process-title handles title elements, which are +generic elements for styling, like HTML's .

+
+
XML NMTOKEN $class +
+ An attribute that can be used for stylesheet style +
+

+By default, titles are handled by invocing process-p with +the parameter class with a value "title".

+
+

process-value-of

+

The process-value-of template handles value-of +elements, which are used in diagnostic messages to allow very +specific hinting .

+
+
XPath $select +
+ The path of some node that will be evaluated and printed.

+
+

Global Parameters

+

There are several global parameters that may be available for use. +However, it is not a requirement to follow these, and implementations +may not supply them with any value. So a test of +string-length(variable) < +0 is appropriate in each case.

+



+

+
passed/pending/failed/total - - - - + passed: pending: failed: total: 
- - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Parameter

+
+

Value

+
+

Description

+
+

allow-foreign

+
+

"true" | "false" (default) +

+
+

Pass non-Schematron elements to the generated + stylesheet. Pass the Schematron elements span, emph and dir: to + the output SVRL. +

+
+

fileNameParameter

+
+

string

+
+

A parameter passed to the Validator and + potentially available as a variable in Schematron schemas as + $fileNameParameter

+
+

fileDirParameter

+
+

string

+
+

A parameter passed to the Validator and + potentially available as a variable in Schematron schemas as + $fileDirParameter

+
+

archiveNamePaameter

+
+

string

+
+

A parameter passed to the Validator and + potentially available as a variable in Schematron schemas as + $archiveNameParameter

+
+

archiveDirParameter

+
+

string

+
+

A parameter passed to the Validator and + potentially available as a variable in Schematron schemas as + $archivePathParameter

+
+

debug +

+
+

true” | “false” (default)

+
+

Verbose error messages (Note this may be + superceded by “verbose” at some stage in the future.)

+
+

generate-paths

+
+

true|false +

+
+

generate the SVRL @location attribute with XPaths

+
+

diagnose

+
+

yes | no +

+
+

Add the diagnostics to the assertion results

+
+

terminate

+
+

yes | no | true | false | assert +

+
+

Terminate on the first failed assertion or + successful report

+
+

message-newline +

+
+

"true" (default) | "false" +

+
+

Generate an extra newline at the end of messages

+
+

output-encoding

+
+

string

+
+

The encoding used for output, for example if the + output is XML

+
+
+
+
+ + \ No newline at end of file diff --git a/src/schematron/sch-location-compare.xsl b/src/schematron/sch-location-compare.xsl new file mode 100644 index 000000000..7715ce76e --- /dev/null +++ b/src/schematron/sch-location-compare.xsl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/schematron/schut-to-xspec.xsl b/src/schematron/schut-to-xspec.xsl new file mode 100644 index 000000000..7f198a6b1 --- /dev/null +++ b/src/schematron/schut-to-xspec.xsl @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BEGIN IMPORT "" + + END IMPORT "" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Makefile b/test/Makefile index c08db7c28..865bcf375 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,6 @@ # ========================================================================== # # File: test/Makefile # # Author: Jeni Tennsion # -# URI: http://xspec.googlecode.com/ # # Tags: # # Copyright (c) 2010 Jeni Tennsion (see end of file.) # # -------------------------------------------------------------------------- # diff --git a/test/catalog/xspec-160_catalog.xml b/test/catalog/xspec-160_catalog.xml new file mode 100644 index 000000000..07302b5ee --- /dev/null +++ b/test/catalog/xspec-160_catalog.xml @@ -0,0 +1,4 @@ + + + + diff --git a/test/catalog/xspec-160_schematron.xspec b/test/catalog/xspec-160_schematron.xspec new file mode 100644 index 000000000..f2ca12c6e --- /dev/null +++ b/test/catalog/xspec-160_schematron.xspec @@ -0,0 +1,6 @@ + + + + + diff --git a/test/catalog/xspec-160_xslt.xspec b/test/catalog/xspec-160_xslt.xspec new file mode 100644 index 000000000..1a1310120 --- /dev/null +++ b/test/catalog/xspec-160_xslt.xspec @@ -0,0 +1,5 @@ + + + + diff --git a/test/end-to-end/README.md b/test/end-to-end/README.md new file mode 100644 index 000000000..1c45babcf --- /dev/null +++ b/test/end-to-end/README.md @@ -0,0 +1,42 @@ +This procedure is a primitive end-to-end testing for XSpec itself. + +The primary goal is to verify that XSpec is generating the report HTML files as expected. The test should be done as simply as possible and without using XSpec itself. + +## Preparing the expected HTML files + +First you need to set up the expected HTML files. This is a manual operation which you have to perform only once. + +1. Put `*.xspec` files into the `cases` directory. + +1. Run `./generate-expected.sh` (or `.cmd`). + + The script executes the `cases/*.xspec` files. + + In the `cases/expected` directory, two kinds of the report HTML files are generated: + + * Original ones: `*-result.html` + * Normalized ones: `*-result-norm.html` + +1. Verify that the original ones (`*-result.html`) contain the scenario results as expected. + +1. Compare the normalized ones (`*-result-norm.html`) with the original ones (`*-result.html`). + + Verify that they are essentially identical. Only the transient parts (`href`, `id`, datetime and file path) should be different. + +1. Commit the normalized ones (`*-result-norm.html`) to the repository. (You can discard the other sibling files.) + + They are called the expected HTML files hereafter. + +## Running the regular tests + +Once the expected HTML files are prepared, you can run tests regularly by executing `./run-e2e-tests.sh` (or `.cmd`). + +The script performs these tasks in sequence: + +1. Executes the `cases/*.xspec` files. + + The report HTML files are generated: `cases/xspec/*-result.html` + +1. Loads the report HTML files, normalizes them on memory, and compares them with the expected HTML files (`cases/expected/*-result-norm.html`). + + If they are different, the test is considered as failure. diff --git a/test/end-to-end/cases/.gitignore b/test/end-to-end/cases/.gitignore new file mode 100644 index 000000000..470876dfe --- /dev/null +++ b/test/end-to-end/cases/.gitignore @@ -0,0 +1 @@ +/xspec/ diff --git a/test/end-to-end/cases/expected/.gitignore b/test/end-to-end/cases/expected/.gitignore new file mode 100644 index 000000000..51a7e8c61 --- /dev/null +++ b/test/end-to-end/cases/expected/.gitignore @@ -0,0 +1,4 @@ +/*-result.html +/*.xml +/*.xsl +/*.xq diff --git a/test/end-to-end/cases/expected/schematron-01-result-norm.html b/test/end-to-end/cases/expected/schematron-01-result-norm.html new file mode 100644 index 000000000..9a1cbbb13 --- /dev/null +++ b/test/end-to-end/cases/expected/schematron-01-result-norm.html @@ -0,0 +1,72 @@ + + + + Test Report for schematron-01.sch (passed: 3 / pending: 0 / failed: 0 / total: 3) + + + +

Test Report

+

Schematron: schematron-01.sch

+

XSpec: schematron-01.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + +
passed: 3pending: 0failed: 0total: 3
schematron-013003
+
+

schematron-01passed: 3 / pending: 0 / failed: 0 / total: 3

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
schematron-01passed: 3 / pending: 0 / failed: 0 / total: 3
article should have a titlepassed: 1 / pending: 0 / failed: 0 / total: 1
not assert a001Success
section should have a titlepassed: 2 / pending: 0 / failed: 0 / total: 2
assert a002 /article[1]/section[2]Success
assert a002 /article[1]/section[3]Success
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xquery-tutorial-result-norm.html b/test/end-to-end/cases/expected/xquery-tutorial-result-norm.html new file mode 100644 index 000000000..7246f3301 --- /dev/null +++ b/test/end-to-end/cases/expected/xquery-tutorial-result-norm.html @@ -0,0 +1,56 @@ + + + + Test Report for www.functx.com (passed: 1 / pending: 0 / failed: 0 / total: 1) + + + +

Test Report

+

Query: www.functx.com

+

XSpec: xquery-tutorial.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + +
passed: 1pending: 0failed: 0total: 1
Calling function capitalize-first1001
+
+

Calling function capitalize-firstpassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
Calling function capitalize-firstpassed: 1 / pending: 0 / failed: 0 / total: 1
should capitalize the first character of the stringSuccess
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-50-result-norm.html b/test/end-to-end/cases/expected/xspec-50-result-norm.html new file mode 100644 index 000000000..588e2cc3a --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-50-result-norm.html @@ -0,0 +1,75 @@ + + + + Test Report for xspec-50.xsl (passed: 0 / pending: 0 / failed: 1 / total: 1) + + + +

Test Report

+

Stylesheet: xspec-50.xsl

+

XSpec: xspec-50.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + +
passed: 0pending: 0failed: 1total: 1
Expecting xs:hexBinary('0123') when $x:result is xs:untypedAtomic('0123')0011
+
+

Expecting xs:hexBinary('0123') when $x:result is xs:untypedAtomic('0123')passed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
Expecting xs:hexBinary('0123') when $x:result is xs:untypedAtomic('0123')passed: 0 / pending: 0 / failed: 1 / total: 1
must generate a failure report HTML which reads [Result] = "xs:untypedAtomic('0123')" + and [Expected Result] = "xs:hexBinary('0123')"Failure
+

Expecting xs:hexBinary('0123') when $x:result is xs:untypedAtomic('0123')

+

must generate a failure report HTML which reads [Result] = "xs:untypedAtomic('0123')" + and [Expected Result] = "xs:hexBinary('0123')" +

+ + + + + + + + + + + + + +
ResultExpected Result
xs:untypedAtomic('0123')
xs:hexBinary('0123')
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-55-result-norm.html b/test/end-to-end/cases/expected/xspec-55-result-norm.html new file mode 100644 index 000000000..2ce5a30b4 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-55-result-norm.html @@ -0,0 +1,113 @@ + + + + Test Report for xspec-55.xsl (passed: 0 / pending: 0 / failed: 3 / total: 3) + + + +

Test Report

+

Stylesheet: xspec-55.xsl

+

XSpec: xspec-55.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + +
passed: 0pending: 0failed: 3total: 3
In a failure report HTML0033
+
+

In a failure report HTMLpassed: 0 / pending: 0 / failed: 3 / total: 3

+ + + + + + + + + + + + + + + + + + + + + +
In a failure report HTMLpassed: 0 / pending: 0 / failed: 3 / total: 3
[Expected Result] must represent xs:decimal(1) by "1.0" (numeric literal of decimal)Failure
[Expected Result] must represent xs:double(1) by "xs:double('1')" (constructor of + double)Failure
[Expected Result] must represent xs:integer(1) by "1" (numeric literal of integer)Failure
+

In a failure report HTML

+

[Expected Result] must represent xs:decimal(1) by "1.0" (numeric literal of decimal)

+ + + + + + + + + + + + + +
ResultExpected Result
()
1.0
+

[Expected Result] must represent xs:double(1) by "xs:double('1')" (constructor of + double) +

+ + + + + + + + + + + + + +
ResultExpected Result
()
xs:double('1')
+

[Expected Result] must represent xs:integer(1) by "1" (numeric literal of integer)

+ + + + + + + + + + + + + +
ResultExpected Result
()
1
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-focus-1-result-norm.html b/test/end-to-end/cases/expected/xspec-focus-1-result-norm.html new file mode 100644 index 000000000..d60c60882 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-focus-1-result-norm.html @@ -0,0 +1,110 @@ + + + + Test Report for xspec-tested.xsl (passed: 1 / pending: 2 / failed: 1 / total: 4) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-focus-1.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 1pending: 2failed: 1total: 4
(testing @focus) an unfocused correct scenario must be Pending0101
(testing @focus) an unfocused incorrect scenario must be Pending0101
a focused correct scenario1001
a focused incorrect scenario0011
+
+

a focused correct scenariopassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
a focused correct scenariopassed: 1 / pending: 0 / failed: 0 / total: 1
must execute the test and return SuccessSuccess
+
+
+

a focused incorrect scenariopassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
a focused incorrect scenariopassed: 0 / pending: 0 / failed: 1 / total: 1
must execute the test and return FailureFailure
+

a focused incorrect scenario

+

must execute the test and return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-function-result-norm.html b/test/end-to-end/cases/expected/xspec-function-result-norm.html new file mode 100644 index 000000000..70560f547 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-function-result-norm.html @@ -0,0 +1,119 @@ + + + + Test Report for xspec-tested.xsl (passed: 2 / pending: 0 / failed: 2 / total: 4) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-function.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 2pending: 0failed: 2total: 4
when calling a function and expecting correctly2002
when calling a function and expecting incorrectly0022
+
+

when calling a function and expecting correctlypassed: 2 / pending: 0 / failed: 0 / total: 2

+ + + + + + + + + + + + + + + + + +
when calling a function and expecting correctlypassed: 2 / pending: 0 / failed: 0 / total: 2
expecting the correct value must return SuccessSuccess
expecting the correct type must return SuccessSuccess
+
+
+

when calling a function and expecting incorrectlypassed: 0 / pending: 0 / failed: 2 / total: 2

+ + + + + + + + + + + + + + + + + +
when calling a function and expecting incorrectlypassed: 0 / pending: 0 / failed: 2 / total: 2
expecting an incorrect value must return FailureFailure
expecting an incorrect type must return FailureFailure
+

when calling a function and expecting incorrectly

+

expecting an incorrect value must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+

expecting an incorrect type must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-import-result-norm.html b/test/end-to-end/cases/expected/xspec-import-result-norm.html new file mode 100644 index 000000000..798b3269a --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-import-result-norm.html @@ -0,0 +1,164 @@ + + + + Test Report for xspec-tested.xsl (passed: 3 / pending: 0 / failed: 2 / total: 5) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-import.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 3pending: 0failed: 2total: 5
when testing a correct scenario in an importing file2002
when testing an incorrect scenario in an importing file0011
a correct scenario in an imported file1001
an incorrect scenario in an imported file0011
+
+

when testing a correct scenario in an importing filepassed: 2 / pending: 0 / failed: 0 / total: 2

+ + + + + + + + + + + + + + + + + +
when testing a correct scenario in an importing filepassed: 2 / pending: 0 / failed: 0 / total: 2
expecting the correct result must return SuccessSuccess
expecting the correct type must return SuccessSuccess
+
+
+

when testing an incorrect scenario in an importing filepassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
when testing an incorrect scenario in an importing filepassed: 0 / pending: 0 / failed: 1 / total: 1
it must return FailureFailure
+

when testing an incorrect scenario in an importing file

+

it must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+
+

a correct scenario in an imported filepassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
a correct scenario in an imported filepassed: 1 / pending: 0 / failed: 0 / total: 1
must return SuccessSuccess
+
+
+

an incorrect scenario in an imported filepassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
an incorrect scenario in an imported filepassed: 0 / pending: 0 / failed: 1 / total: 1
must return FailureFailure
+

an incorrect scenario in an imported file

+

must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-imported-result-norm.html b/test/end-to-end/cases/expected/xspec-imported-result-norm.html new file mode 100644 index 000000000..69b0db4cc --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-imported-result-norm.html @@ -0,0 +1,96 @@ + + + + Test Report for xspec-tested.xsl (passed: 1 / pending: 0 / failed: 1 / total: 2) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-imported.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 1pending: 0failed: 1total: 2
a correct scenario in an imported file1001
an incorrect scenario in an imported file0011
+
+

a correct scenario in an imported filepassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
a correct scenario in an imported filepassed: 1 / pending: 0 / failed: 0 / total: 1
must return SuccessSuccess
+
+
+

an incorrect scenario in an imported filepassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
an incorrect scenario in an imported filepassed: 0 / pending: 0 / failed: 1 / total: 1
must return FailureFailure
+

an incorrect scenario in an imported file

+

must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-pending-result-norm.html b/test/end-to-end/cases/expected/xspec-pending-result-norm.html new file mode 100644 index 000000000..328c07d71 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-pending-result-norm.html @@ -0,0 +1,124 @@ + + + + Test Report for xspec-tested.xsl (passed: 1 / pending: 4 / failed: 1 / total: 6) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-pending.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 1pending: 4failed: 1total: 6
(testing x:pending) a correct scenario in x:pending must be Pending0101
(testing x:pending) an incorrect scenario in x:pending must be Pending0101
a non-pending correct scenario alongside a pending scenario1001
a non-pending incorrect scenario alongside a pending scenario0011
(testing @pending) a correct scenario with @pending must be Pending0101
(testing @pending) an incorrect scenario with @pending must be Pending0101
+
+

a non-pending correct scenario alongside a pending scenariopassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
a non-pending correct scenario alongside a pending scenariopassed: 1 / pending: 0 / failed: 0 / total: 1
must execute the test and return SuccessSuccess
+
+
+

a non-pending incorrect scenario alongside a pending scenariopassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
a non-pending incorrect scenario alongside a pending scenariopassed: 0 / pending: 0 / failed: 1 / total: 1
must execute the test and return FailureFailure
+

a non-pending incorrect scenario alongside a pending scenario

+

must execute the test and return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
4
()
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-rule-result-norm.html b/test/end-to-end/cases/expected/xspec-rule-result-norm.html new file mode 100644 index 000000000..6256a5b13 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-rule-result-norm.html @@ -0,0 +1,110 @@ + + + + Test Report for xspec-tested.xsl (passed: 1 / pending: 2 / failed: 1 / total: 4) + + + +

Test Report

+

Stylesheet: xspec-tested.xsl

+

XSpec: xspec-rule.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 1pending: 2failed: 1total: 4
x:context with correct x:expect1001
x:context with incorrect x:expect0011
(not implemented yet) x:apply with correct x:expect0101
(not implemented yet) x:apply with incorrect x:expect0101
+
+

x:context with correct x:expectpassed: 1 / pending: 0 / failed: 0 / total: 1

+ + + + + + + + + + + + + +
x:context with correct x:expectpassed: 1 / pending: 0 / failed: 0 / total: 1
must return SuccessSuccess
+
+
+

x:context with incorrect x:expectpassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
x:context with incorrect x:expectpassed: 0 / pending: 0 / failed: 1 / total: 1
must return FailureFailure
+

x:context with incorrect x:expect

+

must return Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<transformed xmlns:my="http://example.org/ns/my" />
<erroneous />
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/expected/xspec-three-dots-result-norm.html b/test/end-to-end/cases/expected/xspec-three-dots-result-norm.html new file mode 100644 index 000000000..efecd8bf2 --- /dev/null +++ b/test/end-to-end/cases/expected/xspec-three-dots-result-norm.html @@ -0,0 +1,1238 @@ + + + + Test Report for xspec-three-dots.xsl (passed: 42 / pending: 0 / failed: 30 / total: + 72) + + + + +

Test Report

+

Stylesheet: xspec-three-dots.xsl

+

XSpec: xspec-three-dots.xspec

+

Tested: ONCE-UPON-A-TIME

+

Contents

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
passed: 42pending: 0failed: 30total: 72
For resultant element (simple)5027
For resultant element (with attribute)2013
For resultant element (with mixed content)4015
For resultant attribute5016
For resultant text node4059
For resultant comment5016
For resultant processing instruction5016
For resultant document node5027
For resultant namespace node (TODO: xspec/xspec#67)3047
For resultant sequence of multiple nodes2035
When result is empty sequence0011
For resultant atomic value2046
For any resultant item0044
+
+

For resultant element (simple)passed: 5 / pending: 0 / failed: 2 / total: 7

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant element (simple)passed: 5 / pending: 0 / failed: 2 / total: 7
When result is <elem>text</elem> passed: 2 / pending: 0 / failed: 0 / total: 2
expecting <elem>...</elem> should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is <elem /> passed: 1 / pending: 0 / failed: 1 / total: 2
expecting <elem>...</elem> should be SuccessSuccess
expecting <elem attrib="..." /> should be FailureFailure
When result is <elem>...</elem> passed: 2 / pending: 0 / failed: 1 / total: 3
expecting <elem>...</elem> should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting <elem>text</elem> should be FailureFailure
+

For resultant element (simple) When result is <elem />

+

expecting <elem attrib="..." /> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem />
<elem attrib="..." />
+

For resultant element (simple) When result is <elem>...</elem>

+

expecting <elem>text</elem> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem>...</elem>
<elem>text</elem>
+
+
+

For resultant element (with attribute)passed: 2 / pending: 0 / failed: 1 / total: 3

+ + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant element (with attribute)passed: 2 / pending: 0 / failed: 1 / total: 3
When result is <elem attrib="val" /> passed: 2 / pending: 0 / failed: 1 / total: 3
expecting <elem attrib="..." /> should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting <elem>...</elem> should be FailureFailure
+

For resultant element (with attribute) When result is <elem attrib="val" />

+

expecting <elem>...</elem> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem attrib="val" />
<elem>...</elem>
+
+
+

For resultant element (with mixed content)passed: 4 / pending: 0 / failed: 1 / total: 5

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant element (with mixed content)passed: 4 / pending: 0 / failed: 1 / total: 5
When result is <outer>text<inner1 /><inner2 /></outer> passed: 3 / pending: 0 / failed: 0 / total: 3
expecting <outer>...</outer> should be SuccessSuccess
expecting <outer>...<inner1 />...</outer> should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is <outer><inner /></outer> passed: 1 / pending: 0 / failed: 1 / total: 2
expecting <outer>...</outer> should be SuccessSuccess
expecting <outer>...<inner /></outer> should be FailureFailure
+

For resultant element (with mixed content) When result is <outer><inner /></outer> + +

+

expecting <outer>...<inner /></outer> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<outer>
+   <inner />
+</outer>
<outer>...<inner />
+</outer>
+
+
+

For resultant attributepassed: 5 / pending: 0 / failed: 1 / total: 6

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant attributepassed: 5 / pending: 0 / failed: 1 / total: 6
When result is @attrib="val" passed: 2 / pending: 0 / failed: 0 / total: 2
expecting @attrib="..." should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is @attrib="" passed: 1 / pending: 0 / failed: 0 / total: 1
expecting @attrib="..." should be SuccessSuccess
When result is @attrib="..." passed: 2 / pending: 0 / failed: 1 / total: 3
expecting @attrib="..." should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting @attrib="val" should be FailureFailure
+

For resultant attribute When result is @attrib="..."

+

expecting @attrib="val" should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /*/(@* | node()) from: +

<temp attrib="..." />
+

XPath /*/(@* | node()) from: +

<temp attrib="val" />
+
+
+

For resultant text nodepassed: 4 / pending: 0 / failed: 5 / total: 9

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant text nodepassed: 4 / pending: 0 / failed: 5 / total: 9
When result is usual text nodepassed: 1 / pending: 0 / failed: 1 / total: 2
expecting ... should be SuccessSuccess
expecting '...' should be FailureFailure
When result is whitespace-only text nodepassed: 1 / pending: 0 / failed: 1 / total: 2
expecting ... should be SuccessSuccess
expecting usual text node should be FailureFailure
When result is zero-length text nodepassed: 1 / pending: 0 / failed: 1 / total: 2
expecting ... should be SuccessSuccess
expecting usual text node should be FailureFailure
When result is three-dot text nodepassed: 1 / pending: 0 / failed: 2 / total: 3
expecting ... should be SuccessSuccess
expecting usual text node should be FailureFailure
expecting '...' should be FailureFailure
+

For resultant text node When result is usual text node

+

expecting '...' should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

text
'...'
+

For resultant text node When result is whitespace-only text node

+

expecting usual text node should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

\t\n\r.
+

XPath /node() from: +

text
+

For resultant text node When result is zero-length text node

+

expecting usual text node should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

+

XPath /node() from: +

text
+

For resultant text node When result is three-dot text node

+

expecting usual text node should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

...
+

XPath /node() from: +

text
+

expecting '...' should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

...
'...'
+
+
+

For resultant commentpassed: 5 / pending: 0 / failed: 1 / total: 6

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant commentpassed: 5 / pending: 0 / failed: 1 / total: 6
When result is <!--comment--> passed: 2 / pending: 0 / failed: 0 / total: 2
expecting <!--...--> should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is <!----> passed: 1 / pending: 0 / failed: 0 / total: 1
expecting <!--...--> should be SuccessSuccess
When result is <!--...--> passed: 2 / pending: 0 / failed: 1 / total: 3
expecting <!--...--> should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting <!--comment--> should be FailureFailure
+

For resultant comment When result is <!--...-->

+

expecting <!--comment--> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

<--...-->
+

XPath /node() from: +

<--comment-->
+
+
+

For resultant processing instructionpassed: 5 / pending: 0 / failed: 1 / total: 6

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant processing instructionpassed: 5 / pending: 0 / failed: 1 / total: 6
When result is <?pi data?> passed: 2 / pending: 0 / failed: 0 / total: 2
expecting <?pi ...?> should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is <?pi?> passed: 1 / pending: 0 / failed: 0 / total: 1
expecting <?pi ...?> should be SuccessSuccess
When result is <?pi ...?> passed: 2 / pending: 0 / failed: 1 / total: 3
expecting <?pi ...?> should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting <?pi data?> should be FailureFailure
+

For resultant processing instruction When result is <?pi ...?>

+

expecting <?pi data?> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

<?pi ...?>
+

XPath /node() from: +

<?pi data?>
+
+
+

For resultant document nodepassed: 5 / pending: 0 / failed: 2 / total: 7

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant document nodepassed: 5 / pending: 0 / failed: 2 / total: 7
When result is <xsl:document><?pi?><!--comment--><elem /></xsl:document> passed: 2 / pending: 0 / failed: 0 / total: 2
expecting <xsl:document>...</xsl:document> should be SuccessSuccess
expecting ... should be SuccessSuccess
When result is <xsl:document /> passed: 1 / pending: 0 / failed: 1 / total: 2
expecting ... should be SuccessSuccess
expecting <xsl:document>...</xsl:document> should be FailureFailure
When result is <xsl:document>...</xsl:document> passed: 2 / pending: 0 / failed: 1 / total: 3
expecting <xsl:document>...</xsl:document> should be SuccessSuccess
expecting ... should be SuccessSuccess
expecting <xsl:document>text</xsl:document> should be FailureFailure
+

For resultant document node When result is <xsl:document />

+

expecting <xsl:document>...</xsl:document> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
/
+

XPath / from: +

...
+

For resultant document node When result is <xsl:document>...</xsl:document>

+

expecting <xsl:document>text</xsl:document> should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath / from: +

...
+

XPath / from: +

text
+
+
+

For resultant namespace node (TODO: xspec/xspec#67)passed: 3 / pending: 0 / failed: 4 / total: 7

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant namespace node (TODO: xspec/xspec#67)passed: 3 / pending: 0 / failed: 4 / total: 7
When result is xmlns:prefix="namespace-uri" passed: 1 / pending: 0 / failed: 1 / total: 2
expecting xmlns:prefix="..." should be SuccessFailure
expecting ... should be SuccessSuccess
When result is xmlns="namespace-uri" passed: 1 / pending: 0 / failed: 1 / total: 2
expecting xmlns="..." should be SuccessFailure
expecting ... should be SuccessSuccess
When result is xmlns:prefix="..." passed: 1 / pending: 0 / failed: 2 / total: 3
expecting xmlns:prefix="..." should be SuccessFailure
expecting ... should be SuccessSuccess
expecting xmlns:prefix="namespace-uri" should be FailureFailure
+

For resultant namespace node (TODO: xspec/xspec#67) When result is xmlns:prefix="namespace-uri" + +

+

expecting xmlns:prefix="..." should be Success

+ + + + + + + + + + + + + +
ResultExpected Result
/node()
/node()
+

For resultant namespace node (TODO: xspec/xspec#67) When result is xmlns="namespace-uri" + +

+

expecting xmlns="..." should be Success

+ + + + + + + + + + + + + +
ResultExpected Result
/node()
/node()
+

For resultant namespace node (TODO: xspec/xspec#67) When result is xmlns:prefix="..." + +

+

expecting xmlns:prefix="..." should be Success

+ + + + + + + + + + + + + +
ResultExpected Result
/node()
/node()
+

expecting xmlns:prefix="namespace-uri" should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
/node()
/node()
+
+
+

For resultant sequence of multiple nodespassed: 2 / pending: 0 / failed: 3 / total: 5

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant sequence of multiple nodespassed: 2 / pending: 0 / failed: 3 / total: 5
When result is sequence of <elem1 /><elem2 /> passed: 2 / pending: 0 / failed: 3 / total: 5
expecting ...<elem2 /> should be SuccessSuccess
expecting sequence of two ... should be SuccessSuccess
expecting ... should be FailureFailure
expecting ...... should be FailureFailure
expecting sequence of three ... should be FailureFailure
+

For resultant sequence of multiple nodes When result is sequence of <elem1 /><elem2 + /> +

+

expecting ... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem1 /><elem2 />
+

XPath /node() from: +

...
+

expecting ...... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem1 /><elem2 />
+

XPath /node() from: +

......
+

expecting sequence of three ... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
<elem1 /><elem2 />
+

XPath /node() from: +

.........
+
+
+

When result is empty sequencepassed: 0 / pending: 0 / failed: 1 / total: 1

+ + + + + + + + + + + + + +
When result is empty sequencepassed: 0 / pending: 0 / failed: 1 / total: 1
expecting ... should be FailureFailure
+

When result is empty sequence

+

expecting ... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
()
+

XPath /node() from: +

...
+
+
+

For resultant atomic valuepassed: 2 / pending: 0 / failed: 4 / total: 6

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
For resultant atomic valuepassed: 2 / pending: 0 / failed: 4 / total: 6
When result is 'string'passed: 1 / pending: 0 / failed: 2 / total: 3
expecting 'string' should be SuccessSuccess
expecting ... should be FailureFailure
expecting '...' should be FailureFailure
When result is '...'passed: 1 / pending: 0 / failed: 2 / total: 3
expecting '...' should be SuccessSuccess
expecting ... should be FailureFailure
expecting 'string' should be FailureFailure
+

For resultant atomic value When result is 'string'

+

expecting ... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
'string'
+

XPath /node() from: +

...
+

expecting '...' should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
'string'
'...'
+

For resultant atomic value When result is '...'

+

expecting ... should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
'...'
+

XPath /node() from: +

...
+

expecting 'string' should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
'...'
'string'
+
+
+

For any resultant itempassed: 0 / pending: 0 / failed: 4 / total: 4

+ + + + + + + + + + + + + + + + + + + + + + + + + +
For any resultant itempassed: 0 / pending: 0 / failed: 4 / total: 4
expecting .... (four dots) should be FailureFailure
expecting ...x (three dots with extra character) should be FailureFailure
expecting ... with surrounding whitespace should be FailureFailure
expecting '...' (xs:string) should be FailureFailure
+

For any resultant item

+

expecting .... (four dots) should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

item
+

XPath /node() from: +

....
+

expecting ...x (three dots with extra character) should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

item
+

XPath /node() from: +

...x
+

expecting ... with surrounding whitespace should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

item
+

XPath /node() from: +

 ...
+

expecting '...' (xs:string) should be Failure

+ + + + + + + + + + + + + +
ResultExpected Result
+

XPath /node() from: +

item
'...'
+
+ + \ No newline at end of file diff --git a/test/end-to-end/cases/schematron-01.sch b/test/end-to-end/cases/schematron-01.sch new file mode 100644 index 000000000..77d8befa4 --- /dev/null +++ b/test/end-to-end/cases/schematron-01.sch @@ -0,0 +1,17 @@ + + + + + + + article should have a title + + + + + section should have a title + + + + + \ No newline at end of file diff --git a/test/end-to-end/cases/schematron-01.xml b/test/end-to-end/cases/schematron-01.xml new file mode 100644 index 000000000..2147a8641 --- /dev/null +++ b/test/end-to-end/cases/schematron-01.xml @@ -0,0 +1,14 @@ + +
+ Example +
+ Introduction +

Welcome to demo 3!

+
+
+

This is an example.

+
+
+

Scenario excpect's can specify a location in the context XML that an assert or report is expected to identify.

+
+
diff --git a/test/end-to-end/cases/schematron-01.xspec b/test/end-to-end/cases/schematron-01.xspec new file mode 100644 index 000000000..d8683fc61 --- /dev/null +++ b/test/end-to-end/cases/schematron-01.xspec @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/end-to-end/cases/xquery-tutorial.xq b/test/end-to-end/cases/xquery-tutorial.xq new file mode 100644 index 000000000..cbfae4918 --- /dev/null +++ b/test/end-to-end/cases/xquery-tutorial.xq @@ -0,0 +1,8 @@ +module namespace functx = "http://www.functx.com"; + +declare function functx:capitalize-first +($arg as xs:string?) as xs:string? { + + concat(upper-case(substring($arg, 1, 1)), + substring($arg, 2)) +}; \ No newline at end of file diff --git a/test/end-to-end/cases/xquery-tutorial.xspec b/test/end-to-end/cases/xquery-tutorial.xspec new file mode 100644 index 000000000..5d25a4fb7 --- /dev/null +++ b/test/end-to-end/cases/xquery-tutorial.xspec @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/end-to-end/cases/xspec-50.xsl b/test/end-to-end/cases/xspec-50.xsl new file mode 100644 index 000000000..ca32b7683 --- /dev/null +++ b/test/end-to-end/cases/xspec-50.xsl @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/test/end-to-end/cases/xspec-50.xspec b/test/end-to-end/cases/xspec-50.xspec new file mode 100644 index 000000000..ecbc8a419 --- /dev/null +++ b/test/end-to-end/cases/xspec-50.xspec @@ -0,0 +1,10 @@ + + + + 0123 + + must generate a failure report HTML which reads [Result] = + "xs:untypedAtomic('0123')" and [Expected Result] = "xs:hexBinary('0123')" + + + \ No newline at end of file diff --git a/test/end-to-end/cases/xspec-55.xsl b/test/end-to-end/cases/xspec-55.xsl new file mode 100644 index 000000000..c5f5a30df --- /dev/null +++ b/test/end-to-end/cases/xspec-55.xsl @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/test/end-to-end/cases/xspec-55.xspec b/test/end-to-end/cases/xspec-55.xspec new file mode 100644 index 000000000..43ef30d08 --- /dev/null +++ b/test/end-to-end/cases/xspec-55.xspec @@ -0,0 +1,18 @@ + + + + + + [Expected Result] must represent xs:decimal(1) by "1.0" (numeric literal of + decimal) + + + [Expected Result] must represent xs:double(1) by "xs:double('1')" (constructor + of double) + + + [Expected Result] must represent xs:integer(1) by "1" (numeric literal of + integer) + + + \ No newline at end of file diff --git a/test/xspec-focus-1.xspec b/test/end-to-end/cases/xspec-focus-1.xspec similarity index 62% rename from test/xspec-focus-1.xspec rename to test/end-to-end/cases/xspec-focus-1.xspec index 624a6ba27..151253206 100644 --- a/test/xspec-focus-1.xspec +++ b/test/end-to-end/cases/xspec-focus-1.xspec @@ -2,64 +2,46 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - diff --git a/test/xspec-function.xspec b/test/end-to-end/cases/xspec-function.xspec similarity index 70% rename from test/xspec-function.xspec rename to test/end-to-end/cases/xspec-function.xspec index 5cb103aca..aa6ebc125 100644 --- a/test/xspec-function.xspec +++ b/test/end-to-end/cases/xspec-function.xspec @@ -2,41 +2,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - diff --git a/test/xspec-import.xspec b/test/end-to-end/cases/xspec-import.xspec similarity index 68% rename from test/xspec-import.xspec rename to test/end-to-end/cases/xspec-import.xspec index bd362057b..97c60bb6f 100644 --- a/test/xspec-import.xspec +++ b/test/end-to-end/cases/xspec-import.xspec @@ -2,44 +2,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - diff --git a/test/xspec-imported.xspec b/test/end-to-end/cases/xspec-imported.xspec similarity index 74% rename from test/xspec-imported.xspec rename to test/end-to-end/cases/xspec-imported.xspec index 86c42e6b8..b47905f20 100644 --- a/test/xspec-imported.xspec +++ b/test/end-to-end/cases/xspec-imported.xspec @@ -2,39 +2,23 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - diff --git a/test/xspec-pending.xspec b/test/end-to-end/cases/xspec-pending.xspec similarity index 56% rename from test/xspec-pending.xspec rename to test/end-to-end/cases/xspec-pending.xspec index 22f86fc3c..b08232d85 100644 --- a/test/xspec-pending.xspec +++ b/test/end-to-end/cases/xspec-pending.xspec @@ -2,89 +2,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - - - + + + - + - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/test/xspec-rule.xspec b/test/end-to-end/cases/xspec-rule.xspec similarity index 65% rename from test/xspec-rule.xspec rename to test/end-to-end/cases/xspec-rule.xspec index aaf5e4964..7bbc22db1 100644 --- a/test/xspec-rule.xspec +++ b/test/end-to-end/cases/xspec-rule.xspec @@ -2,63 +2,51 @@ - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/test/end-to-end/cases/xspec-three-dots.xsl b/test/end-to-end/cases/xspec-three-dots.xsl new file mode 100644 index 000000000..814f48e9b --- /dev/null +++ b/test/end-to-end/cases/xspec-three-dots.xsl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + ... + + + + text + + + + + text + + + + + + + + + + + + ... + + diff --git a/test/end-to-end/cases/xspec-three-dots.xspec b/test/end-to-end/cases/xspec-three-dots.xspec new file mode 100644 index 000000000..23391ab2a --- /dev/null +++ b/test/end-to-end/cases/xspec-three-dots.xspec @@ -0,0 +1,527 @@ + + + + + When result istext + ]]> + + text + + + expecting... + ]]>should be Success + ... + + ... + + + + When result is + ]]> + + + + + expecting... + ]]>should be Success + ... + + + + expecting + ]]>should be Failure + + + + + + When result is... + ]]> + + ... + + + expecting... + ]]>should be Success + ... + + ... + + + expectingtext + ]]>should be Failure + text + + + + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + ... + + + expecting... + ]]>should be Failure + ... + + + + + + + When result istext + ]]> + + text + + + expecting... + ]]>should be Success + ... + + + expecting...... + ]]>should be Success + ...... + + ... + + + + When result is + ]]> + + + + + expecting... + ]]>should be Success + ... + + + + expecting... + ]]>should be Failure + ... + + + + + + + When result is + + + + + expectingshould be Success + + + ... + + + + When result is + + + + + expectingshould be Success + + + + + + When result is + + + + + expectingshould be Success + + + ... + + + expectingshould be Failure + + + + + + + + + + + ... + + + + + + + + + ... + + + + + + + + + ... + + + + + + + + + ... + + + + + + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + ... + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + ... + + + expecting + ]]>should be Failure + + + + + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + ... + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + + + + When result is + ]]> + + + + + expecting + ]]>should be Success + + + ... + + + expecting + ]]>should be Failure + + + + + + + + When result is + ]]> + + + + + expecting... + ]]>should be Success + + ... + + + + When result is + ]]> + + + + ... + + + expecting... + ]]>should be Failure + + + + + When result is... + ]]> + + + + + expecting... + ]]>should be Success + + ... + + + expectingtext + ]]>should be Failure + + + + + + + When result is + + + + + + + expectingshould be Success + + + ... + + + + When result is + + + + + + + expectingshould be Success + + + ... + + + + When result is + + + + + + + expectingshould be Success + + + ... + + + expectingshould be Failure + + + + + + + + When result is sequence of + ]]> + + + + + expecting + ]]>should be Success + ... + + + ... + ... + + + ... + ...... + + ... + ... + ... + + + + + + + ... + + + + + + + + + + ... + + + + + + + + + + ... + + + + + + item + .... + ...x + ... + + + diff --git a/test/end-to-end/generate-expected.cmd b/test/end-to-end/generate-expected.cmd new file mode 100644 index 000000000..e21f46c63 --- /dev/null +++ b/test/end-to-end/generate-expected.cmd @@ -0,0 +1,74 @@ +@echo off + +rem +rem Begin localization of environment changes. +rem Also make sure the command processor extensions are enabled. +rem +verify other 2> NUL +setlocal enableextensions +if errorlevel 1 ( + echo Unable to enable extensions + exit /b %ERRORLEVEL% +) + +rem +rem Go to the directory where this script resides +rem +pushd "%~dp0" + +rem +rem .xspec files directory +rem +set CASES_DIR=cases + +rem +rem XSpec output directory +rem +set TEST_DIR=%CASES_DIR%\expected + +rem +rem Process .xspec files +rem +for %%I in ("%CASES_DIR%\*.xspec") do ( + echo: + echo ---------- + echo Processing "%%~I"... + + rem + rem Generate the report HTML + rem + call :check_test_type "%%~nI" + if errorlevel 2 ( + "%COMSPEC%" /c ..\..\bin\xspec.bat -s "%%~I" + ) else if errorlevel 1 ( + "%COMSPEC%" /c ..\..\bin\xspec.bat -q "%%~I" + ) else ( + "%COMSPEC%" /c ..\..\bin\xspec.bat "%%~I" + ) + + rem + rem Normalize the report HTML + rem + java -classpath "%SAXON_CP%" net.sf.saxon.Transform -o:"%TEST_DIR%\%%~nI-result-norm.html" -s:"%TEST_DIR%\%%~nI-result.html" -xsl:processor\normalize.xsl +) + +rem +rem Go back to the initial directory +rem +popd + +rem +rem Exit as success +rem +exit /b 0 + +:check_test_type + set var=%~1 + if "%var:~0,6%"=="xquery" ( + set TEST_TYPE=1 + ) else if "%var:~0,10%"=="schematron" ( + set TEST_TYPE=2 + ) else ( + set TEST_TYPE=0 + ) + exit /b %TEST_TYPE% diff --git a/test/end-to-end/generate-expected.sh b/test/end-to-end/generate-expected.sh new file mode 100755 index 000000000..36569b820 --- /dev/null +++ b/test/end-to-end/generate-expected.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# This script must be run from the script's directory + +# .xspec files directory +CASES_DIR=cases + +# XSpec output directory +export TEST_DIR=${CASES_DIR}/expected + +# Process .xspec files +for CASE_FILEPATH in ${CASES_DIR}/*.xspec +do + echo + echo "----------" + echo "Processing ${CASE_FILEPATH}..." + + CASE_FILENAME=${CASE_FILEPATH##*/} + CASE_BASENAME=${CASE_FILENAME%.xspec} + + # Generate the report HTML + if test "${CASE_FILENAME:0:10}" = "schematron"; then + ../../bin/xspec.sh -s ${CASE_FILEPATH} + elif test "${CASE_FILENAME:0:6}" = "xquery"; then + ../../bin/xspec.sh -q ${CASE_FILEPATH} + else + ../../bin/xspec.sh ${CASE_FILEPATH} + fi + + # Normalize the report HTML + java -classpath ${SAXON_CP} net.sf.saxon.Transform -o:${TEST_DIR}/${CASE_BASENAME}-result-norm.html -s:${TEST_DIR}/${CASE_BASENAME}-result.html -xsl:processor/normalize.xsl +done diff --git a/test/end-to-end/processor/_deserializer.xsl b/test/end-to-end/processor/_deserializer.xsl new file mode 100644 index 000000000..d85a055fe --- /dev/null +++ b/test/end-to-end/processor/_deserializer.xsl @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/end-to-end/processor/_normalizer.xsl b/test/end-to-end/processor/_normalizer.xsl new file mode 100644 index 000000000..3b37437f1 --- /dev/null +++ b/test/end-to-end/processor/_normalizer.xsl @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../../../../ + + + src/reporter/test-report.css + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/end-to-end/processor/_serializer.xsl b/test/end-to-end/processor/_serializer.xsl new file mode 100644 index 000000000..441dbd68a --- /dev/null +++ b/test/end-to-end/processor/_serializer.xsl @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/test/end-to-end/processor/_util.xsl b/test/end-to-end/processor/_util.xsl new file mode 100644 index 000000000..4de2a0649 --- /dev/null +++ b/test/end-to-end/processor/_util.xsl @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/end-to-end/processor/compare.xsl b/test/end-to-end/processor/compare.xsl new file mode 100644 index 000000000..e23ae0888 --- /dev/null +++ b/test/end-to-end/processor/compare.xsl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : Compared + + with + + + + diff --git a/test/end-to-end/processor/normalize.xsl b/test/end-to-end/processor/normalize.xsl new file mode 100644 index 000000000..cb224846f --- /dev/null +++ b/test/end-to-end/processor/normalize.xsl @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/end-to-end/run-e2e-tests.cmd b/test/end-to-end/run-e2e-tests.cmd new file mode 100644 index 000000000..46582a26b --- /dev/null +++ b/test/end-to-end/run-e2e-tests.cmd @@ -0,0 +1,80 @@ +@echo off + +rem +rem Begin localization of environment changes. +rem Also make sure the command processor extensions are enabled. +rem +verify other 2> NUL +setlocal enableextensions +if errorlevel 1 ( + echo Unable to enable extensions + exit /b %ERRORLEVEL% +) + +rem +rem Go to the directory where this script resides +rem +pushd "%~dp0" + +rem +rem .xspec files directory +rem +set CASES_DIR=cases + +rem +rem XSpec output directory (same as default) +rem +set TEST_DIR=%CASES_DIR%\xspec + +rem +rem Run test cases +rem +for %%I in ("%CASES_DIR%\*.xspec") do ( + if /i "%APPVEYOR%"=="True" appveyor AddTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Running + + rem + rem Generate the report HTML + rem + call :check_test_type "%%~nI" + if errorlevel 2 ( + "%COMSPEC%" /c ..\..\bin\xspec.bat -s "%%~I" > NUL 2>&1 + ) else if errorlevel 1 ( + "%COMSPEC%" /c ..\..\bin\xspec.bat -q "%%~I" > NUL 2>&1 + ) else ( + "%COMSPEC%" /c ..\..\bin\xspec.bat "%%~I" > NUL 2>&1 + ) + + rem + rem Compare with the expected HTML + rem + java -classpath "%SAXON_CP%" net.sf.saxon.Transform -s:"%TEST_DIR%\%%~nI-result.html" -xsl:processor\compare.xsl | findstr /b /l /c:"OK: Compared " + if errorlevel 1 ( + echo FAILED: %%~I + if /i "%APPVEYOR%"=="True" appveyor UpdateTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Failed -Duration 0 + exit /b 1 + ) + + if /i "%APPVEYOR%"=="True" appveyor UpdateTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Passed -Duration 0 +) + +rem +rem Go back to the initial directory +rem +popd + +rem +rem Exit as success +rem +exit /b 0 + +:check_test_type + set var=%~1 + if "%var:~0,6%"=="xquery" ( + set TEST_TYPE=1 + ) else if "%var:~0,10%"=="schematron" ( + set TEST_TYPE=2 + ) else ( + set TEST_TYPE=0 + ) + exit /b %TEST_TYPE% + diff --git a/test/end-to-end/run-e2e-tests.sh b/test/end-to-end/run-e2e-tests.sh new file mode 100755 index 000000000..df5298f1a --- /dev/null +++ b/test/end-to-end/run-e2e-tests.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# This script must be run from the script's directory + +# .xspec files directory +CASES_DIR=cases + +# XSpec output directory (same as default) +export TEST_DIR=${CASES_DIR}/xspec + +# Run test cases +for CASE_FILEPATH in ${CASES_DIR}/*.xspec +do + CASE_FILENAME=${CASE_FILEPATH##*/} + CASE_BASENAME=${CASE_FILENAME%.xspec} + + # Generate the report HTML + if test "${CASE_FILENAME:0:10}" = "schematron"; then + ../../bin/xspec.sh -s ${CASE_FILEPATH} > /dev/null 2>&1 + elif test "${CASE_FILENAME:0:6}" = "xquery"; then + ../../bin/xspec.sh -q ${CASE_FILEPATH} > /dev/null 2>&1 + else + ../../bin/xspec.sh ${CASE_FILEPATH} > /dev/null 2>&1 + fi + + # Compare with the expected HTML + if java -classpath ${SAXON_CP} net.sf.saxon.Transform -s:${TEST_DIR}/${CASE_BASENAME}-result.html -xsl:processor/compare.xsl | grep '^OK: Compared ' + then + # OK, nothing to do + : + else + echo "FAILED: ${CASE_FILEPATH}" + exit 1 + fi +done diff --git a/test/generate-tests-utils.xspec b/test/generate-tests-utils.xspec index cfb7cb16b..235e1475c 100644 --- a/test/generate-tests-utils.xspec +++ b/test/generate-tests-utils.xspec @@ -1,118 +1,636 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Test + + + Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Using "..." to indicate missing text + + + ... + + + foo + + + + + + + Using "..." to indicate missing mixed content + + + ... + + + foofoo + + + + + + + Using "..." to indicate missing attribute values + + + + + + + + + + + + + Using "..." to indicate missing empty content + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - foo - bar - - - foobar - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/generate-x-utils.xspec b/test/generate-x-utils.xspec new file mode 100644 index 000000000..958aa8ced --- /dev/null +++ b/test/generate-x-utils.xspec @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foo + bar + + + foobar + + + + + + + + + + + + + foobar + foobar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/generate-xspec-tests.xspec b/test/generate-xspec-tests.xspec index 807349b75..d573250a3 100644 --- a/test/generate-xspec-tests.xspec +++ b/test/generate-xspec-tests.xspec @@ -2,64 +2,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - diff --git a/test/run-xspec-tests.cmd b/test/run-xspec-tests.cmd new file mode 100644 index 000000000..2f7dd5b21 --- /dev/null +++ b/test/run-xspec-tests.cmd @@ -0,0 +1,83 @@ +@echo off + +rem ============================================================================ +rem +rem DESCRIPTION: This script is a Windows version of run-xspec-tests.sh +rem See run-xspec-tests.sh for details +rem +rem DEPENDENCIES: This script does *not* need to be run from the current directory (i.e. the test directory) +rem +rem ============================================================================ + +rem +rem Begin localization of environment changes. +rem Also make sure the command processor extensions are enabled. +rem +verify other 2> NUL +setlocal enableextensions +if errorlevel 1 ( + echo Unable to enable extensions + exit /b %ERRORLEVEL% +) + +rem +rem Go to the directory where this script resides +rem +pushd "%~dp0" + +rem +rem Result log +rem +set RESULT_FILE=result.log + +rem +rem Run tests +rem +for %%I in (*.xspec) do ( + if /i "%APPVEYOR%"=="True" appveyor AddTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Running + + rem + rem Run + rem + call :is_schematron "%%~nI" + if errorlevel 1 ( + "%COMSPEC%" /c ..\bin\xspec.bat -s "%%~I" > "%RESULT_FILE%" 2>&1 + ) else ( + "%COMSPEC%" /c ..\bin\xspec.bat "%%~I" > "%RESULT_FILE%" 2>&1 + ) + + rem + rem Inspect result + rem + ( findstr /r /c:".*failed: [1-9]" "%RESULT_FILE%" || findstr /r /c:"\*\** Error [a-z][a-z]*ing the test suite" "%RESULT_FILE%" || findstr /r /c:"\*\** Error .*Schematron" "%RESULT_FILE%" ) > NUL + if not errorlevel 1 ( + echo FAILED: %%~I + echo ---------- "%RESULT_FILE%" + type "%RESULT_FILE%" + echo ---------- + if /i "%APPVEYOR%"=="True" appveyor UpdateTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Failed -Duration 0 + exit /b 1 + ) else ( + echo OK: %%~I + if /i "%APPVEYOR%"=="True" appveyor UpdateTest "%%~I" -Framework custom -Filename "%~nx0" -Outcome Passed -Duration 0 + ) +) + +rem +rem Go back to the initial directory +rem +popd + +rem +rem Exit as success +rem +exit /b 0 + +:is_schematron + set var=%~1 + if "%var:~0,10%"=="schematron" ( + set IS_SCHEMATRON=1 + ) else ( + set IS_SCHEMATRON=0 + ) + exit /b %IS_SCHEMATRON% diff --git a/test/run-xspec-tests.sh b/test/run-xspec-tests.sh new file mode 100755 index 000000000..746f08aa4 --- /dev/null +++ b/test/run-xspec-tests.sh @@ -0,0 +1,42 @@ +#!/bin/bash +#=============================================================================== +# +# USAGE: ./run-xspec.tests.sh +# +# DESCRIPTION: This script is a runner for XSpec test suite inside test directory +# it runs all the tests with extension .xspec in the test directory +# it outputs stdout and stderr into a file result.log +# it greps for failing tests in the log file or for compilation errors +# it returns no output if the tests are successful +# or an error message if there are failing tests or compilation errors +# +# INPUT: N/A +# +# OUTPUT: Error message if there are failing tests or compilation errors +# A log file is created at result.log +# +# DEPENDENCIES: This script must be run from the current directory (i.e. the test directory) +# +# AUTHORS: Sandro Cirulli, github.com/cirulls +# Tobias Fischer, github.com/tofi86 +# +# LICENSE: MIT License +# +#=============================================================================== +for xspectest in *.xspec +do + if test "${xspectest:0:10}" = "schematron"; then + ../bin/xspec.sh -s $xspectest &> result.log; + else + ../bin/xspec.sh $xspectest &> result.log; + fi + if grep -q ".*failed:\s[1-9]" result.log || grep -q -E "\*+\sError\s(.*Schematron.*|(running|compiling)\sthe\stest\ssuite)" result.log; + then + echo "FAILED: $xspectest"; + echo "---------- result.log"; + cat result.log; + echo "----------"; + exit 1; + else echo "OK: $xspectest"; + fi +done diff --git a/test/sch-location-compare.xspec b/test/sch-location-compare.xspec new file mode 100644 index 000000000..e54f5efba --- /dev/null +++ b/test/sch-location-compare.xspec @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /ex1:section + /section[1] + + + + + + + + + /root/ex1:sec/ex1:sec/ex2:para + /root/*[local-name()='sec'][2]/*[local-name()='sec'][2]/*[local-name()='para'][2] + + + + + + + + + + + + @*[namespace-uri()='http://example.com/ns2' and local-name()='type'] + + + + + + + + + + + + + /article[1]/section[2] + /article[1]/section[2] + + + + + + + + /article/section[2] + /article[1]/section[2] + + + + + + + + article[1]/section[2] + /article[1]/section[2] + + + + + + + + /root/ex1:sec[2]/ex2:para[2] + /root/*[local-name()='sec'][2]/*[local-name()='para'][2] + + + + + + + + + + + /root/ex1:sec[2]/ex2:para[2] + /root[1]/*:sec[namespace-uri()='http://example.com/ns1'][2]/*:para[namespace-uri()='http://example.com/ns2'][2] + + + + + + + + + + + + /article/section[1]/@type + /article[1]/section[1]/@type + + + + + + + /ex1:article[1]/ex1:sec[2]/@ex2:type + /*:article[namespace-uri()='http://example.com/ns1'][1]/*:sec[namespace-uri()='http://example.com/ns1'][2]/@*[namespace-uri()='http://example.com/ns2' and local-name()='type'] + + + + + + + + + + + + /root/body/div/para + /root[1]/div[1]/para[1] + + + + + + + + /root/ex1:sec[2]/ex2:para + /root/*[local-name()='sec'][2] + + + + + + + + + + + /root/ex1:sec[2]/ex1:sec[1]/ex2:para[2] + /root[1]/*:sec[namespace-uri()='http://example.com/ns1'][2]/*:para[namespace-uri()='http://example.com/ns2'][2] + + + + + + + + + + + + + diff --git a/test/schematron-01.sch b/test/schematron-01.sch new file mode 100644 index 000000000..77d8befa4 --- /dev/null +++ b/test/schematron-01.sch @@ -0,0 +1,17 @@ + + + + + + + article should have a title + + + + + section should have a title + + + + + \ No newline at end of file diff --git a/test/schematron-01.xml b/test/schematron-01.xml new file mode 100644 index 000000000..2147a8641 --- /dev/null +++ b/test/schematron-01.xml @@ -0,0 +1,14 @@ + +
+ Example +
+ Introduction +

Welcome to demo 3!

+
+
+

This is an example.

+
+
+

Scenario excpect's can specify a location in the context XML that an assert or report is expected to identify.

+
+
diff --git a/test/schematron-01.xspec b/test/schematron-01.xspec new file mode 100644 index 000000000..d8683fc61 --- /dev/null +++ b/test/schematron-01.xspec @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/schematron-012.xspec b/test/schematron-012.xspec new file mode 100644 index 000000000..ea958301c --- /dev/null +++ b/test/schematron-012.xspec @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/schematron-014-01.xml b/test/schematron-014-01.xml new file mode 100644 index 000000000..74dddb5fc --- /dev/null +++ b/test/schematron-014-01.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/test/schematron-014.sch b/test/schematron-014.sch new file mode 100644 index 000000000..2c11869db --- /dev/null +++ b/test/schematron-014.sch @@ -0,0 +1,16 @@ + + + + + + + + + sec should contain para + + + para should not contain another para + + + + \ No newline at end of file diff --git a/test/schematron-014.xspec b/test/schematron-014.xspec new file mode 100644 index 000000000..e8130b2b8 --- /dev/null +++ b/test/schematron-014.xspec @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/schematron-015.sch b/test/schematron-015.sch new file mode 100644 index 000000000..10ccb0117 --- /dev/null +++ b/test/schematron-015.sch @@ -0,0 +1,16 @@ + + + + + + + + + sec should contain para + + + para should not contain another para + + + + \ No newline at end of file diff --git a/test/schematron-015.xspec b/test/schematron-015.xspec new file mode 100644 index 000000000..18297a098 --- /dev/null +++ b/test/schematron-015.xspec @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/schematron-016.sch b/test/schematron-016.sch new file mode 100644 index 000000000..b83961204 --- /dev/null +++ b/test/schematron-016.sch @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/test/schematron-016.xspec b/test/schematron-016.xspec new file mode 100644 index 000000000..6e8855640 --- /dev/null +++ b/test/schematron-016.xspec @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/schematron-017.xspec b/test/schematron-017.xspec new file mode 100644 index 000000000..180d3d96e --- /dev/null +++ b/test/schematron-017.xspec @@ -0,0 +1,26 @@ + + + + + + + + + XML + + + + + + + + Markdown + + + + + + + + diff --git a/test/schematron-018.xspec b/test/schematron-018.xspec new file mode 100644 index 000000000..835727f97 --- /dev/null +++ b/test/schematron-018.xspec @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ + <para/> + <title/> + </section> + </x:context> + <x:expect-rule context="title[position() gt 1]"/> + </x:scenario> + </x:scenario> + <x:scenario label="count"> + <x:scenario label="0"> + <x:context> + <article/> + </x:context> + <x:expect-rule label="verify that a rule does not fire" count="0"/> + </x:scenario> + <x:scenario label="1"> + <x:context> + <section/> + </x:context> + <x:expect-rule count="1"/> + </x:scenario> + <x:scenario label="2"> + <x:context> + <article> + <section/> + <section/> + </article> + </x:context> + <x:expect-rule count="2"/> + </x:scenario> + </x:scenario> + <x:scenario label="id and context"> + <x:context> + <article> + <title/> + </article> + </x:context> + <x:expect-rule context="title[position() eq 1]" id="r3"/> + </x:scenario> + <x:scenario label="id and count"> + <x:context> + <article> + <para/> + <para/> + <para/> + </article> + </x:context> + <x:expect-rule id="r1" count="3"/> + </x:scenario> + <x:scenario label="context and count"> + <x:context> + <article> + <para/> + <para/> + <para/> + <para/> + </article> + </x:context> + <x:expect-rule context="para" count="4"/> + </x:scenario> + <x:scenario label="id, context, and count"> + <x:context> + <article> + <para/> + <para/> + <para/> + <para/> + <para/> + </article> + </x:context> + <x:expect-rule id="r1" context="para" count="5"/> + </x:scenario> + <x:scenario label="specific rules fire or do not fire"> + <x:context> + <section/> + </x:context> + <x:expect-rule label="verify that a specific rule does not fire" id="r1" count="0"/> + <x:expect-rule label="verify that a specific rule does fire" id="r2" count="1"/> + </x:scenario> + </x:scenario> + +</x:description> diff --git a/test/schematron-019.xspec b/test/schematron-019.xspec new file mode 100644 index 000000000..b53b309c9 --- /dev/null +++ b/test/schematron-019.xspec @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="schematron/schematron-019.sch"> + + <x:scenario label="XSLT Function in Schematrion"> + <x:scenario label="XSLT function test"> + <x:call function="e:add" xmlns:e="example"> + <x:param name="a" select="5" as="xs:integer"/> + <x:param name="b" select="2" as="xs:integer"/> + </x:call> + <x:expect label="add 5 + 2" select="xs:integer(7)"/> + </x:scenario> + </x:scenario> + +</x:description> diff --git a/test/schematron-020.xspec b/test/schematron-020.xspec new file mode 100644 index 000000000..9ac7876a7 --- /dev/null +++ b/test/schematron-020.xspec @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="schematron/schematron-020.sch"> + + <x:scenario label="match id attribute"> + <x:context> + <para/> + </x:context> + + <x:scenario label="in schema"> + <x:scenario label="on assertion"> + <x:expect-assert id="assert1"/> + </x:scenario> + <x:scenario label="on rule"> + <x:expect-assert id="rule2"/> + </x:scenario> + <x:scenario label="on pattern"> + <x:expect-assert id="pattern3"/> + </x:scenario> + </x:scenario> + + <x:scenario label="in imported pattern"> + <x:scenario label="on assertion"> + <x:expect-assert id="include1-assert1"/> + </x:scenario> + <x:scenario label="on rule"> + <x:expect-assert id="include1-rule2"/> + </x:scenario> + <x:scenario label="on pattern"> + <x:expect-assert id="include1-pattern3"/> + </x:scenario> + </x:scenario> + + <x:scenario label="in imported rule"> + <x:scenario label="on assertion"> + <x:expect-assert id="include1-assert4"/> + </x:scenario> + <x:scenario label="on rule"> + <x:expect-assert id="include1-rule5"/> + </x:scenario> + </x:scenario> + + <x:scenario label="in imported assertion"> + <x:scenario label="on assertion"> + <x:expect-assert id="include1-assert6"/> + </x:scenario> + </x:scenario> + + </x:scenario> + + +</x:description> diff --git a/test/schematron-021.xspec b/test/schematron-021.xspec new file mode 100644 index 000000000..06aefa1cb --- /dev/null +++ b/test/schematron-021.xspec @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="schematron/schematron-021.sch"> + + <x:scenario label="abstract pattern"> + <x:scenario label="implementation 1"> + <x:context> + <div/> + </x:context> + <x:expect-assert id="rule1"/> + </x:scenario> + <x:scenario label="implementation 2"> + <x:context> + <para/> + </x:context> + <x:expect-assert id="rule1"/> + </x:scenario> + <x:scenario label="id on pattern"> + <x:context> + <figure/> + </x:context> + <x:expect-assert id="pattern5"/> + </x:scenario> + </x:scenario> + +</x:description> diff --git a/test/schematron-022.xspec b/test/schematron-022.xspec new file mode 100644 index 000000000..9a25861a4 --- /dev/null +++ b/test/schematron-022.xspec @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="schematron/schematron-022.sch"> + + <x:scenario label="abstract rule"> + <x:context> + <body/> + </x:context> + <x:expect-assert id="assert1"/> + <x:expect-assert id="rule3"/> + <x:expect-assert id="assert3"/> + </x:scenario> + +</x:description> diff --git a/test/schematron-param-001.xspec b/test/schematron-param-001.xspec new file mode 100644 index 000000000..a99871990 --- /dev/null +++ b/test/schematron-param-001.xspec @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schematron/schut-to-xspec-test.sch"> + <x:param name="phase">P1</x:param> + <x:param name="selected" select="codepoints-to-string((80,49))"/> + <!--x:param name="escape1">AAA BBB CCC</x:param--> + <!--x:param name="escape2">a"b</x:param--> + <!--x:param name="escape3">a'b</x:param--> + <!--x:param name="escape4">A ' " B</x:param--> + <x:scenario label="Schematron phase/parameters are passed to Schematron compile"/> +<!-- +With xspec.bat: +All of the above examples work properly with xspec.bat. +Have not been able to make them all work in xspec-bat.cmd test. + +With xspec.sh: +With xspec.sh escaping spaces (escape1, escape4) is not working. +Have not been able to make them all work in xspec.bats test. + +Tested manually by modifying iso_svrl_for_xslt2.xsl to add inside xsl:stylesheet: + + <xsl:param name="selected"/> + <xsl:param name="escape1"/> + <xsl:param name="escape2"/> + <xsl:param name="escape3"/> + <xsl:param name="escape4"/> + +And inside <xsl:template name="process-root"> + + <xsl:message> + Phase + <xsl:value-of select="$phase"/> + Selected + <xsl:value-of select="$selected"/> + Escape1 + <xsl:value-of select="$escape1"/> + Escape2 + <xsl:value-of select="$escape2"/> + Escape3 + <xsl:value-of select="$escape3"/> + Escape4 + <xsl:value-of select="$escape4"/> + </xsl:message> + +Then running: +bin\xspec.bat -s test\schematron\param-001.xspec +bin\xspec.sh -s test\schematron\param-001.xspec + +--> +</x:description> diff --git a/test/schematron/data/standards.xml b/test/schematron/data/standards.xml new file mode 100644 index 000000000..1fb91a016 --- /dev/null +++ b/test/schematron/data/standards.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<list> + <item>XML</item> + <item>XSLT</item> + <item>XQuery</item> + <item>Schematron</item> +</list> diff --git a/test/schematron/schematron-017.sch b/test/schematron/schematron-017.sch new file mode 100644 index 000000000..8bc4fee39 --- /dev/null +++ b/test/schematron/schematron-017.sch @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:pattern> + <sch:let name="list" value="doc('data/standards.xml')/list/item/text()"/> + <sch:rule context="standard"> + <sch:assert test="text() = $list" id="t1">"<sch:value-of select="text()"/> is not in the list of standards.</sch:assert> + </sch:rule> + </sch:pattern> +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-018.sch b/test/schematron/schematron-018.sch new file mode 100644 index 000000000..fc4b3becb --- /dev/null +++ b/test/schematron/schematron-018.sch @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:pattern> + <sch:rule context="para" id="r1"> + <sch:assert test="true()"/> + </sch:rule> + <sch:rule context="section" id="r2"> + <sch:assert test="true()"/> + </sch:rule> + <sch:rule context="title[position() eq 1]" id="r3"> + <sch:assert test="true()"/> + </sch:rule> + <sch:rule context="title[position() gt 1]" id="r4"> + <sch:assert test="true()"/> + </sch:rule> + </sch:pattern> +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-019.sch b/test/schematron/schematron-019.sch new file mode 100644 index 000000000..7d38beeae --- /dev/null +++ b/test/schematron/schematron-019.sch @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + <sch:ns uri="example" prefix="e"/> + + <xsl:function name="e:add" as="xs:integer"> + <xsl:param name="a" as="xs:integer"/> + <xsl:param name="b" as="xs:integer"/> + <xsl:value-of select="$a + $b"/> + </xsl:function> + +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-020-01.sch b/test/schematron/schematron-020-01.sch new file mode 100644 index 000000000..f507e2433 --- /dev/null +++ b/test/schematron/schematron-020-01.sch @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:pattern id="include1-pattern1"> + <sch:rule context="para" id="include1-rule1"> + <sch:assert test="false()" id="include1-assert1"/> + </sch:rule> + </sch:pattern> + <sch:pattern id="include1-pattern2"> + <sch:rule context="para" id="include1-rule2"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + <sch:pattern id="include1-pattern3"> + <sch:rule context="para"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + <!-- *********************************** --> + <sch:pattern id="include1-pattern4"> + <sch:rule context="para" id="include1-rule4"> + <sch:assert test="false()" id="include1-assert4"/> + </sch:rule> + </sch:pattern> + <sch:pattern id="include1-pattern5"> + <sch:rule context="para" id="include1-rule5"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + <!-- *********************************** --> + <sch:pattern id="include1-pattern6"> + <sch:rule context="para" id="include1-rule6"> + <sch:assert test="false()" id="include1-assert6"/> + </sch:rule> + </sch:pattern> +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-020.sch b/test/schematron/schematron-020.sch new file mode 100644 index 000000000..1f454ac7e --- /dev/null +++ b/test/schematron/schematron-020.sch @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:pattern id="pattern1"> + <sch:rule context="para" id="rule1"> + <sch:assert test="false()" id="assert1"/> + </sch:rule> + </sch:pattern> + <sch:pattern id="pattern2"> + <sch:rule context="para" id="rule2"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + <sch:pattern id="pattern3"> + <sch:rule context="para"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + <sch:include href="schematron-020-01.sch#include1-pattern1"/> + <sch:include href="schematron-020-01.sch#include1-pattern2"/> + <sch:include href="schematron-020-01.sch#include1-pattern3"/> + <sch:pattern id="pattern4"> + <sch:include href="schematron-020-01.sch#include1-rule4"/> + </sch:pattern> + <sch:pattern id="pattern5"> + <sch:include href="schematron-020-01.sch#include1-rule5"/> + </sch:pattern> + <sch:pattern id="pattern6"> + <sch:rule context="para"> + <sch:include href="schematron-020-01.sch#include1-assert6"/> + </sch:rule> + </sch:pattern> +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-021.sch b/test/schematron/schematron-021.sch new file mode 100644 index 000000000..c56e28471 --- /dev/null +++ b/test/schematron/schematron-021.sch @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + + <sch:pattern id="pattern1" abstract="true"> + <sch:rule context="$element" id="rule1"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + + <sch:pattern id="pattern2" is-a="pattern1"> + <sch:param name="element" value="div"/> + </sch:pattern> + + <sch:pattern id="pattern3" is-a="pattern1"> + <sch:param name="element" value="para"/> + </sch:pattern> + + <sch:pattern id="pattern4" abstract="true"> + <sch:rule context="$element"> + <sch:assert test="false()"/> + </sch:rule> + </sch:pattern> + + <sch:pattern id="pattern5" is-a="pattern4"> + <sch:param name="element" value="figure"/> + </sch:pattern> + +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-022.sch b/test/schematron/schematron-022.sch new file mode 100644 index 000000000..e8d849379 --- /dev/null +++ b/test/schematron/schematron-022.sch @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + + <sch:pattern id="pattern1"> + <sch:rule id="rule1" abstract="true"> + <sch:assert test="false()" id="assert1"/> + </sch:rule> + <sch:rule id="rule2" abstract="true"> + <sch:assert test="false()"/> + </sch:rule> + <sch:rule id="rule3" context="body"> + <sch:extends rule="rule1"/> + <sch:extends rule="rule2"/> + <sch:assert test="false()" id="assert3"/> + </sch:rule> + </sch:pattern> + +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schematron-xslt-compile.xsl b/test/schematron/schematron-xslt-compile.xsl new file mode 100644 index 000000000..c7797eaf7 --- /dev/null +++ b/test/schematron/schematron-xslt-compile.xsl @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + <xsl:template match="/"> + <xsl:element name="test"> + <xsl:message>Schematron XSLT compile</xsl:message> + </xsl:element> + </xsl:template> +</xsl:stylesheet> diff --git a/test/schematron/schematron-xslt-expand.xsl b/test/schematron/schematron-xslt-expand.xsl new file mode 100644 index 000000000..7ba44f379 --- /dev/null +++ b/test/schematron/schematron-xslt-expand.xsl @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + <xsl:template match="/"> + <xsl:element name="test"> + <xsl:message>Schematron XSLT expand</xsl:message> + </xsl:element> + </xsl:template> +</xsl:stylesheet> diff --git a/test/schematron/schematron-xslt-include.xsl b/test/schematron/schematron-xslt-include.xsl new file mode 100644 index 000000000..1fb6f5db4 --- /dev/null +++ b/test/schematron/schematron-xslt-include.xsl @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + <xsl:template match="/"> + <xsl:element name="test"> + <xsl:message>Schematron XSLT include</xsl:message> + </xsl:element> + </xsl:template> +</xsl:stylesheet> diff --git a/test/schematron/schut-to-xspec-001-in.xspec b/test/schematron/schut-to-xspec-001-in.xspec new file mode 100644 index 000000000..548be9eae --- /dev/null +++ b/test/schematron/schut-to-xspec-001-in.xspec @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-001-out.xspec b/test/schematron/schut-to-xspec-001-out.xspec new file mode 100644 index 000000000..ab220bdd4 --- /dev/null +++ b/test/schematron/schut-to-xspec-001-out.xspec @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-002-in.xspec b/test/schematron/schut-to-xspec-002-in.xspec new file mode 100644 index 000000000..9632b099c --- /dev/null +++ b/test/schematron/schut-to-xspec-002-in.xspec @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-002.sch"> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-002-out.xspec b/test/schematron/schut-to-xspec-002-out.xspec new file mode 100644 index 000000000..9f92c9636 --- /dev/null +++ b/test/schematron/schut-to-xspec-002-out.xspec @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + xmlns:xlink="http://www.w3.org/1999/xlink" stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-002.sch b/test/schematron/schut-to-xspec-002.sch new file mode 100644 index 000000000..701d48835 --- /dev/null +++ b/test/schematron/schut-to-xspec-002.sch @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/> +</sch:schema> diff --git a/test/schematron/schut-to-xspec-003-in.xspec b/test/schematron/schut-to-xspec-003-in.xspec new file mode 100644 index 000000000..8aa5a0253 --- /dev/null +++ b/test/schematron/schut-to-xspec-003-in.xspec @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"> + <x:scenario label="nested"></x:scenario> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-003-out.xspec b/test/schematron/schut-to-xspec-003-out.xspec new file mode 100644 index 000000000..3ab9d0edd --- /dev/null +++ b/test/schematron/schut-to-xspec-003-out.xspec @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"> + <x:scenario label="nested"></x:scenario> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-004-in.xspec b/test/schematron/schut-to-xspec-004-in.xspec new file mode 100644 index 000000000..25a01aa62 --- /dev/null +++ b/test/schematron/schut-to-xspec-004-in.xspec @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"> + <x:scenario label="pending via attribute" pending="test"></x:scenario> + </x:scenario> + <x:pending> + <x:scenario label="pending via element"></x:scenario> + </x:pending> + <x:scenario label="pending nested scenario"> + <x:pending> + <x:scenario label="nested"></x:scenario> + </x:pending> + </x:scenario> + <x:scenario label="pending assertions"> + <x:pending> + <x:expect-assert/> + </x:pending> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-004-out.xspec b/test/schematron/schut-to-xspec-004-out.xspec new file mode 100644 index 000000000..dfc75f07f --- /dev/null +++ b/test/schematron/schut-to-xspec-004-out.xspec @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"> + <x:scenario label="pending via attribute" pending="test"></x:scenario> + </x:scenario> + <x:pending> + <x:scenario label="pending via element"></x:scenario> + </x:pending> + <x:scenario label="pending nested scenario"> + <x:pending> + <x:scenario label="nested"></x:scenario> + </x:pending> + </x:scenario> + <x:scenario label="pending assertions"> + <x:pending> + <x:expect label="assert" test="exists(svrl:schematron-output/svrl:failed-assert)"/> + </x:pending> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-005-in.xspec b/test/schematron/schut-to-xspec-005-in.xspec new file mode 100644 index 000000000..837300c27 --- /dev/null +++ b/test/schematron/schut-to-xspec-005-in.xspec @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"/> + <x:scenario label="focused" focus="test"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-005-out.xspec b/test/schematron/schut-to-xspec-005-out.xspec new file mode 100644 index 000000000..1d0371c66 --- /dev/null +++ b/test/schematron/schut-to-xspec-005-out.xspec @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"/> + <x:scenario label="focused" focus="test"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-006-in.xspec b/test/schematron/schut-to-xspec-006-in.xspec new file mode 100644 index 000000000..8325ab03e --- /dev/null +++ b/test/schematron/schut-to-xspec-006-in.xspec @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="s1" shared="yes"> + <x:context href="schut-to-xspec-test.sch"/> + </x:scenario> + <x:scenario label="s2"> + <x:like label="s1"/> + <x:expect-assert/> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-006-out.xspec b/test/schematron/schut-to-xspec-006-out.xspec new file mode 100644 index 000000000..e7d58d4d3 --- /dev/null +++ b/test/schematron/schut-to-xspec-006-out.xspec @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="s1" shared="yes"> + <x:context href="schut-to-xspec-test.sch"/> + </x:scenario> + <x:scenario label="s2"> + <x:like label="s1"/> + <x:expect label="assert" test="exists(svrl:schematron-output/svrl:failed-assert)"/> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-007-in.xspec b/test/schematron/schut-to-xspec-007-in.xspec new file mode 100644 index 000000000..66f994acc --- /dev/null +++ b/test/schematron/schut-to-xspec-007-in.xspec @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"> + <x:context href="schut-to-xspec-007.xml"/> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-007-out.xspec b/test/schematron/schut-to-xspec-007-out.xspec new file mode 100644 index 000000000..84cd00d5b --- /dev/null +++ b/test/schematron/schut-to-xspec-007-out.xspec @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"> + <x:context href="schut-to-xspec-007.xml"/> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-007.xml b/test/schematron/schut-to-xspec-007.xml new file mode 100644 index 000000000..6cc709ca0 --- /dev/null +++ b/test/schematron/schut-to-xspec-007.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document/> diff --git a/test/schematron/schut-to-xspec-008-in.xspec b/test/schematron/schut-to-xspec-008-in.xspec new file mode 100644 index 000000000..b0003efb2 --- /dev/null +++ b/test/schematron/schut-to-xspec-008-in.xspec @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="Schematron test scenario"> + <x:context> + <snippet/> + </x:context> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-008-out.xspec b/test/schematron/schut-to-xspec-008-out.xspec new file mode 100644 index 000000000..31bbc78da --- /dev/null +++ b/test/schematron/schut-to-xspec-008-out.xspec @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:scenario label="Schematron test scenario"> + <x:context href="xspec/context-d1e6.xml"/> + </x:scenario> +</x:description> diff --git a/test/schematron/schut-to-xspec-009-import-in.xspec b/test/schematron/schut-to-xspec-009-import-in.xspec new file mode 100644 index 000000000..f0492c6d2 --- /dev/null +++ b/test/schematron/schut-to-xspec-009-import-in.xspec @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:scenario label="B"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-009-in.xspec b/test/schematron/schut-to-xspec-009-in.xspec new file mode 100644 index 000000000..2cf0a64db --- /dev/null +++ b/test/schematron/schut-to-xspec-009-in.xspec @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:import href="schut-to-xspec-009-import-in.xspec"/> + <x:scenario label="A"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-009-out.xspec b/test/schematron/schut-to-xspec-009-out.xspec new file mode 100644 index 000000000..f82696955 --- /dev/null +++ b/test/schematron/schut-to-xspec-009-out.xspec @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <!--BEGIN IMPORT "schut-to-xspec-009-import-in.xspec"--> + <x:scenario label="B"/> + <!--END IMPORT "schut-to-xspec-009-import-in.xspec"--> + <x:scenario label="A"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-010-import.xspec b/test/schematron/schut-to-xspec-010-import.xspec new file mode 100644 index 000000000..bafd2f98c --- /dev/null +++ b/test/schematron/schut-to-xspec-010-import.xspec @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"> + <x:scenario label="B"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-010-in.xspec b/test/schematron/schut-to-xspec-010-in.xspec new file mode 100644 index 000000000..894de3afc --- /dev/null +++ b/test/schematron/schut-to-xspec-010-in.xspec @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:import href="schut-to-xspec-010-import.xspec"/> + <x:scenario label="A"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-010-out.xspec b/test/schematron/schut-to-xspec-010-out.xspec new file mode 100644 index 000000000..0df7b76e7 --- /dev/null +++ b/test/schematron/schut-to-xspec-010-out.xspec @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:import href="schut-to-xspec-010-import.xspec"/> + <x:scenario label="A"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-011-in.xspec b/test/schematron/schut-to-xspec-011-in.xspec new file mode 100644 index 000000000..5944ee630 --- /dev/null +++ b/test/schematron/schut-to-xspec-011-in.xspec @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:param name="phase">P1</x:param> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-011-out.xspec b/test/schematron/schut-to-xspec-011-out.xspec new file mode 100644 index 000000000..d39acd75f --- /dev/null +++ b/test/schematron/schut-to-xspec-011-out.xspec @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:param name="phase">P1</x:param> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-012-01.xml b/test/schematron/schut-to-xspec-012-01.xml new file mode 100644 index 000000000..114f64b17 --- /dev/null +++ b/test/schematron/schut-to-xspec-012-01.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<article> + <div>Test</div> +</article> diff --git a/test/schematron/schut-to-xspec-012-02.xml b/test/schematron/schut-to-xspec-012-02.xml new file mode 100644 index 000000000..ff4c23df0 --- /dev/null +++ b/test/schematron/schut-to-xspec-012-02.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<article> + <div> + <section> + <p>test</p> + </section> + </div> + <div>text</div> + <div> + This text is longer than any other. + </div> + <div>more text</div> +</article> diff --git a/test/schematron/schut-to-xspec-012-out.xspec b/test/schematron/schut-to-xspec-012-out.xspec new file mode 100644 index 000000000..05e52cfb2 --- /dev/null +++ b/test/schematron/schut-to-xspec-012-out.xspec @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?><?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?><x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="schut-to-xspec-test.sch.xsl" schematron="..." xspec-original-location="..."> + <x:scenario label="expect-valid"> + <x:context href="schematron/schut-to-xspec-012-01.xml"/> + <x:expect label="valid" test="boolean(svrl:schematron-output[svrl:fired-rule]) and not(boolean((svrl:schematron-output/svrl:failed-assert union svrl:schematron-output/svrl:successful-report)[ not(@role) or @role = ('error','fatal')]))"/> + </x:scenario> + <x:scenario label="assertions"> + <x:scenario label="without attributes"> + <x:scenario label="not thrown"> + <x:context href="schematron/schut-to-xspec-012-01.xml"/> + <x:expect label="not assert" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert)"/> + <x:expect label="not report" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report)"/> + </x:scenario> + <x:scenario label="thrown"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert" test="exists(svrl:schematron-output/svrl:failed-assert)"/> + <x:expect label="report" test="exists(svrl:schematron-output/svrl:successful-report)"/> + </x:scenario> + </x:scenario> + <x:scenario label="with id"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert a1" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a1'])"/> + <x:expect label="not assert a2" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a2'])"/> + <x:expect label="report r1" test="exists(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r1'])"/> + <x:expect label="not report r2" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r2'])"/> + </x:scenario> + <x:scenario label="with role"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert warn" test="exists(svrl:schematron-output/svrl:failed-assert[(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'])"/> + <x:expect label="not assert fatal" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'fatal'])"/> + <x:expect label="report warn" test="exists(svrl:schematron-output/svrl:successful-report[(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'])"/> + <x:expect label="not report info" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report[(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'info'])"/> + </x:scenario> + <x:scenario label="with location"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert /article[1]/div[1]" test="exists(svrl:schematron-output/svrl:failed-assert[x:schematron-location-compare('/article[1]/div[1]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not assert /article[1]/div[2]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[x:schematron-location-compare('/article[1]/div[2]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="report /article[1]/div[3]" test="exists(svrl:schematron-output/svrl:successful-report[x:schematron-location-compare('/article[1]/div[3]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not report /article[1]/div[4]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report[x:schematron-location-compare('/article[1]/div[4]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + </x:scenario> + <x:scenario label="with id, location"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert a1 /article[1]/div[1]" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a1'][x:schematron-location-compare('/article[1]/div[1]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not assert a2 /article[1]/div[2]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a2'][x:schematron-location-compare('/article[1]/div[2]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="report r1 /article[1]/div[3]" test="exists(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r1'][x:schematron-location-compare('/article[1]/div[3]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not report r2 /article[1]/div[4]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r2'][x:schematron-location-compare('/article[1]/div[4]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + </x:scenario> + <x:scenario label="with id, role, location"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert a1 warn /article[1]/div[1]" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a1'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'][x:schematron-location-compare('/article[1]/div[1]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not assert a2 error /article[1]/div[2]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'a2'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'error'][x:schematron-location-compare('/article[1]/div[2]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="report r1 warn /article[1]/div[3]" test="exists(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r1'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'][x:schematron-location-compare('/article[1]/div[3]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + <x:expect label="not report r2 info /article[1]/div[4]" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'r2'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'info'][x:schematron-location-compare('/article[1]/div[4]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + </x:scenario> + </x:scenario> + <x:scenario label="inherrit from rule"> + <x:scenario label="id and role from rule"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert ru1 error" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru1'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'error'])"/> + </x:scenario> + <x:scenario label="id from rule and role from assertion"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert ru1 warn" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru1'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'])"/> + </x:scenario> + <x:scenario label="role from rule and id from assertion"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert ru2 error" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru2'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'error'])"/> + </x:scenario> + <x:scenario label="match only current rule"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="not assert ru3" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru3'])"/> + <x:expect label="not assert ru3 warn" test="boolean(svrl:schematron-output[svrl:fired-rule]) and empty(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru3'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'])"/> + <x:expect label="report ru3 warn /article[1]" test="exists(svrl:schematron-output/svrl:successful-report[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'ru3'][(@role, preceding-sibling::svrl:fired-rule[1]/@role, preceding-sibling::svrl:active-pattern[1]/@role)[1] = 'warn'][x:schematron-location-compare('/article[1]', @location, preceding-sibling::svrl:ns-prefix-in-attribute-values)])"/> + </x:scenario> + </x:scenario> + <x:scenario label="inherrit from pattern"> + <x:scenario label="id from pattern"> + <x:context href="schematron/schut-to-xspec-012-02.xml"/> + <x:expect label="assert pattern3" test="exists(svrl:schematron-output/svrl:failed-assert[(@id, preceding-sibling::svrl:fired-rule[1]/@id, preceding-sibling::svrl:active-pattern[1]/@id)[1] = 'pattern3'])"/> + </x:scenario> + </x:scenario> +</x:description> \ No newline at end of file diff --git a/test/schematron/schut-to-xspec-013-in.xspec b/test/schematron/schut-to-xspec-013-in.xspec new file mode 100644 index 000000000..c4dd6fac2 --- /dev/null +++ b/test/schematron/schut-to-xspec-013-in.xspec @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" schematron="schut-to-xspec-test.sch"> + <x:param name="phase" select="concat('P','1')"/> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-013-out.xspec b/test/schematron/schut-to-xspec-013-out.xspec new file mode 100644 index 000000000..b14bb2c4a --- /dev/null +++ b/test/schematron/schut-to-xspec-013-out.xspec @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?xml-model href="../../src/schemas/xspec.rnc" type="application/relax-ng-compact-syntax"?> +<x:description xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:x="http://www.jenitennison.com/xslt/xspec" + schematron="..." xspec-original-location="..." + stylesheet="schut-to-xspec-test.sch.xsl"> + <x:param name="phase" select="concat('P','1')"/> + <x:scenario label="Schematron test scenario"/> +</x:description> diff --git a/test/schematron/schut-to-xspec-test.sch b/test/schematron/schut-to-xspec-test.sch new file mode 100644 index 000000000..4b725ffcb --- /dev/null +++ b/test/schematron/schut-to-xspec-test.sch @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:phase id="P1"/> +</sch:schema> \ No newline at end of file diff --git a/test/schematron/schut-to-xspec-test.sch.xsl b/test/schematron/schut-to-xspec-test.sch.xsl new file mode 100644 index 000000000..e33336683 --- /dev/null +++ b/test/schematron/schut-to-xspec-test.sch.xsl @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + +</xsl:stylesheet> \ No newline at end of file diff --git a/test/schut-to-xspec-012.sch b/test/schut-to-xspec-012.sch new file mode 100644 index 000000000..12a2f3db5 --- /dev/null +++ b/test/schut-to-xspec-012.sch @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + <sch:pattern> + <sch:rule context="div"> + <sch:assert id="a1" role="warn" test="not(section)">A section inside a div is usually superflous</sch:assert> + <sch:assert id="a2" role="error" test="node()">div should not be empty</sch:assert> + <sch:report id="r1" role="warn" test="string-length(normalize-space()) gt 10">text is longer than 10 characters</sch:report> + <sch:report id="r2" role="warn" test="img">An image was found</sch:report> + </sch:rule> + </sch:pattern> + <sch:pattern> + <sch:rule context="section" id="ru1" role="error"> + <sch:assert test="title">section should have a title</sch:assert> + <sch:assert test="p[2]" role="warn">section should contain at least 2 paragraphs</sch:assert> + <sch:assert test="img" id="ru2">section should contain an image</sch:assert> + </sch:rule> + <sch:rule context="article" id="ru3" role="warn"> + <sch:assert test="div">article should contain div</sch:assert> + <sch:report test="div[2]">article has more than 1 div</sch:report> + </sch:rule> + </sch:pattern> + <sch:pattern id="pattern3"> + <sch:rule context="section"> + <sch:assert test="title">section should have a title</sch:assert> + </sch:rule> + </sch:pattern> +</sch:schema> diff --git a/test/schut-to-xspec.xspec b/test/schut-to-xspec.xspec new file mode 100644 index 000000000..99d3b0bb4 --- /dev/null +++ b/test/schut-to-xspec.xspec @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" + xmlns:s="http://www.jenitennison.com/xslt/xspec/schematron" stylesheet="../src/schematron/schut-to-xspec.xsl"> + <x:param name="stylesheet" select="'schut-to-xspec-test.sch.xsl'"/> + <x:scenario label="templates"> + <x:scenario label="identity"> + <x:context> + <example attr="1"> + <!-- comment --> + <?pi?> + <p>this is a <i>mixed</i> text <b> example</b>.</p> + <other xmlns="other">foreign</other> + </example> + </x:context> + <x:expect label="copied"> + <example attr="1"> + <!-- comment --> + <?pi?> + <p>this is a <i>mixed</i> text <b> example</b>.</p> + <other xmlns="other">foreign</other> + </example> + </x:expect> + </x:scenario> + </x:scenario> + <x:scenario label="parameters"> + <x:scenario label="no phase"> + <x:context href="schematron/schut-to-xspec-001-in.xspec"/> + <x:expect label="xspec description" href="schematron/schut-to-xspec-001-out.xspec"/> + </x:scenario> + <x:scenario label="with phase"> + <x:context href="schematron/schut-to-xspec-011-in.xspec"/> + <x:expect label="xspec description" href="schematron/schut-to-xspec-011-out.xspec"/> + </x:scenario> + <x:scenario label="with phase in select"> + <x:context href="schematron/schut-to-xspec-013-in.xspec"/> + <x:expect label="xspec description" href="schematron/schut-to-xspec-013-out.xspec"/> + </x:scenario> + </x:scenario> + <x:scenario label="namespaces defined in Schematron"> + <x:context href="schematron/schut-to-xspec-002-in.xspec"/> + <x:expect label="copied from sch:ns to x:description" href="schematron/schut-to-xspec-002-out.xspec"/> + </x:scenario> + <x:scenario label="scenario"> + <x:scenario label="nested"> + <x:context href="schematron/schut-to-xspec-003-in.xspec"/> + <x:expect label="nested scenarios" href="schematron/schut-to-xspec-003-out.xspec"/> + </x:scenario> + <x:scenario label="pending"> + <x:context href="schematron/schut-to-xspec-004-in.xspec"/> + <x:expect label="pending scenarios" href="schematron/schut-to-xspec-004-out.xspec"/> + </x:scenario> + <x:scenario label="focus"> + <x:context href="schematron/schut-to-xspec-005-in.xspec"/> + <x:expect label="focused scenario" href="schematron/schut-to-xspec-005-out.xspec"/> + </x:scenario> + <x:scenario label="shared"> + <x:context href="schematron/schut-to-xspec-006-in.xspec"/> + <x:expect label="shared scenarios" href="schematron/schut-to-xspec-006-out.xspec"/> + </x:scenario> + </x:scenario> + <x:scenario label="context"> + <x:scenario label="file"> + <x:context href="schematron/schut-to-xspec-007-in.xspec"/> + <x:expect label="context href" href="schematron/schut-to-xspec-007-out.xspec"/> + </x:scenario> + <x:scenario label="inline" pending="Can't test inline context because of error: "XTDE1480: Cannot execute xsl:result-document while evaluating xsl:variable""> + <x:context href="schematron/schut-to-xspec-008-in.xspec"/> + <x:expect label="context href to generated file" href="schematron/schut-to-xspec-008-out.xspec"/> + </x:scenario> + </x:scenario> + <x:scenario label="import"> + <x:scenario label="type schut (default)"> + <x:context href="schematron/schut-to-xspec-009-in.xspec"/> + <x:expect label="copy contents of imported file" href="schematron/schut-to-xspec-009-out.xspec"/> + </x:scenario> + <x:scenario label="type xspec"> + <x:context href="schematron/schut-to-xspec-010-in.xspec"/> + <x:expect label="import href" href="schematron/schut-to-xspec-010-out.xspec"/> + </x:scenario> + </x:scenario> + <x:scenario label="assertions"> + <x:context href="schematron-012.xspec" select="x:description"/> + <x:expect label="expect elements with correct label and test" href="schematron/schut-to-xspec-012-out.xspec" select="x:description"/> + </x:scenario> +</x:description> diff --git a/test/unit-expect-xsl.xspec b/test/unit-expect-xsl.xspec index ead674cd4..1b7223858 100644 --- a/test/unit-expect-xsl.xspec +++ b/test/unit-expect-xsl.xspec @@ -2,73 +2,27 @@ <!-- ===================================================================== --> <!-- File: test/unit-expect-xsl.xspec --> <!-- Author: Florent Georges --> -<!-- URI: http://xspec.googlecode.com/ --> <!-- Tags: --> <!-- Copyright (c) 2010 Florent Georges (see end of file.) --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - <!-- Test only the XSLT version. It is very difficult to test the (textual) XQuery output. Unless, of course, we use XQueryX... --> -<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - stylesheet="../generate-xspec-tests.xsl"> - - <!-- - <t:expect/> - +<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" stylesheet="../src/compiler/generate-xspec-tests.xsl"> + <!-- TODO: Track down how it is transformed (named templated, rule in a mode, etc.) and test it explicitely... --> - <t:scenario label="pending call"> - <t:context mode="t:compile"> - <t:param tunnel="yes" name="context"/> - <t:param tunnel="yes" name="call"/> - <t:expect test="false()"/> - </t:context> - <t:expect label="is a template" - test="$t:result instance of element(xsl:template)"/> - <t:expect label="@test must be transformed to @select" - test="$t:result/xsl:variable[@name eq 'impl:test-result']/*/xsl:otherwise/*"> - <xsl:sequence select="false()" version="..."/> - </t:expect> - <t:expect label="is a template" - assert="$t:result instance of element(xsl:template)"/> - <t:expect label="@test must be transformed to @select" - context="$t:result/xsl:variable[@name eq 'impl:test-result']/*/xsl:otherwise/*"> - <xsl:sequence select="false()" version="..."/> - </t:expect> - </t:scenario> - + <t:scenario label="pending call"> + <t:context mode="t:compile"> + <t:param tunnel="yes" name="context"/> + <t:param tunnel="yes" name="call"/> + <t:expect test="false()"/> + </t:context> + <t:expect label="is a template" test="$t:result instance of element(xsl:template)"/> + <t:expect label="@test must be transformed to @select" test="$t:result/xsl:variable[@name eq 'impl:test-result']/*/xsl:otherwise/*"> + <xsl:sequence select="false()" version="..."/> + </t:expect> + </t:scenario> </t:description> - - -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> -<!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. --> -<!-- --> -<!-- Copyright (c) 2010 Florent Georges --> -<!-- --> -<!-- The contents of this file are subject to the MIT License (see the URI --> -<!-- http://www.opensource.org/licenses/mit-license.php for details). --> -<!-- --> -<!-- Permission is hereby granted, free of charge, to any person obtaining --> -<!-- a copy of this software and associated documentation files (the --> -<!-- "Software"), to deal in the Software without restriction, including --> -<!-- without limitation the rights to use, copy, modify, merge, publish, --> -<!-- distribute, sublicense, and/or sell copies of the Software, and to --> -<!-- permit persons to whom the Software is furnished to do so, subject to --> -<!-- the following conditions: --> -<!-- --> -<!-- The above copyright notice and this permission notice shall be --> -<!-- included in all copies or substantial portions of the Software. --> -<!-- --> -<!-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, --> -<!-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --> -<!-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.--> -<!-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --> -<!-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --> -<!-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --> -<!-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> -<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> diff --git a/test/xspec-26.xsl b/test/xspec-26.xsl new file mode 100644 index 000000000..142e080f8 --- /dev/null +++ b/test/xspec-26.xsl @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" + version="2.0"> + + <xsl:template match="document"> + <container> + <xsl:apply-templates/> + </container> + </xsl:template> + + <xsl:template match="heading"> + <child> + <xsl:apply-templates/> + </child> + </xsl:template> + +</xsl:stylesheet> diff --git a/test/xspec-26.xspec b/test/xspec-26.xspec new file mode 100644 index 000000000..73dc9b388 --- /dev/null +++ b/test/xspec-26.xspec @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- full description at https://github.com/xspec/xspec/26 --> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="xspec-26.xsl"> + <x:scenario label="When converting heading element"> + <x:context> + <document> + <heading>Some Text</heading> + </document> + </x:context> + <x:expect label="Wrap it in a container element"> + <container>...</container> + </x:expect> + <x:expect label="With a child" test="container/child[1]"> + <child>Some Text</child> + </x:expect> + </x:scenario> +</x:description> diff --git a/test/xspec-30.xml b/test/xspec-30.xml new file mode 100644 index 000000000..ee6a09c1d --- /dev/null +++ b/test/xspec-30.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<foo/> diff --git a/test/xspec-30.xsl b/test/xspec-30.xsl new file mode 100644 index 000000000..408c53a20 --- /dev/null +++ b/test/xspec-30.xsl @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template as="document-node()" match="document-node()"> + <xsl:sequence select="." /> + </xsl:template> +</xsl:stylesheet> diff --git a/test/xspec-30.xspec b/test/xspec-30.xspec new file mode 100644 index 000000000..d338e857a --- /dev/null +++ b/test/xspec-30.xspec @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- full description at https://github.com/xspec/xspec/issues/30 --> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="xspec-30.xsl"> + <x:scenario label="When an XML is passed via the href attribute of x:context"> + <x:context href="xspec-30.xml"/> + <x:expect href="xspec-30.xml" label="the href attribute of x:expect works"/> + </x:scenario> +</x:description> diff --git a/test/xspec-33.xsl b/test/xspec-33.xsl new file mode 100644 index 000000000..f95726a72 --- /dev/null +++ b/test/xspec-33.xsl @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet exclude-result-prefixes="#all" version="2.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template as="node()" match="node()"> + <xsl:sequence select="." /> + </xsl:template> +</xsl:stylesheet> diff --git a/test/xspec-33.xspec b/test/xspec-33.xspec new file mode 100644 index 000000000..6df403fe6 --- /dev/null +++ b/test/xspec-33.xspec @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="xspec-33.xsl"> + <x:scenario label="When context contains descendant"> + <x:context> + <foo> + <bar> + <baz>original-text</baz> + </bar> + </foo> + </x:context> + <x:expect label="descendant is picked up correctly using XPath in @test" test="descendant::baz"> + <baz>original-text</baz> + </x:expect> + </x:scenario> +</x:description> diff --git a/test/xspec-46.xsl b/test/xspec-46.xsl new file mode 100644 index 000000000..4dfcaf1b6 --- /dev/null +++ b/test/xspec-46.xsl @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet exclude-result-prefixes="#all" version="2.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:template as="node()" match="node()"> + <xsl:sequence select="." /> + </xsl:template> +</xsl:stylesheet> diff --git a/test/xspec-46.xspec b/test/xspec-46.xspec new file mode 100644 index 000000000..ff2975837 --- /dev/null +++ b/test/xspec-46.xspec @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema" stylesheet="xspec-46.xsl"> + <x:scenario label="Scenario-1"> + <x:context> + <foo/> + </x:context> + <x:expect label="Expect-1" select="1" test="count(foo)"/> + </x:scenario> +</x:description> diff --git a/test/xspec-72.xsl b/test/xspec-72.xsl new file mode 100644 index 000000000..4e7ca726a --- /dev/null +++ b/test/xspec-72.xsl @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> + + <xsl:output encoding="UTF-8"/> + + <xsl:template match="@*|node()"> + <xsl:copy> + <xsl:apply-templates select="@*|node()"/> + </xsl:copy> + </xsl:template> + +</xsl:stylesheet> + diff --git a/test/xspec-72.xspec b/test/xspec-72.xspec new file mode 100644 index 000000000..99d1e7745 --- /dev/null +++ b/test/xspec-72.xspec @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:fn="http://www.w3.org/2005/xpath-functions" stylesheet="xspec-72.xsl"> + <x:scenario label="When processing text in UTF-8"> + <x:context> + <text> + <p>Überprüfung von Umlauten</p> + <p>Œ, œ, Ÿ</p> + <p>Бесы</p> + </text> + </x:context> + <x:expect label="the encoding is correct"> + <text> + <p>Überprüfung von Umlauten</p> + <p>Œ, œ, Ÿ</p> + <p>Бесы</p> + </text> + </x:expect> + </x:scenario> +</x:description> diff --git a/test/xspec-bat.cmd b/test/xspec-bat.cmd new file mode 100644 index 000000000..002cfd802 --- /dev/null +++ b/test/xspec-bat.cmd @@ -0,0 +1,757 @@ +@echo off +if defined DEBUG @echo on + +rem +rem Begin localization of environment changes. +rem Also make sure the command processor extensions are enabled. +rem +verify other 2> NUL +setlocal enableextensions +if errorlevel 1 ( + echo Unable to enable extensions + exit /b %ERRORLEVEL% +) + +rem +rem Results log file +rem +set RESULTS_FILE=%TEMP%\%~n0_results.log +call :del "%RESULTS_FILE%" + +rem +rem Work directory +rem - Created at :setup +rem - Removed recursively at :teardown +rem +set WORK_DIR=%TEMP%\%~n0_work + +rem +rem Output log files for :run +rem +set OUTPUT_RAW=%WORK_DIR%\run_raw.log +set OUTPUT_LINENUM=%WORK_DIR%\run_linenum.log + +rem +rem Name and extension of this file +rem +set THIS_FILE_NX=%~nx0 + +rem +rem Go to the directory where this script resides +rem +pushd "%~dp0" + +rem +rem Full path to the parent directory +rem +for %%I in (..) do set PARENT_DIR_ABS=%%~fI + +echo === START TEST CASES ================================================ + +setlocal + call :setup "invoking xspec without arguments prints usage" + + call :run ..\bin\xspec.bat + call :verify_retval 1 + call :verify_line 3 x "Usage: xspec [-t|-q|-s|-c|-j|-h] filename [coverage]" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -s and -t prints error message" + + call :run ..\bin\xspec.bat -s -t + call :verify_retval 1 + call :verify_line 2 x "-s and -t are mutually exclusive" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -s and -q prints error message" + + call :run ..\bin\xspec.bat -s -q + call :verify_retval 1 + call :verify_line 2 x "-s and -q are mutually exclusive" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -t and -q prints error message" + + call :run ..\bin\xspec.bat -t -q + call :verify_retval 1 + call :verify_line 2 x "-t and -q are mutually exclusive" + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon9HE returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon9he.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon9SA returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon9sa.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon9 returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon9.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon8SA returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon8sa.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon8 returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon8.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon9EE creates test stylesheet" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon9ee.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Creating Test Stylesheet..." + + call :teardown +endlocal + +setlocal + call :setup "invoking code coverage with Saxon9PE creates test stylesheet" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon9pe.jar + + call :run ..\bin\xspec.bat -c ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Creating Test Stylesheet..." + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec generates XML report file" + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :verify_exist ..\tutorial\xspec\escape-for-regex-result.xml + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec generates HTML report file" + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :verify_exist ..\tutorial\xspec\escape-for-regex-result.html + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -j option with Saxon8 returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon8.jar + + call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Saxon8 detected. JUnit report requires Saxon9." + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -j option with Saxon8-SA returns error message" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxon8sa.jar + + call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Saxon8 detected. JUnit report requires Saxon9." + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -j option generates message with JUnit report location" + + call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec + call :verify_retval 0 + call :verify_line 19 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-junit.xml" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -j option generates XML report file" + + call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec + call :verify_exist ..\tutorial\xspec\escape-for-regex-result.xml + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with -j option generates JUnit report file" + + call :run ..\bin\xspec.bat -j ..\tutorial\escape-for-regex.xspec + call :verify_exist ..\tutorial\xspec\escape-for-regex-junit.xml + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with Saxon-B-9-1-0-8 creates test stylesheet" + + set SAXON_CP=%SYSTEMDRIVE%\path\to\saxonb9-1-0-8.jar + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :verify_retval 1 + call :verify_line 2 x "Creating Test Stylesheet..." + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat with TEST_DIR already set externally generates files inside TEST_DIR" + + set TEST_DIR=%WORK_DIR% + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :verify_retval 0 + call :verify_line 19 x "Report available at %TEST_DIR%\escape-for-regex-result.html" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat without TEST_DIR generates files in default location" + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :verify_retval 0 + call :verify_line 19 x "Report available at %PARENT_DIR_ABS%\tutorial\xspec\escape-for-regex-result.html" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat that passes a non xs:boolean does not raise a warning #46" + + call :run ..\bin\xspec.bat ..\test\xspec-46.xspec + call :verify_retval 0 + call :verify_line 4 r "Testing with" + + call :teardown +endlocal + +setlocal + call :setup "executing the Saxon XProc harness generates a report with UTF-8 encoding" + + if defined XMLCALABASH_CP ( + call :run java -Xmx1024m -cp "%XMLCALABASH_CP%" com.xmlcalabash.drivers.Main -isource=xspec-72.xspec -p xspec-home="file:/%PARENT_DIR_ABS:\=/%/" -oresult=xspec/xspec-72-result.html ..\src\harnesses\saxon\saxon-xslt-harness.xproc + call :run java -cp "%SAXON_CP%" net.sf.saxon.Query -s:xspec\xspec-72-result.html -qs:"declare default element namespace 'http://www.w3.org/1999/xhtml'; concat(/html/head/meta[@http-equiv eq 'Content-Type']/@content = 'text/html; charset=UTF-8', ' ')" !method=text + call :verify_line 1 x "true" + ) else ( + call :skip "test for XProc skipped as XMLCalabash uses a higher version of Saxon" + ) + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat for parentheses dir generates HTML report file #84" + + set PARENTHESES_DIR=%WORK_DIR%\%~n0 (84) + call :mkdir "%PARENTHESES_DIR%" + copy ..\tutorial\escape-for-regex.* "%PARENTHESES_DIR%" > NUL + + set EXPECTED_REPORT=%PARENTHESES_DIR%\xspec\escape-for-regex-result.html + + call :run ..\bin\xspec.bat "%PARENTHESES_DIR%\escape-for-regex.xspec" + call :verify_retval 0 + call :verify_line 20 x "Report available at %EXPECTED_REPORT%" + call :verify_exist "%EXPECTED_REPORT%" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat with path containing an apostrophe runs successfully #119" + + set APOSTROPHE_DIR=%WORK_DIR%\some'path + call :mkdir "%APOSTROPHE_DIR%" + copy ..\tutorial\escape-for-regex.* "%APOSTROPHE_DIR%" > NUL + + call :run ..\bin\xspec.bat "%APOSTROPHE_DIR%\escape-for-regex.xspec" + call :verify_retval 0 + call :verify_line 20 x "Report available at %APOSTROPHE_DIR%\xspec\escape-for-regex-result.html" + + call :teardown +endlocal + +setlocal + call :setup "Schematron phase/parameters are passed to Schematron compile" + + call :run ..\bin\xspec.bat -s ..\test\schematron-param-001.xspec + call :verify_retval 0 + call :verify_line 3 x "Paramaters: phase=P1 ?selected=codepoints-to-string((80,49))" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec with Schematron XSLTs provided externally uses provided XSLTs for Schematron compile" + + set SCHEMATRON_XSLT_INCLUDE=schematron\schematron-xslt-include.xsl + set SCHEMATRON_XSLT_EXPAND=schematron\schematron-xslt-expand.xsl + set SCHEMATRON_XSLT_COMPILE=schematron\schematron-xslt-compile.xsl + + call :run ..\bin\xspec.bat -s ..\tutorial\schematron\demo-01.xspec + call :verify_line 5 x "Schematron XSLT include" + call :verify_line 6 x "Schematron XSLT expand" + call :verify_line 7 x "Schematron XSLT compile" + + call :teardown +endlocal + +setlocal + call :setup "invoking xspec.bat with the -s option does not display Schematron warnings #129 #131" + + call :run ..\bin\xspec.bat -s ..\tutorial\schematron\demo-01.xspec + call :verify_retval 0 + call :verify_line 5 x "Compiling the Schematron tests..." + + call :teardown +endlocal + +setlocal + call :setup "Cleanup removes temporary files" + + call :run ..\bin\xspec.bat -s ..\tutorial\schematron\demo-03.xspec + call :verify_retval 0 + call :verify_not_exist ..\tutorial\schematron\demo-03.xspec-compiled.xspec + call :run dir /on ..\tutorial\schematron\xspec + call :verify_line 9 r ".*3 File.*" + call :verify_exist ..\tutorial\schematron\xspec\demo-03-result.html + call :verify_exist ..\tutorial\schematron\xspec\demo-03-result.xml + call :verify_exist ..\tutorial\schematron\xspec\demo-03.xsl + + call :teardown +endlocal + +setlocal + call :setup "HTML report contains CSS inline and not as an external file #135" + + call :run ..\bin\xspec.bat ..\tutorial\escape-for-regex.xspec + call :run java -cp "%SAXON_CP%" net.sf.saxon.Query -s:..\tutorial\xspec\escape-for-regex-result.html -qs:"declare default element namespace 'http://www.w3.org/1999/xhtml'; concat(/html/head[not(link[@type = 'text/css'])]/style[@type = 'text/css']/contains(., 'margin-right:'), ' ')" !method=text + call :verify_line 1 x "true" + + call :teardown +endlocal + +setlocal + call :setup "Ant for XSLT with default properties fails on test failure" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\..\tutorial\escape-for-regex.xspec" -lib "%SAXON_CP%" + call :verify_retval 1 + call :verify_line -4 x "BUILD FAILED" + ) else ( + call :skip "test for XSLT Ant with default properties skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for XSLT with xspec.fail=false continues on test failure" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\..\tutorial\escape-for-regex.xspec" -lib "%SAXON_CP%" -Dxspec.fail=false + call :verify_retval 0 + call :verify_line -2 x "BUILD SUCCESSFUL" + ) else ( + call :skip "test for XSLT Ant with xspec.fail=false skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for XSLT with catalog resolves URI" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\catalog\xspec-160_xslt.xspec" -lib "%SAXON_CP%" -Dxspec.fail=false -Dcatalog="%CD%\catalog\xspec-160_catalog.xml" -lib "%XML_RESOLVER_CP%" + call :verify_retval 0 + call :verify_line -2 x "BUILD SUCCESSFUL" + ) else ( + call :skip "test for XSLT Ant with catalog skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for Schematron with minimum properties" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\..\tutorial\schematron\demo-02-PhaseA.xspec" -lib "%SAXON_CP%" -Dtest.type=s + call :verify_retval 0 + call :verify_line -2 x "BUILD SUCCESSFUL" + + rem Verify default clean.output.dir is false + call :verify_exist ..\tutorial\schematron\xspec\ + call :verify_exist ..\tutorial\schematron\demo-02-PhaseA.xspec-compiled.xspec + call :verify_exist ..\tutorial\schematron\demo-02.sch-compiled.xsl + + rem Delete temp file + call :del ..\tutorial\schematron\demo-02-PhaseA.xspec-compiled.xspec + call :del ..\tutorial\schematron\demo-02.sch-compiled.xsl + ) else ( + call :skip "test for Schematron Ant with minimum properties skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for Schematron with various properties except catalog" + + set BUILD_XML=%WORK_DIR%\build.xml + + if defined ANT_VERSION ( + rem Remove a temp dir created by setup + call :rmdir ..\tutorial\schematron\xspec + + rem For testing -Dxspec.project.dir + copy ..\build.xml "%BUILD_XML%" > NUL + + call :run ant -buildfile "%BUILD_XML%" -Dxspec.xml="%CD%\..\tutorial\schematron\demo-03.xspec" -lib "%SAXON_CP%" -Dtest.type=s -Dxspec.project.dir="%CD%\.." -Dxspec.phase=#ALL -Dxspec.dir="%CD%\xspec-temp" -Dclean.output.dir=true + call :verify_retval 0 + call :verify_line -2 x "BUILD SUCCESSFUL" + + rem Verify that -Dxspec-dir was honered and the default dir was not created + call :verify_not_exist ..\tutorial\schematron\xspec\ + + rem Verify clean.output.dir=true + call :verify_not_exist xspec-temp\ + call :verify_not_exist ..\tutorial\schematron\demo-03.xspec-compiled.xspec + call :verify_not_exist ..\tutorial\schematron\demo-03.sch-compiled.xsl + ) else ( + call :skip "test for Schematron Ant with various properties except catalog skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for Schematron with catalog and default xspec.fail fails on test failure" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\catalog\xspec-160_schematron.xspec" -lib "%SAXON_CP%" -Dtest.type=s -Dxspec.phase=#ALL -Dclean.output.dir=true -Dcatalog="%CD%\catalog\xspec-160_catalog.xml" -lib "%XML_RESOLVER_CP%" + call :verify_retval 1 + call :verify_line -4 x "BUILD FAILED" + + rem Verify the build fails before cleanup + call :verify_exist catalog\xspec\ + + rem Verify the build fails after Schematron setup + call :verify_exist catalog\xspec-160_schematron.xspec-compiled.xspec + call :verify_exist ..\tutorial\schematron\demo-04.sch-compiled.xsl + + rem Delete temp file + call :del catalog\xspec-160_schematron.xspec-compiled.xspec + call :del ..\tutorial\schematron\demo-04.sch-compiled.xsl + ) else ( + call :skip "test for Schematron Ant with catalog and default xspec.fail skipped" + ) + + call :teardown +endlocal + +setlocal + call :setup "Ant for Schematron with catalog and xspec.fail=false continues on test failure" + + if defined ANT_VERSION ( + call :run ant -buildfile "%CD%\..\build.xml" -Dxspec.xml="%CD%\catalog\xspec-160_schematron.xspec" -lib "%SAXON_CP%" -Dtest.type=s -Dxspec.phase=#ALL -Dclean.output.dir=true -Dcatalog="%CD%\catalog\xspec-160_catalog.xml" -lib "%XML_RESOLVER_CP%" -Dxspec.fail=false + call :verify_retval 0 + call :verify_line -2 x "BUILD SUCCESSFUL" + ) else ( + call :skip "test for Schematron Ant with catalog and xspec.fail=false skipped" + ) + + call :teardown +endlocal + +echo === END TEST CASES ================================================== + +rem +rem Go back to the initial directory +rem +popd + +rem +rem Retrieve the results and determine the exit code +rem +for /f "usebackq eol=# delims=" %%I in ("%RESULTS_FILE%") do if %%I EQU 0 set EXIT_CODE=%%I +for /f "usebackq eol=# delims=" %%I in ("%RESULTS_FILE%") do if %%I NEQ 0 set EXIT_CODE=%%I +if not defined EXIT_CODE ( + echo No test cases performed! + set EXIT_CODE=1 +) +if %EXIT_CODE% NEQ 0 ( + echo ---------- %RESULTS_FILE% + type "%RESULTS_FILE%" + echo ---------- +) +call :del "%RESULTS_FILE%" + +rem +rem Exit +rem +echo EXIT_CODE=%EXIT_CODE% +exit /b %EXIT_CODE% + +rem +rem Subroutines +rem + +:del + if exist %1 ( + del /q %1 + if errorlevel 1 call :failed "Failed to del: %~1" + ) + goto :EOF + +:mkdir + mkdir %1 + if errorlevel 1 call :failed "Failed to mkdir: %~1" + goto :EOF + +:rmdir + if exist %1 ( + call :del "%~1\*" + rmdir %1 + if errorlevel 1 call :failed "Failed to rmdir: %~1" + ) + goto :EOF + +:rmdir-s + if exist %1 ( + rmdir /s /q %1 + if errorlevel 1 call :failed "Failed to rmdir /s: %~1" + ) + goto :EOF + +:appveyor + if /i "%APPVEYOR%"=="True" appveyor %* + goto :EOF + +:setup + rem + rem Report 'Running' + rem + set CASE_NAME=%~1 + call :appveyor AddTest "%CASE_NAME%" -Framework custom -Filename "%THIS_FILE_NX%" -Outcome Running + echo CASE: %CASE_NAME% + (echo # %CASE_NAME%) >> "%RESULTS_FILE%" + + rem + rem Create the work directory + rem + call :mkdir "%WORK_DIR%" + + rem + rem Create the XSpec output directories + rem + call :mkdir ..\test\xspec + call :mkdir ..\tutorial\xspec + call :mkdir ..\tutorial\schematron\xspec + + goto :EOF + +:teardown + rem + rem Remove the XSpec output directories + rem + call :rmdir ..\test\xspec + call :rmdir ..\tutorial\xspec + call :rmdir ..\tutorial\schematron\xspec + + rem + rem Remove the work directory + rem + call :rmdir-s "%WORK_DIR%" + + rem + rem Report 'Passed' + rem + if %CASE_RESULT% EQU 0 ( + echo ...PASS + (echo %CASE_RESULT%) >> "%RESULTS_FILE%" + call :appveyor UpdateTest "%CASE_NAME%" -Framework custom -Filename "%THIS_FILE_NX%" -Outcome Passed -Duration 0 + ) + goto :EOF + +:verified + echo ...Verified: %~1 + if not defined CASE_RESULT set CASE_RESULT=0 + goto :EOF + +:failed + echo ...FAIL: %~1 + set CASE_RESULT=1 + (echo %CASE_RESULT%) >> "%RESULTS_FILE%" + if defined CASE_NAME call :appveyor UpdateTest "%CASE_NAME%" -Framework custom -Filename "%THIS_FILE_NX%" -Outcome Failed -Duration 0 -ErrorMessage %1 + goto :EOF + +:skip + echo ...SKIP: %~1 + set CASE_RESULT=2 + (echo # %~1) >> "%RESULTS_FILE%" + call :appveyor UpdateTest "%CASE_NAME%" -Framework custom -Filename "%THIS_FILE_NX%" -Outcome Skipped -Duration 0 + goto :EOF + +:run + rem + rem Executes the specified command line. + rem Saves stdout and stderr in a single file. + rem Saves the return value in RETVAL. + rem + + rem + rem Print parameters and env vars + rem + echo ...%0 @ %TIME%: %* + rem set SAXON_ + rem set TEST_ + rem set XSPEC + + rem + rem Run + rem + "%COMSPEC%" /c %* > "%OUTPUT_RAW%" 2>&1 + set RETVAL=%ERRORLEVEL% + + rem + rem Remove the JAVA_TOOL_OPTIONS output, to keep the line numbers predictable. + rem Remove the empty lines, to be compatible with Bats $lines. + rem Prefix each line with its line number. + rem + findstr /b /l /v /c:"Picked up JAVA_TOOL_OPTIONS:" "%OUTPUT_RAW%" | findstr /r /v /c:"^$" | find /v /n "" > "%OUTPUT_LINENUM%" + + goto :EOF + +:verify_retval + if %RETVAL% EQU %1 ( + call :verified "Return value: %RETVAL%" + ) else ( + call :failed "Return value is %RETVAL%. Expected %~1." + echo ---------- %OUTPUT_RAW% + type "%OUTPUT_RAW%" + echo ---------- + ) + goto :EOF + +:verify_line + if defined DEBUG ( + echo *: %* + echo 0: %0 + echo 1: %1 + echo 2: %2 + echo 3: %3 + ) + rem + rem Checks to see if the specified line of the output log file matches exactly the specified string + rem + rem Parameters: + rem 1: Line number. Starts with 1, unlike Bats $lines which starts with 0. + rem Negative values indicate the reverse order. -1 is the last line. -2 is the line before the last line, and so on. + rem 2: Operator + rem x : Exact match ("=" on Bats) + rem r : Compare with regular expression ("=~" on Bats) + rem 3: Expected string + rem For 'r' operator, always evaluated as if the expression started with "^". + rem + + set LINE_NUMBER=%~1 + if %LINE_NUMBER% LSS 0 for /f %%I in ('type "%OUTPUT_LINENUM%" ^| find /v /c ""') do set /a LINE_NUMBER+=%%I+1 + + rem + rem Search the line-numbered output log file + rem + if /i "%~2"=="x" ( + findstr /l /x /c:"[%LINE_NUMBER%]%~3" "%OUTPUT_LINENUM%" > NUL + ) else if /i "%~2"=="r" ( + findstr /b /r /c:"\[%LINE_NUMBER%\]%~3" "%OUTPUT_LINENUM%" > NUL + ) else ( + call :failed "Bad operator: %~2" + goto :EOF + ) + if errorlevel 1 ( + call :failed "Line %LINE_NUMBER% does not match the expected string" + echo ---------- %OUTPUT_LINENUM% + type "%OUTPUT_LINENUM%" + echo ---------- + ) else ( + call :verified "Line %LINE_NUMBER%" + ) + goto :EOF + +:verify_exist + if exist %1 ( + call :verified "Exist: %~1" + ) else ( + call :failed "Not exist: %~1" + ) + goto :EOF + +:verify_not_exist + if exist %1 ( + call :failed "Exist: %~1" + ) else ( + call :verified "Not exist: %~1" + ) + goto :EOF \ No newline at end of file diff --git a/test/xspec-focus-2.xspec b/test/xspec-focus-2.xspec index 140690d88..3322e453e 100644 --- a/test/xspec-focus-2.xspec +++ b/test/xspec-focus-2.xspec @@ -2,93 +2,66 @@ <!-- ===================================================================== --> <!-- File: test/xspec-pending.xspec --> <!-- Author: Florent Georges --> -<!-- URI: http://xspec.googlecode.com/ --> <!-- Tags: --> <!-- Copyright (c) 2010 Jeni Tennsion (see end of file.) --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - -<?oxygen RNGSchema="http://xspec.googlecode.com/svn/trunk/xspec.rnc" type="compact"?> - -<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:my="http://example.org/ns/my" - query="http://example.org/ns/my" - query-at="xspec-tested.xql" - stylesheet="xspec-tested.xsl"> - - <!-- - Test @focus and pending toghether (both @pending and t:pending). +<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="http://example.org/ns/my" query="http://example.org/ns/my" query-at="xspec-tested.xql" stylesheet="xspec-tested.xsl"> + <!-- + Test @focus and pending together (both @pending and t:pending). --> - <!-- + <!-- Test x:pending. --> - <t:pending label="testing pending element"> - - <t:scenario label="pending call (element)"> - <t:call function="my:square"> - <t:param select="3"/> - </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> - - <t:scenario label="pending call (element) + focus" focus="focus"> - <t:call function="my:square"> - <t:param select="3"/> - </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> - - </t:pending> - - <!-- - Non-pending scenarios. - --> - <t:scenario label="call"> + <t:pending label="testing x:pending"> + <t:scenario label="an unfocused correct scenario in x:pending must be Pending"> <t:call function="my:square"> - <t:param select="3"/> + <t:param select="3"/> </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> - - <t:scenario label="call + focus" focus="focus"> + <t:expect label="it would return Success if it were not Pending" test="$x:result eq 9"/> + </t:scenario> + <t:scenario label="a focused correct scenario in x:pending" focus="testing @focus"> <t:call function="my:square"> - <t:param select="3"/> + <t:param select="3"/> </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> + <t:expect label="must execute the test and return Success" test="$x:result eq 9"/> + </t:scenario> + </t:pending> - <!-- - Test @pending. + <!-- + Non-pending scenarios. --> - <t:scenario label="pending call (attribute)" - pending="testing pending attribute"> - <t:call function="my:square"> - <t:param select="3"/> - </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> + <t:scenario label="a non-pending correct scenario alongside a focused scenario must be Pending"> + <t:call function="my:square"> + <t:param select="3"/> + </t:call> + <t:expect label="it would return Success if it were not Pending" test="$x:result eq 9"/> + </t:scenario> + <t:scenario label="a focused correct scenario alongside another focused scenario" focus="testing @focus"> + <t:call function="my:square"> + <t:param select="3"/> + </t:call> + <t:expect label="must execute the test and return Success" test="$x:result eq 9"/> + </t:scenario> - <!-- does not make sense, really, but to see how the implem reacts --> - <t:scenario label="pending call (attribute) + focus" - pending="testing pending attribute" - focus="focus"> - <t:call function="my:square"> - <t:param select="3"/> - </t:call> - <t:expect label="the result" test="$x:result eq 9"/> - <t:expect label="the result" assert="$x:result eq 9"/> - </t:scenario> + <!-- + Test @pending. + --> + <t:scenario label="a correct scenario with @pending must be Pending" pending="testing @pending"> + <t:call function="my:square"> + <t:param select="3"/> + </t:call> + <t:expect label="it would return Success if it were not Pending" test="$x:result eq 9"/> + </t:scenario> + <!-- does not make sense, really, but to see how the implem reacts --> + <t:scenario label="a correct scenario with both @pending and @focus (not recommended as ambiguous)" pending="testing @pending" focus="testing @focus"> + <t:call function="my:square"> + <t:param select="3"/> + </t:call> + <t:expect label="must execute the test and return Success" test="$x:result eq 9"/> + </t:scenario> </t:description> - - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. --> <!-- --> diff --git a/test/xspec-junit.xspec b/test/xspec-junit.xspec new file mode 100644 index 000000000..9e10616d4 --- /dev/null +++ b/test/xspec-junit.xspec @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="../src/reporter/junit-report.xsl" xslt-version="3.0"> + + <x:scenario label="When processing a successful test"> + <x:context> + <x:test successful="true"> + <x:label>Successful test</x:label> + <x:result> + <p>Foo</p> + </x:result> + <x:expect> + <p>Foo</p> + </x:expect> + </x:test> + </x:context> + + <x:expect label="convert it to test case with status passed"> + <testcase name="Successful test" status="passed"/> + </x:expect> + </x:scenario> + + + <x:scenario label="When processing a failing test"> + <x:context> + <x:test successful="false"> + <x:label>failing test</x:label> + <x:result> + <p>Foo</p> + </x:result> + <x:expect> + <p>Bar</p> + </x:expect> + </x:test> + </x:context> + + + <x:expect label="convert it to test case with status failed"> + <testcase name="failing test" + status="failed"> + <failure message="expect assertion failed"><x:expect xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:test="http://www.jenitennison.com/xslt/unit-test" xmlns:x="http://www.jenitennison.com/xslt/xspec"><p>Bar</p></x:expect></failure> + </testcase> + </x:expect> + </x:scenario> + + + <x:scenario label="When processing successful and failing tests"> + <x:context> + <x:test successful="true"> + <x:label>Successful test</x:label> + <x:result> + <p>Foo</p> + </x:result> + <x:expect> + <p>Foo</p> + </x:expect> + </x:test> + <x:test successful="false"> + <x:label>Failing test</x:label> + <x:result> + <p>Foo</p> + </x:result> + <x:expect> + <p>Bar</p> + </x:expect> + </x:test> + </x:context> + + <x:expect label="convert it to test cases with status passed and failing"> + <testcase name="Successful test" status="passed"/> + <testcase name="Failing test" + status="failed"> + <failure message="expect assertion failed"><x:expect xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:test="http://www.jenitennison.com/xslt/unit-test" xmlns:x="http://www.jenitennison.com/xslt/xspec"><p>Bar</p></x:expect></failure> + </testcase> + </x:expect> + </x:scenario> + + +</x:description> diff --git a/test/xspec-result-naming-collision.xml b/test/xspec-result-naming-collision.xml new file mode 100644 index 000000000..086fc1c99 --- /dev/null +++ b/test/xspec-result-naming-collision.xml @@ -0,0 +1,1003 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document> + <entry>1</entry> + <entry>2</entry> + <entry>3</entry> + <entry>4</entry> + <entry>5</entry> + <entry>6</entry> + <entry>7</entry> + <entry>8</entry> + <entry>9</entry> + <entry>10</entry> + <entry>11</entry> + <entry>12</entry> + <entry>13</entry> + <entry>14</entry> + <entry>15</entry> + <entry>16</entry> + <entry>17</entry> + <entry>18</entry> + <entry>19</entry> + <entry>20</entry> + <entry>21</entry> + <entry>22</entry> + <entry>23</entry> + <entry>24</entry> + <entry>25</entry> + <entry>26</entry> + <entry>27</entry> + <entry>28</entry> + <entry>29</entry> + <entry>30</entry> + <entry>31</entry> + <entry>32</entry> + <entry>33</entry> + <entry>34</entry> + <entry>35</entry> + <entry>36</entry> + <entry>37</entry> + <entry>38</entry> + <entry>39</entry> + <entry>40</entry> + <entry>41</entry> + <entry>42</entry> + <entry>43</entry> + <entry>44</entry> + <entry>45</entry> + <entry>46</entry> + <entry>47</entry> + <entry>48</entry> + <entry>49</entry> + <entry>50</entry> + <entry>51</entry> + <entry>52</entry> + <entry>53</entry> + <entry>54</entry> + <entry>55</entry> + <entry>56</entry> + <entry>57</entry> + <entry>58</entry> + <entry>59</entry> + <entry>60</entry> + <entry>61</entry> + <entry>62</entry> + <entry>63</entry> + <entry>64</entry> + <entry>65</entry> + <entry>66</entry> + <entry>67</entry> + <entry>68</entry> + <entry>69</entry> + <entry>70</entry> + <entry>71</entry> + <entry>72</entry> + <entry>73</entry> + <entry>74</entry> + <entry>75</entry> + <entry>76</entry> + <entry>77</entry> + <entry>78</entry> + <entry>79</entry> + <entry>80</entry> + <entry>81</entry> + <entry>82</entry> + <entry>83</entry> + <entry>84</entry> + <entry>85</entry> + <entry>86</entry> + <entry>87</entry> + <entry>88</entry> + <entry>89</entry> + <entry>90</entry> + <entry>91</entry> + <entry>92</entry> + <entry>93</entry> + <entry>94</entry> + <entry>95</entry> + <entry>96</entry> + <entry>97</entry> + <entry>98</entry> + <entry>99</entry> + <entry>100</entry> + <entry>101</entry> + <entry>102</entry> + <entry>103</entry> + <entry>104</entry> + <entry>105</entry> + <entry>106</entry> + <entry>107</entry> + <entry>108</entry> + <entry>109</entry> + <entry>110</entry> + <entry>111</entry> + <entry>112</entry> + <entry>113</entry> + <entry>114</entry> + <entry>115</entry> + <entry>116</entry> + <entry>117</entry> + <entry>118</entry> + <entry>119</entry> + <entry>120</entry> + <entry>121</entry> + <entry>122</entry> + <entry>123</entry> + <entry>124</entry> + <entry>125</entry> + <entry>126</entry> + <entry>127</entry> + <entry>128</entry> + <entry>129</entry> + <entry>130</entry> + <entry>131</entry> + <entry>132</entry> + <entry>133</entry> + <entry>134</entry> + <entry>135</entry> + <entry>136</entry> + <entry>137</entry> + <entry>138</entry> + <entry>139</entry> + <entry>140</entry> + <entry>141</entry> + <entry>142</entry> + <entry>143</entry> + <entry>144</entry> + <entry>145</entry> + <entry>146</entry> + <entry>147</entry> + <entry>148</entry> + <entry>149</entry> + <entry>150</entry> + <entry>151</entry> + <entry>152</entry> + <entry>153</entry> + <entry>154</entry> + <entry>155</entry> + <entry>156</entry> + <entry>157</entry> + <entry>158</entry> + <entry>159</entry> + <entry>160</entry> + <entry>161</entry> + <entry>162</entry> + <entry>163</entry> + <entry>164</entry> + <entry>165</entry> + <entry>166</entry> + <entry>167</entry> + <entry>168</entry> + <entry>169</entry> + <entry>170</entry> + <entry>171</entry> + <entry>172</entry> + <entry>173</entry> + <entry>174</entry> + <entry>175</entry> + <entry>176</entry> + <entry>177</entry> + <entry>178</entry> + <entry>179</entry> + <entry>180</entry> + <entry>181</entry> + <entry>182</entry> + <entry>183</entry> + <entry>184</entry> + <entry>185</entry> + <entry>186</entry> + <entry>187</entry> + <entry>188</entry> + <entry>189</entry> + <entry>190</entry> + <entry>191</entry> + <entry>192</entry> + <entry>193</entry> + <entry>194</entry> + <entry>195</entry> + <entry>196</entry> + <entry>197</entry> + <entry>198</entry> + <entry>199</entry> + <entry>200</entry> + <entry>201</entry> + <entry>202</entry> + <entry>203</entry> + <entry>204</entry> + <entry>205</entry> + <entry>206</entry> + <entry>207</entry> + <entry>208</entry> + <entry>209</entry> + <entry>210</entry> + <entry>211</entry> + <entry>212</entry> + <entry>213</entry> + <entry>214</entry> + <entry>215</entry> + <entry>216</entry> + <entry>217</entry> + <entry>218</entry> + <entry>219</entry> + <entry>220</entry> + <entry>221</entry> + <entry>222</entry> + <entry>223</entry> + <entry>224</entry> + <entry>225</entry> + <entry>226</entry> + <entry>227</entry> + <entry>228</entry> + <entry>229</entry> + <entry>230</entry> + <entry>231</entry> + <entry>232</entry> + <entry>233</entry> + <entry>234</entry> + <entry>235</entry> + <entry>236</entry> + <entry>237</entry> + <entry>238</entry> + <entry>239</entry> + <entry>240</entry> + <entry>241</entry> + <entry>242</entry> + <entry>243</entry> + <entry>244</entry> + <entry>245</entry> + <entry>246</entry> + <entry>247</entry> + <entry>248</entry> + <entry>249</entry> + <entry>250</entry> + <entry>251</entry> + <entry>252</entry> + <entry>253</entry> + <entry>254</entry> + <entry>255</entry> + <entry>256</entry> + <entry>257</entry> + <entry>258</entry> + <entry>259</entry> + <entry>260</entry> + <entry>261</entry> + <entry>262</entry> + <entry>263</entry> + <entry>264</entry> + <entry>265</entry> + <entry>266</entry> + <entry>267</entry> + <entry>268</entry> + <entry>269</entry> + <entry>270</entry> + <entry>271</entry> + <entry>272</entry> + <entry>273</entry> + <entry>274</entry> + <entry>275</entry> + <entry>276</entry> + <entry>277</entry> + <entry>278</entry> + <entry>279</entry> + <entry>280</entry> + <entry>281</entry> + <entry>282</entry> + <entry>283</entry> + <entry>284</entry> + <entry>285</entry> + <entry>286</entry> + <entry>287</entry> + <entry>288</entry> + <entry>289</entry> + <entry>290</entry> + <entry>291</entry> + <entry>292</entry> + <entry>293</entry> + <entry>294</entry> + <entry>295</entry> + <entry>296</entry> + <entry>297</entry> + <entry>298</entry> + <entry>299</entry> + <entry>300</entry> + <entry>301</entry> + <entry>302</entry> + <entry>303</entry> + <entry>304</entry> + <entry>305</entry> + <entry>306</entry> + <entry>307</entry> + <entry>308</entry> + <entry>309</entry> + <entry>310</entry> + <entry>311</entry> + <entry>312</entry> + <entry>313</entry> + <entry>314</entry> + <entry>315</entry> + <entry>316</entry> + <entry>317</entry> + <entry>318</entry> + <entry>319</entry> + <entry>320</entry> + <entry>321</entry> + <entry>322</entry> + <entry>323</entry> + <entry>324</entry> + <entry>325</entry> + <entry>326</entry> + <entry>327</entry> + <entry>328</entry> + <entry>329</entry> + <entry>330</entry> + <entry>331</entry> + <entry>332</entry> + <entry>333</entry> + <entry>334</entry> + <entry>335</entry> + <entry>336</entry> + <entry>337</entry> + <entry>338</entry> + <entry>339</entry> + <entry>340</entry> + <entry>341</entry> + <entry>342</entry> + <entry>343</entry> + <entry>344</entry> + <entry>345</entry> + <entry>346</entry> + <entry>347</entry> + <entry>348</entry> + <entry>349</entry> + <entry>350</entry> + <entry>351</entry> + <entry>352</entry> + <entry>353</entry> + <entry>354</entry> + <entry>355</entry> + <entry>356</entry> + <entry>357</entry> + <entry>358</entry> + <entry>359</entry> + <entry>360</entry> + <entry>361</entry> + <entry>362</entry> + <entry>363</entry> + <entry>364</entry> + <entry>365</entry> + <entry>366</entry> + <entry>367</entry> + <entry>368</entry> + <entry>369</entry> + <entry>370</entry> + <entry>371</entry> + <entry>372</entry> + <entry>373</entry> + <entry>374</entry> + <entry>375</entry> + <entry>376</entry> + <entry>377</entry> + <entry>378</entry> + <entry>379</entry> + <entry>380</entry> + <entry>381</entry> + <entry>382</entry> + <entry>383</entry> + <entry>384</entry> + <entry>385</entry> + <entry>386</entry> + <entry>387</entry> + <entry>388</entry> + <entry>389</entry> + <entry>390</entry> + <entry>391</entry> + <entry>392</entry> + <entry>393</entry> + <entry>394</entry> + <entry>395</entry> + <entry>396</entry> + <entry>397</entry> + <entry>398</entry> + <entry>399</entry> + <entry>400</entry> + <entry>401</entry> + <entry>402</entry> + <entry>403</entry> + <entry>404</entry> + <entry>405</entry> + <entry>406</entry> + <entry>407</entry> + <entry>408</entry> + <entry>409</entry> + <entry>410</entry> + <entry>411</entry> + <entry>412</entry> + <entry>413</entry> + <entry>414</entry> + <entry>415</entry> + <entry>416</entry> + <entry>417</entry> + <entry>418</entry> + <entry>419</entry> + <entry>420</entry> + <entry>421</entry> + <entry>422</entry> + <entry>423</entry> + <entry>424</entry> + <entry>425</entry> + <entry>426</entry> + <entry>427</entry> + <entry>428</entry> + <entry>429</entry> + <entry>430</entry> + <entry>431</entry> + <entry>432</entry> + <entry>433</entry> + <entry>434</entry> + <entry>435</entry> + <entry>436</entry> + <entry>437</entry> + <entry>438</entry> + <entry>439</entry> + <entry>440</entry> + <entry>441</entry> + <entry>442</entry> + <entry>443</entry> + <entry>444</entry> + <entry>445</entry> + <entry>446</entry> + <entry>447</entry> + <entry>448</entry> + <entry>449</entry> + <entry>450</entry> + <entry>451</entry> + <entry>452</entry> + <entry>453</entry> + <entry>454</entry> + <entry>455</entry> + <entry>456</entry> + <entry>457</entry> + <entry>458</entry> + <entry>459</entry> + <entry>460</entry> + <entry>461</entry> + <entry>462</entry> + <entry>463</entry> + <entry>464</entry> + <entry>465</entry> + <entry>466</entry> + <entry>467</entry> + <entry>468</entry> + <entry>469</entry> + <entry>470</entry> + <entry>471</entry> + <entry>472</entry> + <entry>473</entry> + <entry>474</entry> + <entry>475</entry> + <entry>476</entry> + <entry>477</entry> + <entry>478</entry> + <entry>479</entry> + <entry>480</entry> + <entry>481</entry> + <entry>482</entry> + <entry>483</entry> + <entry>484</entry> + <entry>485</entry> + <entry>486</entry> + <entry>487</entry> + <entry>488</entry> + <entry>489</entry> + <entry>490</entry> + <entry>491</entry> + <entry>492</entry> + <entry>493</entry> + <entry>494</entry> + <entry>495</entry> + <entry>496</entry> + <entry>497</entry> + <entry>498</entry> + <entry>499</entry> + <entry>500</entry> + <entry>501</entry> + <entry>502</entry> + <entry>503</entry> + <entry>504</entry> + <entry>505</entry> + <entry>506</entry> + <entry>507</entry> + <entry>508</entry> + <entry>509</entry> + <entry>510</entry> + <entry>511</entry> + <entry>512</entry> + <entry>513</entry> + <entry>514</entry> + <entry>515</entry> + <entry>516</entry> + <entry>517</entry> + <entry>518</entry> + <entry>519</entry> + <entry>520</entry> + <entry>521</entry> + <entry>522</entry> + <entry>523</entry> + <entry>524</entry> + <entry>525</entry> + <entry>526</entry> + <entry>527</entry> + <entry>528</entry> + <entry>529</entry> + <entry>530</entry> + <entry>531</entry> + <entry>532</entry> + <entry>533</entry> + <entry>534</entry> + <entry>535</entry> + <entry>536</entry> + <entry>537</entry> + <entry>538</entry> + <entry>539</entry> + <entry>540</entry> + <entry>541</entry> + <entry>542</entry> + <entry>543</entry> + <entry>544</entry> + <entry>545</entry> + <entry>546</entry> + <entry>547</entry> + <entry>548</entry> + <entry>549</entry> + <entry>550</entry> + <entry>551</entry> + <entry>552</entry> + <entry>553</entry> + <entry>554</entry> + <entry>555</entry> + <entry>556</entry> + <entry>557</entry> + <entry>558</entry> + <entry>559</entry> + <entry>560</entry> + <entry>561</entry> + <entry>562</entry> + <entry>563</entry> + <entry>564</entry> + <entry>565</entry> + <entry>566</entry> + <entry>567</entry> + <entry>568</entry> + <entry>569</entry> + <entry>570</entry> + <entry>571</entry> + <entry>572</entry> + <entry>573</entry> + <entry>574</entry> + <entry>575</entry> + <entry>576</entry> + <entry>577</entry> + <entry>578</entry> + <entry>579</entry> + <entry>580</entry> + <entry>581</entry> + <entry>582</entry> + <entry>583</entry> + <entry>584</entry> + <entry>585</entry> + <entry>586</entry> + <entry>587</entry> + <entry>588</entry> + <entry>589</entry> + <entry>590</entry> + <entry>591</entry> + <entry>592</entry> + <entry>593</entry> + <entry>594</entry> + <entry>595</entry> + <entry>596</entry> + <entry>597</entry> + <entry>598</entry> + <entry>599</entry> + <entry>600</entry> + <entry>601</entry> + <entry>602</entry> + <entry>603</entry> + <entry>604</entry> + <entry>605</entry> + <entry>606</entry> + <entry>607</entry> + <entry>608</entry> + <entry>609</entry> + <entry>610</entry> + <entry>611</entry> + <entry>612</entry> + <entry>613</entry> + <entry>614</entry> + <entry>615</entry> + <entry>616</entry> + <entry>617</entry> + <entry>618</entry> + <entry>619</entry> + <entry>620</entry> + <entry>621</entry> + <entry>622</entry> + <entry>623</entry> + <entry>624</entry> + <entry>625</entry> + <entry>626</entry> + <entry>627</entry> + <entry>628</entry> + <entry>629</entry> + <entry>630</entry> + <entry>631</entry> + <entry>632</entry> + <entry>633</entry> + <entry>634</entry> + <entry>635</entry> + <entry>636</entry> + <entry>637</entry> + <entry>638</entry> + <entry>639</entry> + <entry>640</entry> + <entry>641</entry> + <entry>642</entry> + <entry>643</entry> + <entry>644</entry> + <entry>645</entry> + <entry>646</entry> + <entry>647</entry> + <entry>648</entry> + <entry>649</entry> + <entry>650</entry> + <entry>651</entry> + <entry>652</entry> + <entry>653</entry> + <entry>654</entry> + <entry>655</entry> + <entry>656</entry> + <entry>657</entry> + <entry>658</entry> + <entry>659</entry> + <entry>660</entry> + <entry>661</entry> + <entry>662</entry> + <entry>663</entry> + <entry>664</entry> + <entry>665</entry> + <entry>666</entry> + <entry>667</entry> + <entry>668</entry> + <entry>669</entry> + <entry>670</entry> + <entry>671</entry> + <entry>672</entry> + <entry>673</entry> + <entry>674</entry> + <entry>675</entry> + <entry>676</entry> + <entry>677</entry> + <entry>678</entry> + <entry>679</entry> + <entry>680</entry> + <entry>681</entry> + <entry>682</entry> + <entry>683</entry> + <entry>684</entry> + <entry>685</entry> + <entry>686</entry> + <entry>687</entry> + <entry>688</entry> + <entry>689</entry> + <entry>690</entry> + <entry>691</entry> + <entry>692</entry> + <entry>693</entry> + <entry>694</entry> + <entry>695</entry> + <entry>696</entry> + <entry>697</entry> + <entry>698</entry> + <entry>699</entry> + <entry>700</entry> + <entry>701</entry> + <entry>702</entry> + <entry>703</entry> + <entry>704</entry> + <entry>705</entry> + <entry>706</entry> + <entry>707</entry> + <entry>708</entry> + <entry>709</entry> + <entry>710</entry> + <entry>711</entry> + <entry>712</entry> + <entry>713</entry> + <entry>714</entry> + <entry>715</entry> + <entry>716</entry> + <entry>717</entry> + <entry>718</entry> + <entry>719</entry> + <entry>720</entry> + <entry>721</entry> + <entry>722</entry> + <entry>723</entry> + <entry>724</entry> + <entry>725</entry> + <entry>726</entry> + <entry>727</entry> + <entry>728</entry> + <entry>729</entry> + <entry>730</entry> + <entry>731</entry> + <entry>732</entry> + <entry>733</entry> + <entry>734</entry> + <entry>735</entry> + <entry>736</entry> + <entry>737</entry> + <entry>738</entry> + <entry>739</entry> + <entry>740</entry> + <entry>741</entry> + <entry>742</entry> + <entry>743</entry> + <entry>744</entry> + <entry>745</entry> + <entry>746</entry> + <entry>747</entry> + <entry>748</entry> + <entry>749</entry> + <entry>750</entry> + <entry>751</entry> + <entry>752</entry> + <entry>753</entry> + <entry>754</entry> + <entry>755</entry> + <entry>756</entry> + <entry>757</entry> + <entry>758</entry> + <entry>759</entry> + <entry>760</entry> + <entry>761</entry> + <entry>762</entry> + <entry>763</entry> + <entry>764</entry> + <entry>765</entry> + <entry>766</entry> + <entry>767</entry> + <entry>768</entry> + <entry>769</entry> + <entry>770</entry> + <entry>771</entry> + <entry>772</entry> + <entry>773</entry> + <entry>774</entry> + <entry>775</entry> + <entry>776</entry> + <entry>777</entry> + <entry>778</entry> + <entry>779</entry> + <entry>780</entry> + <entry>781</entry> + <entry>782</entry> + <entry>783</entry> + <entry>784</entry> + <entry>785</entry> + <entry>786</entry> + <entry>787</entry> + <entry>788</entry> + <entry>789</entry> + <entry>790</entry> + <entry>791</entry> + <entry>792</entry> + <entry>793</entry> + <entry>794</entry> + <entry>795</entry> + <entry>796</entry> + <entry>797</entry> + <entry>798</entry> + <entry>799</entry> + <entry>800</entry> + <entry>801</entry> + <entry>802</entry> + <entry>803</entry> + <entry>804</entry> + <entry>805</entry> + <entry>806</entry> + <entry>807</entry> + <entry>808</entry> + <entry>809</entry> + <entry>810</entry> + <entry>811</entry> + <entry>812</entry> + <entry>813</entry> + <entry>814</entry> + <entry>815</entry> + <entry>816</entry> + <entry>817</entry> + <entry>818</entry> + <entry>819</entry> + <entry>820</entry> + <entry>821</entry> + <entry>822</entry> + <entry>823</entry> + <entry>824</entry> + <entry>825</entry> + <entry>826</entry> + <entry>827</entry> + <entry>828</entry> + <entry>829</entry> + <entry>830</entry> + <entry>831</entry> + <entry>832</entry> + <entry>833</entry> + <entry>834</entry> + <entry>835</entry> + <entry>836</entry> + <entry>837</entry> + <entry>838</entry> + <entry>839</entry> + <entry>840</entry> + <entry>841</entry> + <entry>842</entry> + <entry>843</entry> + <entry>844</entry> + <entry>845</entry> + <entry>846</entry> + <entry>847</entry> + <entry>848</entry> + <entry>849</entry> + <entry>850</entry> + <entry>851</entry> + <entry>852</entry> + <entry>853</entry> + <entry>854</entry> + <entry>855</entry> + <entry>856</entry> + <entry>857</entry> + <entry>858</entry> + <entry>859</entry> + <entry>860</entry> + <entry>861</entry> + <entry>862</entry> + <entry>863</entry> + <entry>864</entry> + <entry>865</entry> + <entry>866</entry> + <entry>867</entry> + <entry>868</entry> + <entry>869</entry> + <entry>870</entry> + <entry>871</entry> + <entry>872</entry> + <entry>873</entry> + <entry>874</entry> + <entry>875</entry> + <entry>876</entry> + <entry>877</entry> + <entry>878</entry> + <entry>879</entry> + <entry>880</entry> + <entry>881</entry> + <entry>882</entry> + <entry>883</entry> + <entry>884</entry> + <entry>885</entry> + <entry>886</entry> + <entry>887</entry> + <entry>888</entry> + <entry>889</entry> + <entry>890</entry> + <entry>891</entry> + <entry>892</entry> + <entry>893</entry> + <entry>894</entry> + <entry>895</entry> + <entry>896</entry> + <entry>897</entry> + <entry>898</entry> + <entry>899</entry> + <entry>900</entry> + <entry>901</entry> + <entry>902</entry> + <entry>903</entry> + <entry>904</entry> + <entry>905</entry> + <entry>906</entry> + <entry>907</entry> + <entry>908</entry> + <entry>909</entry> + <entry>910</entry> + <entry>911</entry> + <entry>912</entry> + <entry>913</entry> + <entry>914</entry> + <entry>915</entry> + <entry>916</entry> + <entry>917</entry> + <entry>918</entry> + <entry>919</entry> + <entry>920</entry> + <entry>921</entry> + <entry>922</entry> + <entry>923</entry> + <entry>924</entry> + <entry>925</entry> + <entry>926</entry> + <entry>927</entry> + <entry>928</entry> + <entry>929</entry> + <entry>930</entry> + <entry>931</entry> + <entry>932</entry> + <entry>933</entry> + <entry>934</entry> + <entry>935</entry> + <entry>936</entry> + <entry>937</entry> + <entry>938</entry> + <entry>939</entry> + <entry>940</entry> + <entry>941</entry> + <entry>942</entry> + <entry>943</entry> + <entry>944</entry> + <entry>945</entry> + <entry>946</entry> + <entry>947</entry> + <entry>948</entry> + <entry>949</entry> + <entry>950</entry> + <entry>951</entry> + <entry>952</entry> + <entry>953</entry> + <entry>954</entry> + <entry>955</entry> + <entry>956</entry> + <entry>957</entry> + <entry>958</entry> + <entry>959</entry> + <entry>960</entry> + <entry>961</entry> + <entry>962</entry> + <entry>963</entry> + <entry>964</entry> + <entry>965</entry> + <entry>966</entry> + <entry>967</entry> + <entry>968</entry> + <entry>969</entry> + <entry>970</entry> + <entry>971</entry> + <entry>972</entry> + <entry>973</entry> + <entry>974</entry> + <entry>975</entry> + <entry>976</entry> + <entry>977</entry> + <entry>978</entry> + <entry>979</entry> + <entry>980</entry> + <entry>981</entry> + <entry>982</entry> + <entry>983</entry> + <entry>984</entry> + <entry>985</entry> + <entry>986</entry> + <entry>987</entry> + <entry>988</entry> + <entry>989</entry> + <entry>990</entry> + <entry>991</entry> + <entry>992</entry> + <entry>993</entry> + <entry>994</entry> + <entry>995</entry> + <entry>996</entry> + <entry>997</entry> + <entry>998</entry> + <entry>999</entry> + <entry>1000</entry> +</document> diff --git a/test/xspec-result-naming-collision.xslt b/test/xspec-result-naming-collision.xslt new file mode 100644 index 000000000..012eb4d07 --- /dev/null +++ b/test/xspec-result-naming-collision.xslt @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xspec-17="https://github.com/xspec/xspec/pull/17" xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" version="2.0"> + + <xsl:function name="xspec-17:read-document" as="document-node()?"> + <xsl:sequence select="doc('xspec-result-naming-collision.xml')"/> + </xsl:function> + +</xsl:stylesheet> diff --git a/test/xspec-result-naming-collision.xspec b/test/xspec-result-naming-collision.xspec new file mode 100644 index 000000000..236849724 --- /dev/null +++ b/test/xspec-result-naming-collision.xspec @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:xspec-17="https://github.com/xspec/xspec/pull/17" stylesheet="xspec-result-naming-collision.xslt"> + <!-- https://github.com/expath/xspec/issues/67 + test result naming collision when a function which reads a document containing more than 1000 node --> + <x:scenario label="scenario 1"> + <x:call function="xspec-17:read-document"/> + <x:expect>...</x:expect> + </x:scenario> + <x:scenario label="scenario 2"> + <x:call function="xspec-17:read-document"/> + <x:expect>...</x:expect> + </x:scenario> +</x:description> diff --git a/test/xspec-tested.xql b/test/xspec-tested.xql index c9855990e..9b5538ebf 100644 --- a/test/xspec-tested.xql +++ b/test/xspec-tested.xql @@ -1,7 +1,6 @@ (::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::) (: File: test/xspec-tested.xql :) (: Author: Jeni Tennsion :) -(: URI: http://xspec.googlecode.com/ :) (: Tags: :) (: Copyright (c) 2010 Jeni Tennsion (see end of file.) :) (: ------------------------------------------------------------------------ :) diff --git a/test/xspec-tested.xsl b/test/xspec-tested.xsl index 299457969..fdf92bff9 100644 --- a/test/xspec-tested.xsl +++ b/test/xspec-tested.xsl @@ -2,7 +2,6 @@ <!-- ===================================================================== --> <!-- File: test/xspec-tested.xsl --> <!-- Author: Jeni Tennsion --> -<!-- URI: http://xspec.googlecode.com/ --> <!-- Tags: --> <!-- Copyright (c) 2010 Jeni Tennsion (see end of file.) --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> diff --git a/test/xspec-variable.xspec b/test/xspec-variable.xspec index 2e2dd0cce..49f2f64a2 100644 --- a/test/xspec-variable.xspec +++ b/test/xspec-variable.xspec @@ -2,51 +2,33 @@ <!-- ===================================================================== --> <!-- File: test/xspec-variable.xspec --> <!-- Author: Florent Georges --> -<!-- URI: http://xspec.googlecode.com/ --> <!-- Tags: --> <!-- Copyright (c) 2010 Jeni Tennsion (see end of file.) --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - -<?oxygen RNGSchema="http://xspec.googlecode.com/svn/trunk/xspec.rnc" type="compact"?> - -<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" - xmlns:xs="http://www.w3.org/2001/XMLSchema" - xmlns:my="http://example.org/ns/my" - query="http://example.org/ns/my" - query-at="xspec-tested.xql" - stylesheet="xspec-tested.xsl"> - - <t:variable name="test-data" href="xspec-variable.xml"/> - <t:variable name="test-3" select="$test-data/*/test[xs:integer(@num) eq 3]"/> - - <t:scenario label="call global var"> - <t:call function="my:square"> - <t:param select="$test-3/@num"/> - </t:call> - <t:expect label="the result" test="$x:result eq $test-3/xs:integer(@value)"/> - <t:expect label="the result" assert="$x:result eq $test-3/xs:integer(@value)"/> - </t:scenario> - - <!-- +<t:description xmlns:t="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="http://example.org/ns/my" query="http://example.org/ns/my" query-at="xspec-tested.xql" stylesheet="xspec-tested.xsl"> + <t:variable name="test-data" href="xspec-variable.xml"/> + <t:variable name="test-3" select="$test-data/*/test[xs:integer(@num) eq 3]"/> + <t:scenario label="call global var"> + <t:call function="my:square"> + <t:param select="$test-3/@num"/> + </t:call> + <t:expect label="the result" test="$x:result eq $test-3/xs:integer(@value)"/> + </t:scenario> + <!-- TODO: For now, x:call and x:context are pulled first, then templates are applied to other x:scenario/*. So the order is not respected, and the variable declaration is compiled after the call/appling! --> - <t:scenario label="call local var"> - <t:variable name="param" select="$test-3/@num"/> - <t:call function="my:square"> - <t:param select="$param"/> - </t:call> - <t:variable name="result" select="$test-3/@value"/> - <t:expect label="the result" test="$x:result eq xs:integer($result)"/> - <t:expect label="the result" assert="$x:result eq xs:integer($result)"/> - </t:scenario> - + <t:scenario label="call local var"> + <t:variable name="param" select="$test-3/@num"/> + <t:call function="my:square"> + <t:param select="$param"/> + </t:call> + <t:variable name="result" select="$test-3/@value"/> + <t:expect label="the result" test="$x:result eq xs:integer($result)"/> + </t:scenario> </t:description> - - <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS COMMENT. --> <!-- --> diff --git a/test/xspec-xslt3.xsl b/test/xspec-xslt3.xsl new file mode 100644 index 000000000..cb1ae7414 --- /dev/null +++ b/test/xspec-xslt3.xsl @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + exclude-result-prefixes="xs" version="3.0"> + + <xsl:template name="supportXPath3"> + <root> + <question><xsl:text>Does XSpec support XPath 3.0?</xsl:text></question> + <answer><xsl:value-of select="let $answer := 'Yes it does' return $answer"/></answer> + </root> + </xsl:template> + +</xsl:stylesheet> diff --git a/test/xspec-xslt3.xspec b/test/xspec-xslt3.xspec new file mode 100644 index 000000000..12d5601a2 --- /dev/null +++ b/test/xspec-xslt3.xspec @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" stylesheet="xspec-xslt3.xsl" xslt-version="3.0"> + <x:scenario label="When testing the string concatenation operator in XPath 3.0"> + <x:call template="supportXPath3"/> + <x:expect label="concatenate strings"> + <root> + <question>Does XSpec support XPath 3.0?</question> + <answer>Yes it does</answer> + </root> + </x:expect> + </x:scenario> +</x:description> diff --git a/test/xspec.bats b/test/xspec.bats new file mode 100644 index 000000000..6519736df --- /dev/null +++ b/test/xspec.bats @@ -0,0 +1,420 @@ +#!/usr/bin/env bats +#=============================================================================== +# +# USAGE: bats xspec.bats +# +# DESCRIPTION: Unit tests for script bin/xspec.sh +# +# INPUT: N/A +# +# OUTPUT: Unit tests results +# +# DEPENDENCIES: This script requires bats (https://github.com/sstephenson/bats) +# +# AUTHOR: Sandro Cirulli, github.com/cirulls +# +# LICENSE: MIT License (https://opensource.org/licenses/MIT) +# +#=============================================================================== + +setup() { + mkdir ../tutorial/xspec + mkdir ../test/xspec + mkdir ../tutorial/schematron/xspec +} + + +teardown() { + rm -rf ../tutorial/xspec + rm -rf ../test/xspec + rm -rf ../tutorial/schematron/xspec +} + + +@test "invoking xspec without arguments prints usage" { + run ../bin/xspec.sh + echo $output + [ "$status" -eq 1 ] + [ "${lines[2]}" = "Usage: xspec [-t|-q|-s|-c|-j|-h] filename [coverage]" ] +} + + +@test "invoking xspec with -s and -t prints error message" { + run ../bin/xspec.sh -s -t + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "-s and -t are mutually exclusive" ] +} + + +@test "invoking xspec with -s and -q prints error message" { + run ../bin/xspec.sh -s -q + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "-s and -q are mutually exclusive" ] +} + + +@test "invoking xspec with -t and -q prints error message" { + run ../bin/xspec.sh -t -q + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "-t and -q are mutually exclusive" ] +} + + +@test "invoking code coverage with Saxon9HE returns error message" { + export SAXON_CP=/path/to/saxon9he.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." ] +} + + +@test "invoking code coverage with Saxon9SA returns error message" { + export SAXON_CP=/path/to/saxon9sa.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." ] +} + + +@test "invoking code coverage with Saxon9 returns error message" { + export SAXON_CP=/path/to/saxon9.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." ] +} + + +@test "invoking code coverage with Saxon8SA returns error message" { + export SAXON_CP=/path/to/saxon8sa.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." ] +} + + +@test "invoking code coverage with Saxon8 returns error message" { + export SAXON_CP=/path/to/saxon8.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Code coverage requires Saxon extension functions which are available only under Saxon9EE or Saxon9PE." ] +} + + +@test "invoking code coverage with Saxon9EE creates test stylesheet" { + export SAXON_CP=/path/to/saxon9ee.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Creating Test Stylesheet..." ] +} + + +@test "invoking code coverage with Saxon9PE creates test stylesheet" { + export SAXON_CP=/path/to/saxon9pe.jar + run ../bin/xspec.sh -c ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Creating Test Stylesheet..." ] +} + + +@test "invoking xspec generates XML report file" { + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + run stat ../tutorial/xspec/escape-for-regex-result.xml + echo $output + [ "$status" -eq 0 ] +} + + +@test "invoking xspec generates HTML report file" { + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + run stat ../tutorial/xspec/escape-for-regex-result.html + echo $output + [ "$status" -eq 0 ] +} + + +@test "invoking xspec with -j option with Saxon8 returns error message" { + export SAXON_CP=/path/to/saxon8.jar + run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Saxon8 detected. JUnit report requires Saxon9." ] +} + + +@test "invoking xspec with -j option with Saxon8-SA returns error message" { + export SAXON_CP=/path/to/saxon8sa.jar + run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Saxon8 detected. JUnit report requires Saxon9." ] +} + + +@test "invoking xspec with -j option generates message with JUnit report location" { + run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 0 ] + [ "${lines[18]}" = "Report available at ../tutorial/xspec/escape-for-regex-junit.xml" ] +} + + +@test "invoking xspec with -j option generates XML report file" { + run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec + run stat ../tutorial/xspec/escape-for-regex-result.xml + echo $output + [ "$status" -eq 0 ] +} + + +@test "invoking xspec with -j option generates JUnit report file" { + run ../bin/xspec.sh -j ../tutorial/escape-for-regex.xspec + run stat ../tutorial/xspec/escape-for-regex-junit.xml + echo $output + [ "$status" -eq 0 ] +} + + +@test "invoking xspec with Saxon-B-9-1-0-8 creates test stylesheet" { + export SAXON_CP=/path/to/saxonb9-1-0-8.jar + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 1 ] + [ "${lines[1]}" = "Creating Test Stylesheet..." ] +} + + +@test "invoking xspec.sh with TEST_DIR already set externally generates files inside TEST_DIR" { + export TEST_DIR=/tmp + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 0 ] + [ "${lines[18]}" = "Report available at /tmp/escape-for-regex-result.html" ] +} + + +@test "invoking xspec.sh without TEST_DIR generates files in default location" { + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 0 ] + [ "${lines[18]}" = "Report available at ../tutorial/xspec/escape-for-regex-result.html" ] +} + + +@test "invoking xspec.sh that passes a non xs:boolean does not raise a warning #46" { + run ../bin/xspec.sh ../test/xspec-46.xspec + echo $output + [ "$status" -eq 0 ] + [[ "${lines[3]}" =~ "Testing with" ]] +} + + +@test "executing the Saxon XProc harness generates a report with UTF-8 encoding" { + + if [ -z ${XMLCALABASH_CP} ]; then + skip "test for XProc skipped as XMLCalabash uses a higher version of Saxon"; + else + run java -Xmx1024m -cp ${XMLCALABASH_CP} com.xmlcalabash.drivers.Main -isource=xspec-72.xspec -p xspec-home=file:${PWD}/../ -oresult=xspec/xspec-72-result.html ../src/harnesses/saxon/saxon-xslt-harness.xproc + + query="declare default element namespace 'http://www.w3.org/1999/xhtml'; concat(/html/head/meta[@http-equiv eq 'Content-Type']/@content = 'text/html; charset=UTF-8', ' ')"; + + run java -cp ${SAXON_CP} net.sf.saxon.Query -s:xspec/xspec-72-result.html -qs:"$query" !method=text + fi + + echo $output + [ "${lines[0]}" = "true" ] +} + + +@test "invoking xspec.sh with path containing an apostrophe runs successfully #119" { + mkdir some\'path + cp ../tutorial/escape-for-regex.* some\'path + run ../bin/xspec.sh some\'path/escape-for-regex.xspec + echo $output + [ "$status" -eq 0 ] + [ "${lines[19]}" = "Report available at some'path/xspec/escape-for-regex-result.html" ] + rm -rf some\'path +} + + +@test "invoking xspec.sh with saxon script uses the saxon script #121 #122" { + echo "echo 'Saxon script with EXPath Packaging System'" > /tmp/saxon + chmod +x /tmp/saxon + export PATH=$PATH:/tmp + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + echo $output + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Saxon script found, use it." ] + rm /tmp/saxon +} + + +@test "Schematron phase/parameters are passed to Schematron compile" { + run ../bin/xspec.sh -s ../test/schematron-param-001.xspec + echo "${lines[2]}" + [ "$status" -eq 0 ] + [ "${lines[2]}" == "Parameters: phase=P1 ?selected=codepoints-to-string((80,49))" ] +} + +@test "invoking xspec with Schematron XSLTs provided externally uses provided XSLTs for Schematron compile" { + + export SCHEMATRON_XSLT_INCLUDE=schematron/schematron-xslt-include.xsl + export SCHEMATRON_XSLT_EXPAND=schematron/schematron-xslt-expand.xsl + export SCHEMATRON_XSLT_COMPILE=schematron/schematron-xslt-compile.xsl + + run ../bin/xspec.sh -s ../tutorial/schematron/demo-01.xspec + echo $output + [ "${lines[4]}" = "Schematron XSLT include" ] + [ "${lines[5]}" = "Schematron XSLT expand" ] + [ "${lines[6]}" = "Schematron XSLT compile" ] +} + + +@test "invoking xspec.sh with the -s option does not display Schematron warnings #129 #131" { + run ../bin/xspec.sh -s ../tutorial/schematron/demo-01.xspec + echo "${lines[4]}" + echo $output + [ "$status" -eq 0 ] + [ "${lines[4]}" == "Compiling the Schematron tests..." ] +} + + +@test "Cleanup removes temporary files" { + run ../bin/xspec.sh -s ../tutorial/schematron/demo-03.xspec + [ "$status" -eq 0 ] + [ ! -f "../tutorial/schematron/demo-03.xspec-compiled.xspec" ] + run ls ../tutorial/schematron/xspec + [ "${#lines[@]}" = "3" ] + [ "${lines[0]}" = "demo-03-result.html" ] + [ "${lines[1]}" = "demo-03-result.xml" ] + [ "${lines[2]}" = "demo-03.xsl" ] +} + + +@test "invoking xspec.sh with -q option runs XSpec test for XQuery" { + run ../bin/xspec.sh -q ../tutorial/xquery-tutorial.xspec + echo "${lines[5]}" + [ "$status" -eq 0 ] + [ "${lines[5]}" = "passed: 1 / pending: 0 / failed: 0 / total: 1" ] +} + + +@test "executing the XProc harness for BaseX generates a report" { + + if [[ -z ${XMLCALABASH_CP} && -z ${BASEX_CP} ]]; then + skip "test for BaseX skipped as it requires XMLCalabash and a higher version of Saxon"; + else + run java -Xmx1024m -cp ${XMLCALABASH_CP} com.xmlcalabash.drivers.Main -i source=../tutorial/xquery-tutorial.xspec -p xspec-home=file:${PWD}/../ -p basex-jar=${BASEX_CP} -o result=xspec/xquery-tutorial-result.html ../src/harnesses/basex/basex-standalone-xquery-harness.xproc + fi + + echo $output + [[ "${output}" =~ "src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1" ]] +} + + +@test "HTML report contains CSS inline and not as an external file #135" { + run ../bin/xspec.sh ../tutorial/escape-for-regex.xspec + grep '<style type="text/css">' ../tutorial/xspec/escape-for-regex-result.html + grep 'margin-right:' ../tutorial/xspec/escape-for-regex-result.html +} + + +@test "Ant for XSLT with default properties fails on test failure" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/escape-for-regex.xspec -lib ${SAXON_CP} + echo $output + [ "$status" -eq 1 ] + [[ "${output}" =~ "BUILD FAILED" ]] +} + + +@test "Ant for XSLT with xspec.fail=false continues on test failure" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/escape-for-regex.xspec -lib ${SAXON_CP} -Dxspec.fail=false + echo $output + [ "$status" -eq 0 ] + [[ "${output}" =~ "BUILD SUCCESSFUL" ]] +} + + +@test "Ant for XSLT with catalog resolves URI" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/catalog/xspec-160_xslt.xspec -lib ${SAXON_CP} -Dxspec.fail=false -Dcatalog=${PWD}/catalog/xspec-160_catalog.xml -lib ${XML_RESOLVER_CP} + echo $output + [ "$status" -eq 0 ] + [[ "${output}" =~ "BUILD SUCCESSFUL" ]] +} + + +@test "Ant for Schematron with minimum properties" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/../tutorial/schematron/demo-02-PhaseA.xspec -lib ${SAXON_CP} -Dtest.type=s + echo $output + [ "$status" -eq 0 ] + [[ "${output}" =~ "BUILD SUCCESSFUL" ]] + + # Verify default clean.output.dir is false + [ -d "../tutorial/schematron/xspec/" ] + [ -f "../tutorial/schematron/demo-02-PhaseA.xspec-compiled.xspec" ] + [ -f "../tutorial/schematron/demo-02.sch-compiled.xsl" ] + + # Delete temp file + rm -f "../tutorial/schematron/demo-02-PhaseA.xspec-compiled.xspec" + rm -f "../tutorial/schematron/demo-02.sch-compiled.xsl" +} + + +@test "Ant for Schematron with various properties except catalog" { + # Remove a temp dir created by setup + rm -r ../tutorial/schematron/xspec + + # For testing -Dxspec.project.dir + cp ../build.xml /tmp/ + + run ant -buildfile /tmp/build.xml -Dxspec.xml=${PWD}/../tutorial/schematron/demo-03.xspec -lib ${SAXON_CP} -Dtest.type=s -Dxspec.project.dir=${PWD}/.. -Dxspec.phase=#ALL -Dxspec.dir=${PWD}/xspec-temp -Dclean.output.dir=true + echo $output + [ "$status" -eq 0 ] + [[ "${output}" =~ "BUILD SUCCESSFUL" ]] + + # Verify that -Dxspec-dir was honered and the default dir was not created + [ ! -d "../tutorial/schematron/xspec/" ] + + # Verify clean.output.dir=true + [ ! -d "xspec-temp/" ] + [ ! -f "../tutorial/schematron/demo-03.xspec-compiled.xspec" ] + [ ! -f "../tutorial/schematron/demo-03.sch-compiled.xsl" ] + + rm /tmp/build.xml +} + + +@test "Ant for Schematron with catalog and default xspec.fail fails on test failure" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/catalog/xspec-160_schematron.xspec -lib ${SAXON_CP} -Dtest.type=s -Dxspec.phase=#ALL -Dclean.output.dir=true -Dcatalog=${PWD}/catalog/xspec-160_catalog.xml -lib ${XML_RESOLVER_CP} + echo $output + [ "$status" -eq 1 ] + [[ "${output}" =~ "BUILD FAILED" ]] + + # Verify the build fails before cleanup + [ -d "catalog/xspec/" ] + + # Verify the build fails after Schematron setup + [ -f "catalog/xspec-160_schematron.xspec-compiled.xspec" ] + [ -f "../tutorial/schematron/demo-04.sch-compiled.xsl" ] + + # Delete temp file + rm -f "catalog/xspec-160_schematron.xspec-compiled.xspec" + rm -f "../tutorial/schematron/demo-04.sch-compiled.xsl" +} + + +@test "Ant for Schematron with catalog and xspec.fail=false continues on test failure" { + run ant -buildfile ${PWD}/../build.xml -Dxspec.xml=${PWD}/catalog/xspec-160_schematron.xspec -lib ${SAXON_CP} -Dtest.type=s -Dxspec.phase=#ALL -Dclean.output.dir=true -Dcatalog=${PWD}/catalog/xspec-160_catalog.xml -lib ${XML_RESOLVER_CP} -Dxspec.fail=false + echo $output + [ "$status" -eq 0 ] + [[ "${output}" =~ "BUILD SUCCESSFUL" ]] +} diff --git a/tutorial/escape-for-regex.xspec b/tutorial/escape-for-regex.xspec index 9bf96daf6..58de3cf83 100644 --- a/tutorial/escape-for-regex.xspec +++ b/tutorial/escape-for-regex.xspec @@ -1,88 +1,75 @@ <?xml version="1.0" encoding="UTF-8"?> - -<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" - xmlns:functx="http://www.functx.com" - stylesheet="escape-for-regex.xslt"> - - <!-- +<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:functx="http://www.functx.com" stylesheet="escape-for-regex.xslt"> + <!-- This is a sample test suite written in the XSpec language. It tests the stylesheet escape-for-regex.xslt. It contains three main scenarios (the second of which in turn contains two sub- scenarios). - See http://code.google.com/p/xspec/wiki/GettingStarted for the + See https://github.com/xspec/xspec/wiki/Getting-Started for the full tutorial it is part of. --> - - <!-- + <!-- This is a very simple scenario, checking the return value of a function call (the param does not contain any character to be escaped). --> - <x:scenario label="No escaping"> - <!-- call the function with the string 'Hello' --> - <x:call function="functx:escape-for-regex"> - <x:param select="'Hello'"/> - </x:call> - <!-- check the result --> - <x:expect label="Must not be escaped at all" select="'Hello'"/> - </x:scenario> - - <!-- + <x:scenario label="No escaping"> + <!-- call the function with the string 'Hello' --> + <x:call function="functx:escape-for-regex"> + <x:param select="'Hello'"/> + </x:call> + <!-- check the result --> + <x:expect label="Must not be escaped at all" select="'Hello'"/> + </x:scenario> + <!-- This scenario demonstrates: (1) how to test a function (named templates can be simliarly tested) (2) that scenarios can be nested (3) a test can have multiple expectations. --> - <x:scenario label="Test simple patterns"> - - <!-- first sub-scenario --> - <x:scenario label="When encountering parentheses"> - <!-- call the function --> - <x:call function="functx:escape-for-regex"> - <x:param name="arg" select="'(Hello)'"/> - </x:call> - <!-- check the result --> - <x:expect label="escape them." select="'\(Hello\)'"/> - </x:scenario> - - <!-- second sub-scenario --> - <x:scenario label="When encountering a whitespace character class"> - <!-- call the function with another parameter --> - <x:call function="functx:escape-for-regex"> - <x:param name="arg" select="'\sHello'"/> - </x:call> - <!-- check the result --> - <x:expect label="escape the backslash" select="'\\sHello'"/> - <!-- we can have several checks on the same result --> - <x:expect label="result should have one more character than source" - test="string-length(.) = 8"/> - </x:scenario> - - </x:scenario> - - <!-- + <x:scenario label="Test simple patterns"> + <!-- first sub-scenario --> + <x:scenario label="When encountering parentheses"> + <!-- call the function --> + <x:call function="functx:escape-for-regex"> + <x:param name="arg" select="'(Hello)'"/> + </x:call> + <!-- check the result --> + <x:expect label="escape them." select="'\(Hello\)'"/> + </x:scenario> + <!-- second sub-scenario --> + <x:scenario label="When encountering a whitespace character class"> + <!-- call the function with another parameter --> + <x:call function="functx:escape-for-regex"> + <x:param name="arg" select="'\sHello'"/> + </x:call> + <!-- check the result --> + <x:expect label="escape the backslash" select="'\\sHello'"/> + <!-- we can have several checks on the same result --> + <x:expect label="result should have one more character than source" test="string-length(.) = 8"/> + </x:scenario> + </x:scenario> + <!-- This scenario demonstrates how to test a matching template. --> - <x:scenario label="When processing a list of phrases"> - <!-- apply template rules to this element --> - <x:context> - <phrases> - <phrase>Hello!</phrase> - <phrase>Goodbye!</phrase> - <phrase>(So long!)</phrase> - </phrases> - </x:context> - <!-- check the result --> - <x:expect label="All phrase elements should remain" - test="count(phrases/phrase) = 3"/> - <x:expect label="Strings should be escaped and status attributes should be added"> - <phrases> - <phrase status="same">Hello!</phrase> - <phrase status="same">Goodbye!</phrase> - <phrase status="changed">\(So long!\)</phrase> - </phrases> - </x:expect> - </x:scenario> - + <x:scenario label="When processing a list of phrases"> + <!-- apply template rules to this element --> + <x:context> + <phrases> + <phrase>Hello!</phrase> + <phrase>Goodbye!</phrase> + <phrase>(So long!)</phrase> + </phrases> + </x:context> + <!-- check the result --> + <x:expect label="All phrase elements should remain" test="count(phrases/phrase) = 3"/> + <x:expect label="Strings should be escaped and status attributes should be added"> + <phrases> + <phrase status="same">Hello!</phrase> + <phrase status="same">Goodbye!</phrase> + <phrase status="changed">\(So long!\)</phrase> + </phrases> + </x:expect> + </x:scenario> </x:description> diff --git a/tutorial/schematron/demo-01.sch b/tutorial/schematron/demo-01.sch new file mode 100644 index 000000000..77d8befa4 --- /dev/null +++ b/tutorial/schematron/demo-01.sch @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"> + + <sch:pattern> + <sch:rule context="article"> + <sch:assert test="title" id="a001"> + article should have a title + </sch:assert> + </sch:rule> + <sch:rule context="section"> + <sch:assert test="title" id="a002"> + section should have a title + </sch:assert> + </sch:rule> + </sch:pattern> + +</sch:schema> \ No newline at end of file diff --git a/tutorial/schematron/demo-01.xml b/tutorial/schematron/demo-01.xml new file mode 100644 index 000000000..8ac5f18c4 --- /dev/null +++ b/tutorial/schematron/demo-01.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<article> + <title>Example +
+ Introduction +

This is an example.

+
+
+

This is an example.

+
+ diff --git a/tutorial/schematron/demo-01.xspec b/tutorial/schematron/demo-01.xspec new file mode 100644 index 000000000..0a9fc0971 --- /dev/null +++ b/tutorial/schematron/demo-01.xspec @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tutorial/schematron/demo-02-PhaseA.xspec b/tutorial/schematron/demo-02-PhaseA.xspec new file mode 100644 index 000000000..de8370bb7 --- /dev/null +++ b/tutorial/schematron/demo-02-PhaseA.xspec @@ -0,0 +1,11 @@ + + + + PhaseA + + + + + + + diff --git a/tutorial/schematron/demo-02-PhaseB.xspec b/tutorial/schematron/demo-02-PhaseB.xspec new file mode 100644 index 000000000..5cdd45649 --- /dev/null +++ b/tutorial/schematron/demo-02-PhaseB.xspec @@ -0,0 +1,12 @@ + + + + PhaseB + + + + + + + + diff --git a/tutorial/schematron/demo-02-import1.xspec b/tutorial/schematron/demo-02-import1.xspec new file mode 100644 index 000000000..d1df9e050 --- /dev/null +++ b/tutorial/schematron/demo-02-import1.xspec @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tutorial/schematron/demo-02-import2.xspec b/tutorial/schematron/demo-02-import2.xspec new file mode 100644 index 000000000..287f9a714 --- /dev/null +++ b/tutorial/schematron/demo-02-import2.xspec @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tutorial/schematron/demo-02-import3.xspec b/tutorial/schematron/demo-02-import3.xspec new file mode 100644 index 000000000..d410b6482 --- /dev/null +++ b/tutorial/schematron/demo-02-import3.xspec @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tutorial/schematron/demo-02.sch b/tutorial/schematron/demo-02.sch new file mode 100644 index 000000000..8c86c779b --- /dev/null +++ b/tutorial/schematron/demo-02.sch @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + sec element should have a sec-type attribute. + + + + + + + + sec element should have a sec-type attribute. + + + + + + + + section should have a title + + + + + + + + Short section has only one paragraph. + + + + + \ No newline at end of file diff --git a/tutorial/schematron/demo-02.xml b/tutorial/schematron/demo-02.xml new file mode 100644 index 000000000..5363c74cb --- /dev/null +++ b/tutorial/schematron/demo-02.xml @@ -0,0 +1,19 @@ + +
+ Demo 2 + + + Welcome! +

Schematron is a wonderful tool for testing XML to find out if the XML follows an expected structure.

+

In addition to validating XML, Schematron can also raise alerts for things you might want to know through warnings and informational messages. It can pass/fail validation and much more!

+
+ +

Schematron uses XPath to test the contents of XML.

+
+ + Testing Schematron +

While Schematron is useful for testing XML files, it is also useful to have a tool for testing Schematron itself.

+

Schematron is simple to use. However sometimes tests can sometimes become very complex. A good set of test cases can help you to avoid problems and makes your work go faster.

+
+ +
diff --git a/tutorial/schematron/demo-03-doc1.xml b/tutorial/schematron/demo-03-doc1.xml new file mode 100644 index 000000000..ed8684068 --- /dev/null +++ b/tutorial/schematron/demo-03-doc1.xml @@ -0,0 +1,6 @@ + + +
+ Introduction +
+
diff --git a/tutorial/schematron/demo-03-doc2.xml b/tutorial/schematron/demo-03-doc2.xml new file mode 100644 index 000000000..42c2e7889 --- /dev/null +++ b/tutorial/schematron/demo-03-doc2.xml @@ -0,0 +1,7 @@ + + +
+ INTRODUCTION +

Some text

+
+
diff --git a/tutorial/schematron/demo-03.sch b/tutorial/schematron/demo-03.sch new file mode 100644 index 000000000..c48d034a8 --- /dev/null +++ b/tutorial/schematron/demo-03.sch @@ -0,0 +1,29 @@ + + + + + + + + title should be followed by a paragraph + + + title should not be all upper case + + + + + + paragraph is less than 10 characters long + + + + + + the document has at least one section + + + + + + \ No newline at end of file diff --git a/tutorial/schematron/demo-03.xspec b/tutorial/schematron/demo-03.xspec new file mode 100644 index 000000000..8b181f9ae --- /dev/null +++ b/tutorial/schematron/demo-03.xspec @@ -0,0 +1,63 @@ + + + + + + + + + + + Introduction +

some paragraph text

+
+
+ + +
+ + + + Introduction + + + + + + + + Introduction +

Hello!

+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
diff --git a/tutorial/schematron/demo-04.sch b/tutorial/schematron/demo-04.sch new file mode 100644 index 000000000..363982f3a --- /dev/null +++ b/tutorial/schematron/demo-04.sch @@ -0,0 +1,20 @@ + + + + + + + + + + article should have a title + + + sec should have at least one para + + + figure should have a caption + + + + \ No newline at end of file diff --git a/tutorial/schematron/demo-04.xspec b/tutorial/schematron/demo-04.xspec new file mode 100644 index 000000000..8bb63071f --- /dev/null +++ b/tutorial/schematron/demo-04.xspec @@ -0,0 +1,33 @@ + + + + + + + + + + paragraph 1 + + +
+
+
+
+ + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/tutorial/schematron/quickfix.sch b/tutorial/schematron/quickfix.sch new file mode 100644 index 000000000..80356d2b4 --- /dev/null +++ b/tutorial/schematron/quickfix.sch @@ -0,0 +1,81 @@ + + + + + + + This Schematron Quick Fix is intended to help with adding id and role attributes to assert and report elements in a Schematron. + + To use this quick fix create a validation scenario in oXygen that uses this Schematron. + The validation scenario configuration might look something like this: + + + + Apply the validation scenario to validate any Schematron. + + Using the check-id phase, + each assert or report element that is missing an id attribute will be flagged. + Click on each flagged element and use the quick fix to insert an id attribute. + The generated ID will be based on a running number and will use the nearest ancestor ID if there is one. + + Using the check-role phase, + each assert or report element that is missing a role attribute will be flagged. + Click on each flagged element and use the quick fix to insert a role attribute to + make the result of the test be an 'error', 'warn', or 'info'. + + + + + + + + + + + + + should have an id attribute. + + + + + Add id attribute + + + + + + + + + should have a role attribute. + + + Add role 'error' + + + + + + Add role 'warn' + + + + + + Add role 'info' + + + + + + + \ No newline at end of file diff --git a/tutorial/xquery-tutorial.xq b/tutorial/xquery-tutorial.xq new file mode 100644 index 000000000..cbfae4918 --- /dev/null +++ b/tutorial/xquery-tutorial.xq @@ -0,0 +1,8 @@ +module namespace functx = "http://www.functx.com"; + +declare function functx:capitalize-first +($arg as xs:string?) as xs:string? { + + concat(upper-case(substring($arg, 1, 1)), + substring($arg, 2)) +}; \ No newline at end of file diff --git a/tutorial/xquery-tutorial.xspec b/tutorial/xquery-tutorial.xspec new file mode 100644 index 000000000..5d25a4fb7 --- /dev/null +++ b/tutorial/xquery-tutorial.xspec @@ -0,0 +1,16 @@ + + + + + + + + + + + + + \ No newline at end of file