Schematron is a XPath/XSLT-based language for defining context-dependent rules. Schematron doesn't directly support structure or datatype validation, but a schema author may write rules that implement these checks. To write a full schema with Schematron, the author needs to take care to include all the rules needed to qualify the structure of the document. Table A-4 provides the fact sheet for Schematron.
|
Author: |
Rick Jelliffe and other contributors. Will be described by ISO/DSDL. |
|
Status: |
Unofficial. |
|
Location: |
|
|
Type: |
Rule-based. |
|
PSVI: |
No. |
|
Structures: |
No (although the structure can be controlled by rules). |
|
Datatypes: |
No (although the datatypes can be controlled by rules). |
|
Integrity: |
No (although the integrity can be controlled by rules). |
|
Rules: |
Yes. |
|
Vendor support: |
Low but increasing. |
|
Miscellaneous: |
Pure rule expression. Can be embedded in W3C XML Schema and RELAX NG. |
<sch:schema xmlns:sch="http://www.ascc.net/xml/schematron">
<sch:title>
Schematron Schema for library
</sch:title>
<sch:pattern>
<sch:rule context="/">
<sch:assert test="library">
The document element should be "library".
</sch:assert>
</sch:rule>
<sch:rule context="/library">
<sch:assert test="book">
There should be at least a book!
</sch:assert>
<sch:assert test="not(@*)">
No attribute for library, please!
</sch:assert>
</sch:rule>
<sch:rule context="/library/book">
<sch:assert test="not(following-sibling::book/@id=@id)">
Duplicated ID for this book.
</sch:assert>
<sch:assert test="@id=concat('-', isbn)">
The id should be derived from the ISBN.
</sch:assert>
</sch:rule>
<sch:rule context="/library/*">
<sch:assert test="name()='book' or name( )='author' or
name( )='character'">
This element shouldn't be here...
</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
Note that the previous Schematron is a partial schema meant as a supplement.
Copyright © 2002 O'Reilly & Associates. All rights reserved.