Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more helpful output from schematron.
  • Loading branch information
EsGeh authored and EsGeh committed Jul 30, 2019
1 parent 56ecd9d commit d63ad4f
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 3 deletions.
20 changes: 20 additions & 0 deletions patch_schematron.patch
@@ -0,0 +1,20 @@
diff -c -r dependencies/schematron/trunk/schematron/code/iso_svrl_for_xslt2.xsl dependencies/schematron.new/trunk/schematron/code/iso_svrl_for_xslt2.xsl
*** dependencies/schematron/trunk/schematron/code/iso_svrl_for_xslt2.xsl 2019-07-30 15:14:11.218172813 +0200
--- dependencies/schematron.new/trunk/schematron/code/iso_svrl_for_xslt2.xsl 2019-07-30 15:13:07.882697877 +0200
***************
*** 147,153 ****
-->

<xsl:stylesheet
! version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
--- 147,153 ----
-->

<xsl:stylesheet
! version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias"
4 changes: 4 additions & 0 deletions scripts/init.sh
Expand Up @@ -32,4 +32,8 @@ unzip -d "fxsl" "fxsl/*.zip"
cd $BASE_DIR
patch -p0 -i patch_fxsl.patch

# patch schematron:
cd $BASE_DIR
patch -p0 -i patch_schematron.patch

$BASE_DIR/scripts/updateOutput.sh
2 changes: 1 addition & 1 deletion scripts/updateOutput.sh
Expand Up @@ -127,7 +127,7 @@ $SCRIPT_DIR/local_stylesheet.sh \
--input-dir "$BASE_DIR/schema/s2/generated/schematron" \
--output-dir "$BASE_DIR/schema/s2/generated/schematron" \
--suffix '.xsl' \
"schematron/iso_schematron_skeleton_for_saxon.xsl" \
"schematron/iso_svrl_for_xslt2.xsl" \
>$BASE_DIR/schema/s2/logs/schematron_to_xsl.log \
2>&1

Expand Down
28 changes: 26 additions & 2 deletions scripts/validate_xml_by_schematron.sh
Expand Up @@ -5,6 +5,7 @@ SCRIPT_DIR=$(dirname $0)
DEP_DIR=$BASE_DIR/dependencies

input_dir="$BASE_DIR/corpus"
output_dir="-"
schema_dir="$BASE_DIR/schema/s2/generated/schematron"
input_pattern='*.xml'

Expand All @@ -21,6 +22,7 @@ function print_help {
echo "OPTIONS:"
echo " -s|--schema-dir SCHEMA_DIR. default: '$schema_dir'"
echo " -i|--input-dir INPUT_DIR. default: '$input_dir'"
echo " -o|--output-dir INPUT_DIR. default: '$output_dir'"
echo
echo "ARGUMENTS:"
echo " INPUT_PATTERN. default: '$input_pattern'"
Expand All @@ -42,6 +44,11 @@ while [[ $# > 0 ]]; do
input_dir="$1"
shift
;;
-o|--output-dir)
shift
output_dir="$1"
shift
;;
-s|--schema-dir)
shift
schema_dir="$1"
Expand Down Expand Up @@ -74,12 +81,29 @@ fi

while read schema_file; do
echo "checking schema '$schema_file'"
output_dir="$(mktemp -d)"
if [[ "$output_dir" != "-" ]]; then
echo "output dir: $output_dir"
mkdir -pv "$output_dir"
else
output_dir="$(mktemp -d)"
stdout=1
fi
$SCRIPT_DIR/local_stylesheet.sh \
--input-dir "$input_dir" \
--output-dir "$output_dir" \
--stylesheet-dir "." \
--suffix '.svrl' \
"$schema_file" \
"$input_pattern"
cat $(find "$output_dir" -type f) | sed 's/^/ /'
$SCRIPT_DIR/local_stylesheet.sh \
--input-dir "$output_dir" \
--output-dir "$output_dir" \
--suffix '.txt' \
"svrl_to_txt.xsl" \
'*.svrl'
if [[ "$stdout" = "1" ]]; then
echo "deleting temp dir... $output_dir"
cat $(find "$output_dir" -type f -name '*.txt') | sed 's/^/ /'
rm -rv $output_dir
fi
done < <(find "$schema_dir" \( -type f -o -type l \) -name '*.xsl')
35 changes: 35 additions & 0 deletions stylesheets/svrl_to_txt.xsl
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
note: downloaded from http://debeissat.nicolas.free.fr/relaxng_simplification.php
-->
<stylesheet
version="2.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

<output
method="text"
omit-xml-declaration="yes"
indent="no"
/>

<variable name="newline" select="'&#xA;'"/>

<!-- 7.2 -->

<template match="svrl:failed-assert">
<text>ERROR: at '</text>
<value-of select="@location"/>
<text>':</text>
<value-of select="$newline"/>
<value-of select="svrl:text"/>
<value-of select="$newline"/>
</template>

<template match="node()">
<apply-templates/>
</template>

</stylesheet>

0 comments on commit d63ad4f

Please sign in to comment.