Skip to content

Commit

Permalink
Rationalizing including file name regularization
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez committed Feb 12, 2024
1 parent 662cc46 commit 054061c
Show file tree
Hide file tree
Showing 17 changed files with 221 additions and 260 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0"
xmlns:metaschema="http://csrc.nist.gov/ns/metaschema/1.0" type="metaschema:CURRENT-TEST-MODELS-REFRESH"
name="CURRENT-TEST-MODELS-REFRESH">

<!-- Purpose: For a given metaschema instance, produces both a viable InspectorXSLT and a viable XSD -->
<!-- Use to refresh artifacts for testing metaschemas -->
<!-- Input: A valid, properly-linked metaschema -->

<!-- Output: For a metaschema input, produces both an XSD and an InspectorXSLT, together -->

<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<p:input port="parameters" kind="parameter"/>

<!-- For some reason this errors when run on a sequence from Maven (but not in oXygen's older XML Calabash) -->

<p:option name="targetDir" select="'current'"/>

<p:input port="METASCHEMA" primary="true" sequence="true">
<p:document href="tiny_metaschema.xml"/>
<p:document href="computer_metaschema.xml"/>
</p:input>


<p:import href="../../METASCHEMA-XSD.xpl"/>

<p:import href="INSPECTOR-XSLT-TEST.xpl"/>


<p:for-each name="iterate">
<p:iteration-source>
<p:pipe port="METASCHEMA" step="CURRENT-TEST-MODELS-REFRESH"/>
</p:iteration-source>

<p:variable name="baseURI" select="base-uri(.)"/>
<p:variable name="filepath" select="(replace($baseURI,'[^/]+$',''), $targetDir, replace($baseURI,'(.*/|\.xml$)','') ) => string-join('/')"/>

<p:identity name="this-metaschema"/>

<metaschema:METASCHEMA-XSD name="produce-xsd"/>

<!--<p:sink/>-->
<p:store name="save-xsd" indent="true" encoding="ASCII">
<p:with-option name="href" select="$filepath || '-schema.xsd'"/>
<p:input port="source">
<p:pipe port="XSD" step="produce-xsd"/>
</p:input>
</p:store>


<metaschema:INSPECTOR-XSLT-TEST name="produce-inspector">
<p:input port="METASCHEMA">
<p:pipe port="result" step="this-metaschema"/>
</p:input>
<p:input port="instance">
<p:inline><X/></p:inline>
</p:input>
<p:input port="parameters"/>
</metaschema:INSPECTOR-XSLT-TEST>


<p:store name="save-inspector" indent="true" encoding="ASCII">
<p:with-option name="href" select="$filepath || '-inspector.xsl'"/>
<p:input port="source">
<p:pipe port="INT_50_inspector" step="produce-inspector"/>
</p:input>
</p:store>


</p:for-each>

</p:declare-step>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# This script shows how to use Saxon with only a Maven dependency.
# Unlike other scripts in this folder it does not rely on an external (bash scripting) dependency
# You do need Maven installed..

# Fail early if an error occurs
set -Eeuo pipefail

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [ADDITIONAL_ARGS]
Refreshes current/computer_inspector.xsl
Additional arguments are provided to SaxonHE - see https://www.saxonica.com/documentation11/#!using-xsl/commandline
EOF
}

if ! [ -x "$(command -v mvn)" ]; then
echo 'Error: Maven (mvn) is not in the PATH, is it installed?' >&2
exit 1
fi

METASCHEMA_SOURCE=computer_metaschema.xml

XSLT_RESULT=current/computer_metaschema-inspector.xsl

ADDITIONAL_ARGS=$(echo ${*// /\\ })

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
POM_FILE="${SCRIPT_DIR}/../../../../support/pom.xml"

MAIN_CLASS="net.sf.saxon.Transform" # Saxon defined in pom.xml

if [ -e "$XSLT_RESULT" ]
then
echo "Deleting prior $XSLT_RESULT ..."
rm -f ./$XSLT_RESULT
fi

mvn \
-quiet \
-f "$POM_FILE" \
exec:java \
-Dexec.mainClass="$MAIN_CLASS" \
-Dexec.args="-xsl:${SCRIPT_DIR}/../../nist-metaschema-MAKE-INSPECTOR-XSLT.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSLT_RESULT\" $ADDITIONAL_ARGS"

if [ -e "$XSLT_RESULT" ]
then
echo "XSLT written to file $XSLT_RESULT"
fi
Loading

0 comments on commit 054061c

Please sign in to comment.