Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent error in output when using JSON parameter #51

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/converter-gen/json-to-xml/package-json-converter.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@

<!-- -->
<XSLT:template name="from-json">
<XSLT:if test="not(unparsed-text-available($file))" expand-text="true">
<XSLT:if test="matches($file, '\S') and not(unparsed-text-available($file))" expand-text="true">
<nm:ERROR>No file found at { $file }</nm:ERROR>
</XSLT:if>
<XSLT:variable name="source">
Expand Down
18 changes: 5 additions & 13 deletions src/converter-gen/mvn-jsonxml-converter-xsl.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

# Fail early if an error occurs
set -Eeuo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
# shellcheck source=../common/subcommand_common.bash
source "$SCRIPT_DIR/../common/subcommand_common.bash"

usage() {
cat <<EOF
Expand All @@ -25,24 +26,15 @@ METASCHEMA_SOURCE=$1
[[ -z "${2-}" ]] && { echo "Error: XSL_RESULT not specified"; usage; exit 1; }
XSL_RESULT=$2

ADDITIONAL_ARGS=$(shift 2; 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
ADDITIONAL_ARGS=$(shift 2; echo "${*// /\\ }")

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

mvn \
-f "$POM_FILE" \
exec:java \
-Dexec.mainClass="$MAIN_CLASS" \
-Dexec.args="-xsl:${SCRIPT_DIR}/nist-metaschema-MAKE-JSON-TO-XML-CONVERTER.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSL_RESULT\" $ADDITIONAL_ARGS"
invoke_saxon "-xsl:${SCRIPT_DIR}/nist-metaschema-MAKE-JSON-TO-XML-CONVERTER.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSL_RESULT\" $ADDITIONAL_ARGS"

if [ -e "$XSL_RESULT" ]
then
Expand Down
18 changes: 5 additions & 13 deletions src/converter-gen/mvn-xmljson-converter-xsl.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

# Fail early if an error occurs
set -Eeuo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
# shellcheck source=../common/subcommand_common.bash
source "$SCRIPT_DIR/../common/subcommand_common.bash"

usage() {
cat <<EOF
Expand All @@ -25,24 +26,15 @@ METASCHEMA_SOURCE=$1
[[ -z "${2-}" ]] && { echo "Error: XSL_RESULT not specified"; usage; exit 1; }
XSL_RESULT=$2

ADDITIONAL_ARGS=$(shift 2; 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
ADDITIONAL_ARGS=$(shift 2; echo "${*// /\\ }")

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

mvn \
-f "$POM_FILE" \
exec:java \
-Dexec.mainClass="$MAIN_CLASS" \
-Dexec.args="-xsl:${SCRIPT_DIR}/nist-metaschema-MAKE-XML-TO-JSON-CONVERTER.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSL_RESULT\" $ADDITIONAL_ARGS"
invoke_saxon "-xsl:${SCRIPT_DIR}/nist-metaschema-MAKE-XML-TO-JSON-CONVERTER.xsl -s:\"$METASCHEMA_SOURCE\" -o:\"$XSL_RESULT\" $ADDITIONAL_ARGS"

if [ -e "$XSL_RESULT" ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@
<xsl:text>&#xA;</xsl:text>
<xsl:comment> JSON to XML conversion: Markdown to markup inferencing </xsl:comment>

<xsl:apply-templates mode="package-converter" select="document('markdown-to-supermodel-xml-converter.xsl')/xsl:*/( xsl:* except (xsl:output | xsl:mode) )"/>
<xsl:apply-templates mode="package-converter" select="document('json-to-xml/markdown-to-supermodel-xml-converter.xsl')/xsl:*/( xsl:* except (xsl:output | xsl:mode) )"/>

<xsl:text>&#xA;</xsl:text>
<xsl:comment> JSON to XML conversion: Supermodel serialization as XML </xsl:comment>
<xsl:apply-templates mode="package-converter" select="document('supermodel-to-xml.xsl')/xsl:*/( xsl:* except xsl:output )"/>
<xsl:apply-templates mode="package-converter" select="document('json-to-xml/supermodel-to-xml.xsl')/xsl:*/( xsl:* except xsl:output )"/>
</xsl:copy>
</xsl:template>

Expand Down Expand Up @@ -178,7 +178,7 @@

<!-- -->
<XSLT:template name="from-json">
<XSLT:if test="not(unparsed-text-available($file))" expand-text="true">
<XSLT:if test="matches($file, '\S') and not(unparsed-text-available($file))" expand-text="true">
<nm:ERROR>No file found at { $file }</nm:ERROR>
</XSLT:if>
<XSLT:variable name="source">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<xsl:variable name="metaschema-source" select="/"/>

<xsl:variable name="json-serializer-xslt" select="document('supermodel-to-json.xsl')"/>
<xsl:variable name="json-serializer-xslt" select="document('xml-to-json/supermodel-to-json.xsl')"/>

<xsl:template match="/">
<xsl:variable name="converter">
Expand Down