Skip to content

Instantly share code, notes, and snippets.

@dmj
Created February 26, 2023 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmj/d15b9911a1338e68f363614cf14ea49b to your computer and use it in GitHub Desktop.
Save dmj/d15b9911a1338e68f363614cf14ea49b to your computer and use it in GitHub Desktop.
<project name="Test" basedir="." default="build">
<taskdef name="schematron" classname="name.dmaus.schxslt.ant.Task" classpath="target/ant-schxslt-1.9.5.jar"/>
<target name="build">
<schematron schema="schema.sch" file="document.xml" report="report.xml"/>
</target>
</project>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3">
<sch:pattern>
<sch:rule context="*">
<sch:assert test="false()"/>
</sch:rule>
</sch:pattern>
</sch:schema>
@sydb
Copy link

sydb commented Feb 26, 2023

Oh. I can put comments here? Excellent. Happy to provide a complete example. How about yours?
I took the 3 files above and, after adding an XML declaration and changing the path to the JAR file to match mine, ran ant. Results:

$ cat build.xml 
<?xml version="1.0" encoding="UTF-8"?>
<project name="Test" basedir="." default="build">
  <taskdef name="schematron" classname="name.dmaus.schxslt.ant.Task" classpath="/usr/local/bin/ant-schxslt-1.9.5.jar"/>
  <target name="build">
    <schematron schema="schema.sch" file="document.xml" report="report.xml"/>
  </target>
</project>

$ cat document.xml 
<?xml version="1.0" encoding="UTF-8"?>
<document/>

$ cat schema.sch 
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt3">
  <sch:pattern>
    <sch:rule context="*">
      <sch:assert test="false()"/>
    </sch:rule>
  </sch:pattern>
</sch:schema>

$ time ant
Buildfile: /tmp/dmt/build.xml

build:
[schematron] Generating validation stylesheet for Schematron '/tmp/dmt/schema.sch'
[schematron] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[schematron] SLF4J: Defaulting to no-operation (NOP) logger implementation
[schematron] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

BUILD FAILED
/tmp/dmt/build.xml:5: Unable to compile validation stylesheet

Total time: 0 seconds

real	0m0.184s
user	0m0.457s
sys	0m0.051s
$ 

@dmj
Copy link
Author

dmj commented Feb 27, 2023

All right. You need Saxon on your CLASSPATH. Could you add the Saxon HE jar to CLASSPATH and try again?

@sydb
Copy link

sydb commented Feb 27, 2023

Sure!
(You mean to the bash environment variable $CLASSPATH, or to the ant @classpath on the <taskdef> for SchXslt?)

@sydb
Copy link

sydb commented Feb 27, 2023

(BTW, I do not remember what I did yesterday to cause it, but I am now getting a different error:)

WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.apache.tools.ant.types.Permissions (file:/usr/share/ant/lib/ant.jar)
WARNING: Please consider reporting this to the maintainers of org.apache.tools.ant.types.Permissions
WARNING: System::setSecurityManager will be removed in a future release

@sydb
Copy link

sydb commented Feb 27, 2023

Ah! Fixed that last one. Martin had warned me you sometimes need to specify fork="true" when calling Saxon via in ant. Sigh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment