Search code examples
marklogicsaxonxercesschematronxsd-1.1

What engine does MarkLogic use to validate XML documents against an XML Schema version 1.1?


I have been asked to look into using version 1.1 XML Schemas in a MarkLogic environment to fold the Schematron asserts into the XML Schema.

One thing that XSD 1.1 does not specify is the use of custom error messages as they are in Schematron files.

I have found that both Saxonica and Xerces have extensions to address that issue.

Here is how Saxonica deals with the issue:

<xs:element name="date">
  <xs:simpleType>
     <xs:restriction base="xs:date" xmlns:saxon="http://saxon.sf.net/">
       <xs:assertion test=". lt current-date()"
                  saxon:message="The date must not be in the future"/>
       <xs:pattern value="[^Z:]*" 
                  saxon:message="The date must not have a timezone"/>
     </xs:restriction>   
  </xs:simpleType>
</xs:element>

Here is how Xerces deals with the issue:

  <xs:simpleType name="myPrecisionDecimal">
    <xs:restriction base="xs:decimal" xmlns:xerces="http://xerces.apache.org">
       <xs:totalDigits value="6" />
       <xs:fractionDigits value="4" />
       <xs:assertion test="string-length(substring-after(string($value), '.')) ge 2" 
              xerces:message="minScale of this decimal number should be 2" />
    </xs:restriction>
  </xs:simpleType>

Also: Do either of these extensions handle anything like the <sch:name/> or <sch:value-of/> tags in the Schematron assert tag <sch:assert test="..."/>?


Solution

  • As regards Saxon, there is no way to parameterize the message. However, you can ask Saxon to generate a report in XML format containing all the information about invalidities with context information about where they appear, and you could run a transformation on this report to assemble the information into any form you like (including, for example, an interactive rendition that shows the source document with invalid elements redlined).