XML Schema or RELAX NG with Embedded Schematron Rules
Schematron rules can be embedded into an XML Schema through annotations (using the
appinfo
element), or in any element on any level of a RELAX NG Schema
(taking into account that the RELAX NG validator ignores all elements that are not
in the
RELAX NG namespace).
Oxygen XML Editor plugin accepts such documents as Schematron validation schemas and it is able to extract and use the embedded rules.
Validating XML Documents with Relax NG and Embedded Schematron
To validate an XML document with both RELAX NG schema and its embedded Schematron rules, you need to associate the document with both schemas. For example:
<?xml-model href="percent.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <?xml-model href="percent.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
The second association validates your document with Schematron rules extracted from the RELAX NG Schema.
Validating XML Documents with XML Schema and Embedded Schematron
Similarly, you can specify an XML Schema having the embedded Schematron rules.
<?xml-model href="percent.xsd" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
Note
Example: Embedded Schematron in Relax NG Schema
<sch:pattern> <sch:rule context="..."> <sch:assert test="...">Message.</sch:assert> </sch:rule> </sch:pattern>
Example: Embedded Schematron in XML Schema
<xsd:appinfo> <sch:pattern> <sch:rule context="..."> <sch:assert test="...">Message.</sch:assert> </sch:rule> </sch:pattern> </xsd:appinfo>