Restrictions
With the exception of constraints expressed by the RELAX NG schema for RELAX NG and those which are part of the simplification itself, RELAX NG defines all the restrictions on schema structures as they apply to the simplified version. Most of them are obvious and easy to understand.
Constraints on Attributes
RELAX NG’s constraints match the constraints on attributes defined by the XML 1.0 recommendation:
Attributes can’t contain other attributes;
attributepatterns can’t have anotherattributepattern in their descendants.Attributes can’t contain elements;
attributepatterns can’t have arefpattern in their descendants.Attributes can’t be duplicated; an attribute may not be found in a
oneOrMorepattern with a combination bygrouporinterleave. Furthermore, ifattributepatterns are combined in agrouporinterleavepattern, their name classes must not overlap: they can’t have any name that belongs to both name classes.Attributes that have an infinite name class (
anyNameornsName) must be enclosed in aoneOrMorepattern. In other words, you can’t specify only one or a certain number of occurrences of these attributes. They can have onlytextas their model (in other words,datapatterns are forbidden here).
Let’s explore schemas that may look valid at a quick glance but are going to collide with these restrictions.
Bad example: attribute content model
This schema states that any content
model can be accepted in the bar attribute:
anything = (element * { anything } | attribute ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access