home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- RELAX NG for RELAX NG -->
- <!--
- Initial version information
- URL:
- http://relaxng.org/relaxng.rng
- Description:
- http://relaxng.org/#schemas
- RELAX NG 1.0, from the RELAX NG Specification, with errata applied.
- -->
- <!--
- Contributor:
- Syncro Soft - oXygen XML Editor
- Date:
- July 12, 2005
- Description:
- Annotated with descriptions form Relax NG book by Eric van der Vlist
- http://books.xmlschemata.org/relaxng/
- -->
- <grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
- ns="http://relaxng.org/ns/structure/1.0"
- xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
- xmlns="http://relaxng.org/ns/structure/1.0">
- <start>
- <ref name="pattern"/>
- </start>
-
- <define name="pattern">
- <choice>
- <element name="element">
- <a:documentation>The element pattern matches elements.
- The name of the element may be defined either through a name attribute or through a name class.</a:documentation>
- <choice>
- <attribute name="name">
- <a:documentation>When name is specified, the element pattern matches only elements with this name.
- name is a shortcut to define a single name as a name class for the element pattern.
- name and the definition of a name class can't be specified together (they are exclusive options).</a:documentation>
- <data type="QName"/>
- </attribute>
- <ref name="open-name-class"/>
- </choice>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="attribute">
- <a:documentation>The attribute pattern matches attributes.
- The name of the attribute may be defined by using either a name attribute or a name class.
- After simplification, attribute patterns can contain only patterns relevant for text nodes.
- Attributes can't be duplicated, either directly or by overlapping name classes.
- Attributes that have an infinite name class (anyName or nsName) must be enclosed in a oneOrMore or zeroOrMore pattern.
- </a:documentation>
- <ref name="common-atts"/>
- <choice>
- <attribute name="name">
- <a:documentation>When name is specified, the attribute pattern matches attributes with this name only.
- This can be a shortcut to define a single name as a name class for the attribute pattern).
- name and the definition of a name class can't both be specified (they are exclusive options).</a:documentation>
- <data type="QName"/>
- </attribute>
- <ref name="open-name-class"/>
- </choice>
- <interleave>
- <ref name="other"/>
- <optional>
- <ref name="pattern"/>
- </optional>
- </interleave>
- </element>
- <element name="group">
- <a:documentation>The group pattern defines an ordered group of subpatterns.
- Note that when attribute patterns are included in such a group, their order isn't enforced.
- group patterns are implicit with element and define patterns.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="interleave">
- <a:documentation>The interleave pattern "interleaves" subpatterns; it allows their leaves to be mixed in any order.
- The interleave pattern can't be used within a list.
- The interleave behavior is applied to attribute patterns even when they are embedded in (ordered) group patterns
- (the reason for this is that XML 1.0 specifies the relative order of attributes isn't significant).
- Elements within a interleave pattern can't have overlapping name classes.
- There can be at most one text pattern in each set of patterns combined by interleave.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="choice">
- <a:documentation>The choice pattern defines a choice between different patterns;
- it matches a node if, and only if, at least one of its subpatterns matches this node.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="optional">
- <a:documentation>The optional pattern specifies that its subpatterns considered as an
- ordered group is optional, i.e., be matched zero or one times.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="zeroOrMore">
- <a:documentation>The zeroOrMore pattern specifies that its subpatterns are considered
- an ordered group that must be matched zero or more times.
- The zeroOrMore pattern can't contain attribute definitions.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="oneOrMore">
- <a:documentation>The oneOrMore pattern specifies that its subpatterns considered as an
- ordered group must be matched one or more times. The oneOrMore pattern can't contain attribute definitions.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="list">
- <a:documentation>The list pattern splits a text node into tokens separated by whitespace.
- The splitting allows the validation of these tokens separately.
- This practice is most useful for validating lists of values.
- interleave can't be used within list.
- The content of a list is only about data: it's forbidden to define element, attribute, or text there.
- It's forbidden to embed list into list.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="mixed">
- <a:documentation>The mixed pattern is a shortcut for interleave with an embedded text pattern.
- It describes unordered content models in which a text node may be included before and after
- each element. Note that RELAX NG doesn't allow the addition of constraints on these text nodes.
- The mixed pattern can't be used within a list.
- Elements within a mixed pattern can't have overlapping name classes.
- There must no other text pattern in each set of patterns combined by mixed.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- <element name="ref">
- <a:documentation>The ref pattern defines a reference to a named pattern defined in the current grammar.</a:documentation>
- <attribute name="name">
- <a:documentation>This attribute specifies the name of the named pattern that is referenced.</a:documentation>
- <data type="NCName"/>
- </attribute>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="parentRef">
- <a:documentation>The parentRef pattern is a reference to a named pattern belonging
- to the parent grammar - in other words, the grammar in which the current grammar is included.
- The scope of a named pattern is usually limited to the grammar in which they are defined.
- The parentRef pattern provides a way to extend this scope and refer to a named pattern
- defined in the parent grammar.</a:documentation>
- <attribute name="name">
- <a:documentation>This attribute specifies the name of the named pattern that is referenced.</a:documentation>
- <data type="NCName"/>
- </attribute>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="empty">
- <a:documentation>Empty content.
- empty patterns define nodes that are empty, for example, elements that have no child elements, text, or attributes.
- Note that it is mandatory to use this pattern explicitly in such cases; the simpler-looking form
- <element name="foo"/> is forbidden. There is no such thing as an empty attribute.
- An attribute such as foo="" is considered to have a value that is the empty string rather
- than considered empty - i.e., having no value. Therefore, empty applies only to elements.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="text">
- <a:documentation>The text pattern matches zero or more text nodes.
- A match of more than one text node has no effect when it is used in ordered content models
- (the data model used by RELAX NG for XML documents is similar to the data model of XPath 1.0,
- and two text nodes can't be adjacent) but makes a difference when a text pattern is used in interleave.
- Adding a single text pattern in an interleave pattern has the effect of allowing any number of text nodes,
- which can interleave before and after each element (note that the mixed pattern is provided as a
- shortcut to define these content models).
- No more than one text pattern can be included in an interleave pattern.</a:documentation>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="value">
- <a:documentation>The value pattern matches a text node against a value using the semantic
- of a specified datatype to perform the comparison.
- The value pattern is meant for data-oriented applications and can't be used in mixed-content models.
- It is used to define enumerations.</a:documentation>
- <optional>
- <attribute name="type">
- <a:documentation>This attribute specifies which datatype to use to perform the comparison.
- Note that this isn't an inherited attribute. When it isn't specified, the comparison is done using
- the default datatype, the token datatype of RELAX NG's built-in type library. Because of this, a string
- comparison is done on the values after space normalization.</a:documentation>
- <data type="NCName"/>
- </attribute>
- </optional>
- <ref name="common-atts"/>
- <text/>
- </element>
- <element name="data">
- <a:documentation>The data pattern matches a string that represents a value of a named datatype.
- If the children of an element or an attribute match a data pattern, then complete content of the element
- or attribute must match that data pattern. It is not permitted to have a pattern which allows part of the
- content to match a data pattern, and another part to match another pattern.
- The restrictions are applied through the type attribute, which defines the datatype and the param and except child patterns.
- The data pattern is meant for data-oriented applications and can't be used in mixed content models.
- </a:documentation>
- <attribute name="type">
- <a:documentation>The type attribute specifies the name of the datatype in the library identified by the datatypeLibrary attribute.</a:documentation>
- <data type="NCName"/>
- </attribute>
- <ref name="common-atts"/>
- <interleave>
- <ref name="other"/>
- <group>
- <zeroOrMore>
- <element name="param">
- <a:documentation>The param element specifies parameters passed to the datatype library
- to determine whether a value is valid per a datatype. When the datatype library is the
- W3C XML Schema datatype, these parameters are the facets of the datatype and define
- additional restrictions to be applied. The name of the parameter is defined by the name attribute,
- and its value is the content of the param element.</a:documentation>
- <attribute name="name">
- <a:documentation>This attribute specifies the name of the parameter.</a:documentation>
- <data type="NCName"/>
- </attribute>
- <ref name="common-atts"/>
- <text/>
- </element>
- </zeroOrMore>
- <optional>
- <element name="except">
- <a:documentation>The except pattern is used to remove a set of values from a data pattern.
- The except pattern can be used only in the context of data and can contain only data, value, and choice elements.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- </optional>
- </group>
- </interleave>
- </element>
- <element name="notAllowed">
- <a:documentation>The notAllowed pattern always fails. It can provide abstract definitions
- that must be overridden before they can be used in a schema.</a:documentation>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="externalRef">
- <a:documentation>The externalRef pattern is a reference to an external schema.
- It has the same effect as replacing the externalRef pattern with the external schema,
- which is treated as a pattern.</a:documentation>
- <attribute name="href">
- <a:documentation>This attribute defines the location of the external schema.</a:documentation>
- <data type="anyURI"/>
- </attribute>
- <ref name="common-atts"/>
- <ref name="other"/>
- </element>
- <element name="grammar">
- <a:documentation>Defines a grammar pattern.
- The grammar pattern encapsulates the definitions of start and named patterns.
- A grammar pattern is matched by matching the pattern contained in the start element.
- The most common use of grammar is to validate XML documents.
- In these cases, the start pattern specifies which elements can be used as the document root element.
- The grammar pattern may also be used to write modular schemas.
- In this case, the start pattern specifies which nodes must be matched by the grammar wherever it appears in the schema.
- In every case, the named patterns defined in a grammar are considered local to this grammar.
- </a:documentation>
- <ref name="common-atts"/>
- <ref name="grammar-content"/>
- </element>
- </choice>
- </define>
-
- <define name="grammar-content">
- <interleave>
- <ref name="other"/>
- <zeroOrMore>
- <choice>
- <ref name="start-element"/>
- <ref name="define-element"/>
- <element name="div">
- <a:documentation>The div element is provided to define logical divisions in RELAX NG schemas.
- It has no effect on validation. Its purpose is to define a group of definitions that may be annotated
- as a whole. The div elements may be embedded in other div elements.
- In the context of a grammar, the content of a div element is the
- same as the content of a grammar.</a:documentation>
- <ref name="common-atts"/>
- <ref name="grammar-content"/>
- </element>
- <element name="include">
- <a:documentation>The include pattern includes a grammar and merges its definitions with the definitions
- of the current grammar. The definitions of the included grammar may be redefined and overridden by the
- definitions embedded in the include pattern. Note that a schema must contain an explicit grammar
- definition in order to be included.</a:documentation>
- <attribute name="href">
- <a:documentation>This attribute defines the location of the schema and specifies the grammar to be included.</a:documentation>
- <data type="anyURI"/>
- </attribute>
- <ref name="common-atts"/>
- <ref name="include-content"/>
- </element>
- </choice>
- </zeroOrMore>
- </interleave>
- </define>
-
- <define name="include-content">
- <interleave>
- <ref name="other"/>
- <zeroOrMore>
- <choice>
- <ref name="start-element"/>
- <ref name="define-element"/>
- <element name="div">
- <a:documentation>In the context of an include, the content of a div element is
- the same as the content of an include.</a:documentation>
- <ref name="common-atts"/>
- <ref name="include-content"/>
- </element>
- </choice>
- </zeroOrMore>
- </interleave>
- </define>
-
- <define name="start-element">
- <element name="start">
- <a:documentation>The start pattern defines the "start" of a grammar.
- When this grammar is used to validate a complete document, the start pattern specifies which elements
- can be used as the document (root) element. When this grammar is embedded in another grammar, the
- start pattern specifies which pattern should be applied at the location where the grammar is embedded.
- Like named pattern definitions, start patterns may be combined by choice or interleave and redefined when
- they are included in include patterns.</a:documentation>
- <ref name="combine-att"/>
- <ref name="common-atts"/>
- <ref name="open-pattern"/>
- </element>
- </define>
-
- <define name="define-element">
- <element name="define">
- <a:documentation>
- When define is embedded in a grammar, it defines a named pattern or combines a new definition with an existing one.
- Named patterns are global to a grammar and can be referenced by ref in the scope of their grammar and by parentRef
- in the scope of the grammars directly embedded in their grammar.
- When define is embedded in include, the new definition is a redefinition.
- It replaces the definitions from the included grammar, unless a combine attribute
- is specified, in which case, the definitions are combined.
- </a:documentation>
- <attribute name="name">
- <a:documentation>This attribute specifies the name of the named pattern.</a:documentation>
- <data type="NCName"/>
- </attribute>
- <ref name="combine-att"/>
- <ref name="common-atts"/>
- <ref name="open-patterns"/>
- </element>
- </define>
-
- <define name="combine-att">
- <optional>
- <attribute name="combine">
- <a:documentation>This attribute specifies how multiple definitions of a pattern (named pattern or start pattern)
- should be combined. The possible values are choice and interleave.
- When the combine attribute is specified and set to choice, multiple definitions of a pattern are
- combined in a choice pattern. When the combine attribute is specified and set to interleave, multiple
- definitions of a pattern are combined in an interleave pattern.
- Note that it's forbidden to specify more than one define with the same name and no combine attribute or
- multiple defines with different values of the combine attribute.
- </a:documentation>
- <choice>
- <value>choice</value>
- <a:documentation>Specifies that multiple definitions of a named pattern are
- combined in a choice pattern</a:documentation>
- <value>interleave</value>
- <a:documentation>Specifies that multiple definitions of a named pattern are
- combined in an interleave pattern</a:documentation>
- </choice>
- </attribute>
- </optional>
- </define>
-
- <define name="open-patterns">
- <interleave>
- <ref name="other"/>
- <oneOrMore>
- <ref name="pattern"/>
- </oneOrMore>
- </interleave>
- </define>
-
- <define name="open-pattern">
- <interleave>
- <ref name="other"/>
- <ref name="pattern"/>
- </interleave>
- </define>
-
- <define name="name-class">
- <choice>
- <element name="name">
- <a:documentation>The name name class defines a class with a single name.</a:documentation>
- <ref name="common-atts"/>
- <data type="QName"/>
- </element>
- <element name="anyName">
- <a:documentation>Name class accepting any name.
- The anyName name class matches any name from any namespace.
- This wide spectrum may be restricted by embedding except name classes.</a:documentation>
- <ref name="common-atts"/>
- <ref name="except-name-class"/>
- </element>
- <element name="nsName">
- <a:documentation>The nsName name class allows any name in a specific namespace.
- Within the scope of an element, the name classes of attributes can't overlap.
- The same restriction applies to name classes of elements when these elements are combined by interleave.
- It is impossible to use nsName to produce empty name classes by including nsName in an except name class
- included in another nsName.</a:documentation>
- <ref name="common-atts"/>
- <ref name="except-name-class"/>
- </element>
- <element name="choice">
- <a:documentation>The choice name class makes a choice between several
- name classes: a name matches choice if, and only if, it matches at least one
- of the subname classes.</a:documentation>
- <ref name="common-atts"/>
- <ref name="open-name-classes"/>
- </element>
- </choice>
- </define>
-
- <define name="except-name-class">
- <interleave>
- <ref name="other"/>
- <optional>
- <element name="except">
- <a:documentation>The except name class can remove a name class from another. Note that this name class has no attributes.</a:documentation>
- <ref name="open-name-classes"/>
- </element>
- </optional>
- </interleave>
- </define>
-
- <define name="open-name-classes">
- <interleave>
- <ref name="other"/>
- <oneOrMore>
- <ref name="name-class"/>
- </oneOrMore>
- </interleave>
- </define>
-
- <define name="open-name-class">
- <interleave>
- <ref name="other"/>
- <ref name="name-class"/>
- </interleave>
- </define>
-
- <define name="common-atts">
- <optional>
- <attribute name="ns"/>
- <a:documentation>This attribute defines the default namespace for the elements defined in a portion of a schema.
- The value is inherited.</a:documentation>
- </optional>
- <optional>
- <attribute name="datatypeLibrary">
- <a:documentation>The datatypeLibrary attribute contains a URI identifying the library of
- datatypes being used. The value is inherited. The datatype library defined by W3C XML Schema Datatypes would
- be identified by the URI http://www.w3.org/2001/XMLSchema-datatypes.</a:documentation>
- <data type="anyURI"/>
- </attribute>
- </optional>
- <zeroOrMore>
- <attribute>
- <anyName>
- <except>
- <nsName/>
- <nsName ns=""/>
- </except>
- </anyName>
- </attribute>
- </zeroOrMore>
- </define>
-
- <define name="other">
- <zeroOrMore>
- <element>
- <anyName>
- <except>
- <nsName/>
- </except>
- </anyName>
- <zeroOrMore>
- <choice>
- <attribute>
- <anyName/>
- </attribute>
- <text/>
- <ref name="any"/>
- </choice>
- </zeroOrMore>
- </element>
- </zeroOrMore>
- </define>
-
- <define name="any">
- <element>
- <anyName/>
- <zeroOrMore>
- <choice>
- <attribute>
- <anyName/>
- </attribute>
- <text/>
- <ref name="any"/>
- </choice>
- </zeroOrMore>
- </element>
- </define>
- </grammar>
-