generated from usnistgov/opensource-repo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding XML Calabash scripting for testing
- Loading branch information
1 parent
2cdd898
commit eb8338a
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# This script attempts to download XML Calabash 3.0 | ||
|
||
# NEEDED - a .bat version of this to run under Windows w/o bash | ||
|
||
mkdir -p lib | ||
|
||
|
||
pushd lib > /dev/null | ||
|
||
VERSION=3.0.0-alpha9 | ||
RELEASES=https://github.com/xmlcalabash/xmlcalabash3/releases/download | ||
|
||
|
||
if [ ! -f "xmlcalabash-${VERSION}.zip" ]; then | ||
echo "Downloading XML Calabash 3 (may take a few seconds) ..." | ||
curl -s -L -o xmlcalabash-$VERSION.zip $RELEASES/$VERSION/xmlcalabash-$VERSION.zip | ||
|
||
# unzip -qo "${morgana}.zip" -x __MACOSX/** | ||
# chmod +x "${morgana}/Morgana.sh" | ||
else | ||
echo "You have XML Calabash ${VERSION} in directory lib" | ||
fi | ||
|
||
unzip -q xmlcalabash-$VERSION.zip | ||
|
||
echo "Smoke test:" | ||
java -jar xmlcalabash-$VERSION/xmlcalabash-app-$VERSION.jar version | ||
|
||
popd > /dev/null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<p:declare-step version="3.0" | ||
xmlns:p="http://www.w3.org/ns/xproc" | ||
xmlns:ox="http://csrc.nist.gov/ns/oscal-xproc3" | ||
type="ox:PROCESSOR-REPORT" | ||
name="PROCESSOR-REPORT"> | ||
|
||
<p:output port="result" | ||
serialization="map{'indent' : true(), 'omit-xml-declaration': true() }" /> | ||
|
||
<!-- /prologue --> | ||
|
||
<p:identity message="[PROCESSOR-REPORT] XPROC 3 Processor Report"> | ||
<!-- p:inline is implicit w/in p:with-input containing an element not in the p: namespace --> | ||
<!-- Also note the whitespace in the XProc file comes with the XML tagging --> | ||
<!-- we provide xml:space="preserve" which should inhibit munge the code --> | ||
<p:with-input xml:space="preserve"> | ||
<PROCESSOR reporting="{ current-dateTime() }"> | ||
<product-name>{ p:system-property('p:product-name') }</product-name> | ||
<product-version>{ p:system-property('p:product-version') }</product-version> | ||
<vendor>{ p:system-property('p:vendor') }</vendor> | ||
<vendor-uri>{ p:system-property('p:vendor-uri') }</vendor-uri> | ||
<version>{ p:system-property('p:version') }</version> | ||
<xpath-version>{ p:system-property('p:xpath-version') }</xpath-version> | ||
<psvi-supported>{ p:system-property('p:psvi-supported') }</psvi-supported> | ||
</PROCESSOR></p:with-input> | ||
</p:identity> | ||
|
||
<p:insert match="/PROCESSOR" position="last-child"> | ||
<!--Unlike XSLT, we use an absolute XPath, there is no relative context just a tree --> | ||
<p:with-input port="insertion"> | ||
<p:inline xml:space="preserve"> <report-time>{ string(/*/@reporting) }</report-time> | ||
</p:inline> | ||
</p:with-input> | ||
</p:insert> | ||
|
||
<!-- Fancy XPath! | ||
|| is a string concatenator | ||
format-dateTime() is a function with a 'picture' argument --> | ||
<p:string-replace match="/PROCESSOR/report-time/text()" | ||
replace="'REPORTING AT ' || format-dateTime(., | ||
'[h01]:[m01] [P] on [FNn] [MNn] [D1o], [Y]')"/> | ||
|
||
<!-- making labels explicit in content --> | ||
<p:string-replace match="/PROCESSOR/*/text()" | ||
replace="(local-name(parent::*), string(.)) => string-join(': ')"/> | ||
|
||
<!-- Wiping markup by replacing the element with its string value --> | ||
<p:string-replace match="/*" replace="string(.)"/> | ||
|
||
</p:declare-step> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@echo off | ||
|
||
echo Invoking XML Calabash for XProc 3 pipeline execution . . . | ||
rem All arguments are passed to the script in the distribution. | ||
|
||
set XML_CALABASH_VERSION=3.0.0-alpha9 | ||
set XML_CALABASH_JAR=%~P0\lib\xmlcalabash-%XML_CALABASH_VERSION%\xmlcalabash-app-%XML_CALABASH_VERSION%.jar | ||
set XML_CALABASH=java -jar %XML_CALABASH_JAR% | ||
|
||
call %XML_CALABASH% %* | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# This script attempts to run XML Calabash 3 | ||
|
||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" | ||
|
||
XML_CALABASH_VERSION=3.0.0-alpha9 | ||
XML_CALABASH_JAR="${SCRIPT_DIR}/lib/xmlcalabash-${XML_CALABASH_VERSION}/xmlcalabash-app-${XML_CALABASH_VERSION}.jar" | ||
XML_CALABASH="java -jar ${XML_CALABASH_JAR}" | ||
|
||
# java -jar lib/xmlcalabash-3.0.0-alpha5/xmlcalabash-app-3.0.0-alpha5.jar version | ||
|
||
# echo $XML_CALABASH | ||
|
||
usage() { | ||
cat <<EOF | ||
Usage: ${BASE_COMMAND:-$(basename "${BASH_SOURCE[0]}")} XPROC_FILE [ADDITIONAL_ARGS] | ||
Applies XML Calabash 3 processor to the designated pipeline, using Saxon for XSLT transformations | ||
EOF | ||
} | ||
|
||
[[ -z "${1-}" ]] && { echo "The script requires an XProc 3 pipeline - try helloworld.xpl or TEST-XPROC3.xpl"; usage; exit 1; } | ||
|
||
if [ ! -f "${XML_CALABASH_JAR}" ]; then | ||
|
||
echo "XML Calabash not found ... try running setup-xmlcalabash.sh ..." | ||
|
||
elif [ "${1:-}" = '-h' ] || [ "${1:-}" = '--help' ]; then usage | ||
|
||
else | ||
|
||
${XML_CALABASH} $@ | ||
|
||
fi |