Table of Contents
Element context(s)
library
is a root element
Clause 5.4.8 (
library
element)The library element is an allowed root element containing external declarations, including abstract rules [...] and patterns [...].The contents of this element can be included in a schema by using
extends
.
element library {
attribute id { xsd:ID }?,
rich,
(foreign
& (inclusion | extends)*
& (title?, p*, param*, let*, abstract-rules*, (rule-set|pattern)*, p*, diagnostics?, properties?))
}
Example 13. library
element
Given this schema:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xquery"> <sch:extends href='library.sch'/> <sch:pattern> <sch:rule context="/"> <sch:assert test="true()">Always true</sch:assert> </sch:rule> </sch:pattern> </sch:schema>
and the library imported via extends
from library.sch
(see highlight above):
<library xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xquery"> <pattern id='blort'> <rule context="blort"> <assert test="@wibble">Element <name/> must have attribute 'wibble'</assert> </rule> </pattern> <pattern id='wibble'> <rule context="wibble"> <assert test=". = $some-global">Element <name/> must have value '<value-of select="$some-global"/>'</assert> </rule> </pattern> </library>
the contents of the library will be included in place of the extends
element, to produce the resulting schema:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xquery"> <pattern xmlns="http://purl.oclc.org/dsdl/schematron" id="blort"> <rule context="blort"> <assert test="@wibble">Element <name/> must have attribute 'wibble'</assert> </rule> </pattern> <pattern xmlns="http://purl.oclc.org/dsdl/schematron" id="wibble"> <rule context="wibble"> <assert test=". = $some-global">Element <name/> must have value '<value-of select="$some-global"/>'</assert> </rule> </pattern> <sch:pattern> <sch:rule context="/"> <sch:assert test="true()">Always true</sch:assert> </sch:rule> </sch:pattern> </sch:schema>