Name

rng:include — Includes another grammar into the current grammar

XML syntax example

include.rng

<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<include href="type.rng"/>

<start combine="choice">
 <ref name="type" />
</start>
<define name="type">
 <element name="type">
  <list>
   <choice>
    <value>html</value>
    <value>xhtml</value>
    <value>xml</value>
   </choice>
  </list>
 </element>
</define>

</grammar>

type.rng

<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<start combine="choice">
 <element name="type">
  <list>
   <choice>
    <value>text</value>
    <value>other</value>
   </choice>
  </list>
 </element>
</start>

</grammar>

Compact syntax example

include.rnc

include “type.rnc”

start |= type
type = element type { list { "html" | "xhtml" | "xml" } }

type.rnc

start |= element type { list { "text" | "other" } }

Attributes

href

The location of the grammar to include

Parents

div, grammar

Description

The include element includes another grammar in the current one. The included grammar must have a grammar element as the document element. Its rules are effectively merged with the including grammar. An include element may contain define elements that override or are combined with definitions of the same name in the including grammar.

See also

§9.3, grammar, start

Get XML Pocket Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.