- You need to be aware that in choosing a template rule, the system takes no account of the type hierarchy in the schema. If
direct-debit
is defined as a subtype of
movement
, this does not mean that the template rule defined with
match = “element(*, direct-debit)”
takes priority over the rule with
match = “element(*, movement)”
You need to allocate explicit priorities in the stylesheet to make sure that the right rule is invoked.
- If subtypes have been defined by extending the base type, then it can often be useful to invoke processing of the extensions by using the
instruction, described in Chapter 6. The template rule for the base type can process all the contents that are common to all instances of the type, while the template rule for an extended type needs to process only those contents that are included in the extension.
- Sometimes substitution groups are used to define a collection of similar elements. Whereas types identify elements or attributes with common content, substitution groups identify elements that are interchangeable in terms of where they can appear in a document. But XML Schema also imposes a rule that an element in a substitution group must have a content model that is either a restriction or an extension of the content model of the substitution group head. This means that the elements in a substitution group will generally have some content in common, for example all elements in the substitution group of
might have attributes
time
and
place
. In this case a pattern such as
schema-element(event)
can be used to process this common content.
- Patterns that match all elements in a substitution group can also be useful in contexts other than
. For example, suppose a genealogy database allows a
element to contain any number of
elements among its children, and that elements such as
,
,
, and
are defined as elements within the substitution group for
. In this case, if you want to number the events for a particular person you can use
count=“schema-element(event)”/>
.
Predicates
The form of a
Predicate
is defined in the XPath expression language: it is any expression enclosed in square brackets. For example
[speaker=‘Hamlet’]
, or
[@width> 100]
or
[*]
, or
[1]
. A
PatternStep
may include any number of predicates. These are additive—a node must satisfy all the predicates if it is to match.