This action was previously named Run Schematron. The name changed in Validation plug-in v5; the action itself is unchanged and existing workflows are unaffected.
The Validate with Schematron workflow action uses ISO Schematron 2016 to test for the presence or absence of patterns in XML documents.
A “Schematron” refers to a collection of one or more rules which contain tests. Schematrons are written in a form of XML, which makes it easy for people to understand and write.
One of the brilliant things about running a Schematron is that error messages can be customised to be human-readable. For example, you could use a Schematron to verify headings are nested correctly and write the error message to read as "Incorrect heading order: Heading 3, Heading 4, Heading 5 or Heading 6 cannot follow Heading 1."
TIP Since Content XML, the data format used by Typefi to encode content, is a type of XML, you can use the Validate with Schematron workflow action with Content XML documents too.
JATS Schematrons that previously failed with unrelated errors—for example, false JATS-0043-003 failures—now run correctly. If you still see errors like this on an older JATS Schematron, consider migrating to jats-schematron-v2.0.sch or later.
Use cases
You can use a Schematron to validate:
- the content and structure of XML documents
- the presence or absence of attributes
- the content of attributes
- any co-occurring constraints
Validate the content and structure XML documents
Use a Schematron to validate the content and structure of your XML document. For example, you can check that headings are nested properly ("Does Heading 2 always follow Heading 1?"), or check for the presence or absence of elements ("Does every <row> contain at least one <entry>"?).
Validate the presence or absence of attributes
Use a Schematron to validate the presence or absence of attributes. For example, you can check that every Typefi Element has an ID ("Does every <context> have an @id attribute?").
Validate the content of attributes
Use a Schematron to validate the content of attributes. For example, you can check that every video in a document displays the video control buttons ("Does every <video> have the @autoplay attribute and is @autoplay set to true?").
Validate any co-occurring constraints
Use a Schematron to validate any co-occurring constraints. For example, you can check if a Typefi Section contains a table; if so, the Typefi Section should contain a paragraph too ("Does this <section> contain a <table>? If so, does this <section> also include a <p>?").
Validate with Schematron
| Field | Description |
|---|---|
| Input | Choose the Content XML or XML file to be validated. |
| Schematron |
Choose the Schematron file (.sch) to test for the presence or absence of patterns. If left blank, a default Schematron that scans for invalid styles is applied. Validate with Schematron isn't compatible with Schematrons that load other files, for example with |
| On error |
Choose how the action reacts to validation errors:
Whether a finding actually fails the job also depends on the schema itself. Each rule can carry a severity, and only errors affect the job's outcome:
If the XML itself is broken (for example, mismatched or unclosed tags), or the schema fails to compile, the job fails no matter which option you choose. |
| Output |
Enter the filename for the Schematron Validation Report Language (.svrl) report. Output is optional: if you leave it blank, the action still validates and logs results, it just doesn't write a report file. A report that lists errors, even though the job succeeded, is expected under Report only. The report always reflects whether the document is valid; the job's outcome is decided separately by your On error choice. |
| Parameters |
Enter any optional parameters. For example, selecting a subset of patterns and only validating against those, or defining the active phase to be applied according to the state of a document within its lifecycle. Requirements:
Example 1: Selecting a subset of patterns You are validating an XML file that contains contact information for people in your organisation. At a minimum, each person should have a mobile phone number and first name listed in the XML file. The XML file might look like this:
And the Schematron file has these defined parameters:
These parameters are used in the Schematron assertions, which are used to specify the constraints that should be checked. Then, you can pass the values for those parameters as:
Example 2: Defining the active phase Typefi uses ph-schematron to convert the source Schematron file (.sch) to an XSLT script and apply this XSLT on the Input document (.xml or .cxml) to be validated. You can define the active phase by passing in a parameter:
If a value is not set for the phase ( If a phase is not defined via a parameter, then the Note: If the phase name doesn't match any phase in your Schematron, the job succeeds with no findings. Check the spelling if you expected findings. |
If the Validate with Schematron workflow action fails, then the job in Typefi Server will also fail.
Comments
0 comments
Please sign in to leave a comment.