|
|
|
|
|
|
Co-occurrence constraints in XML Schema |
|
Schematron |
|
Processing model |
|
Writing rules |
|
Embedding Schematron in XML Schema |
|
|
|
|
|
XML Schema can't articulate certain kinds of
constraints: |
|
When an element's type depends on an attribute
value |
|
When an element's content depends on the
presence of an attribute |
|
When the text in mixed content has to be a
certain type |
|
When a value has to match an ID in a separate
document |
|
When an element can contain repeatable elements
in any order |
|
Schematron can be used to plug the gaps |
|
|
|
|
|
Rule-based schema language |
|
Asserts conditions that elements/attributes must
or must not fulfil |
|
Built on top of XSLT |
|
Schematron schemas are transformed into XSLT
stylesheets |
|
Constructed stylesheet produces validity report |
|
Style of validity report depends on how the
stylesheet was created |
|
|
|
|
|
|
Schematron namespace is http://www.ascc.net/xml/schematron |
|
Usually associated with prefix sch |
|
Schematron schema made up of patterns |
|
Named collections of similar rules |
|
e.g. pattern for "structure", pattern
for "data" |
|
Patterns operate in parallel |
|
Can define phases to combine different patterns |
|
Patterns contain a number of rules |
|
|
|
|
|
Defined with sch:rule |
|
Each rule matches a particular set of nodes |
|
identified through XSLT pattern in context
attribute |
|
Inside each rule are a number of sch:assert and sch:report
elements |
|
Assertions are positive (things that must be
true) |
|
Reports are negative (things that should be
reported if they occur) |
|
Test is XPath expression held in test attribute |
|
Content gives description to be passed to
validator |
|
|
|
|
|
|
|
|
Schematron patterns (sch:pattern) can be
embedded in any xs:appinfo within an XML Schema schema |
|
Topologi's Schematron validator |
|
Extracts Schematron schema |
|
Can configure extraction routine |
|
Validates against XML Schema schema |
|
Validates against Schematron schema |
|
Can configure which meta-stylesheet is used, and
therefore what kind of report you get |
|
|
|
|
|
|
|
Schematron is very useful for "plugging the
gaps" in XML Schema |
|
Use to express constraints over and above those
allowed in Schematron |
|
Schematron schemas contain patterns |
|
Patterns are named and contain rules |
|
Rules have a context and contain assertions and
reports |
|
Assertions and reports have tests and contain
descriptions or error messages |
|
Schematron patterns can be embedded in XML
Schema schemas |
|
|
|
|
Add Schematron rules to the schema to express
additional constraints |
|