Name

grammar — Grammar pattern

Synopsis

element grammar
{
 (
 attribute ns { text }?,
 attribute datatypeLibrary { xsd:anyURI }?,
 attribute * - (rng:* | local:*) { text }*
 ),
 (
 ( element * - rng:* { ... }* )
 & (
 ( element start { ... } )
 | ( element define { ... } )
 | element div { ... }
 | element include { ... }
 )*
 )
}

Class

pattern

May be included in

attribute, choice, define, element, except, group, interleave, list, mixed, oneOrMore, optional, start, zeroOrMore

Compact syntax equivalent

grammar

Description

The grammar pattern encapsulates the definitions of start and named patterns. 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.

Example

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
 <start>
  <element name="library">
   <oneOrMore>
    <ref name="book-element"/>
   </oneOrMore>
  </element>
 </start>
 <define name="author-element">
  ...
 </define>
</grammar>
 <define name="author-element">
   <grammar>
     <start>
       <element name="author">
         <attribute name="id"/>
         <ref name="name-element"/>
         <parentRef name="born-element"/>
         <optional>
           <ref name="died-element"/>
         </optional>
       </element>
     </start>
     <define name="name-element">
       <element name="name">
         <text/>
       </element>
     </define>
     <define name="died-element">
       <element name="died">
         <text/>
       </element>
     </define>
   </grammar>
 </define>
 <element xmlns="http://relaxng.org/ns/structure/1.0" name="university">
  <element name="name">
    <text/>
  </element>
  <grammar>
    <include href="flat.rng"/>
  </grammar>
</element>

Attributes

datatypeLibrary

This attribute defines the default datatype library. The value is inherited.

ns

This attribute defines the default namespace for the elements defined in a portion of a schema. The value is inherited.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.245.39