How to Run Schematron from the Command Line

This page provides technical details about Schematron.

This page describes how to run the Schematron for JATS from the command line using free software tools. The process that is described here will normally be happening behind the scenes automatically. Each release of Schematron for JATS 1.2 will include the Schematron along with pre-compiled XSLT for each phase created using the same process described here. You might need to use the process described here when getting started so that you can see how Schematron works.

The Taylor & Francis Schematron for JATS 1.2 should work in any software that supports ISO Schematron 2016 with XSLT 2.0 and XML Catalogs. The software linked below is recommended as a starting point. These instructions have been written for Windows 10, but should work equally well on Linux or Mac by using a Java version that is specific to the operating system and adjusting file paths to replace \ with /.

What you will need

Software Version Download Link
Java Java 8 or higher, 64-bit, recommended Java 11 JRE 64-bit for Windows or other operating systems
Saxon version 9.9, HE or EE Saxonica
XML Resolver 1.2 Maven
SchXslt 1.8.5 GitHub
JATS Schemas and XML Catalog jats-schemas-2019-11-03.zip
JATS Schematron jats.sch
any JATS 1.2 XML file for example: FAST_I_17_2_J.zip

After downloading the files linked above, create a folder and extract the .zip packages to arrange the files in a structure like this:

tutorial
|   jats.sch
|   saxon9he.jar
|   xml-resolver-1.2.jar
|   
+---FAST_I_17_2_J
|   |   FAST_I_17_2_J.xml
|   |   
|   \---FAST_A_1641689
|           FAST_A_1641689_J.xml
|           
+---jats-schemas
|   |   catalog.xml
|   |   
|   \---minified
|           atypon-jats-v1.1-issue.dtd
|           JATS-archive-oasis-article1-mathml3-v1.2.dtd
|           
+---jdk-11.0.6+10-jre
|   \---bin
|           java.exe
|           
\---schxslt-1.8.5
    \---2.0
            compile-for-svrl.xsl
            expand.xsl
            include.xsl

Step by step

Begin by checking that Java is working.

Enter command:

.\jdk-11.0.6+10-jre\bin\java.exe -version

You should then see:

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

Step 1: Schematron include

Enter command:

.\jdk-11.0.6+10-jre\bin\java.exe -jar saxon9he.jar -xsl:schxslt-1.8.5/2.0/include.xsl -o:stage-1.sch  jats-generated.sch

This command will not display any output, but a file named stage-1.sch should be created.

Step 2: Schematron expand

Enter command:

.\jdk-11.0.6+10-jre\bin\java.exe -jar saxon9he.jar -xsl:schxslt-1.8.5/2.0/expand.xsl -o:stage-2.sch stage-1.sch

This command will not display any output, but a file named stage-2.sch should be created.

Step 3: Schematron compile

Enter command:

.\jdk-11.0.6+10-jre\bin\java.exe -jar saxon9he.jar  -xsl:schxslt-1.8.5/2.0/compile-for-svrl.xsl -o:stage-3.xsl stage-2.sch phase=current_content

This command will not display any output, but a file named stage-3.xsl should be created.

The file stage-3.xsl can be reused to validate multiple XML files using Schematron phase current_content.

The value given for phase can be either current_content, scanned_content, or converted_content.

Step 4: Run Schematron on a JATS 1.2 file

Enter command:

.\jdk-11.0.6+10-jre\bin\java.exe -classpath "xml-resolver-1.2.jar;saxon9he.jar" net.sf.saxon.Transform -xsl:stage-3.xsl -o:report.xml -catalog:"jats-schemas/catalog.xml" "FAST_I_17_2_J/FAST_A_1636634/FAST_A_1636634_J.xml"

This command produces file named report.xml that contains the Schematron report for the JATS 1.2 file FAST_A_1636634_J.xml.

This command may display a series of messages such as “WARNING: Rule for context “issn” shadowed by preceeding rule”, and these messages can be ignored in this case.

Step 5: View the Schematron Report

The Schematron report file report.xml can be opened and viewed. Schematron reports are usually converted into another format for viewing, such as HTML, or interpreted by an application. See this description of SVRL for details.

Saxon Editions

This step by step process assumes that you are using the free edition of Saxon. If you have a paid license for Saxon Enterprise Edition or Saxon Professional Edition, adjust the file names in the examples below from saxon9he.jar to saxon9ee.jar or saxon9pe.jar and ensure that your license file saxon-license.lic is in the same folder as the Saxon .jar file.

Using Saxon EE, the Schematron XSLT can be compiled into a bytecode file to gain a performance boost.

After Step 3, enter this command to create the bytecode file stage-3.sef:

.\jdk-11.0.6+10-jre\bin\java.exe -jar saxon9ee.jar -xsl:stage-3.xsl -export:stage-3.sef -nogo

Then in Step 4 replace stage-3.xsl with stage-3.sef.

.\jdk-11.0.6+10-jre\bin\java.exe -classpath "xml-resolver-1.2.jar;saxon9ee.jar" net.sf.saxon.Transform -xsl:stage-3.sef -o:report.xml -catalog:"jats-schemas/catalog.xml" "FAST_I_17_2_J/FAST_A_1636634/FAST_A_1636634_J.xml"

A .sef file can be used in place of an XSLT using Saxon EE or Saxon PE.