[xml/sgml-commit] r1628 - in /packages/relax-ng/trunk/relaxng-1.0: ./ html/

dleidert-guest at users.alioth.debian.org dleidert-guest at users.alioth.debian.org
Wed Nov 11 20:36:50 UTC 2009


Author: dleidert-guest
Date: Wed Nov 11 20:36:49 2009
New Revision: 1628

URL: http://svn.debian.org/wsvn/debian-xml-sgml/?sc=1&rev=1628
Log:
* relaxng-1.0/: Add RELAX NG 1.0 schemes, specs and tutorials.


Added:
    packages/relax-ng/trunk/relaxng-1.0/
    packages/relax-ng/trunk/relaxng-1.0/catalog.xml
    packages/relax-ng/trunk/relaxng-1.0/html/
    packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html   (with props)
    packages/relax-ng/trunk/relaxng-1.0/relaxng.dtd
    packages/relax-ng/trunk/relaxng-1.0/relaxng.rng
    packages/relax-ng/trunk/relaxng-1.0/relaxng.xsd

Added: packages/relax-ng/trunk/relaxng-1.0/catalog.xml
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/catalog.xml?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/catalog.xml (added)
+++ packages/relax-ng/trunk/relaxng-1.0/catalog.xml Wed Nov 11 20:36:49 2009
@@ -1,0 +1,20 @@
+<?xml version='1.0'?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
+    "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+
+<!-- ..................................................................... -->
+<!-- This catalog was written for the Debian system. ..................... -->
+<!-- ..................................................................... -->
+
+<rewriteURI         uriStartString="http://relaxng.org/relaxng.rng" rewritePrefix="./rng/1.0/"/>
+<rewriteSystem systemIdStartString="http://relaxng.org/relaxng.rng" rewritePrefix="./rng/1.0/"/>
+
+<rewriteURI         uriStartString="http://relaxng.org/relaxng.xsd" rewritePrefix="./xsd/1.0/"/>
+<rewriteSystem systemIdStartString="http://relaxng.org/relaxng.xsd" rewritePrefix="./xsd/1.0/"/>
+
+<rewriteURI         uriStartString="http://relaxng.org/relaxng.dtd" rewritePrefix="./dtd/1.0/"/>
+<rewriteSystem systemIdStartString="http://relaxng.org/relaxng.dtd" rewritePrefix="./dtd/1.0/"/>
+
+</catalog>

Added: packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,633 @@
+
+<!DOCTYPE html
+  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head>
+      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <title>RELAX NG Compact Syntax</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.57.0"><meta name="description" content="This document specifies a compact, non-XML syntax for ."><meta http-equiv="content-style-type" content="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="d0e2"></a>RELAX NG Compact Syntax</h1></div><div><h2>Committee Specification&nbsp;21 November 2002</h2></div><div><dl><dt>This version:</dt><dd>Committee Specification: 21 November 2002</dd></dl></div><div><dl><dt>Editor:</dt><dd>James Clark&nbsp;<tt>&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright &copy; The Organization for the Advancement of
+Structured Information Standards [OASIS] 2002. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="d0e61"></a>Abstract</h2><p>This document specifies a compact, non-XML syntax for [<a href="#spec">RELAX NG</a>].</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This Committee Specification was approved for publication by the
+OASIS RELAX NG technical committee. It is a stable document which
+represents the consensus of the committee. Comments on this document
+may be sent to <a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p><p>A list of known errors in this document is available at <a href="http://www.oasis-open.org/committees/relax-ng/compact-20021121-errata.html" target="_top">http://www.oasis-open.org/committees/relax-ng/compact-20021121-errata.html</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1. <a href="#d0e74">Introduction</a></dt><dt>2. <a href="#syntax">Syntax</a></dt><dt>3. <a href="#d0e171">Lexical structure</a></dt><dt>4. <a href="#d0e205">Declarations</a></dt><dt>5. <a href="#annotations">Annotations</a></dt><dd><dl><dt>5.1. <a href="#d0e331">Initial annotations</a></dt><dt>5.2. <a href="#d0e339">Documentation shorthand</a></dt><dt>5.3. <a href="#d0e377">Following annotations</a></dt><dt>5.4. <a href="#d0e385">Grammar annotations</a></dt></dl></dd><dt>6. <a href="#d0e401">Conformance</a></dt><dd><dl><dt>6.1. <a href="#d0e406">Validator</a></dt><dt>6.2. <a href="#d0e419">Structure preserving translator</a></dt><dt>6.3. <a href="#d0e456">Non-structure preserving translator</a></dt></dl></dd></dl><h3>Appendixes</h3><dl><dt>A. <a href="#formal">Formal description</a></dt><dd><dl><dt>1. <a href="#formal-syntax">Syntax</a></dt><dt>2. <a href="#d0e3892">Lexical structure</a></dt><dd><dl><dt>2.1. <a href="#d0e3901">Character encoding</a></dt><dt>2.2. <a href="#d0e3915">BOM stripping</a></dt><dt>2.3. <a href="#d0e3920">Newline normalization</a></dt><dt>2.4. <a href="#d0e3937">Escape interpretation</a></dt><dt>2.5. <a href="#d0e4256">Tokenization</a></dt></dl></dd></dl></dd><dt>B. <a href="#compact-relax-ng">Compact syntax RELAX NG schema for RELAX NG (Non-Normative)</a></dt><dt><a href="#d0e4913">References</a></dt></dl></div><hr><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e74"></a>1.&nbsp;Introduction</h2></div></div><p>This specification describes a compact, non-XML syntax for [<a href="#spec">RELAX NG</a>].</p><p>The goals of this syntax are to:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e84"></a>maximize readability;</li><li><a name="d0e87"></a>support all features of RELAX NG; it must be possible
+to translate a schema from the XML syntax to the compact syntax and
+back without losing significant information;</li><li><a name="d0e90"></a>support separate translation; a RELAX NG schema may be
+spread amongst multiple files; it must be possible to represent each
+of the files separately in the compact syntax; the representation of
+each file must not depend on the other files.</li></ul></div><p>The syntax has similarities to [<a href="#xquery">XQuery Formal Semantics</a>], to
+[<a href="#xduce">XDuce</a>] and to the DTD syntax of [<a href="#xml-rec">XML 1.0</a>].</p><p>The body of this document contains an informal description of
+the syntax and how it maps onto the XML syntax.  Developers should
+consult <a href="#formal" title="A. Formal description">Appendix&nbsp;A</a> for a complete, rigorous
+description. <a href="#compact-relax-ng" title="B. Compact syntax RELAX NG schema for RELAX NG (Non-Normative)">Appendix&nbsp;B</a> contains an example in
+the form of schema for RELAX NG.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="syntax"></a>2.&nbsp;Syntax</h2></div></div><p>The following is a summary of the syntax in EBNF. Square
+brackets are used to indicate optionality. The reader may find it
+helpful to compare this with the syntax in Section 3 of [<a href="#spec">RELAX NG</a>]. The start symbol is topLevel.</p><table><tr valign="baseline"><td>topLevel</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>decl</i>* (<i>pattern</i> | <i>grammarContent</i>*)</td></tr><tr valign="baseline"><td>decl</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>namespace</code>" <i>identifierOrKeyword</i> "<code>=</code>" <i>namespaceURILiteral</i><br>| "<code>default</code>" "<code>namespace</code>" [<i>identifierOrKeyword</i>] "<code>=</code>" <i>namespaceURILiteral</i><br>| "<code>datatypes</code>" <i>identifierOrKeyword</i> "<code>=</code>" <i>literal</i></td></tr><tr valign="baseline"><td>pattern</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>element</code>" <i>nameClass</i> "<code>{</code>" <i>pattern</i> "<code>}</code>"<br>| "<code>attribute</code>" <i>nameClass</i> "<code>{</code>" <i>pattern</i> "<code>}</code>"<br>| <i>pattern</i> ("<code>,</code>" <i>pattern</i>)+<br>| <i>pattern</i> ("<code>&amp;</code>" <i>pattern</i>)+<br>| <i>pattern</i> ("<code>|</code>" <i>pattern</i>)+<br>| <i>pattern</i> "<code>?</code>"<br>| <i>pattern</i> "<code>*</code>"<br>| <i>pattern</i> "<code>+</code>"<br>| "<code>list</code>" "<code>{</code>" <i>pattern</i> "<code>}</code>"<br>| "<code>mixed</code>" "<code>{</code>" <i>pattern</i> "<code>}</code>"<br>| <i>identifier</i><br>| "<code>parent</code>" <i>identifier</i><br>| "<code>empty</code>"<br>| "<code>text</code>"<br>| [<i>datatypeName</i>] <i>datatypeValue</i><br>| <i>datatypeName</i> ["<code>{</code>" <i>param</i>* "<code>}</code>"] [<i>exceptPattern</i>]<br>| "<code>notAllowed</code>"<br>| "<code>external</code>" <i>anyURILiteral</i> [<i>inherit</i>]<br>| "<code>grammar</code>" "<code>{</code>" <i>grammarContent</i>* "<code>}</code>"<br>| "<code>(</code>" <i>pattern</i> "<code>)</code>"</td></tr><tr valign="baseline"><td>param</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>identifierOrKeyword</i> "<code>=</code>" <i>literal</i></td></tr><tr valign="baseline"><td>exceptPattern</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>-</code>" <i>pattern</i></td></tr><tr valign="baseline"><td>grammarContent</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>start</i><br>| <i>define</i><br>| "<code>div</code>" "<code>{</code>" <i>grammarContent</i>* "<code>}</code>"<br>| "<code>include</code>" <i>anyURILiteral</i> [<i>inherit</i>] ["<code>{</code>" <i>includeContent</i>* "<code>}</code>"]</td></tr><tr valign="baseline"><td>includeContent</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>define</i><br>| <i>start</i><br>| "<code>div</code>" "<code>{</code>" <i>includeContent</i>* "<code>}</code>"</td></tr><tr valign="baseline"><td>start</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>start</code>" <i>assignMethod</i> <i>pattern</i></td></tr><tr valign="baseline"><td>define</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>identifier</i> <i>assignMethod</i> <i>pattern</i></td></tr><tr valign="baseline"><td>assignMethod</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>=</code>"<br>| "<code>|=</code>"<br>| "<code>&amp;=</code>"</td></tr><tr valign="baseline"><td>nameClass</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>name</i><br>| <i>nsName</i> [<i>exceptNameClass</i>]<br>| <i>anyName</i> [<i>exceptNameClass</i>]<br>| <i>nameClass</i> "<code>|</code>" <i>nameClass</i><br>| "<code>(</code>" <i>nameClass</i> "<code>)</code>"</td></tr><tr valign="baseline"><td>name</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>identifierOrKeyword</i><br>| <i>CName</i></td></tr><tr valign="baseline"><td>exceptNameClass</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>-</code>" <i>nameClass</i></td></tr><tr valign="baseline"><td>datatypeName</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>CName</i><br>| "<code>string</code>"<br>| "<code>token</code>"</td></tr><tr valign="baseline"><td>datatypeValue</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>literal</i></td></tr><tr valign="baseline"><td>anyURILiteral</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>literal</i></td></tr><tr valign="baseline"><td>namespaceURILiteral</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>literal</i><br>| "<code>inherit</code>"</td></tr><tr valign="baseline"><td>inherit</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>inherit</code>" "<code>=</code>" <i>identifierOrKeyword</i></td></tr><tr valign="baseline"><td>identifierOrKeyword</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>identifier</i><br>| <i>keyword</i></td></tr><tr valign="baseline"><td>identifier</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>(<i>NCName</i> - <i>keyword</i>)<br>| <i>quotedIdentifier</i></td></tr><tr valign="baseline"><td>quotedIdentifier</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>\</code>" <i>NCName</i></td></tr><tr valign="baseline"><td>CName</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>NCName</i> "<code>:</code>" <i>NCName</i></td></tr><tr valign="baseline"><td>nsName</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>NCName</i> "<code>:*</code>"</td></tr><tr valign="baseline"><td>anyName</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>*</code>"</td></tr><tr valign="baseline"><td>literal</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>literalSegment</i> ("<code>~</code>" <i>literalSegment</i>)+</td></tr><tr valign="baseline"><td>literalSegment</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>'<code>"</code>' (<i>Char</i> - ('<code>"</code>' | <i>newline</i>))* '<code>"</code>'<br>| "<code>'</code>" (<i>Char</i> - ("<code>'</code>" | <i>newline</i>))* "<code>'</code>"<br>| '<code>"""</code>' (['<code>"</code>'] ['<code>"</code>'] (<i>Char</i> - '<code>"</code>'))* '<code>"""</code>'<br>| "<code>'''</code>" (["<code>'</code>"] ["<code>'</code>"] (<i>Char</i> - "<code>'</code>"))* "<code>'''</code>"</td></tr><tr valign="baseline"><td>keyword</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>attribute</code>"<br>| "<code>default</code>"<br>| "<code>datatypes</code>"<br>| "<code>div</code>"<br>| "<code>element</code>"<br>| "<code>empty</code>"<br>| "<code>external</code>"<br>| "<code>grammar</code>"<br>| "<code>include</code>"<br>| "<code>inherit</code>"<br>| "<code>list</code>"<br>| "<code>mixed</code>"<br>| "<code>namespace</code>"<br>| "<code>notAllowed</code>"<br>| "<code>parent</code>"<br>| "<code>start</code>"<br>| "<code>string</code>"<br>| "<code>text</code>"<br>| "<code>token</code>"</td></tr></table><p>NCName is defined in [<a href="#xml-names">XML Namespaces</a>].  Char is
+defined in [<a href="#xml-rec">XML 1.0</a>].</p><p>In order to use a keyword as an identifier, it must be quoted
+with <tt>\</tt>. It is not necessary to quote a keyword that
+is used as the name of an element or attribute or as datatype
+parameter.</p><p>The value of a literal is the concatenation of the values of its
+constituent literalSegments.  A literalSegment is always terminated
+only by an occurrence of the same delimiter that began it.  The
+delimiter used to begin a literalSegment may be either one or three
+occurrences of a single or double quote character.  Newlines are
+allowed only in literalSegments delimited by three quote characters.
+The value of a literal segment consists of the characters between its
+delimiters.  One way to get a literal whose value contains both a
+single and a double quote is to divide the literal into multiple
+literalSegments so that the single and double quote are in separate
+literalSegments.  Another way is to use a literalSegment delimited by
+three single or double quotes.</p><p>Annotations can be specified as described in <a href="#annotations" title="5.&nbsp;Annotations">Section&nbsp;5</a>.</p><p>There is no notion of operator precedence.  It is an error
+for patterns to combine the <tt>|</tt>, <tt>&amp;</tt>,
+<tt>,</tt> and <tt>-</tt> operators without using
+parentheses to make the grouping explicit.  For example,
+<tt>foo | bar, baz</tt> is not allowed; instead,
+either <tt>(foo | bar), baz</tt> or
+<tt>foo | (bar, baz)</tt> must be used. A similar
+restriction applies to name classes and the use of the
+<tt>|</tt> and <tt>-</tt> operators.  These
+restrictions are not expressed in the above EBNF but they are made
+explicit in the BNF in <a href="#formal-syntax" title="1.&nbsp;Syntax">Section&nbsp;1</a>.</p><p>The value of an anyURILiteral specified with
+<tt>include</tt> or <tt>external</tt> is a URI
+reference to a grammar in the compact syntax.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e171"></a>3.&nbsp;Lexical structure</h2></div></div><p>Whitespace is allowed between tokens. Tokens are the strings
+occurring in double quotes in the EBNF in <a href="#syntax" title="2.&nbsp;Syntax">Section&nbsp;2</a>, except
+that literalSegment, nsName, CName, identifier and quotedIdentifer are
+single tokens.</p><p>Comments are also allowed between tokens.  Comments start with a
+<tt>#</tt> and continue to the end of the line.  Comments
+starting with <tt>##</tt> are treated specially; see <a href="#annotations" title="5.&nbsp;Annotations">Section&nbsp;5</a>.</p><p>A Unicode character with hex code <i><tt>N</tt></i>
+can be represented by the escape sequence
+<tt>\x{<i><tt>N</tt></i>}</tt>.  Using such an
+escape sequence is completely equivalent to the entering the
+corresponding character directly. For example,</p><pre class="programlisting">
+element \x{66}\x{6f}\x{6f} { empty }
+</pre><p>is equivalent to</p><pre class="programlisting">
+element foo { empty }
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e205"></a>4.&nbsp;Declarations</h2></div></div><p>A <tt>datatypes</tt> declaration declares a prefix
+used in a QName identifying a datatype. For example,</p><pre class="programlisting">
+datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
+element height { xsd:double }
+</pre><p>In fact, in the above example, the <tt>datatypes</tt>
+declaration is not required: the
+<tt>xsd</tt> prefix is predeclared to the above URI.</p><p>A <tt>namespace</tt> declaration declares a prefix used in a
+QName specifying the name of an element or attribute.  For
+example,</p><pre class="programlisting">
+namespace rng = "http://relaxng.org/ns/structure/1.0"
+element rng:text { empty }
+</pre><p>As in XML, the <tt>xml</tt> prefix is predeclared.</p><p>A <tt>default namespace</tt> declaration declares
+the namespace used for unprefixed names specifying the name
+of an element (but not of an attribute). For example,</p><pre class="programlisting">
+default namespace = "http://example.com"
+element foo { attribute bar { string } }
+</pre><p>is equivalent to</p><pre class="programlisting">
+namespace ex = "http://example.com"
+element ex:foo { attribute bar { string } }
+</pre><p>A <tt>default namespace</tt> declaration may have a prefix
+as well.  For example,</p><pre class="programlisting">
+default namespace ex = "http://example.com"
+</pre><p>is equivalent to</p><pre class="programlisting">
+default namespace = "http://example.com"
+namespace ex = "http://example.com"
+</pre><p>The URI may be empty.  This makes the prefix stand for the absent
+namespace URI.  This is necessary for specifying a name class that
+matches any name with an absent namespace URI. For example:</p><pre class="programlisting">
+namespace local = ""
+element foo { attribute * - local:* { string }* }
+</pre><p>is equivalent to</p><pre class="programlisting">
+&lt;element xmlns="http://relaxng.org/ns/structure/1.0""
+         name="foo"
+         ns="http://example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName&gt;
+	&lt;except&gt;
+	  &lt;nsName ns=""/&gt;
+	&lt;/except&gt;
+      &lt;/anyName&gt;
+      &lt;data type="string"/&gt;
+    &lt;/attribute&gt;
+  &lt;zeroOrMore&gt;
+&lt;/element&gt;
+</pre><p>RELAX NG has the feature that if a file does not specify an
+<tt>ns</tt> attribute then the <tt>ns</tt>
+attribute can be inherited from the including file.  To support this
+feature, the keyword <tt>inherit</tt> can be specified in
+place of the namespace URI in a namespace declaration. For
+example,</p><pre class="programlisting">
+default namespace this = inherit
+element foo { element * - this:* { string }* }
+</pre><p>is equivalent to</p><pre class="programlisting">
+&lt;element xmlns="http://relaxng.org/ns/structure/1.0""
+         name="foo"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element&gt;
+      &lt;anyName&gt;
+	&lt;except&gt;
+	  &lt;nsName/&gt;
+	&lt;/except&gt;
+      &lt;/anyName&gt;
+      &lt;data type="string"/&gt;
+    &lt;/element&gt;
+  &lt;zeroOrMore&gt;
+&lt;/element&gt;
+</pre><p>In addition, the <tt>include</tt> and
+<tt>external</tt> patterns can specify <tt>inherit =
+<i><tt>prefix</tt></i></tt> to specify the namespace
+to be inherited by the referenced file. For example,</p><pre class="programlisting">
+namespace x = "http://www.example.com"
+external "foo.rng" inherit = x
+</pre><p>is equivalent to</p><pre class="programlisting">
+&lt;externalRef href="foo.rng"
+  ns="http://www.example.com"
+  xmlns="http://relaxng.org/ns/structure/1.0"/&gt;
+</pre><p>In the absence of an <tt>inherit</tt> parameter on
+<tt>include</tt> or <tt>external</tt>, the default
+namespace will be inherited by the referenced file.</p><p>In the absence of a <tt>default namespace</tt>
+declaration, a declaration of</p><pre class="programlisting">
+default namespace = inherit
+</pre><p>is assumed.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="annotations"></a>5.&nbsp;Annotations</h2></div></div><p>The RELAX NG XML syntax allows foreign elements and attributes
+to be used to annotate a RELAX NG schema.  A schema in the compact
+syntax can also have annotations, which will turn into foreign
+elements and attributes when the schema is translated into XML syntax.
+The way these annotations are specified depends on where the foreign
+elements and attributes are to appear in the translated schema.  There
+is also a special shorthand syntax when the foreign element is a
+<tt>documentation</tt> element as described in [<a href="#compat">Compatibility</a>].</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e331"></a>5.1.&nbsp;Initial annotations</h3></div></div><p>An annotation in square brackets can be inserted immediately
+before a pattern, param, nameClass, grammarContent or includeContent. It has
+the following syntax:</p><table><tr valign="baseline"><td>annotation</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>[</code>" <i>annotationAttribute</i>* <i>annotationElement</i>* "<code>]</code>"</td></tr><tr valign="baseline"><td>annotationAttribute</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>name</i> "<code>=</code>" <i>literal</i></td></tr><tr valign="baseline"><td>annotationElement</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td><i>name</i> "<code>[</code>" <i>annotationAttribute</i>* (<i>annotationElement</i> | <i>literal</i>)* "<code>]</code>"</td></tr></table><p>Each of the annotationAttributes will turn into attributes on
+the corresponding RELAX NG element.  Each of the annotationElements
+will turn into initial children of the corresponding RELAX NG element,
+except in the case where the RELAX NG element cannot have children, in
+which case they will turn into following elements.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e339"></a>5.2.&nbsp;Documentation shorthand</h3></div></div><p>Comments starting with <tt>##</tt> are used to specify
+<tt>documentation</tt> elements from the
+<tt>http://relaxng.org/ns/compatibility/annotations/1.0</tt>
+namespace as described in [<a href="#compat">Compatibility</a>].  For example,</p><pre class="programlisting">
+## Represents a language
+element lang { 
+  ## English
+  "en" |
+  ## Japanese
+  "jp"
+}
+</pre><p>turns into</p><pre class="programlisting">
+&lt;element name="lang"
+    xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
+    xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;a:documentation&gt;Represents a language&lt;/a:documentation&gt;
+  &lt;choice&gt;
+    &lt;value&gt;en&lt;/value&gt;
+    &lt;a:documentation&gt;English&lt;/a:documentation&gt;
+    &lt;value&gt;jp&lt;/value&gt;
+    &lt;a:documentation&gt;Japanese&lt;/a:documentation&gt;
+  &lt;/choice&gt;
+&lt;/element&gt;
+</pre><p><tt>##</tt> comments can only be used immediately
+before before a pattern, nameClass, grammarContent or includeContent.
+Multiple <tt>##</tt> comments are allowed. Multiple adjacent
+<tt>##</tt> comments without any intervening blank lines are
+merged into a single
+<tt>documentation</tt> element. Any <tt>##</tt>
+comments must precede any annotation in square brackets.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e377"></a>5.3.&nbsp;Following annotations</h3></div></div><p>A pattern or nameClass may be followed by any number of
+followAnnotations with the following syntax:</p><table><tr valign="baseline"><td>followAnnotation</td><td>&nbsp;&nbsp;::=&nbsp;&nbsp;</td><td>"<code>&gt;&gt;</code>" <i>annotationElement</i></td></tr></table><p>Each such annotationElement turns into a following sibling of
+the RELAX NG element representing the pattern or nameClass.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e385"></a>5.4.&nbsp;Grammar annotations</h3></div></div><p>An annotationElement may be used in any place where
+grammarContent or includeContent is allowed. For example,</p><pre class="programlisting">
+namespace x = "http://www.example.com"
+
+start = foo
+
+x:entity [ name="picture" systemId="picture.jpeg" notation="jpeg" ]
+
+foo = element foo { empty }
+</pre><p>turns into</p><pre class="programlisting">&lt;grammar xmlns:x="http://www.example.com" 
+         xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;start&gt;
+    &lt;ref name="foo"/&gt;
+  &lt;/start&gt;
+  &lt;x:entity name="picture" systemId="picture.jpeg" notation="jpeg"/&gt;
+  &lt;define name="foo"&gt;
+    &lt;element name="foo"&gt;
+      &lt;empty/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+&lt;/grammar&gt;</pre><p>If the name of such an element is a keyword, then it must be
+quoted with <tt>\</tt>.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e401"></a>6.&nbsp;Conformance</h2></div></div><p>There are three kinds of conformant implementation.</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e406"></a>6.1.&nbsp;Validator</h3></div></div><p>A validator conforming to this specification must be able to
+determine whether a textual object is a correct RELAX NG Compact
+Syntax schema as specified in <a href="#formal" title="A. Formal description">Appendix&nbsp;A</a>.  It must also
+be able to determine for any XML document and for any correct RELAX NG
+Compact Syntax schema whether the document is valid (as defined in
+[<a href="#spec">RELAX NG</a>]) with respect to the translation of the schema
+into XML syntax.  It need not be able to output a representation of
+the translation of the schema into XML syntax.</p><p>The requirements in the preceding paragraph are subject to the
+provisions of the second paragraph of Section 8 of [<a href="#spec">RELAX NG</a>].</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e419"></a>6.2.&nbsp;Structure preserving translator</h3></div></div><p>A structure preserving translator must be able to translate any
+correct RELAX NG Compact Syntax schema into an XML document whose data
+model is strictly equivalent to the translation specified in <a href="#formal" title="A. Formal description">Appendix&nbsp;A</a>.  For this purpose, two instances of the data model
+(as specified in Section 2 of [<a href="#spec">RELAX NG</a>]) are considered
+strictly equivalent if they are identical after applying the
+simplifications specified in Sections 4.2, 4.3, 4.4, 4.8, 4.9 and 4.10
+of [<a href="#spec">RELAX NG</a>], with the exception that the base URI in the
+context of elements may differ.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The RELAX NG compact syntax is not a representation of the
+XML syntax of a RELAX NG schema; rather it is a representation of the
+semantics of a RELAX NG schema.  Details of the XML syntax that were
+judged to be insignificant are not captured in the compact syntax.
+For example, in the XML syntax if the name class for an
+<tt>element</tt> or <tt>attribute</tt> pattern
+consists of just a single name, it can be expressed either as a
+<tt>name</tt> attribute or as a <tt>name</tt>
+element; however, in the compact syntax, there is only one way to
+express such a name class.  The simplifications listed in the previous
+paragraph correspond to those syntactic details that are not captured
+in the compact syntax.</p></div><p>When comparing two <tt>include</tt> or
+<tt>externalRef</tt> patterns in the XML source for strict
+equivalence, the value of the <tt>href</tt> attributes are
+not compared; instead the referenced XML documents are compared for
+strict equivalence.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e456"></a>6.3.&nbsp;Non-structure preserving translator</h3></div></div><p>A non-structure preserving translator must be able to translate
+any correct RELAX NG Compact Syntax schema into an XML document whose
+data model is loosely equivalent to the translation specified in <a href="#formal" title="A. Formal description">Appendix&nbsp;A</a>. For this purpose, two instances of the data model
+(as specified in Section 2 of [<a href="#spec">RELAX NG</a>]) are considered
+loosely equivalent if they are such that, after applying all the
+simplifications specified in Section 4 of [<a href="#spec">RELAX NG</a>], one
+can be transformed into the other merely by reordering and renaming
+definitions.  After the simplifications have been applied, the context
+of elements is ignored when comparing the two instances.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>A validator for the compact syntax can be implemented as a
+combination of a non-structure preserving translator for the compact
+syntax and a validator for the XML syntax.</p></div></div></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="formal"></a>A. Formal description</h2><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="formal-syntax"></a>1.&nbsp;Syntax</h3></div></div><p>The compact syntax is specified by a grammar in BNF.  The
+translation into the XML syntax is specified by annotations in the
+grammar.</p><p>The start symbol is <i><a href="#nt-topLevel" class="nt">topLevel</a></i>.</p><p>The BNF description consists of a set of production rules.  Each
+production rule has a left-hand side and right-hand side separated by
+<tt>::=</tt>.  The left-hand side specifies the name of a
+non-terminal.  The right-hand side specifies a list of one or more
+alternatives separated by <tt>|</tt>.  Each alternative
+consists of a sequence of terminals and non-terminals.  A non-terminal
+is specified by a name in italics.  A terminal is either a literal
+string in quotes or a named terminal specified by a name in bold
+italics.  An alternative can also be specified as <i>&#949;</i>, which
+denotes an empty sequence of tokens.</p><p>Each alternative may be followed by references to one or more
+named constraints that apply to that alternative.</p><p>The translation into XML syntax is specified by associating a
+value with each terminal and non-terminal in the derivation.  Each
+alternative in the BNF may be followed by an expression in curly
+braces, which specifies how to compute the value associated with the
+left-hand side non-terminal.  Each terminal and non-terminal on the
+right-hand side can be labelled with a subscript specifying a variable
+name.  When that variable name is used within the curly braces, it
+refers to the value associated with that terminal or non-terminal.  If
+an alternative consists of a single terminal or non-terminal, then the
+expression in curly braces can be omitted; in this case the value of
+the left-hand side is the value of that terminal or
+non-terminal.</p><p>The result of the translation is not a string containing the XML
+representation of a RELAX NG schema, but rather is an instance of the
+data model described in Section 2 of [<a href="#spec">RELAX NG</a>]; this
+instance will match the RELAX NG schema for RELAX NG.</p><p>A textual object is a correct RELAX NG Compact Syntax schema 
+if:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e503"></a>it matches the grammar specified in this section,</li><li><a name="d0e506"></a>it satisfies all the constraints specified in this section, and</li><li><a name="d0e509"></a>the result of the translation is a correct RELAX NG schema.</li></ul></div><p>The computation of the value of a non-terminal may make use of
+one or more arguments.  When the name of such a non-terminal occurs on
+the left-hand side of a production, it is followed by an argument list
+that declares the formal arguments for the non-terminal; these formal
+arguments may be referred to by expressions on the right-hand side,
+as, for example, in <i><a href="#nt-simpleNameClass" class="nt">simpleNameClass</a></i>.  When the name
+occurs on the right-hand side of a production, it may be followed by
+one or more assignments that specify the actual arguments which will
+be bound to the formal arguments during the computation of the value
+of the non-terminal.  Arguments may be passed down implicitly: if
+there is no actual argument corresponding to a particular formal
+argument, then the formal argument is bound to the value of the
+variable with the same name as the name of the formal argument.  In
+other words, for any variable <i>x</i>, a default actual
+argument of <i>x</i> := <i>x</i> is assumed.  For example, see <i><a href="#nt-nameClassChoice" class="nt">nameClassChoice</a></i>.</p><p>In addition to explicit arguments, every non-terminal implicitly
+has an argument that specifies an environment for the interpretation
+of a pattern.  By default, the implicit environment argument to each
+non-terminal is the same as its parent.  This may be overridden for a
+particular non-terminal by including <b>environment</b> in the
+argument list.  For example, see <i><a href="#nt-topLevel" class="nt">topLevel</a></i> and <i><a href="#nt-preamble" class="nt">preamble</a></i>.</p><p>An environment specifies:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e534"></a>a mapping from datatype prefixes to
+URIs;</li><li><a name="d0e537"></a>a mapping from namespace prefixes to URIs; a namespace
+prefix may be mapped to a special value <b>inherit</b> as well as to a
+URI;</li><li><a name="d0e542"></a>the default namespace; the default namespace is either
+a URI or the special value <b>inherit</b>;</li><li><a name="d0e547"></a>the base URI.</li></ul></div><p>The special value <b>inherit</b> is used to indicate that a
+namespace URI should be inherited from the referencing schema.</p><p>In the initial environment used for the start symbol,
+<tt>xml</tt> is bound as a namespace prefix to
+<tt>http://www.w3.org/XML/1998/namespace</tt>, and
+<tt>xsd</tt> is bound as a datatype prefix to
+<tt>http://www.w3.org/2001/XMLSchema-datatypes</tt>; the
+base URI is determined as specified by [<a href="#rfc2396">RFC 2396</a>].</p><p>The value of an expression is one of the following:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e573"></a>the constants true, false or
+inherit;</li><li><a name="d0e576"></a>a string;</li><li><a name="d0e579"></a>a name (a namespace URI/local name pair);</li><li><a name="d0e582"></a>a qualified-name (a prefix/local name pair);</li><li><a name="d0e585"></a>an XML fragment, where an XML fragment is a pair of a
+set of zero or more attributes and a content sequence of zero or more
+strings and elements, as described in the data model of [<a href="#spec">RELAX NG</a>]; an XML fragment is thus the same kind of thing as
+what is matched against a RELAX NG pattern;</li><li><a name="d0e590"></a>an environment.</li></ul></div><p>Each terminal and non-terminal has an associated type identified
+by a name.  A type is simply a set of values.  The value of a terminal
+or non-terminal is always a member of the set of values identified by
+the name of its type.  The name of the type of a terminal or
+non-terminal is given following the keyword returns before ::= in the
+production rule.  Similarly, each argument has a type, which is given
+immediately before the name of the argument.  The value of a
+non-terminal may also be specified to be void; no expression is given
+for the value of such a non-terminal, nor will the value of such a
+non-terminal be used in any expression.</p><p>The following types are all disjoint:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e598"></a>Boolean contains true and false;</li><li><a name="d0e603"></a>Inherit contains inherit;</li><li><a name="d0e608"></a>String contains all strings;</li><li><a name="d0e613"></a>Name contains all names;</li><li><a name="d0e618"></a>Qname contains all qualified-names;</li><li><a name="d0e623"></a>Environment contains all enviroments;</li><li><a name="d0e628"></a>Xml contains all XML fragments.</li></ul></div><p>It is also useful to identify some subtypes of Xml.  One type is
+a subtype of another if the set of values of the one type is a subset
+of the set of values of the other.</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e639"></a>Content contains all XML fragments that have an empty
+set of attributes;</li><li><a name="d0e644"></a>Elements contains all XML fragments that have an empty
+set of attributes and whose content sequence does not have any string
+members; it is a subtype of content;</li><li><a name="d0e649"></a>Element contains all XML fragments that have an empty
+set of attributes and whose content sequence consists of a single
+element; it is a subtype of elements;</li><li><a name="d0e654"></a>Attributes contains all XML fragments that have an
+empty content sequence;</li><li><a name="d0e659"></a>Attribute contains all XML fragments that have an
+empty content sequence and whose attribute set consists of a single
+attribute.</li></ul></div><p>In addition it is useful to have the following union type.</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e667"></a>NamespaceURI is the union of String and
+Inherit.</li></ul></div><p>Expressions use the following notation:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e681"></a><i>x</i> denotes the value of the variable
+named <i><tt>x</tt></i>;</li><li><a name="d0e688"></a>( ) denotes an empty
+XML fragment;</li><li><a name="d0e692"></a>(<i>x</i>, <i>y</i>) denotes the concatenation of the XML fragments
+<i>x</i> and <i>y</i>; the attributes of the
+resulting XML fragment consist of the union of the attributes of
+<i>x</i> and <i>y</i> and the content sequence
+consists of the concatenation of the content sequence of <i>x</i> and <i>y</i> (this is the same as the meaning of
+the comma operator in the compact syntax);</li><li><a name="d0e710"></a><b>environment</b> denotes the value of the implicit
+environment argument;</li><li><a name="d0e714"></a><b>true</b>, <b>false</b> and <b>inherit</b> are used
+to denote the corresponding special constant;</li><li><a name="d0e722"></a>"<code>xyzzy</code>" denotes a string
+consisting of the characters
+<tt>xyzzy</tt>;</li><li><a name="d0e730"></a>f(<i>x</i>, <i>y</i>, &nbsp;.&nbsp;.&nbsp;.&nbsp;) denotes the
+value of the function f applied to the arguments <i>x</i>,
+<i>y</i>, &nbsp;.&nbsp;.&nbsp;.&nbsp;; the available functions are as
+follows:<dl><dt><a name="prim-qName">qName</a>(String <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> Qname</dt><dd>returns a
+qualified-name with prefix <i>x</i> and local part <i>y</i>;</dd><dt><a name="prim-prefix">prefix</a>(Qname <i>x</i>)  <b>returns</b> String</dt><dd>returns the prefix of the qualified-name <i>x</i>;</dd><dt><a name="prim-localPart">localPart</a>(Qname <i>x</i>)  <b>returns</b> String</dt><dd>returns the local-part of the qualified-name
+<i>x</i>;</dd><dt><a name="prim-name">name</a>(String <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> Name</dt><dd>returns a name
+with namespace URI <i>x</i> and local name <i>y</i>;</dd><dt><a name="prim-attribute">attribute</a>(Name <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> Attribute</dt><dd>returns an XML
+fragment consisting of an attribute with name <i>x</i> and
+value <i>y</i>;</dd><dt><a name="prim-element">element</a>(Environment <i>x</i>,&nbsp;Name <i>y</i>,&nbsp;Xml <i>z</i>)  <b>returns</b> Element</dt><dd>returns an XML fragment consisting of an element with
+name <i>y</i> and attributes and children <i>z</i>; the namespace map of the context of the element contains
+all the mappings from namespace prefixes to URIs from <i>x</i> except those mappings that map to <b>inherit</b> or to the
+empty string; the namespace map may contain an additional mapping from
+an implementation-dependent prefix to the compatibility annotations
+URI; the default namespace of namespace map of the context of the
+element is the RELAX NG namespace URI
+<tt>http://relaxng.org/ns/structure/1.0</tt>; the base URI
+of the context of the element is not
+constrained;</dd><dt><a name="prim-text">text</a>(String <i>x</i>)  <b>returns</b> Content</dt><dd>returns an XML fragment whose content sequence consists of
+<i>x</i> if <i>x</i> is not the empty string,
+and otherwise the empty XML fragment;</dd><dt><a name="prim-bindPrefix">bindPrefix</a>(Environment <i>x</i>,&nbsp;String <i>y</i>,&nbsp;NamespaceURI <i>z</i>)  <b>returns</b> Environment</dt><dd>returns an environment that is the same as
+<i>x</i> except that it has the prefix <i>y</i>
+bound to <i>z</i>;</dd><dt><a name="prim-bindDefault">bindDefault</a>(Environment <i>x</i>,&nbsp;NamespaceURI <i>y</i>)  <b>returns</b> Environment</dt><dd>returns an environment that is the same as
+<i>x</i> except it has the default namespace <i>z</i>;</dd><dt><a name="prim-bindDatatypePrefix">bindDatatypePrefix</a>(Environment <i>x</i>,&nbsp;String <i>y</i>,&nbsp;String <i>z</i>)  <b>returns</b> Environment</dt><dd>returns an environment that is the same
+as <i>x</i> except that it has <i>y</i> bound as
+a prefix for datatypes to the URI <i>z</i>;</dd><dt><a name="prim-lookupPrefix">lookupPrefix</a>(Environment <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> String</dt><dd>returns the
+binding in the environment <i>x</i> for the prefix <i>y</i>; it is an error if there is no applicable
+binding;</dd><dt><a name="prim-lookupDefault">lookupDefault</a>(Environment <i>x</i>)  <b>returns</b> NamespaceURI</dt><dd>returns the default namespace of the
+environment <i>x</i>, or, if no default has been bound,
+<b>inherit</b>;</dd><dt><a name="prim-lookupDatatypePrefix">lookupDatatypePrefix</a>(Environment <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> String</dt><dd>returns the
+binding as a datatype prefix in the environment <i>x</i>
+for the prefix <i>y</i>; it is an error if there is no
+applicable binding;</dd><dt><a name="prim-mapSchemaRef">mapSchemaRef</a>(Environment <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> String</dt><dd>returns a
+URI; <i>y</i> is a URI reference of a resource containing a
+schema in the syntax described by this specification; the returned URI
+is the URI of a resource containing the translation of this schema
+into RELAX NG XML syntax; <i>y</i> is resolved into an
+absolute form as described in section 5.2 of [<a href="#rfc2396">RFC 2396</a>]
+using the base URI from the environment <i>x</i>; the
+restriction on the use of fragment identifiers specified in section
+4.5 of [<a href="#spec">RELAX NG</a>] applies to <i>y</i>;</dd><dt><a name="prim-makeNsAttribute">makeNsAttribute</a>(NamespaceURI <i>x</i>)  <b>returns</b> Attributes</dt><dd>returns an empty set if <i>x</i>
+is <b>inherit</b>, and otherwise an attribute whose namespace
+URI is the empty string, whose local name is
+<tt>ns</tt> and whose value is <i>x</i>;</dd><dt><a name="prim-applyAnnotations">applyAnnotations</a>(Xml <i>x</i>,&nbsp;Element <i>y</i>)  <b>returns</b> Element</dt><dd>returns an element
+whose name is the name of <i>y</i>, whose attributes are
+the union of the first member of <i>x</i> and the
+attributes of <i>y</i>, and whose children are the
+concatenation of the second member of <i>x</i> and the
+children of <i>y</i>;</dd><dt><a name="prim-applyAnnotationsGroup">applyAnnotationsGroup</a>(Xml <i>x</i>,&nbsp;Elements <i>y</i>)  <b>returns</b> Elements</dt><dd>returns the same as <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <code>&lt;group</code><code>&gt;</code> <i>y</i> <code>&lt;/group&gt;</code>) unless
+<i>x</i> is equal to ( ), in which case it
+returns <i>y</i>;</dd><dt><a name="prim-applyAnnotationsChoice">applyAnnotationsChoice</a>(Xml <i>x</i>,&nbsp;Elements <i>y</i>)  <b>returns</b> Elements</dt><dd>returns the same as <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <code>&lt;choice</code><code>&gt;</code> <i>y</i> <code>&lt;/choice&gt;</code>) unless
+<i>x</i> is equal to ( ), in which case it
+returns <i>y</i>;</dd><dt><a name="prim-stringConcat">stringConcat</a>(String <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> String</dt><dd>returns a string that is the
+concatenation of the strings <i>x</i> and <i>y</i>;</dd><dt><a name="prim-datatypeAttributes">datatypeAttributes</a>(String <i>x</i>,&nbsp;String <i>y</i>)  <b>returns</b> Attributes</dt><dd>returns a
+set of two attributes; both attributes have the empty string as their
+namespace URI; one attribute has local name
+<tt>datatypeLibrary</tt> and value <i>x</i>; the
+other attribute has local name
+<tt>type</tt> and value <i>y</i>;</dd><dt><a name="prim-documentationElementName">documentationElementName</a>()  <b>returns</b> Name</dt><dd>returns the name of the <tt>documentation</tt> element
+defined in [<a href="#compat">Compatibility</a>], that is, the name with namespace
+URI <tt>http://relaxng.org/ns/compatibility/annotations/1.0</tt> and
+local name <tt>documentation</tt>;</dd></dl></li><li><a name="d0e1015"></a><i>x</i> ? <i>y</i> : <i>z</i> is a conditional
+expression, which denotes <i>y</i> if <i>x</i>
+is <b>true</b> and <i>z</i> if <i>x</i> is
+<b>false</b>;</li><li><a name="d0e1034"></a><code>&lt;foo</code><code> </code><i>x</i><code>&gt;</code> <i>y</i> <code>&lt;/foo&gt;</code> denotes
+an XML fragment containing an element from the RELAX NG namespace with
+local name <tt>foo</tt>, attributes <i>x</i> and
+content <i>x</i>; the context of the element is determined
+from the implicit environment argument as specified for the element
+function above.</li></ul></div><p><i><a name="nt-topLevel">topLevel</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-preamble" class="nt">preamble</a></i><sub><i>e</i></sub>&nbsp;&nbsp;<i><a href="#nt-topLevelBody" class="nt">topLevelBody</a></i>(<b>environment</b> := <i>e</i>)<sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-preamble">preamble</a></i> <b>returns</b> Environment&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <b>environment</b> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-decl" class="nt">decl</a></i><sub><i>e</i></sub>&nbsp;&nbsp;<i><a href="#nt-preamble" class="nt">preamble</a></i>(<b>environment</b> := <i>e</i>)<sub><i>d</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>d</i> }</p><p><i><a name="nt-decl">decl</a></i> <b>returns</b> Environment&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>namespace</code>"&nbsp;&nbsp;<i><a href="#nt-namespacePrefix" class="nt">namespacePrefix</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-namespaceURILiteral" class="nt">namespaceURILiteral</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xml prefix">xml prefix</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xml namespace URI">xml namespace URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate declaration">duplicate declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-bindPrefix">bindPrefix</a>(<b>environment</b>, <i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>default</code>"&nbsp;&nbsp;"<code>namespace</code>"&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-namespaceURILiteral" class="nt">namespaceURILiteral</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xml namespace URI">xml namespace URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate declaration">duplicate declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-bindDefault">bindDefault</a>(<b>environment</b>, <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>default</code>"&nbsp;&nbsp;"<code>namespace</code>"&nbsp;&nbsp;<i><a href="#nt-namespacePrefix" class="nt">namespacePrefix</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-namespaceURILiteral" class="nt">namespaceURILiteral</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xml prefix">xml prefix</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xml namespace URI">xml namespace URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate declaration">duplicate declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-bindDefault">bindDefault</a>(<a href="#prim-bindPrefix">bindPrefix</a>(<b>environment</b>, <i>x</i>, <i>y</i>), <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>datatypes</code>"&nbsp;&nbsp;<i><a href="#nt-datatypePrefix" class="nt">datatypePrefix</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xsd prefix">xsd prefix</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-datatypes URI">datatypes URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate declaration">duplicate declaration</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-bindDatatypePrefix">bindDatatypePrefix</a>(<b>environment</b>, <i>x</i>, <i>y</i>) }</p><p><i><a name="nt-namespacePrefix">namespacePrefix</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-valid prefix">valid prefix</a></p><p><i><a name="nt-datatypePrefix">datatypePrefix</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i></p><p><i><a name="nt-namespaceURILiteral">namespaceURILiteral</a></i> <b>returns</b> NamespaceURI&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>inherit</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <b>inherit</b> }</p><p><i><a name="nt-topLevelBody">topLevelBody</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-single element">single element</a><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-grammar" class="nt">grammar</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;grammar</code><code>&gt;</code> <i>x</i> <code>&lt;/grammar&gt;</code> }</p><p><i><a name="nt-grammar">grammar</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-member" class="nt">member</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-grammar" class="nt">grammar</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-member">member</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedComponent" class="nt">annotatedComponent</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotationElementNotKeyword" class="nt">annotationElementNotKeyword</a></i></p><p><i><a name="nt-annotatedComponent">annotatedComponent</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-component" class="nt">component</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-component">component</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-start" class="nt">start</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-define" class="nt">define</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-include" class="nt">include</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-div" class="nt">div</a></i></p><p><i><a name="nt-start">start</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>start</code>"&nbsp;&nbsp;<i><a href="#nt-assignOp" class="nt">assignOp</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;start</code><code> </code><i>x</i><code>&gt;</code> <i>y</i> <code>&lt;/start&gt;</code> }</p><p><i><a name="nt-define">define</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-identifier" class="nt">identifier</a></i></b><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-assignOp" class="nt">assignOp</a></i><sub><i>y</i></sub>&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;define</code><code> </code><code>name=</code><i>x</i><code> </code><i>y</i><code>&gt;</code> <i>z</i> <code>&lt;/define&gt;</code> }</p><p><i><a name="nt-assignOp">assignOp</a></i> <b>returns</b> Attributes&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>=</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>|=</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-attribute">attribute</a>(<a href="#prim-name">name</a>("<code></code>", "<code>combine</code>"), "<code>choice</code>") }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>&amp;=</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-attribute">attribute</a>(<a href="#prim-name">name</a>("<code></code>", "<code>combine</code>"), "<code>interleave</code>") }</p><p><i><a name="nt-include">include</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>include</code>"&nbsp;&nbsp;<i><a href="#nt-anyURILiteral" class="nt">anyURILiteral</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-optInherit" class="nt">optInherit</a></i><sub><i>y</i></sub>&nbsp;&nbsp;<i><a href="#nt-optIncludeBody" class="nt">optIncludeBody</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;include</code><code> </code><code>href=</code><a href="#prim-mapSchemaRef">mapSchemaRef</a>(<b>environment</b>, <i>x</i>)<code> </code><i>y</i><code>&gt;</code> <i>z</i> <code>&lt;/include&gt;</code> }</p><p><i><a name="nt-anyURILiteral">anyURILiteral</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-any URI">any URI</a></p><p><i><a name="nt-optInherit">optInherit</a></i> <b>returns</b> Attributes&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-makeNsAttribute">makeNsAttribute</a>(<a href="#prim-lookupDefault">lookupDefault</a>(<b>environment</b>)) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>inherit</code>"&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-makeNsAttribute">makeNsAttribute</a>(<a href="#prim-lookupPrefix">lookupPrefix</a>(<b>environment</b>, <i>x</i>)) }</p><p><i><a name="nt-optIncludeBody">optIncludeBody</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-includeBody" class="nt">includeBody</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-includeBody">includeBody</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-includeMember" class="nt">includeMember</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-includeBody" class="nt">includeBody</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-includeMember">includeMember</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedIncludeComponent" class="nt">annotatedIncludeComponent</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotationElementNotKeyword" class="nt">annotationElementNotKeyword</a></i></p><p><i><a name="nt-annotatedIncludeComponent">annotatedIncludeComponent</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-includeComponent" class="nt">includeComponent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-includeComponent">includeComponent</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-start" class="nt">start</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-define" class="nt">define</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-includeDiv" class="nt">includeDiv</a></i></p><p><i><a name="nt-div">div</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>div</code>"&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-grammar" class="nt">grammar</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;div</code><code>&gt;</code> <i>x</i> <code>&lt;/div&gt;</code> }</p><p><i><a name="nt-includeDiv">includeDiv</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>div</code>"&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-includeBody" class="nt">includeBody</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;div</code><code>&gt;</code> <i>x</i> <code>&lt;/div&gt;</code> }</p><p><i><a name="nt-pattern">pattern</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-innerPattern" class="nt">innerPattern</a></i>(<i>anno</i> := ( ))</p><p><i><a name="nt-innerPattern">innerPattern</a></i>(Xml <i>anno</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-innerParticle" class="nt">innerParticle</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particleChoice" class="nt">particleChoice</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>anno</i>, <code>&lt;choice</code><code>&gt;</code> <i>x</i> <code>&lt;/choice&gt;</code>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particleGroup" class="nt">particleGroup</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>anno</i>, <code>&lt;group</code><code>&gt;</code> <i>x</i> <code>&lt;/group&gt;</code>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particleInterleave" class="nt">particleInterleave</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>anno</i>, <code>&lt;interleave</code><code>&gt;</code> <i>x</i> <code>&lt;/interleave&gt;</code>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotatedDataExcept" class="nt">annotatedDataExcept</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotationsGroup">applyAnnotationsGroup</a>(<i>anno</i>, <i>x</i>) }</p><p><i><a name="nt-particleChoice">particleChoice</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>|</code>"&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>|</code>"&nbsp;&nbsp;<i><a href="#nt-particleChoice" class="nt">particleChoice</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-particleGroup">particleGroup</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>,</code>"&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>,</code>"&nbsp;&nbsp;<i><a href="#nt-particleGroup" class="nt">particleGroup</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-particleInterleave">particleInterleave</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>&amp;</code>"&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-particle" class="nt">particle</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>&amp;</code>"&nbsp;&nbsp;<i><a href="#nt-particleInterleave" class="nt">particleInterleave</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-particle">particle</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-innerParticle" class="nt">innerParticle</a></i>(<i>anno</i> := ( ))</p><p><i><a name="nt-innerParticle">innerParticle</a></i>(Xml <i>anno</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedPrimary" class="nt">annotatedPrimary</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotationsGroup">applyAnnotationsGroup</a>(<i>anno</i>, <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-repeatedPrimary" class="nt">repeatedPrimary</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<a href="#prim-applyAnnotations">applyAnnotations</a>(<i>anno</i>, <i>x</i>), <i>y</i>) }</p><p><i><a name="nt-repeatedPrimary">repeatedPrimary</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedPrimary" class="nt">annotatedPrimary</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>*</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;zeroOrMore</code><code>&gt;</code> <i>x</i> <code>&lt;/zeroOrMore&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotatedPrimary" class="nt">annotatedPrimary</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>+</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;oneOrMore</code><code>&gt;</code> <i>x</i> <code>&lt;/oneOrMore&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotatedPrimary" class="nt">annotatedPrimary</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>?</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;optional</code><code>&gt;</code> <i>x</i> <code>&lt;/optional&gt;</code> }</p><p><i><a name="nt-annotatedPrimary">annotatedPrimary</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedPrimary" class="nt">leadAnnotatedPrimary</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-annotatedDataExcept">annotatedDataExcept</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedDataExcept" class="nt">leadAnnotatedDataExcept</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-leadAnnotatedDataExcept">leadAnnotatedDataExcept</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-dataExcept" class="nt">dataExcept</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-leadAnnotatedPrimary">leadAnnotatedPrimary</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-primary" class="nt">primary</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>(</code>"&nbsp;&nbsp;<i><a href="#nt-innerPattern" class="nt">innerPattern</a></i>(<i>anno</i> := <i>x</i>)<sub><i>y</i></sub>&nbsp;&nbsp;"<code>)</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>y</i> }</p><p><i><a name="nt-primary">primary</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>element</code>"&nbsp;&nbsp;<i><a href="#nt-nameClass" class="nt">nameClass</a></i>(<i>isElem</i> := <b>true</b>)<sub><i>x</i></sub>&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>y</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;element</code><code>&gt;</code> <i>x</i> <i>y</i> <code>&lt;/element&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>attribute</code>"&nbsp;&nbsp;<i><a href="#nt-nameClass" class="nt">nameClass</a></i>(<i>isElem</i> := <b>false</b>)<sub><i>x</i></sub>&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>y</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;attribute</code><code>&gt;</code> <i>x</i> <i>y</i> <code>&lt;/attribute&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>mixed</code>"&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;mixed</code><code>&gt;</code> <i>x</i> <code>&lt;/mixed&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>list</code>"&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-pattern" class="nt">pattern</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;list</code><code>&gt;</code> <i>x</i> <code>&lt;/list&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-datatypeName" class="nt">datatypeName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-optParams" class="nt">optParams</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;data</code><code> </code><i>x</i><code>&gt;</code> <i>y</i> <code>&lt;/data&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-datatypeName" class="nt">datatypeName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-datatypeValue" class="nt">datatypeValue</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;value</code><code> </code><i>x</i><code>&gt;</code> <i>y</i> <code>&lt;/value&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-datatypeValue" class="nt">datatypeValue</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;value</code><code>&gt;</code> <i>x</i> <code>&lt;/value&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>empty</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;empty</code><code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>notAllowed</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;notAllowed</code><code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>empty</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;text</code><code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-ref" class="nt">ref</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;ref</code><code> </code><code>name=</code><i>x</i><code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>parent</code>"&nbsp;&nbsp;<i><a href="#nt-ref" class="nt">ref</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;parentRef</code><code> </code><code>name=</code><i>x</i><code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>grammar</code>"&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-grammar" class="nt">grammar</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;grammar</code><code>&gt;</code> <i>x</i> <code>&lt;/grammar&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>external</code>"&nbsp;&nbsp;<i><a href="#nt-anyURILiteral" class="nt">anyURILiteral</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-optInherit" class="nt">optInherit</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;externalRef</code><code> </code><code>href=</code><a href="#prim-mapSchemaRef">mapSchemaRef</a>(<i>x</i>)<code> </code><i>y</i><code>/&gt;</code> }</p><p><i><a name="nt-dataExcept">dataExcept</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-datatypeName" class="nt">datatypeName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-optParams" class="nt">optParams</a></i><sub><i>y</i></sub>&nbsp;&nbsp;"<code>-</code>"&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedPrimary" class="nt">leadAnnotatedPrimary</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;data</code><code> </code><i>x</i><code>&gt;</code> <i>y</i> <code>&lt;except</code><code>&gt;</code> <i>z</i> <code>&lt;/except&gt;</code> <code>&lt;/data&gt;</code> }</p><p><i><a name="nt-ref">ref</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-identifier" class="nt">identifier</a></i></b></p><p><i><a name="nt-datatypeName">datatypeName</a></i> <b>returns</b> Attributes&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-CName" class="nt">CName</a></i></b><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-datatypeAttributes">datatypeAttributes</a>(<a href="#prim-lookupDatatypePrefix">lookupDatatypePrefix</a>(<b>environment</b>, <a href="#prim-prefix">prefix</a>(<i>x</i>)), <a href="#prim-localPart">localPart</a>(<i>x</i>)) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>string</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-datatypeAttributes">datatypeAttributes</a>("<code></code>", "<code>string</code>") }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>token</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-datatypeAttributes">datatypeAttributes</a>("<code></code>", "<code>token</code>") }</p><p><i><a name="nt-datatypeValue">datatypeValue</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i></p><p><i><a name="nt-optParams">optParams</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>{</code>"&nbsp;&nbsp;<i><a href="#nt-params" class="nt">params</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>}</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-params">params</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-param" class="nt">param</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-params" class="nt">params</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-param">param</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>y</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <code>&lt;param</code><code> </code><code>name=</code><i>y</i><code>&gt;</code> <i>z</i> <code>&lt;/param&gt;</code>) }</p><p><i><a name="nt-nameClass">nameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-innerNameClass" class="nt">innerNameClass</a></i>(<i>anno</i> := ( ))</p><p><i><a name="nt-innerNameClass">innerNameClass</a></i>(Boolean <i>isElem</i>, Xml <i>anno</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedSimpleNameClass" class="nt">annotatedSimpleNameClass</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotationsChoice">applyAnnotationsChoice</a>(<i>anno</i>, <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-nameClassChoice" class="nt">nameClassChoice</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>anno</i>, <code>&lt;choice</code><code>&gt;</code> <i>x</i> <code>&lt;/choice&gt;</code>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotatedExceptNameClass" class="nt">annotatedExceptNameClass</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotationsChoice">applyAnnotationsChoice</a>(<i>anno</i>, <i>x</i>) }</p><p><i><a name="nt-nameClassChoice">nameClassChoice</a></i>(Boolean <i>isElem</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotatedSimpleNameClass" class="nt">annotatedSimpleNameClass</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>|</code>"&nbsp;&nbsp;<i><a href="#nt-annotatedSimpleNameClass" class="nt">annotatedSimpleNameClass</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotatedSimpleNameClass" class="nt">annotatedSimpleNameClass</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>|</code>"&nbsp;&nbsp;<i><a href="#nt-nameClassChoice" class="nt">nameClassChoice</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-annotatedExceptNameClass">annotatedExceptNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedExceptNameClass" class="nt">leadAnnotatedExceptNameClass</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-leadAnnotatedExceptNameClass">leadAnnotatedExceptNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-exceptNameClass" class="nt">exceptNameClass</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-annotatedSimpleNameClass">annotatedSimpleNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedSimpleNameClass" class="nt">leadAnnotatedSimpleNameClass</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-leadAnnotatedSimpleNameClass">leadAnnotatedSimpleNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-simpleNameClass" class="nt">simpleNameClass</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-applyAnnotations">applyAnnotations</a>(<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotations" class="nt">annotations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>(</code>"&nbsp;&nbsp;<i><a href="#nt-innerNameClass" class="nt">innerNameClass</a></i>(<i>anno</i> := <i>x</i>)<sub><i>y</i></sub>&nbsp;&nbsp;"<code>)</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>y</i> }</p><p><i><a name="nt-exceptNameClass">exceptNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-nsName" class="nt">nsName</a></i></b><sub><i>x</i></sub>&nbsp;&nbsp;"<code>-</code>"&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedSimpleNameClass" class="nt">leadAnnotatedSimpleNameClass</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;nsName</code><code> </code><a href="#prim-makeNsAttribute">makeNsAttribute</a>(<a href="#prim-lookupPrefix">lookupPrefix</a>(<b>environment</b>, <i>x</i>))<code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>y</i> <code>&lt;/except&gt;</code> <code>&lt;/nsName&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>*</code>"&nbsp;&nbsp;"<code>-</code>"&nbsp;&nbsp;<i><a href="#nt-leadAnnotatedSimpleNameClass" class="nt">leadAnnotatedSimpleNameClass</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;anyName</code><code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>x</i> <code>&lt;/except&gt;</code> <code>&lt;/anyName&gt;</code> }</p><p><i><a name="nt-simpleNameClass">simpleNameClass</a></i>(Boolean <i>isElem</i>) <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;name</code><code> </code><a href="#prim-makeNsAttribute">makeNsAttribute</a>(<i>isElem</i> ? <a href="#prim-lookupDefault">lookupDefault</a>(<b>environment</b>) : "<code></code>")<code>&gt;</code> <i>x</i> <code>&lt;/name&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<b><i><a href="#t-CName" class="nt">CName</a></i></b><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;name</code><code> </code><a href="#prim-makeNsAttribute">makeNsAttribute</a>(<a href="#prim-lookupPrefix">lookupPrefix</a>(<b>environment</b>, <a href="#prim-prefix">prefix</a>(<i>x</i>)))<code>&gt;</code> <a href="#prim-localPart">localPart</a>(<i>x</i>) <code>&lt;/name&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<b><i><a href="#t-nsName" class="nt">nsName</a></i></b><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;nsName</code><code> </code><a href="#prim-makeNsAttribute">makeNsAttribute</a>(<a href="#prim-lookupPrefix">lookupPrefix</a>(<b>environment</b>, <i>x</i>))<code>/&gt;</code> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>*</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <code>&lt;anyName</code><code>/&gt;</code> }</p><p><i><a name="nt-followAnnotations">followAnnotations</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>&gt;&gt;</code>"&nbsp;&nbsp;<i><a href="#nt-annotationElement" class="nt">annotationElement</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-followAnnotations" class="nt">followAnnotations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-annotations">annotations</a></i> <b>returns</b> Xml&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-documentations" class="nt">documentations</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-documentations" class="nt">documentations</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>[</code>"&nbsp;&nbsp;<i><a href="#nt-annotationAttributes" class="nt">annotationAttributes</a></i><sub><i>y</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationElements" class="nt">annotationElements</a></i><sub><i>z</i></sub>&nbsp;&nbsp;"<code>]</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>y</i>, (<i>x</i>, <i>z</i>)) }</p><p><i><a name="nt-annotationAttributes">annotationAttributes</a></i> <b>returns</b> Attributes&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-foreignAttributeName" class="nt">foreignAttributeName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>y</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationAttributes" class="nt">annotationAttributes</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate attributes">duplicate attributes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<a href="#prim-attribute">attribute</a>(<i>x</i>, <i>y</i>), <i>z</i>) }</p><p><i><a name="nt-foreignAttributeName">foreignAttributeName</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-prefixedName" class="nt">prefixedName</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xmlns namespace URI">xmlns namespace URI</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-unqualified name">unqualified name</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-RELAX NG namespace URI">RELAX NG namespace URI</a></p><p><i><a name="nt-annotationElements">annotationElements</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-annotationElement" class="nt">annotationElement</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationElements" class="nt">annotationElements</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-annotationElement">annotationElement</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-foreignElementName" class="nt">foreignElementName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationAttributesContent" class="nt">annotationAttributesContent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-element">element</a>(<b>environment</b>, <i>x</i>, <i>y</i>) }</p><p><i><a name="nt-foreignElementName">foreignElementName</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-name">name</a>("<code></code>", <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-prefixedName" class="nt">prefixedName</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-RELAX NG namespace URI">RELAX NG namespace URI</a></p><p><i><a name="nt-annotationElementNotKeyword">annotationElementNotKeyword</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-foreignElementNameNotKeyword" class="nt">foreignElementNameNotKeyword</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationAttributesContent" class="nt">annotationAttributesContent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-element">element</a>(<b>environment</b>, <i>x</i>, <i>y</i>) }</p><p><i><a name="nt-foreignElementNameNotKeyword">foreignElementNameNotKeyword</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-identifier" class="nt">identifier</a></i></b><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-name">name</a>("<code></code>", <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-prefixedName" class="nt">prefixedName</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-RELAX NG namespace URI">RELAX NG namespace URI</a></p><p><i><a name="nt-annotationAttributesContent">annotationAttributesContent</a></i> <b>returns</b> Xml&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>[</code>"&nbsp;&nbsp;<i><a href="#nt-nestedAnnotationAttributes" class="nt">nestedAnnotationAttributes</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationContent" class="nt">annotationContent</a></i><sub><i>y</i></sub>&nbsp;&nbsp;"<code>]</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-nestedAnnotationAttributes">nestedAnnotationAttributes</a></i> <b>returns</b> Attributes&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-anyAttributeName" class="nt">anyAttributeName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>=</code>"&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>y</i></sub>&nbsp;&nbsp;<i><a href="#nt-nestedAnnotationAttributes" class="nt">nestedAnnotationAttributes</a></i><sub><i>z</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-duplicate attributes">duplicate attributes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<a href="#prim-attribute">attribute</a>(<i>x</i>, <i>y</i>), <i>z</i>) }</p><p><i><a name="nt-anyAttributeName">anyAttributeName</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-name">name</a>("<code></code>", <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-prefixedName" class="nt">prefixedName</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-xmlns namespace URI">xmlns namespace URI</a></p><p><i><a name="nt-annotationContent">annotationContent</a></i> <b>returns</b> Content&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-nestedAnnotationElement" class="nt">nestedAnnotationElement</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationContent" class="nt">annotationContent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationContent" class="nt">annotationContent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<a href="#prim-text">text</a>(<i>x</i>), <i>y</i>) }</p><p><i><a name="nt-nestedAnnotationElement">nestedAnnotationElement</a></i> <b>returns</b> Element&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-anyElementName" class="nt">anyElementName</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-annotationAttributesContent" class="nt">annotationAttributesContent</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-element">element</a>(<b>environment</b>, <i>x</i>, <i>y</i>) }</p><p><i><a name="nt-anyElementName">anyElementName</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-identifierOrKeyword" class="nt">identifierOrKeyword</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-name">name</a>("<code></code>", <i>x</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-prefixedName" class="nt">prefixedName</a></i></p><p><i><a name="nt-prefixedName">prefixedName</a></i> <b>returns</b> Name&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-CName" class="nt">CName</a></i></b><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Constraint: </b><a href="#constraint-annotation inherit">annotation inherit</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-name">name</a>(<a href="#prim-lookupPrefix">lookupPrefix</a>(<b>environment</b>, <a href="#prim-prefix">prefix</a>(<i>x</i>)), <a href="#prim-localPart">localPart</a>(<i>x</i>)) }</p><p><i><a name="nt-documentations">documentations</a></i> <b>returns</b> Elements&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ ( ) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<b><i><a href="#t-documentation" class="nt">documentation</a></i></b><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-documentations" class="nt">documentations</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<a href="#prim-element">element</a>(<b>environment</b>, <a href="#prim-documentationElementName">documentationElementName</a>(), <a href="#prim-text">text</a>(<i>x</i>)), <i>y</i>) }</p><p><i><a name="nt-identifierOrKeyword">identifierOrKeyword</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-identifier" class="nt">identifier</a></i></b><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-keyword" class="nt">keyword</a></i></p><p><i><a name="nt-keyword">keyword</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>attribute</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>default</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>datatypes</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>div</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>element</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>empty</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>external</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>grammar</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>include</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>inherit</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>list</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>mixed</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>namespace</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>notAllowed</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>parent</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>start</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>string</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>text</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>token</code>"</p><p><i><a name="nt-literal">literal</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="#t-literalSegment" class="nt">literalSegment</a></i></b><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<b><i><a href="#t-literalSegment" class="nt">literalSegment</a></i></b><sub><i>x</i></sub>&nbsp;&nbsp;"<code>~</code>"&nbsp;&nbsp;<i><a href="#nt-literal" class="nt">literal</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><div class="constraint"><h4 class="title">Constraint: <a name="constraint-valid prefix">valid prefix</a></h4>
+<p>It is an error if the value of a <i><a href="#nt-namespacePrefix" class="nt">namespacePrefix</a></i> is <tt>xmlns</tt>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-xml prefix">xml prefix</a></h4>
+<p>It is an error if the value of <i><a href="#nt-namespacePrefix" class="nt">namespacePrefix</a></i> is <tt>xml</tt> and the the value
+of the <i><a href="#nt-namespaceURILiteral" class="nt">namespaceURILiteral</a></i> is not
+<tt>http://www.w3.org/XML/1998/namespace</tt>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-xml namespace URI">xml namespace URI</a></h4><p>It is an error if the value
+of the <i><a href="#nt-namespaceURILiteral" class="nt">namespaceURILiteral</a></i> is
+<tt>http://www.w3.org/XML/1998/namespace</tt> and the value
+of the <i><a href="#nt-namespacePrefix" class="nt">namespacePrefix</a></i> is not
+<tt>xml</tt>.</p></div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-xsd prefix">xsd prefix</a></h4>
+<p>It is an error if the value of <i><a href="#nt-datatypePrefix" class="nt">datatypePrefix</a></i> is <tt>xsd</tt> and the the value
+of the <i><a href="#nt-literal" class="nt">literal</a></i> is not
+<tt>http://www.w3.org/2001/XMLSchema-datatypes</tt>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-datatypes URI">datatypes URI</a></h4><p>It is an error if the value of
+the literal in a <tt>datatypes</tt> declaration is not a
+syntactically legal value for a <tt>datatypeLibrary</tt> as
+specified in Section 3 of [<a href="#spec">RELAX NG</a>].</p></div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-duplicate declaration">duplicate declaration</a></h4><p>It is an error if there
+is more than one namespace declaration of a particular prefix, more
+than one default namespace declaration or more than one declaration of
+a particular datatypes prefix.</p></div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-single element">single element</a></h4><p>It is an error if a top-level
+pattern translates to a sequence of more than one element (which can
+happen as the result of the use of annotations).</p></div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-unqualified name">unqualified name</a></h4>
+<p>It is an error if the namespace URI of a <i><a href="#nt-prefixedName" class="nt">prefixedName</a></i> in a <i><a href="#nt-foreignAttributeName" class="nt">foreignAttributeName</a></i> is the empty string.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-RELAX NG namespace URI">RELAX NG namespace URI</a></h4>
+<p>It is an error if the namespace URI of a <i><a href="#nt-prefixedName" class="nt">prefixedName</a></i> in a <i><a href="#nt-foreignElementName" class="nt">foreignElementName</a></i>, a
+<i><a href="#nt-foreignElementNameNotKeyword" class="nt">foreignElementNameNotKeyword</a></i> or a <i><a href="#nt-foreignAttributeName" class="nt">foreignAttributeName</a></i> is the RELAX NG namespace URI
+<tt>http://relaxng.org/ns/structure/1.0</tt>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-xmlns namespace URI">xmlns namespace URI</a></h4>
+<p>It is an error if the namespace URI of a <i><a href="#nt-prefixedName" class="nt">prefixedName</a></i> in a <i><a href="#nt-foreignAttributeName" class="nt">foreignAttributeName</a></i> or an <i><a href="#nt-anyAttributeName" class="nt">anyAttributeName</a></i> is <tt>http://www.w3.org/2000/xmlns</tt>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-duplicate attributes">duplicate attributes</a></h4>
+<p>It is an error if a <i><a href="#nt-nestedAnnotationAttributes" class="nt">nestedAnnotationAttributes</a></i> or an <i><a href="#nt-annotationAttributes" class="nt">annotationAttributes</a></i> contains two attributes with the same
+namespace URI and local name.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-annotation inherit">annotation inherit</a></h4>
+<p>It is an error if the namespace URI in the value of a <i><a href="#nt-prefixedName" class="nt">prefixedName</a></i> is <b>inherit</b>.</p>
+</div><div class="constraint"><h4 class="title">Constraint: <a name="constraint-any URI">any URI</a></h4>
+<p>It is an error if the value of the literal used with
+<tt>external</tt> or <tt>include</tt> declaration
+does not meet the requirements for the anyURI symbol specified in
+Section 3 of [<a href="#spec">RELAX NG</a>].</p>
+</div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="d0e3892"></a>2.&nbsp;Lexical structure</h3></div></div><p>This section describes how to transform the textual
+representation of a RELAX NG schema in compact syntax into a sequence
+of tokens, which can be parsed using the grammar specified in <a href="#formal-syntax" title="1.&nbsp;Syntax">Section&nbsp;1</a>.</p><p>There are five distinct stages, which are logically consecutive;
+the result of each stage is the input to the following stage.</p><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="d0e3901"></a>2.1.&nbsp;Character encoding</h4></div></div><p>The textual representation of the RELAX NG schema in compact
+syntax may be either a sequence of Unicode characters or a sequence of
+bytes.  In the latter case, the first stage is to transform the
+sequence of bytes to the sequence of characters.  The sequence of
+bytes may have associated metadata specifying the encoding.  One
+example of such metadata is the <tt>charset</tt> parameter
+in a MIME media type [<a href="#rfc2046">RFC 2046</a>].
+If there is such metadata, then the specified
+encoding is used.  Otherwise, the first two bytes of the sequence are
+examined.  If these are #xFF followed by #xFE or #xFE followed by
+#xFF, then an encoding of UTF-16 [<a href="#unicode">Unicode</a>] will be
+used, little-endian in the former case, big-endian in the latter case.
+Otherwise an encoding of UTF-8 [<a href="#unicode">Unicode</a>] is used.  It
+is an error if the sequence of bytes is not a legal sequence in the
+selected encoding.</p></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="d0e3915"></a>2.2.&nbsp;BOM stripping</h4></div></div><p>If the first character of the sequence is a byte order mark
+(#xFEFF), then it is removed.</p></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="d0e3920"></a>2.3.&nbsp;Newline normalization</h4></div></div><p>Representations of newlines are normalized to a newline
+marker. Specifically, each occurrence of</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e3926"></a>a #xA character,</li><li><a name="d0e3929"></a>a #xD character that is not followed by a #xA character, or</li><li><a name="d0e3932"></a>a #xD, #xA character pair</li></ul></div><p>is transformed to a newline marker.  The result of this stage is
+thus a sequence whose members are Unicode characters and newline
+markers.</p></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="d0e3937"></a>2.4.&nbsp;Escape interpretation</h4></div></div><p>In this stage, each escape sequence of the form
+<tt>\x{<i><tt>n</tt></i>}</tt>, where
+<i><tt>n</tt></i> is a hexadecimal number, is replaced by
+the character with Unicode code <i><tt>n</tt></i>.  The
+escape sequence must match the production <i><a href="#nt-escapeSequence" class="nt">escapeSequence</a></i>; the value computed in the BNF is the Unicode
+code of the replacement character.  It is an error if the replacement
+character does not match the <tt>Char</tt> production of
+[<a href="#xml-rec">XML 1.0</a>].  It is an error if the input character
+sequence contains a character sequence <i><a href="#nt-escapeOpen" class="nt">escapeOpen</a></i>
+that does not start an <i><a href="#nt-escapeSequence" class="nt">escapeSequence</a></i>.  After an
+escape sequence has been replaced, scanning for escape sequences
+continues following the replacement character; thus
+<tt>\x{5C}x{5C}</tt> is transformed to
+<tt>\x{5C}</tt> not to <tt>\</tt>.  The
+replacement for <tt>\x{A}</tt> or <tt>\x{D}</tt>
+is a character, as for all other escape sequences, not a newline
+marker.  Thus the sequence that results from this stage can contain #xA
+and #xD characters as well as newline markers.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>The <tt>\</tt> character that opens an escape
+sequence may be followed by more than one <tt>x</tt>.  This
+makes it possible for there to be a reversible transformation that
+maps a schema to a form containing only ASCII characters; the
+transformation replaces adds an extra <tt>x</tt> to each
+existing escape sequence, and replaces every non-ASCII character by an
+escape sequence with exactly one <tt>x</tt>.</p></div><p><i><a name="nt-escapeSequence">escapeSequence</a></i> <b>returns</b> Number&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-escapeOpen" class="nt">escapeOpen</a></i>&nbsp;&nbsp;<i><a href="#nt-hexNumber" class="nt">hexNumber</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-escapeClose" class="nt">escapeClose</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-escapeOpen">escapeOpen</a></i> <b>returns</b> Void&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>\</code>"&nbsp;&nbsp;<i><a href="#nt-xs" class="nt">xs</a></i>&nbsp;&nbsp;"<code>{</code>"</p><p><i><a name="nt-xs">xs</a></i> <b>returns</b> Void&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>x</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>x</code>"&nbsp;&nbsp;<i><a href="#nt-xs" class="nt">xs</a></i></p><p><i><a name="nt-escapeClose">escapeClose</a></i> <b>returns</b> Void&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>}</code>"</p><p><i><a name="nt-hexNumber">hexNumber</a></i> <b>returns</b> Number&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-hexDigit" class="nt">hexDigit</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<i><a href="#nt-hexNumber" class="nt">hexNumber</a></i><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-hexDigit" class="nt">hexDigit</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (<i>x</i> * 16) + <i>y</i> }</p><p><i><a name="nt-hexDigit">hexDigit</a></i> <b>returns</b> Number&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>0</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 0 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>1</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 1 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>2</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 2 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>3</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 3 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>4</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 4 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>5</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 5 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>6</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 6 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>7</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 7 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>8</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 8 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>9</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 9 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>A</code><code>a</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 10 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>B</code><code>b</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 11 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>C</code><code>c</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 12 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>D</code><code>d</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 13 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>E</code><code>e</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 14 }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[<code>F</code><code>f</code>]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ 15 }</p></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="d0e4256"></a>2.5.&nbsp;Tokenization</h4></div></div><p>In this stage, the sequence of characters and newline markers is
+tokenized: it is transformed into a sequence of tokens, where each
+token corresponds to a terminal in the grammar in <a href="#formal-syntax" title="1.&nbsp;Syntax">Section&nbsp;1</a>.</p><p>A sequence of characters and newline markers is tokenized by
+first finding the longest initial subsequence that:</p><div class="itemizedlist"><ul type="disc"><li><a name="d0e4266"></a>is one of the literal string terminals occurring
+in the BNF in <a href="#formal-syntax" title="1.&nbsp;Syntax">Section&nbsp;1</a>;</li><li><a name="d0e4271"></a>matches the grammar of one of the named terminals that
+is referenced in <a href="#formal-syntax" title="1.&nbsp;Syntax">Section&nbsp;1</a> and specified in this
+section, that is, <b><i><a href="#t-identifier" class="nt">identifier</a></i></b>, <b><i><a href="#t-literalSegment" class="nt">literalSegment</a></i></b>, <b><i><a href="#t-CName" class="nt">CName</a></i></b>, <b><i><a href="#t-nsName" class="nt">nsName</a></i></b>
+or <b><i><a href="#t-documentation" class="nt">documentation</a></i></b>; or</li><li><a name="d0e4286"></a>matches the grammar for <b><i><a href="#t-separator" class="nt">separator</a></i></b>.</li></ul></div><p>If the longest such initial subsequence matches <b><i><a href="#t-separator" class="nt">separator</a></i></b>, this subsequence is discarded.  Otherwise, a
+single non-terminal is produced from this initial subsequence. In
+either case, the tokenization proceeds with the rest of the sequence.
+It is an error if there is no such initial subsequence.</p><p>The production rules below use some additional notation.  Square
+brackets enclose a character class.  A character class of the form
+<tt>[^<i><tt>chars</tt></i>]</tt> specifies any
+legal XML character that does not occur in
+<i><tt>chars</tt></i>.  A legal XML character is a
+character that matches the <tt>Char</tt> production of [<a href="#xml-rec">XML 1.0</a>].  A character class of the form
+<tt>[<i><tt>chars</tt></i>]</tt>, where
+<i><tt>chars</tt></i> does not being with
+<tt>^</tt>, specifies any single character that occurs in
+<i><tt>chars</tt></i>.  XML hexadecimal character
+references are used to denote a single character, as in XML.  A
+newline marker is denoted by &amp;newline;. <i>NCName</i>
+is defined in [<a href="#xml-names">XML Namespaces</a>].</p><p>The value of a variable bound to a character class is a string
+of length 1 containing the character that matched the character class;
+if the character class matches a newline marker, then the string
+contains the character #xA.</p><p><b><i><a name="t-identifier">identifier</a></i></b> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>NCName</i><sub><i>x</i></sub> - <i><a href="#nt-keyword" class="nt">keyword</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>\</code>"&nbsp;&nbsp;<i>NCName</i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><b><i><a name="t-CName">CName</a></i></b> <b>returns</b> Qname&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>NCName</i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>:</code>"&nbsp;&nbsp;<i>NCName</i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-qName">qName</a>(<i>x</i>, <i>y</i>) }</p><p><b><i><a name="t-nsName">nsName</a></i></b> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>NCName</i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>:*</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><b><i><a name="t-literalSegment">literalSegment</a></i></b> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>"</code>"&nbsp;&nbsp;<i><a href="#nt-stringNoQuot" class="nt">stringNoQuot</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>"</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>'</code>"&nbsp;&nbsp;<i><a href="#nt-stringNoApos" class="nt">stringNoApos</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>'</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>"""</code>"&nbsp;&nbsp;<i><a href="#nt-stringNoTripleQuot" class="nt">stringNoTripleQuot</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>"""</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>'''</code>"&nbsp;&nbsp;<i><a href="#nt-stringNoTripleApos" class="nt">stringNoTripleApos</a></i><sub><i>x</i></sub>&nbsp;&nbsp;"<code>'''</code>"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-stringNoQuot">stringNoQuot</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^<code>"</code>&amp;newline;]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoQuot" class="nt">stringNoQuot</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-stringNoApos">stringNoApos</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^<code>'</code>&amp;newline;]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoApos" class="nt">stringNoApos</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-stringNoTripleQuot">stringNoTripleQuot</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^<code>"</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleQuot" class="nt">stringNoTripleQuot</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>"</code>"&nbsp;&nbsp;[^<code>"</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleQuot" class="nt">stringNoTripleQuot</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>("<code>"</code>", <i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>""</code>"&nbsp;&nbsp;[^<code>"</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleQuot" class="nt">stringNoTripleQuot</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>("<code>""</code>", <i>x</i>, <i>y</i>) }</p><p><i><a name="nt-stringNoTripleApos">stringNoTripleApos</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^<code>'</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleApos" class="nt">stringNoTripleApos</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>'</code>"&nbsp;&nbsp;[^<code>'</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleApos" class="nt">stringNoTripleApos</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>("<code>'</code>", <i>x</i>, <i>y</i>) }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>''</code>"&nbsp;&nbsp;[^<code>'</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-stringNoTripleApos" class="nt">stringNoTripleApos</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>("<code>''</code>", <i>x</i>, <i>y</i>) }</p><p><b><i><a name="t-documentation">documentation</a></i></b> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i><a href="#nt-documentationLine" class="nt">documentationLine</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;<b><i><a href="#t-documentation" class="nt">documentation</a></i></b><sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-documentationContinuation" class="nt">documentationContinuation</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-documentationLine">documentationLine</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;"<code>##</code>"&nbsp;&nbsp;<i><a href="#nt-documentationLineContent" class="nt">documentationLineContent</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }</p><p><i><a name="nt-documentationContinuation">documentationContinuation</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;[&amp;newline;&amp;#xA;]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-indent" class="nt">indent</a></i>&nbsp;&nbsp;<i><a href="#nt-documentationLine" class="nt">documentationLine</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-indent">indent</a></i> <b>returns</b> Void&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[&amp;#x9;&amp;#x20;]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-indent" class="nt">indent</a></i></p><p><i><a name="nt-documentationLineContent">documentationLineContent</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>#</code>"&nbsp;&nbsp;<i><a href="#nt-documentationLineContent" class="nt">documentationLineContent</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code> </code>"&nbsp;&nbsp;<i><a href="#nt-restOfLine" class="nt">restOfLine</a></i><sub><i>x</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <i>x</i> }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^&amp;newline;&amp;#xA;<code> </code><code>#</code>]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-restOfLine" class="nt">restOfLine</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><i><a name="nt-restOfLine">restOfLine</a></i> <b>returns</b> String&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;<i>&#949;</i><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ "<code></code>" }<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;[^&amp;newline;&amp;#xA;]<sub><i>x</i></sub>&nbsp;&nbsp;<i><a href="#nt-restOfLine" class="nt">restOfLine</a></i><sub><i>y</i></sub><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ <a href="#prim-stringConcat">stringConcat</a>(<i>x</i>, <i>y</i>) }</p><p><b><i><a name="t-separator">separator</a></i></b> <b>returns</b> Void&nbsp;&nbsp;::=<br>&nbsp;&nbsp;&nbsp;&nbsp;[&amp;#x9;&amp;#xA;&amp;#x20;&amp;newline;]<br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>#</code>"&nbsp;&nbsp;[^&amp;newline;&amp;#xA;<code>#</code>]&nbsp;&nbsp;<i><a href="#nt-restOfLine" class="nt">restOfLine</a></i><br>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;"<code>#</code>"</p></div></div></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="compact-relax-ng"></a>B. Compact syntax RELAX NG schema for RELAX NG (Non-Normative)</h2><pre class="programlisting"># RELAX NG XML syntax specified in compact syntax.
+
+default namespace rng = "http://relaxng.org/ns/structure/1.0"
+namespace local = ""
+datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
+
+start = pattern
+
+pattern =
+  element element { (nameQName | nameClass), (common &amp; pattern+) }
+  | element attribute { (nameQName | nameClass), (common &amp; pattern?) }
+  | element group|interleave|choice|optional
+            |zeroOrMore|oneOrMore|list|mixed { common &amp; pattern+ }
+  | element ref|parentRef { nameNCName, common }
+  | element empty|notAllowed|text { common }
+  | element data { type, param*, (common &amp; exceptPattern?) }
+  | element value { commonAttributes, type?, xsd:string }
+  | element externalRef { href, common }
+  | element grammar { common &amp; grammarContent* }
+
+param = element param { commonAttributes, nameNCName, xsd:string }
+
+exceptPattern = element except { common &amp; pattern+ }
+
+grammarContent = 
+  definition
+  | element div { common &amp; grammarContent* }
+  | element include { href, (common &amp; includeContent*) }
+
+includeContent =
+  definition
+  | element div { common &amp; includeContent* }
+
+definition =
+  element start { combine?, (common &amp; pattern+) }
+  | element define { nameNCName, combine?, (common &amp; pattern+) }
+
+combine = attribute combine { "choice" | "interleave" }
+
+nameClass = 
+  element name { commonAttributes, xsd:QName }
+  | element anyName { common &amp; exceptNameClass? }
+  | element nsName { common &amp; exceptNameClass? }
+  | element choice { common &amp; nameClass+ }
+
+exceptNameClass = element except { common &amp; nameClass+ }
+
+nameQName = attribute name { xsd:QName }
+nameNCName = attribute name { xsd:NCName }
+href = attribute href { xsd:anyURI }
+type = attribute type { xsd:NCName }
+
+common = commonAttributes, foreignElement*
+
+commonAttributes = 
+  attribute ns { xsd:string }?,
+  attribute datatypeLibrary { xsd:anyURI }?,
+  foreignAttribute*
+
+foreignElement = element * - rng:* { (anyAttribute | text | anyElement)* }
+foreignAttribute = attribute * - (rng:*|local:*) { text }
+anyElement = element * { (anyAttribute | text | anyElement)* }
+anyAttribute = attribute * { text }</pre></div><div class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="d0e4913"></a>References</h2></div></div><div class="bibliodiv"><h3 class="title">Normative</h3><dl><dt>Compatibility</dt><dd class="bibliomixed"><a name="compat"></a>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/compatibility.html" target="_top">RELAX NG
+DTD Compatibility</a></i></span>.  OASIS, 2001.</dd><dt>RELAX NG</dt><dd class="bibliomixed"><a name="spec"></a>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</dd><dt>RFC 2396</dt><dd class="bibliomixed"><a name="rfc2396"></a>T. Berners-Lee, R. Fielding, L. Masinter.
+<span class="citetitle"><i><a href="http://www.ietf.org/rfc/rfc2396.txt" target="_top">RFC 2396:
+Uniform Resource Identifiers (URI): Generic
+Syntax</a></i></span>.
+IETF (Internet Engineering Task Force). 1998.</dd><dt>Unicode</dt><dd class="bibliomixed"><a name="unicode"></a>The Unicode Consortium.
+<span class="citetitle"><i>The Unicode Standard, Version 3.2 or
+later</i></span></dd><dt>XML 1.0</dt><dd class="bibliomixed"><a name="xml-rec"></a>Tim Bray,
+Jean Paoli, and
+C. M. Sperberg-McQueen, Eve Maler, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml" target="_top">Extensible Markup
+Language (XML) 1.0 Second Edition</a></i></span>.
+W3C (World Wide Web Consortium), 2000.</dd><dt>XML Namespaces</dt><dd class="bibliomixed"><a name="xml-names"></a>Tim Bray,
+Dave Hollander,
+and Andrew Layman, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml-names/" target="_top">Namespaces in
+XML</a></i></span>.
+W3C (World Wide Web Consortium), 1999.</dd></dl></div><div class="bibliodiv"><h3 class="title">Non-Normative</h3><dl><dt>Guidelines</dt><dd class="bibliomixed"><a name="guidelines"></a>James Clark, Kohsuke
+KAWAGUCHI, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/xsd.html" target="_top">Guidelines
+for using W3C XML Schema Datatypes with RELAX NG</a></i></span>.
+OASIS, 2001.</dd><dt>RFC 2046</dt><dd class="bibliomixed"><a name="rfc2046"></a>N. Freed,
+N. Borenstein.  <span class="citetitle"><i><a href="http://www.ietf.org/rfc/rfc2046.txt" target="_top">RFC 2046: Multipurpose
+Internet Mail Extensions (MIME) Part Two: Media
+Types</a></i></span>.  IETF (Internet Engineerig Task Force),
+1996.</dd><dt>W3C XML Schema Datatypes</dt><dd class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XDuce</dt><dd class="bibliomixed"><a name="xduce"></a>Haruo Hosoya.
+<span class="citetitle"><i><a href="http://www.kurims.kyoto-u.ac.jp/~hahosoya/papers/phdth.ps" target="_top">Regular Expression
+Types for XML</a></i></span>. PhD Thesis. The University of
+Tokyo, 2000.</dd><dt>XQuery Formal Semantics</dt><dd class="bibliomixed"><a name="xquery"></a>Peter
+Fankhauser et al., editors.<span class="citetitle"><i><a href="http://www.w3.org/TR/2001/WD-query-semantics-20010607/" target="_top">XQuery
+1.0 Formal Semantics.  W3C Working Draft 07 June
+2001</a></i></span>. W3C (World Wide Web Consortium),
+2001.</dd></dl></div></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/compact-20021121.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,1052 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>RELAX NG Compact Syntax Tutorial</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.60.1"><meta name="description" content="RELAX NG is a simple schema language for XML, based on  and . A RELAX NG schema
+specifies a pattern for the structure and content of an XML
+document. A RELAX NG schema thus identifies a class of XML documents
+consisting of those documents that match the pattern. Two syntaxes have been defined for RELAX NG.  The original
+syntax uses XML; with this syntax an RELAX NG schema is itself an XML
+document.  Subsequently, a compact non-XML syntax has been
+defined. This document is a tutorial for RELAX NG version 1.0 using the
+compact
+syntax."><meta http-equiv="content-style-type" content="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="id2811948"></a>RELAX NG Compact Syntax Tutorial</h1></div><div><h2>Working Draft 26 March 2003</h2></div><div><dl><dt>This version:</dt><dd>Working Draft: 26 March 2003</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt class="email">&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, John Cowan <tt class="email">&lt;<a href="mailto:jcowan at reutershealth.com">jcowan at reutershealth.com</a>&gt;</tt>, MURATA Makoto <tt class="email">&lt;<a href="mailto:EB2M-MRT at asahi-net.or.jp">EB2M-MRT at asahi-net.or.jp</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001, 2003. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an &quot;<span class="quote">AS IS</span>&quot; basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="id2811750"></a>Abstract</h2><p>RELAX NG is a simple schema language for XML, based on [<a href="#relax"><span class="abbrev">RELAX</span></a>] and [<a href="#trex"><span class="abbrev">TREX</span></a>]. A RELAX NG schema
+specifies a pattern for the structure and content of an XML
+document. A RELAX NG schema thus identifies a class of XML documents
+consisting of those documents that match the pattern.</p><p>Two syntaxes have been defined for RELAX NG.  The original
+syntax uses XML; with this syntax an RELAX NG schema is itself an XML
+document.  Subsequently, a compact non-XML syntax has been
+defined.</p><p>This document is a tutorial for RELAX NG version 1.0 using the
+compact
+syntax.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This is a working draft constructed by the editors. It is not an
+official committee work product and may not reflect the consensus
+opinion of the committee.  Comments on this document may be sent to
+<a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1. <a href="#id2814005">Getting started</a></dt><dt>2. <a href="#id2814120">Choice</a></dt><dt>3. <a href="#id2814218">Attributes</a></dt><dt>4. <a href="#id2814516">Named patterns</a></dt><dt>5. <a href="#id2814737">Datatyping</a></dt><dt>6. <a href="#id2814955">Enumerations</a></dt><dt>7. <a href="#id2815107">Lists</a></dt><dt>8. <a href="#id2815185">Interleaving</a></dt><dt>9. <a href="#id2815432">Modularity</a></dt><dd><dl><dt>9.1. <a href="#id2815440">Referencing external patterns</a></dt><dt>9.2. <a href="#id2815524">Combining definitions</a></dt><dt>9.3. <a href="#id2815634">Merging grammars</a></dt><dt>9.4. <a href="#id2815849">Replacing definitions</a></dt></dl></dd><dt>10. <a href="#id2815943">Namespaces</a></dt><dd><dl><dt>10.1. <a href="#id2815950">Qualified names</a></dt><dt>10.2. <a href="#default-namespace">Default namespace</a></dt></dl></dd><dt>11. <a href="#id2816343">Name classes</a></dt><dt>12. <a href="#id2816664">Internationalization</a></dt><dt>13. <a href="#annotations">Annotations</a></dt><dd><dl><dt>13.1. <a href="#id2816743">Applying annotations</a></dt><dt>13.2. <a href="#id2816799">String literal syntax</a></dt><dt>13.3. <a href="#id2816874">Documentation syntax</a></dt><dt>13.4. <a href="#id2816926">Grouping definitions</a></dt></dl></dd><dt>14. <a href="#id2816990">Nested grammars</a></dt><dt>15. <a href="#id2817095">Non-restrictions</a></dt><dt>16. <a href="#id2817156">Advanced features</a></dt><dd><dl><dt>16.1. <a href="#id2817166">inherit keyword</a></dt><dt>16.2. <a href="#id2817360">Grammar-level annotations</a></dt><dt>16.3. <a href="#id2817392">&gt;&gt; annotations</a></dt></dl></dd><dt>17. <a href="#id2817433">Further information</a></dt></dl><h3>Appendixes</h3><dl><dt>A. <a href="#keywords">List of keywords</a></dt><dt>B. <a href="#id2817637">Comparison with XML DTDs</a></dt><dt><a href="#id2817758">References</a></dt></dl></div><hr><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814005"></a>1. Getting started</h2></div></div><p>Consider a simple XML representation of an email address book:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;name&gt;John Smith&lt;/name&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>The DTD (as an internal subset) would be as follows:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card (name, email)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+]&gt;</pre><p>A RELAX NG pattern for this could be written as follows:</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>If the <tt class="literal">addressBook</tt> is required to be non-empty, then
+we can use <tt class="literal">+</tt> instead of
+<tt class="literal">*</tt>:</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }+
+}</pre><p>Now let's change it to allow each <tt class="literal">card</tt> to have an
+optional <tt class="literal">note</tt> element:</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text },
+    element note { text }?
+  }*
+}</pre><p>Note that the <tt class="literal">text</tt> pattern matches arbitrary text,
+including empty text. Note also that whitespace separating tags is
+ignored when matching against a pattern.</p><p>Comments start with a <tt class="literal">#</tt> and
+continue to the end of the line:</p><pre class="programlisting"># A RELAX NG compact syntax pattern
+# for an address book.
+element addressBook {
+  # an entry in the address book
+  element card {
+    element name { text },
+    element email { text }  # an email address
+  }*
+}</pre><p>Comments starting with <tt class="literal">##</tt> are
+treated specially; see <a href="#annotations" title="13. Annotations">Section 13, &#8220;Annotations&#8221;</a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814120"></a>2. Choice</h2></div></div><p>Now suppose we want to allow the <tt class="literal">name</tt> to be broken
+down into a <tt class="literal">givenName</tt> and a <tt class="literal">familyName</tt>,
+allowing an <tt class="literal">addressBook</tt> like this:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;givenName&gt;John&lt;/givenName&gt;
+    &lt;familyName&gt;Smith&lt;/familyName&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>We can use the following pattern:</p><pre class="programlisting">element addressBook {
+  element card {
+    (element name { text }
+     | (element givenName { text },
+        element familyName { text })),
+    element email { text },
+    element note { text }?
+  }*
+}</pre><p>This corresponds to the following DTD:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card ((name | (givenName, familyName)), email, note?)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+&lt;!ELEMENT givenName (#PCDATA)&gt;
+&lt;!ELEMENT familyName (#PCDATA)&gt;
+&lt;!ELEMENT note (#PCDATA)&gt;
+]&gt;</pre><p>Just as with DTDs, there is no implicit
+precedence between connectors. For example,
+<tt class="literal"><i class="replaceable"><tt>x</tt></i>|<i class="replaceable"><tt>y</tt></i>,<i class="replaceable"><tt>z</tt></i></tt>
+is not allowed; the precedence must be made explicit by using
+<tt class="literal">(<i class="replaceable"><tt>x</tt></i>|<i class="replaceable"><tt>y</tt></i>),<i class="replaceable"><tt>z</tt></i></tt>
+or
+<tt class="literal"><i class="replaceable"><tt>x</tt></i>|(<i class="replaceable"><tt>y</tt></i>,<i class="replaceable"><tt>z</tt></i>)</tt>
+must be used.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814218"></a>3. Attributes</h2></div></div><p>Suppose we want the <tt class="literal">card</tt> element to have attributes
+rather than child elements. The DTD might look like this:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED&gt;
+]&gt;</pre><p>Just change each <tt class="literal">element</tt> pattern to an
+<tt class="literal">attribute</tt> pattern:</p><pre class="programlisting">element addressBook {
+  element card {
+    attribute name { text },
+    attribute email { text }
+  }*
+}</pre><p>In XML, the order of attributes is traditionally not significant.
+RELAX NG follows this tradition.  The above pattern would match both</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;</pre><p>and</p><pre class="programlisting">&lt;card email=&quot;js at example.com&quot; name=&quot;John Smith&quot;/&gt;</pre><p>In contrast, the order of elements is significant. The pattern</p><pre class="programlisting">element card {
+  element name { text },
+  element email { text }
+}</pre><p>would <span class="strong">not</span> match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>Note that an <tt class="literal">attribute</tt> pattern by itself indicates a
+required attribute, just as an <tt class="literal">element</tt> pattern by itself
+indicates a required element. To specify an optional attribute, use
+<tt class="literal">?</tt> just as with <tt class="literal">element</tt>:</p><pre class="programlisting">element addressBook {
+  element card {
+    attribute name { text },
+    attribute email { text },
+    attribute note { text }?
+  }*
+}</pre><p>The <tt class="literal">,</tt> and <tt class="literal">|</tt> connectors can be
+applied to <tt class="literal">attribute</tt> patterns in the same way they are
+applied to <tt class="literal">element</tt> patterns.  For example, if we wanted
+to allow either a <tt class="literal">name</tt> attribute or both a
+<tt class="literal">givenName</tt> and a <tt class="literal">familyName</tt> attribute, we can
+specify this in the same way that we would if we were using
+elements:</p><pre class="programlisting">element addressBook {
+  element card {
+    (attribute name { text }
+     | (attribute givenName { text },
+        attribute familyName { text })),
+    attribute email { text }
+  }*
+}</pre><p>The <tt class="literal">,</tt> and <tt class="literal">|</tt> connectors can combine <tt class="literal">element</tt> and
+<tt class="literal">attribute</tt> patterns without restriction. For
+example, the following pattern would allow a choice of elements and
+attributes independently for both the <tt class="literal">name</tt> and the
+<tt class="literal">email</tt> part of a <tt class="literal">card</tt>:</p><pre class="programlisting">element addressBook {
+  element card {
+    (element name { text }
+     | attribute name { text }),
+    (element email { text }
+     | attribute email { text })
+  }*
+}</pre><p>As usual, the relative order of elements is significant, but the
+relative order of attributes is not. Thus the above would match any
+of:</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;card email=&quot;js at example.com&quot; name=&quot;John Smith&quot;/&gt;
+&lt;card email=&quot;js at example.com&quot;&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;
+&lt;card name=&quot;John Smith&quot;&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;
+&lt;card&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;</pre><p>However, it would not match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>because the pattern for <tt class="literal">card</tt> requires any
+<tt class="literal">email</tt> child element to follow any <tt class="literal">name</tt> child
+element.</p><p>When an <tt class="literal">element</tt> pattern does
+not contain any patterns matching attributes, then an element that
+matches the pattern cannot have any attributes. Similarly, when any
+<tt class="literal">element</tt> pattern does not contain any patterns
+matching elements or strings, then an element that matches the pattern
+cannot have any children.  This can be made more explicit by using the
+<tt class="literal">empty</tt> pattern.  For example,</p><pre class="programlisting">element card {
+  attribute email { text },
+  empty
+}</pre><p>is equivalent to</p><pre class="programlisting">element card {
+  attribute email { text }
+}</pre><p>The use of the <tt class="literal">empty</tt> pattern
+is necessary only when an element has neither attributes nor
+children. For example,</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text },
+    element prefersHTML { empty }?
+  }*
+}
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814516"></a>4. Named patterns</h2></div></div><p>For a non-trivial RELAX NG pattern, it is often convenient to be able
+to give names to parts of the pattern.  Instead of</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>we can write</p><pre class="programlisting">grammar {
+  start =
+    element addressBook {
+      element card { cardContent }*
+    }
+  cardContent =
+    element name { text },
+    element email { text }
+}</pre><p>A <tt class="literal">grammar</tt> pattern contains one
+or more definitions.  Each definition associates a name with a
+pattern.  Inside a <tt class="literal">grammar</tt>, a pattern consisting of
+just a name references the definition of that name in the
+<tt class="literal">grammar</tt>.  The name <tt class="literal">start</tt> is
+special.  A <tt class="literal">grammar</tt> pattern is matched by matching
+the definition of <tt class="literal">start</tt>.  A
+<tt class="literal">grammar</tt> pattern must define
+<tt class="literal">start</tt>.</p><p>We can use the <tt class="literal">grammar</tt> pattern to write RELAX NG in a
+style similar to DTDs:</p><pre class="programlisting">grammar {
+  start = AddressBook
+  AddressBook = element addressBook { Card* }
+  Card = element card { Name, Email }
+  Name = element name { text }
+  Email = element email { text }
+}</pre><p>The opening <tt class="literal">grammar {</tt> and
+closing <tt class="literal">}</tt> are required only when a
+<tt class="literal">grammar</tt> pattern is nested within another
+pattern. In the typical case, when the <tt class="literal">grammar</tt>
+pattern is the outermost pattern, they can omitted.  For example, the
+above pattern can be written as:</p><pre class="programlisting">start = AddressBook
+AddressBook = element addressBook { Card* }
+Card = element card { Name, Email }
+Name = element name { text }
+Email = element email { text }</pre><p>Recursive references are allowed.  For example,</p><pre class="programlisting">inline =
+  (text
+   | element bold { inline }
+   | element italic { inline }
+   | element span {
+       attribute style { text }?,
+       inline
+     })*</pre><p>However, recursive references must be within an
+<tt class="literal">element</tt> pattern.  Thus, the following is <span class="strong">not</span>
+allowed:</p><pre class="programlisting">inline =
+  (text
+   | element bold { inline }
+   | element italic { inline }
+   | element span {
+       attribute style { text }?,
+       inline
+     }),
+  inline?</pre><p>To use a keyword such as
+<tt class="literal">element</tt>, <tt class="literal">attribute</tt>,
+<tt class="literal">text</tt>, <tt class="literal">empty</tt>,
+<tt class="literal">grammar</tt> as the name of a definition, it must be
+quoted with <tt class="literal">\</tt>.  For example,</p><pre class="programlisting">start = \element
+\element = element element { text }</pre><p>is equivalent to</p><pre class="programlisting">start = e
+e = element element { text }</pre><p>Note that keywords need not be quoted when
+specifying element or attribute names. A complete list of keywords is
+in <a href="#keywords" title="A. List of keywords">Appendix A, <i>List of keywords</i></a>.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814737"></a>5. Datatyping</h2></div></div><p>RELAX NG allows patterns to reference externally-defined
+datatypes.  RELAX NG implementations may differ in what datatypes they
+support.  You can only use datatypes that are supported by the
+implementation you plan to use. The most commonly used datatypes are
+those defined by [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>].</p><p>A pattern consisting of a name qualified with a
+prefix matches a string that represents a value of a named datatype.
+The prefix identifies the library of datatypes being used and the rest
+of the name specifies the name of the datatype in that library.  The
+prefix <tt class="literal">xsd</tt> identifies the datatype library defined
+by [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>].  Assuming your RELAX NG
+implementation supports this library (most do), you could use:</p><pre class="programlisting">element number { xsd:integer }</pre><p>If the children of an element or an attribute match a
+datatype pattern, then the complete content of the element or
+attribute must match that datatype pattern.  It is not
+permitted to have a pattern which allows part of the content to match
+a datatype pattern, and another part to match another
+pattern. For example, the following pattern is <span class="strong">not</span>
+allowed:</p><pre class="programlisting">element bad {
+  xsd:int,
+  element note { text }
+}</pre><p>However, this would be fine:</p><pre class="programlisting">element ok {
+  xsd:int,
+  attribute note { text }
+}</pre><p>Note that this restriction does not apply to the
+<tt class="literal">text</tt> pattern.</p><p>Datatypes may have parameters. For example, a string datatype may
+have a parameter controlling the length of the string.  The parameters
+applicable to any particular datatype are determined by the datatyping
+vocabulary. In the case of [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>], the
+applicable parameters correspond to the facets defined in
+[<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] with the exception of the
+<tt class="literal">enumeration</tt> and <tt class="literal">whiteSpace</tt>
+facets. Parameters are specified by
+following the datatype name with a list of one or more
+<i class="replaceable"><tt>name</tt></i><tt class="literal">=</tt><i class="replaceable"><tt>value</tt></i>
+parameter assignments in braces. For example, the following
+constrains the <tt class="literal">email</tt> element to contain a string at
+least 6 characters long and at most 127 characters long:</p><pre class="programlisting">element email {
+  xsd:string { minLength = &quot;6&quot; maxLength = &quot;127&quot; }
+}</pre><p>The value of a parameter is a string literal.  As in XML, string
+literals can be delimited using either <tt class="literal">&quot;</tt> or
+<tt class="literal">'</tt>.</p><p>A companion document, [<a href="#guidelines"><span class="abbrev">Guidelines</span></a>], describes
+exactly how the datatypes defined in [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] can
+be used as a RELAX NG datatype library.</p><p>To use a datatype pattern with a prefix other
+than <tt class="literal">xsd</tt>, a <tt class="literal">datatypes</tt>
+declaration must be added to the beginning of the file.
+The <tt class="literal">datatypes</tt> declaration associates the
+prefix with the URI of a datatype library.  The URI of datatype
+library identified by <tt class="literal">xsd</tt> prefix is
+<tt class="literal">http://www.w3.org/2001/XMLSchema-datatypes</tt>. So, for
+example:</p><pre class="programlisting">datatypes xs = &quot;http://www.w3.org/2001/XMLSchema-datatypes&quot;
+
+element number { xs:integer }</pre><p>is equivalent to</p><pre class="programlisting">element number { xsd:integer }</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814955"></a>6. Enumerations</h2></div></div><p>Many markup vocabularies have attributes whose value is constrained
+to be one of a set of specified strings. A pattern
+consisting of a literal string matches that string. For example,</p><pre class="programlisting">element card {
+  attribute name { text },
+  attribute email { text },
+  attribute preferredFormat { &quot;html&quot; | &quot;text&quot; }
+}</pre><p>allows the <tt class="literal">preferredFormat</tt> attribute to have the value
+<tt class="literal">html</tt> or <tt class="literal">text</tt>.  This corresponds to the
+DTD:</p><pre class="programlisting">&lt;!DOCTYPE card [
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED
+  preferredFormat (html|text) #REQUIRED&gt;
+]&gt;</pre><p>Literal string patterns are not restricted to attribute
+values. For example, the following is allowed:</p><pre class="programlisting">element card {
+  element name { text },
+  element email { text },
+  element preferredFormat { &quot;html&quot; | &quot;text&quot; }
+}</pre><p>The prohibition against a datatype pattern's matching
+only part of the content of an element also applies to
+literal string patterns.</p><p>By default, a literal string pattern will consider the string
+in the pattern to match the string in the document if the two strings
+are the same after the whitespace in both strings is normalized.
+Whitespace normalization strips leading and trailing whitespace
+characters, and collapses sequences of one or more whitespace
+characters to a single space character.  This corresponds to the
+behaviour of an XML parser for an attribute that is declared as other
+than CDATA. Thus the above pattern will match any of:</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;html&quot;/&gt;
+&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;  html  &quot;/&gt;</pre><p>The way that a literal string pattern compares the
+pattern string with the document string can be controlled by
+preceding the literal string with a prefixed name, which identifies a
+datatype in the same way as for the datatype pattern.
+The pattern string matches the document string if they both represent
+the same value of the specified datatype. Thus, whereas a datatype pattern matches an arbitrary value of a
+datatype, a literal string pattern matches a specific
+value of a datatype.</p><p>There are two datatypes built-in to
+every RELAX NG implementation. These are named
+<tt class="literal">string</tt> and <tt class="literal">token</tt>:
+<tt class="literal">token</tt> corresponds to the
+default comparison behavior of a literal string pattern;
+<tt class="literal">string</tt> compares strings
+without any whitespace normalization (other than the end-of-line and
+attribute value normalization automatically performed by an XML processor).  For
+example,</p><pre class="programlisting">element card {
+  attribute name { text },
+  attribute email { text },
+  attribute preferredFormat { string &quot;html&quot; | string &quot;text&quot; }
+}</pre><p>will <span class="strong">not</span> match</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;  html  &quot;/&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815107"></a>7. Lists</h2></div></div><p>The <tt class="literal">list</tt> pattern matches a whitespace-separated
+sequence of tokens; it contains a pattern that the sequence of
+individual tokens must match.  The <tt class="literal">list</tt> pattern
+splits a string into a list of strings, and then matches the resulting
+list of strings against the pattern inside the <tt class="literal">list</tt>
+pattern.</p><p>For example, suppose we want to have a <tt class="literal">vector</tt>
+element that contains two floating point numbers separated by
+whitespace.  We could use <tt class="literal">list</tt> as follows:</p><pre class="programlisting">element vector {
+  list { xsd:float, xsd:float }
+}</pre><p>Or suppose we want the <tt class="literal">vector</tt> element to
+contain a list of one or more floating point numbers separated by
+whitespace:</p><pre class="programlisting">element vector {
+  list { xsd:double+ }
+}</pre><p>Or suppose we want a <tt class="literal">path</tt> element containing
+an even number of floating point numbers:</p><pre class="programlisting">element path {
+  list { (xsd:double, xsd:double)+ }
+}</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815185"></a>8. Interleaving</h2></div></div><p>In addition to the <tt class="literal">,</tt> and
+<tt class="literal">|</tt> connectors, RELAX NG provides the
+<tt class="literal">&amp;</tt> connector.  This is useful when child
+elements are allowed
+in any order. For example, the following would allow the
+<tt class="literal">card</tt> element to contain the <tt class="literal">name</tt> and
+<tt class="literal">email</tt> elements in any order:</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text }
+    &amp; element email { text }
+  }*
+}</pre><p>The <tt class="literal">&amp;</tt> connector is called the
+interleave connector because of how it
+works with patterns that match more than one element.  Suppose we want
+to write a pattern for the HTML <tt class="literal">head</tt> element which
+requires exactly one <tt class="literal">title</tt> element, at most one
+<tt class="literal">base</tt> element and zero or more <tt class="literal">style</tt>,
+<tt class="literal">script</tt>, <tt class="literal">link</tt> and <tt class="literal">meta</tt> elements
+and suppose we are writing a <tt class="literal">grammar</tt> pattern that has one
+definition for each element.  Then we could define the pattern for
+<tt class="literal">head</tt> as follows:</p><pre class="programlisting">head = element head { title &amp; base? &amp; style* &amp; script* &amp; link* &amp; meta* }</pre><p>Suppose we had a <tt class="literal">head</tt> element that contained a
+<tt class="literal">meta</tt> element, followed by a <tt class="literal">title</tt> element,
+followed by a <tt class="literal">meta</tt> element.  This would match the pattern
+because it is an interleaving of a sequence of two <tt class="literal">meta</tt>
+elements, which match the child pattern</p><pre class="programlisting">meta*</pre><p>and a sequence of one <tt class="literal">title</tt> element, which matches
+the child pattern</p><pre class="programlisting">title</pre><p>The semantics of the <tt class="literal">&amp;</tt> connector are that a
+sequence of elements matches a
+pattern <tt class="literal"><i class="replaceable"><tt>x</tt></i> &amp;
+<i class="replaceable"><tt>y</tt></i></tt> if it is an interleaving of a
+sequence that matches <i class="replaceable"><tt>x</tt></i> and a sequence that
+matches <i class="replaceable"><tt>y</tt></i>.  Note that this is different from the
+<tt class="literal">&amp;</tt> connector in SGML: <tt class="literal">A* &amp; B</tt> matches
+the sequence of elements <tt class="literal">A A B</tt> or the sequence of
+elements <tt class="literal">B A A</tt> but not the sequence of elements <tt class="literal">A B
+A</tt>.</p><p>One special case of interleaving is very common:
+interleaving <tt class="literal">text</tt> with a pattern
+<i class="replaceable"><tt>p</tt></i> represents a pattern that matches what <i class="replaceable"><tt>p</tt></i>
+matches but also allows characters to occur as children.  The
+<tt class="literal">mixed</tt> pattern is a shorthand for this.</p><pre class="programlisting">mixed { <i class="replaceable"><tt>p</tt></i> }</pre><p>is short for</p><pre class="programlisting">text &amp; <i class="replaceable"><tt>p</tt></i></pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815432"></a>9. Modularity</h2></div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815440"></a>9.1. Referencing external patterns</h3></div></div><p>The <tt class="literal">external</tt> pattern can be used to
+reference a pattern defined in a separate file.  The <tt class="literal">external</tt> keyword is followed by a quoted string specifying the URL of a file containing the pattern.  The <tt class="literal">external</tt> pattern matches if
+the pattern contained in the specified URL matches. Suppose for
+example, you have a RELAX NG pattern that matches HTML inline content
+stored in <tt class="literal">inline.rnc</tt>:</p><pre class="programlisting">start = inline
+inline =
+  (text
+   | element code { inline }
+   | element em { inline }
+     # etc
+     )*</pre><p>Then we could allow the <tt class="literal">note</tt> element to contain
+inline HTML markup by using <tt class="literal">external</tt> as follows:</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text },
+    element note { external &quot;inline.rnc&quot; }?
+  }*
+}</pre><p>For another example, suppose you have two RELAX NG patterns stored in
+files <tt class="literal">pattern1.rnc</tt> and <tt class="literal">pattern2.rnc</tt>. Then
+the following is a pattern that matches anything matched
+by either of those patterns:</p><pre class="programlisting">external &quot;pattern1.rnc&quot; | external &quot;pattern2.rnc&quot;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815524"></a>9.2. Combining definitions</h3></div></div><p>If a grammar contains multiple definitions with the same name,
+then the definitions must specify how they are to be combined into a
+single definition by using <tt class="literal">|=</tt> or <tt class="literal">&amp;=</tt> instead of <tt class="literal">=</tt>. For
+example,</p><pre class="programlisting">inline.class |= element bold { inline }
+inline.class |= element italic { inline }</pre><p>is equivalent to</p><pre class="programlisting">inline.class =
+  element bold { inline }
+  | element italic { inline }</pre><p>When combining attributes, <tt class="literal">&amp;=</tt>
+is typically used.  For example,</p><pre class="programlisting">start =
+  element addressBook {
+    element card { card.attlist }*
+  }
+card.attlist &amp;= attribute name { text }
+card.attlist &amp;= attribute email { text }</pre><p>is equivalent to</p><pre class="programlisting">start =
+  element addressBook {
+    element card { card.attlist }*
+  }
+card.attlist =
+  attribute name { text }
+  &amp; attribute email { text }</pre><p>which is equivalent to</p><pre class="programlisting">start =
+  element addressBook {
+    element card { card.attlist }*
+  }
+card.attlist =
+  attribute name { text },
+  attribute email { text }</pre><p>since combining attributes with <tt class="literal">&amp;</tt>
+has the same effect as combining them with
+<tt class="literal">,</tt>.</p><p>It is an error for the same name to be defined using both <tt class="literal">&amp;=</tt> and <tt class="literal">|=</tt>. Note that the order
+of definitions within a grammar is not significant.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815634"></a>9.3. Merging grammars</h3></div></div><p>The <tt class="literal">include</tt> directive allows
+grammars to be merged together. Along with definitions, a
+<tt class="literal">grammar</tt> pattern contain <tt class="literal">include</tt>
+directives.  An <tt class="literal">include</tt> directive consists of the
+<tt class="literal">include</tt> keywords followed by a quoted string
+specifying the URL of a file containing a <tt class="literal">grammar</tt>
+pattern.  The definitions in the referenced <tt class="literal">grammar</tt>
+pattern will be included in <tt class="literal">grammar</tt> pattern
+containing the <tt class="literal">include</tt> directive.</p><p>Both <tt class="literal">|=</tt> and <tt class="literal">&amp;=</tt> are particularly useful
+in conjunction with <tt class="literal">include</tt>.  For example, suppose
+a RELAX NG pattern <tt class="literal">inline.rnc</tt> provides a pattern
+for inline content, which allows <tt class="literal">bold</tt> and
+<tt class="literal">italic</tt> elements arbitrarily nested:</p><pre class="programlisting">inline = inline.class*
+inline.class =
+  text
+  | element bold { inline }
+  | element italic { inline }</pre><p>Another RELAX NG pattern could use <tt class="literal">inline.rnc</tt>
+and add <tt class="literal">code</tt> and <tt class="literal">em</tt> to the set
+of inline elements as follows:</p><pre class="programlisting">include &quot;inline.rnc&quot;
+start =
+  element doc {
+    element p { inline }*
+  }
+inline.class |=
+  element code { inline }
+  | element em { inline }</pre><p>This would be equivalent to</p><pre class="programlisting">inline = inline.class*
+inline.class =
+  text
+  | element bold { inline }
+  | element italic { inline }
+start =
+  element doc {
+    element p { inline }*
+  }
+inline.class |=
+  element code { inline }
+  | element em { inline }</pre><p>which is equivalent to</p><pre class="programlisting">inline = inline.class*
+inline.class =
+  text
+  | element bold { inline }
+  | element italic { inline }
+  | element code { inline }
+  | element em { inline }
+start =
+  element doc {
+    element p { inline }*
+  }</pre><p>Note that it is allowed for one of the definitions of a name to
+use <tt class="literal">=</tt> rather than <tt class="literal">|=</tt> or <tt class="literal">&amp;=</tt>.  However, it is an
+error if there is more than one definition that does so.</p><p>The <tt class="literal">notAllowed</tt> pattern is useful when merging
+grammars. The <tt class="literal">notAllowed</tt> pattern never matches
+anything.  Just as combining a pattern
+with empty using the , connector does not change the semantics of the
+pattern, so combining a pattern with notAllowed using the | connector
+also does not change the semantics of the
+pattern.  It is typically used to allow an including pattern to
+specify additional choices with <tt class="literal">|=</tt>.
+For example, if <tt class="literal">inline.rnc</tt> were written like
+this:</p><pre class="programlisting">inline =
+  (text
+   | element bold { inline }
+   | element italic { inline }
+   | inline.extra)*
+inline.extra = notAllowed</pre><p>then it could be customized to allow inline
+<tt class="literal">code</tt> and <tt class="literal">em</tt> elements as
+follows:</p><pre class="programlisting">include &quot;inline.rnc&quot;
+start =
+  element doc {
+    element p { inline }*
+  }
+inline.extra |=
+  element code { inline }
+  | element em { inline }</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815849"></a>9.4. Replacing definitions</h3></div></div><p>The <tt class="literal">include</tt> directive may be
+followed by a list of definitions in braces. These definitions replace
+definitions in the included <tt class="literal">grammar</tt> pattern.</p><p>Suppose the file <tt class="literal">addressBook.rnc</tt>
+contains:</p><pre class="programlisting">start =
+  element addressBook {
+    element card { cardContent }*
+  }
+cardContent =
+  element name { text },
+  element email { text }</pre><p>Suppose we wish to modify this pattern so that the
+<tt class="literal">card</tt> element contains an
+<tt class="literal">emailAddress</tt> element instead of an
+<tt class="literal">email</tt> element. Then we could replace the definition
+of <tt class="literal">cardContent</tt> as follows:</p><pre class="programlisting">include &quot;addressBook.rnc&quot; {
+  cardContent =
+    element name { text },
+    element emailAddress { text }
+}</pre><p>This would be equivalent to</p><pre class="programlisting">start =
+  element addressBook {
+    element card { cardContent }*
+  }
+cardContent =
+  element name { text },
+  element emailAddress { text }</pre><p>Definitions of <tt class="literal">start</tt> can be
+replaced in exactly the same way as other definitions.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815943"></a>10. Namespaces</h2></div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815950"></a>10.1. Qualified names</h3></div></div><p>The name following an <tt class="literal">element</tt> or
+<tt class="literal">attribute</tt> keyword may be qualified with a prefix.
+Each such prefix must be associated with a namespace URI using a
+namespace declaration. Namespace declarations occur at the beginning
+of the file, before the pattern. For example,</p><pre class="programlisting">namespace ab = &quot;http://www.example.com/address&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>Multiple namespace declarations are allowed:</p><pre class="programlisting">namespace a = &quot;http://www.example.com/address&quot;
+namespace ab = &quot;http://www.example.com/addressBook&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element a:name { text },
+    element a:email { text }
+  }*
+}</pre><p>When an <tt class="literal">element</tt> or <tt class="literal">attribute</tt>
+pattern is matched against an element or attribute in the XML document,
+namespace URIs rather than prefixes are used.  Thus,</p><pre class="programlisting">namespace eg = &quot;http://www.example.com&quot;
+
+element eg:foo { empty }</pre><p>would match any of</p><pre class="programlisting">&lt;foo xmlns=&quot;http://www.example.com&quot;/&gt;
+&lt;e:foo xmlns:e=&quot;http://www.example.com&quot;/&gt;
+&lt;eg:foo xmlns:eg=&quot;http://www.example.com&quot;/&gt;
+&lt;example:foo xmlns:example=&quot;http://www.example.com&quot;/&gt;</pre><p>but not any of</p><pre class="programlisting">&lt;foo/&gt;
+&lt;eg:foo xmlns:eg=&quot;http://www.example.com/example&quot;/&gt;
+&lt;eg:foo xmlns:eg=&quot;http://WWW.EXAMPLE.COM&quot;/&gt;
+&lt;example:foo xmlns:example=&quot;http://www.example.net&quot;/&gt;</pre><p>The prefix <tt class="literal">xml</tt> is predeclared as in XML: no
+namespace declaration is required for the <tt class="literal">xml</tt>
+prefix.</p><p>Namespace declarations and <tt class="literal">datatypes</tt>
+declarations can be mixed togther at the beginning of the file in any
+order.</p><p>Unlike in XML, namespace declarations cannot be nested.  A
+prefix is therefore always consistently bound to a single namespace
+URI throughout an entire file.</p><p>Namespace declarations apply only to the file in which they
+occur.  A file referenced using <tt class="literal">include</tt> or
+<tt class="literal">external</tt> must declare whatever prefixes occur in
+that file; it cannot take advantage of the namespace declarations in
+the referencing file.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="default-namespace"></a>10.2. Default namespace</h3></div></div><p>A single default namespace can be declared. For example,</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+
+element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>is equivalent to</p><pre class="programlisting">namespace ab = &quot;http://www.example.com/address&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>As with XML, the default namespace does not apply to attribute
+patterns.  Thus,</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+
+element addressBook {
+  element card {
+    attribute name { text },
+    attribute email { text }
+  }*
+}</pre><p>is equivalent to</p><pre class="programlisting">namespace ab = &quot;http://www.example.com/address&quot;
+
+element ab:addressBook {
+  element ab:card {
+    attribute name { text },
+    attribute email { text }
+  }*
+}</pre><p>and so will match</p><pre class="programlisting">&lt;addressBook xmlns=&quot;http://www.example.com&quot;&gt;
+  &lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;/addressBook&gt;</pre><p>or</p><pre class="programlisting">&lt;example:addressBook xmlns:example=&quot;http://www.example.com&quot;&gt;
+  &lt;example:card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;/example:addressBook&gt;</pre><p>but not</p><pre class="programlisting">&lt;example:addressBook xmlns:example=&quot;http://www.example.com&quot;&gt;
+  &lt;example:card example:name=&quot;John Smith&quot; example:email=&quot;js at example.com&quot;/&gt;
+&lt;/example:addressBook&gt;</pre><p>Default namespace declarations can be mixed with normal
+namespace declarations.  For example,</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+namespace ab = &quot;http://www.example.com/addressBook&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>is equivalent to</p><pre class="programlisting">namespace a = &quot;http://www.example.com/address&quot;
+namespace ab = &quot;http://www.example.com/addressBook&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element a:name { text },
+    element a:email { text }
+  }*
+}</pre><p>A default namespace declaration and a normal declaration for the
+same URI can be combined into a single declaration:</p><pre class="programlisting">default namespace eg = &quot;http://www.example.com&quot;</pre><p>is equivalent to</p><pre class="programlisting">default namespace = &quot;http://www.example.com&quot;
+namespace eg = &quot;http://www.example.com&quot;</pre><p>If a file does not declare a default namespace and is
+referenced from another file using <tt class="literal">include</tt> or
+<tt class="literal">external</tt>, then it inherits the default namespace of
+the referencing file. Thus, if <tt class="literal">address.rnc</tt>
+contains</p><pre class="programlisting">element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>then</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+
+external &quot;address.rnc&quot;</pre><p>is equivalent to</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+
+element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>If a file does not declare a default namespace and is a
+top-level file that is not referenced from another file using
+<tt class="literal">include</tt> or <tt class="literal">external</tt>, then the
+default namespace is the absent or null namespace.  Thus, a top-level
+file containing</p><pre class="programlisting">element foo { empty }</pre><p>matches any of:</p><pre class="programlisting">&lt;foo xmlns=&quot;&quot;/&gt;
+&lt;foo/&gt;</pre><p>but not any of:</p><pre class="programlisting">&lt;foo xmlns=&quot;http://www.example.com&quot;/&gt;
+&lt;e:foo xmlns:e=&quot;http://www.example.com&quot;/&gt;</pre><p>A namespace declaration can refer to the null or absent
+namespace by using a namespace URI of <tt class="literal">&quot;&quot;</tt> (like with
+the <tt class="literal">xmlns</tt> attribute). A file can ensure that its
+default namespace will be the null or absent namespace and will not be
+inherited from any referencing file by explicitly declaring the
+default namespace as <tt class="literal">&quot;&quot;</tt>:</p><pre class="programlisting">default namespace = &quot;&quot;</pre></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816343"></a>11. Name classes</h2></div></div><p>In all the examples up to now, the
+<tt class="literal">element</tt> and <tt class="literal">attribute</tt> keywords
+have been followed by a name, possibly qualified with a prefix.
+However, in general, the <tt class="literal">element</tt> and
+<tt class="literal">attribute</tt> keywords are followed by a
+<span class="emphasis"><em>name-class</em></span>.  A name is one particular simple kind
+of a name-class: a name specifies a name-class with that name as its
+only member.  An <tt class="literal">element</tt> or
+<tt class="literal">attribute</tt> pattern will only match an element or
+attribute in the XML document if the name of the element of attribute
+is a member of the name-class in the pattern.  Another simple kind of
+name-class is <tt class="literal">*</tt> which contains all names,
+regardless of their local name and namespace URI. For example, the
+following pattern matches any well-formed XML document:</p><pre class="programlisting">start = anyElement
+anyElement =
+  element * {
+    (attribute * { text }
+     | text
+     | anyElement)*
+  }</pre><p>A name-class
+<tt class="literal"><i class="replaceable"><tt>ns</tt></i>:*</tt> contains all names
+with the namespace URI declared for the prefix
+<i class="replaceable"><tt>ns</tt></i>.</p><p>Name-classes can be combined using the
+<tt class="literal">|</tt> connector. A name-class
+<tt class="literal"><i class="replaceable"><tt>x</tt></i> |
+<i class="replaceable"><tt>y</tt></i></tt> contains the union of
+<i class="replaceable"><tt>x</tt></i> and <i class="replaceable"><tt>y</tt></i>.  In
+other words, a name is a member of
+<tt class="literal"><i class="replaceable"><tt>x</tt></i> |
+<i class="replaceable"><tt>y</tt></i></tt> if it is a member of
+<i class="replaceable"><tt>x</tt></i> and/or a member of
+<i class="replaceable"><tt>y</tt></i>.</p><p>Name-classes can also be combined using the
+<tt class="literal">-</tt> connector. A name-class
+<tt class="literal"><i class="replaceable"><tt>x</tt></i> -
+<i class="replaceable"><tt>y</tt></i></tt> contains the difference of
+<i class="replaceable"><tt>x</tt></i> and <i class="replaceable"><tt>y</tt></i>.  In
+other words, a name is a member of
+<tt class="literal"><i class="replaceable"><tt>x</tt></i> -
+<i class="replaceable"><tt>y</tt></i></tt> if it is a member of
+<i class="replaceable"><tt>x</tt></i> but not a member of
+<i class="replaceable"><tt>y</tt></i>. The left-hand name-class to be combined
+with the <tt class="literal">-</tt> connector must be a <tt class="literal">*</tt>
+or <tt class="literal"><i class="replaceable"><tt>ns</tt></i>:*</tt> name class.  As
+with patterns, there is no implicit precedence between connectors and
+parentheses must be used to make precedence explicit. For
+example,</p><pre class="programlisting">namespace local = &quot;&quot;
+default namespace ex = &quot;http://www.example.com&quot;
+
+element card {
+  attribute * - (ex:* | local:*) { text }*,
+  text
+}</pre><p>would allow the <tt class="literal">card</tt> element to have any number of
+namespace-qualified attributes provided that they were qualified with
+namespace other than that of the <tt class="literal">card</tt> element.</p><p>Note that an <tt class="literal">attribute</tt> pattern matches a single
+attribute even if it has a name-class that contains multiple names.
+To match zero or more attributes, <tt class="literal">*</tt>
+must be used.</p><p>Some schema languages have a concept of <span class="emphasis"><em>lax</em></span> validation,
+where an element or attribute is validated against a definition only
+if there is one.  We can implement this concept in RELAX NG with name
+classes that use the <tt class="literal">-</tt> connector.
+Suppose, for example, we wanted to allow an element to have any
+attribute with a qualified name, but we still wanted to ensure that if
+there was an <tt class="literal">xml:space</tt> attribute, it had the value
+<tt class="literal">default</tt> or <tt class="literal">preserve</tt>.  It wouldn't work to
+use</p><pre class="programlisting">element example {
+  attribute * { text }*,
+  attribute xml:space { &quot;default&quot; | &quot;preserve&quot; }?
+}</pre><p>because an <tt class="literal">xml:space</tt> attribute with a value
+other than <tt class="literal">default</tt> or <tt class="literal">preserve</tt>
+would match</p><pre class="programlisting">attribute * { text }</pre><p>even though it did not match</p><pre class="programlisting">attribute xml:space { &quot;default&quot; | &quot;preserve&quot; }</pre><p>The solution is to use the <tt class="literal">-</tt> connector:</p><pre class="programlisting">element example {
+  attribute * - xml:space { text }*,
+  attribute xml:space { &quot;default&quot; | &quot;preserve&quot; }?
+}</pre><p>Note that definitions cannot define name-classes;
+they can only define patterns.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816664"></a>12. Internationalization</h2></div></div><p>In the absence of externally supplied information, a RELAX NG
+Compact Syntax file will be assumed to be in Unicode using either the
+UTF-8 or UTF-16 encoding.  RELAX NG processors can automatically
+choose between UTF-8 and UTF-16 by using the byte order mark that
+almost all text editors automatically put at the beginning of a UTF-16
+file.  Although particular RELAX NG processors may allow you to use a
+legacy encoding, it is best to use UTF-8 or UTF-16 for
+interchange.</p><p>Unicode characters can be entered using an escape sequence of
+the form <tt class="literal">\x{<i class="replaceable"><tt>N</tt></i>}</tt>, where
+<i class="replaceable"><tt>N</tt></i> is the hex code of the character.  For
+example, <tt class="literal">\x{A9}</tt> can be used to represent represent
+the copyright sign.  Unlike XML character references, the
+<tt class="literal">\x</tt> escape sequence can be used anywhere, even in
+names of elements, attributes and definitions.  For example,</p><pre class="programlisting">element \x{E14}\x{E35} { empty }</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="annotations"></a>13. Annotations</h2></div></div><p>When a RELAX NG pattern is to be used for purposes other than
+validation, it is often desirable to be able to annotate it with
+additional information. For example, if a RELAX NG pattern is intended
+to be read by a human, it is desirable to be able to annotate it
+with documentation; when a RELAX NG pattern is converted into another
+schema language, it is desirable to be able to annotate it
+with information to guide the conversion.</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816743"></a>13.1. Applying annotations</h3></div></div><p>RELAX NG allows an annotation to be placed in square brackets
+immediately preceding the construct to be annotated.  Abstractly, an
+annotation is a fragment of XML consisting of zero or more attributes
+followed by zero or more elements. An attribute is written in a
+similar way to XML. For example,</p><pre class="programlisting">namespace doc = &quot;http://www.example.com/documentation&quot;
+
+[doc:href=&quot;address.html#addressBook&quot;]
+element addressBook {
+  [doc:href=&quot;address.html#card&quot;]
+  element card {
+    [doc:href=&quot;address.html#name&quot;]
+    element name { text },
+    [doc:href=&quot;address.html#email&quot;]
+    element email { text }
+  }*
+}</pre><p>An attribute in an annotation must be qualified with a prefix;
+the prefix must be declared in a namespace declaration with a
+non-empty URI.</p><p>An element in an annotation consists of the element name
+followed by the attributes and children in square brackets.</p><pre class="programlisting">namespace a = &quot;http://www.example.com/annotation&quot;
+
+element addressBook {
+  [ a:documentation [ xml:lang=&quot;en&quot; &quot;Information about a single address.&quot; ] ]
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>The constructs that can be annotated are patterns, name classes,
+parameters, definitions and the include directive.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816799"></a>13.2. String literal syntax</h3></div></div><p>String literals that are delimited with <tt class="literal">'</tt> or
+<tt class="literal">&quot;</tt> are not allowed to contain unescaped newlines. An
+escaped newline <tt class="literal">\x{A}</tt> can be used to include a
+newline in a literal.  Alternatively, string literals can be delimited
+with triple quotes (<tt class="literal">'''</tt> or <tt class="literal">&quot;&quot;&quot;</tt>)
+as in Python. Such string literals are allowed to contain unescaped
+newlines. String literals can be concatenated using
+<tt class="literal">~</tt>.  For example,</p><pre class="programlisting">&quot;A string can contain both '&quot; ~ 'and &quot;.'</pre><p>is equivalent to</p><pre class="programlisting">&quot;&quot;&quot;A string can contain both ' and &quot;.&quot;&quot;&quot;</pre><p>and</p><pre class="programlisting">&quot;Line 1\x{A}&quot; ~
+&quot;Line 2&quot;</pre><p>is equivalent to</p><pre class="programlisting">'''Line 1
+Line 2'''</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816874"></a>13.3. Documentation syntax</h3></div></div><p>A companion specification, RELAX NG DTD Compatibility [<a href="#compat"><span class="abbrev">Compatibility</span></a>], defines annotations to implement some features of
+XML DTDs. It also provides a <tt class="literal">documentation</tt> element
+for use as an annotation. There is a special shorthand syntax for
+this.  Comments starting with <tt class="literal">##</tt> are equivalent to
+an annotation consisting of a <tt class="literal">documentation</tt> element
+from the RELAX NG DTD Compatibility namespace.  For example,</p><pre class="programlisting">## Represents an
+## address book.
+element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre><p>is equivalent to</p><pre class="programlisting">namespace a = &quot;http://relaxng.org/ns/compatibility/annotations/1.0&quot;
+
+[
+  a:documentation [
+    &quot;Represents an\x{A}&quot; ~
+    &quot;address book.
+  ]
+]
+element addressBook {
+  element card {
+    element name { text },
+    element email { text }
+  }*
+}</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816926"></a>13.4. Grouping definitions</h3></div></div><p>RELAX NG also provides a <tt class="literal">div</tt> construct which
+allows an annotation to be applied to a group of definitions in a
+grammar.  For example, you might want to divide up the definitions of
+the grammar into modules:</p><pre class="programlisting">namespace m = &quot;http://www.example.com/module&quot;
+
+[ m:name = &quot;inline&quot; ]
+div {
+  code = <i class="replaceable"><tt>pattern</tt></i>
+  em = <i class="replaceable"><tt>pattern</tt></i>
+  var = <i class="replaceable"><tt>pattern</tt></i>
+}
+[ m:name = &quot;block&quot; ]
+div {
+  p = <i class="replaceable"><tt>pattern</tt></i>
+  ul = <i class="replaceable"><tt>pattern</tt></i>
+  ol = <i class="replaceable"><tt>pattern</tt></i>
+}</pre><p>This would allow you easily to generate variants of the grammar
+based on a selection of modules.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816990"></a>14. Nested grammars</h2></div></div><p>There is no prohibition against nesting grammar patterns.  A
+name refers to the definition from the innermost containing grammar pattern. There is also a
+<tt class="literal">parent</tt> pattern that escapes out of the current
+grammar and references a definition from the parent of the current
+grammar. A <tt class="literal">parent</tt> pattern
+consists of the <tt class="literal">parent</tt> keyword followed
+by the name of the definition.</p><p>Imagine the problem of writing a pattern for tables.  The pattern
+for tables only cares about the structure of tables; it doesn't care
+about what goes inside a table cell.  First, we create a RELAX NG pattern
+<tt class="literal">table.rnc</tt> as follows:</p><pre class="programlisting">cell.content = notAllowed
+start =
+  element table {
+    element tr {
+      element td { cell.content }+
+    }+
+  }</pre><p>Patterns that include <tt class="literal">table.rnc</tt> must redefine
+<tt class="literal">cell.content</tt>. By using a nested
+<tt class="literal">grammar</tt> pattern containing a
+<tt class="literal">parent</tt> pattern, the including pattern can
+redefine <tt class="literal">cell.content</tt> to be a pattern defined in
+the including pattern's grammar, thus effectively importing a pattern
+from the parent grammar into the child grammar:</p><pre class="programlisting">start =
+  element doc {
+    (element p { inline }
+     | grammar {
+         include &quot;table.rnc&quot; {
+           cell.content = parent inline
+         }
+       })*
+  }
+inline =
+  (text
+   | element em { inline })*</pre><p>Of course, in a trivial case like this, there is no advantage in
+nesting the grammars: we could simply have included
+<tt class="literal">table.rnc</tt> within the outer <tt class="literal">grammar</tt> pattern.
+However, when the included grammar has many definitions, nesting it
+avoids the possibility of name conflicts between the including grammar
+and the included grammar.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817095"></a>15. Non-restrictions</h2></div></div><p>RELAX NG does not require patterns to be &quot;deterministic&quot; or
+&quot;unambiguous&quot;.</p><p>Suppose we wanted to write the email address book in HTML, but use
+class attributes to specify the structure:</p><pre class="programlisting">element html {
+  element head {
+    element title { text }
+  },
+  element body {
+    element table {
+      attribute class { &quot;addressBook&quot; },
+      element tr {
+        attribute class { &quot;card&quot; },
+        element td {
+          attribute class { &quot;name&quot; },
+          mixed {
+            element span {
+              attribute class { &quot;givenName&quot; },
+              text
+            }?,
+            element span {
+              attribute class { &quot;familyName&quot; },
+              text
+            }?
+          }
+        },
+        element td {
+          attribute class { &quot;email&quot; },
+          text
+        }
+      }+
+    }
+  }
+}</pre><p>This would match a document such as:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class=&quot;addressBook&quot;&gt;
+      &lt;tr class=&quot;card&quot;&gt;
+        &lt;td class=&quot;name&quot;&gt;
+          &lt;span class=&quot;givenName&quot;&gt;John&lt;/span&gt;
+          &lt;span class=&quot;familyName&quot;&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class=&quot;email&quot;&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre><p>but not:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class=&quot;addressBook&quot;&gt;
+      &lt;tr class=&quot;card&quot;&gt;
+        &lt;td class=&quot;name&quot;&gt;
+          &lt;span class=&quot;givenName&quot;&gt;John&lt;/span&gt;
+          &lt;!-- Note the incorrect class attribute --&gt;
+          &lt;span class=&quot;givenName&quot;&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class=&quot;email&quot;&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817156"></a>16. Advanced features</h2></div></div><p>This section describes advanced features, which most users will
+probably not need.  These features exist primarily to ensure
+equivalence between the XML and compact syntaxes.</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817166"></a>16.1. <tt class="literal">inherit</tt> keyword</h3></div></div><p>Namespace inheritance is in fact a little more flexible than
+described in <a href="#default-namespace" title="10.2. Default namespace">Section 10.2, &#8220;Default namespace&#8221;</a>.</p><p>The inherited namespace need not be the same as the default
+namespace.  The inherited namespace is referenced by using a namespace
+declaration that associates a prefix with the special keyword
+<tt class="literal">inherit</tt>.</p><p>So for example, if <tt class="literal">address.rnc</tt> contains</p><pre class="programlisting">namespace ab = inherit
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>then</p><pre class="programlisting">default namespace = &quot;http://www.example.com/address&quot;
+
+external &quot;address.rnc&quot;</pre><p>is equivalent to</p><pre class="programlisting">namespace ab = &quot;http://www.example.com/address&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>When a file is used as a top-level file rather then being
+referenced by <tt class="literal">external</tt> or
+<tt class="literal">include</tt>, then its inherited namespace is the null
+or absent namespace. We can now describe more simply what happens when
+a file does not declare the default namespace: what happens is simply
+that a declaration of</p><pre class="programlisting">default namespace = inherit</pre><p>is assumed.</p><p>Each <tt class="literal">include</tt> and <tt class="literal">external</tt>
+can independently determine what namespace is inherited by the
+referenced file by following the URL with <tt class="literal">inherit =
+<i class="replaceable"><tt>prefix</tt></i></tt>. Thus, if
+<tt class="literal">address.rnc</tt> contains</p><pre class="programlisting">namespace ab = inherit
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>then</p><pre class="programlisting">namespace a = &quot;http://www.example.com/address&quot;
+
+external &quot;address.rnc&quot; inherit = a</pre><p>is equivalent to</p><pre class="programlisting">namespace ab = &quot;http://www.example.com/address&quot;
+
+element ab:addressBook {
+  element ab:card {
+    element ab:name { text },
+    element ab:email { text }
+  }*
+}</pre><p>If an <tt class="literal">external</tt> or <tt class="literal">include</tt>
+does not specify <tt class="literal">inherit =
+<i class="replaceable"><tt>prefix</tt></i></tt>, then the referenced file
+inherits the default namespace of the referencing file.</p><p>A prefix used in the name of an attribute or element in an
+annotation cannot be associated with the <tt class="literal">inherit</tt>
+keyword.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817360"></a>16.2. Grammar-level annotations</h3></div></div><p>Grammar patterns can contain element annotations interspersed
+among the definitions. For example,</p><pre class="programlisting">
+namespace x = &quot;http://www.example.com&quot;
+
+start = foo
+
+x:entity [ name=&quot;picture&quot; systemId=&quot;picture.jpeg&quot; notation=&quot;jpeg&quot; ]
+
+foo = element foo { empty }
+</pre><p>In the XML syntax, such element annotations will be children of
+the <tt class="literal">grammar</tt> element.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817392"></a>16.3. <tt class="literal">&gt;&gt;</tt> annotations</h3></div></div><p>The <tt class="literal">&gt;&gt;</tt> connector creates a pattern or a
+name-class by combining a pattern or a name-class with an annotation
+element.  In the XML syntax, such element annotations will appear as
+following siblings of the element representing the pattern or
+name-class.  For example,</p><pre class="programlisting">namespace eg = &quot;http://www.example.com&quot;
+
+element foo {
+  text &gt;&gt; x[] &gt;&gt; y[]
+}</pre><p>is equivalent to the XML</p><pre class="programlisting">&lt;element name=&quot;foo&quot; xmlns:eg=&quot;http://www.example.com&quot;&gt;
+  &lt;text/&gt;
+  &lt;eg:x/&gt;
+  &lt;eg:y/&gt;
+&lt;/element&gt;</pre></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817433"></a>17. Further information</h2></div></div><p>The definitive specification of RELAX NG is [<a href="#spec"><span class="abbrev">Specification</span></a>], which uses the XML syntax.  [<a href="#compact"><span class="abbrev">Compact</span></a>] is the definitive specification for the compact
+syntax, which defines the compact syntax by mapping it to the XML
+syntax.</p><p>A tutorial for the XML syntax is available
+separately [<a href="#tutorial"><span class="abbrev">Tutorial</span></a>].</p><p>[<a href="#guidelines"><span class="abbrev">Guidelines</span></a>] defines how to use the datatypes
+defined in [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] as a RELAX NG datatype
+library.</p></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="keywords"></a>A. List of keywords</h2><p>The complete list of keywords is:</p><div class="itemizedlist"><ul type="disc"><li><a name="id2817503"></a><tt class="literal">attribute</tt></li><li><a name="id2817510"></a><tt class="literal">default</tt></li><li><a name="id2817517"></a><tt class="literal">datatypes</tt></li><li><a name="id2817524"></a><tt class="literal">div</tt></li><li><a name="id2817530"></a><tt class="literal">element</tt></li><li><a name="id2817537"></a><tt class="literal">empty</tt></li><li><a name="id2817544"></a><tt class="literal">external</tt></li><li><a name="id2817551"></a><tt class="literal">grammar</tt></li><li><a name="id2817558"></a><tt class="literal">include</tt></li><li><a name="id2817565"></a><tt class="literal">inherit</tt></li><li><a name="id2817572"></a><tt class="literal">list</tt></li><li><a name="id2817579"></a><tt class="literal">mixed</tt></li><li><a name="id2817586"></a><tt class="literal">namespace</tt></li><li><a name="id2817593"></a><tt class="literal">notAllowed</tt></li><li><a name="id2817600"></a><tt class="literal">parent</tt></li><li><a name="id2817607"></a><tt class="literal">start</tt></li><li><a name="id2817614"></a><tt class="literal">string</tt></li><li><a name="id2817620"></a><tt class="literal">text</tt></li><li><a name="id2817627"></a><tt class="literal">token</tt></li></ul></div></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="id2817637"></a>B. Comparison with XML DTDs</h2><p>RELAX NG provides functionality that goes beyond XML DTDs. In
+particular, RELAX NG</p><div class="itemizedlist"><ul type="disc"><li><a name="id2817653"></a>provides a choice of an XML syntax or a compact
+non-XML syntax to represent schemas</li><li><a name="id2817660"></a>supports datatyping</li><li><a name="id2817665"></a>integrates attributes into content
+models</li><li><a name="id2817672"></a>supports XML namespaces</li><li><a name="id2817677"></a>supports unordered content</li><li><a name="id2817683"></a>supports context-sensitive content
+models</li></ul></div><p>ID/IDREF validation is not provided by RELAX NG; however, it is
+provided by a companion specification, RELAX NG DTD Compatibility
+[<a href="#compat"><span class="abbrev">Compatibility</span></a>].  Comprehensive support for
+cross-reference checking is planned for a future specification.</p><p>RELAX NG does not support features of XML DTDs that involve
+changing the infoset of an XML document.  In particular, RELAX
+NG</p><div class="itemizedlist"><ul type="disc"><li><a name="id2817715"></a>does not allow defaults for attributes to be
+specified; however, this is allowed by RELAX NG DTD Compatibility
+[<a href="#compat"><span class="abbrev">Compatibility</span></a>]</li><li><a name="id2817727"></a>does not allow entities to be specified</li><li><a name="id2817731"></a>does not allow notations to be specified</li><li><a name="id2817738"></a>does not specify whether whitespace is significant</li></ul></div><p>Also, whereas an XML document can associate itself with a DTD
+using a <tt class="literal">DOCTYPE</tt> declaration,
+RELAX NG does not define a way for an XML document to associate
+itself with a RELAX NG pattern.</p></div><div id="id2817758" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="id2817758"></a>References</h2></div></div><dl><dt><span class="abbrev">Compact</span></dt><dd class="bibliomixed"><a name="compact"></a>James Clark, editor. <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/compact.html" target="_top">RELAX NG
+Compact Syntax</a></i></span>.  OASIS, 2002.</dd><dt><span class="abbrev">Compatibility</span></dt><dd class="bibliomixed"><a name="compat"></a>James Clark, MURATA
+Makoto, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/compatibility.html" target="_top">RELAX NG
+DTD Compatibility</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">Guidelines</span></dt><dd class="bibliomixed"><a name="guidelines"></a>James Clark, Kohsuke
+KAWAGUCHI, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/xsd.html" target="_top">Guidelines for using W3C XML Schema Datatypes with RELAX NG</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">RELAX</span></dt><dd class="bibliomixed"><a name="relax"></a>MURATA Makoto.
+<span class="citetitle"><i class="citetitle"><a href="http://www.xml.gr.jp/relax/" target="_top">RELAX (Regular
+Language description for XML)</a></i></span>.  INSTAC
+(Information Technology Research and Standardization Center), 2001.</dd><dt><span class="abbrev">Specification</span></dt><dd class="bibliomixed"><a name="spec"></a>James Clark, MURATA
+Makoto, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">TREX</span></dt><dd class="bibliomixed"><a name="trex"></a>James Clark.
+<span class="citetitle"><i class="citetitle"><a href="http://www.thaiopensource.com/trex/" target="_top">TREX - Tree Regular Expressions for XML</a></i></span>.
+Thai Open Source Software Center, 2001.</dd><dt><span class="abbrev">Tutorial</span></dt><dd class="bibliomixed"><a name="tutorial"></a>James Clark, MURATA Makoto, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/tutorial.html" target="_top">RELAX
+NG Tutorial</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">W3C XML Schema Datatypes</span></dt><dd class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i class="citetitle"><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd></dl></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/compact-tutorial-20030326.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,436 @@
+<html><head>
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>RELAX NG DTD Compatibility</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.40"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="IDAHAYR"></a>RELAX NG DTD Compatibility</h1></div><div><h2>Committee Specification 3 December 2001</h2></div><div><dl><dt>This version:</dt><dd>Committee Specification: 3 December 2001</dd></dl><dl><dt>Previous versions:</dt><dd>Committee Specification: 7 September 2001</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt>&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, MURATA Makoto <tt>&lt;<a href="mailto:EB2M-MRT at asahi-net.or.jp">EB2M-MRT at asahi-net.or.jp</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="IDAMCYR"></a>Abstract</h2><p>This specification defines datatypes and annotations for use in
+<a href="#spec" title="[RELAX NG]">[RELAX NG]</a> schemas.  The purpose of these datatypes and
+annotations is to support some of the features of XML 1.0 DTDs that
+are not supported directly by RELAX NG.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This Committee Specification was approved for publication by the
+OASIS RELAX NG technical committee.  It is a stable document which
+represents the consensus of the committee.  Comments on this document
+may be sent to <a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p><p>A list of known errors in this document is available at <a href="http://www.oasis-open.org/committees/relax-ng/compatibility-20011203-errata.html" target="_top">http://www.oasis-open.org/committees/relax-ng/compatibility-20011203-errata.html</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1 <a href="#IDACDYR">Introduction</a></dt><dd><dl><dt>1.1 <a href="#IDABEYR">Example</a></dt><dt>1.2 <a href="#IDAPEYR">Infoset modification</a></dt><dt>1.3 <a href="#IDA0EYR">Ambiguity</a></dt></dl></dd><dt>2 <a href="#IDA2FYR">Conformance</a></dt><dt>3 <a href="#default-value">Attribute default values</a></dt><dt>4 <a href="#id">ID, IDREF and IDREFS</a></dt><dt>5 <a href="#IDAC1YR">Documentation</a></dt></dl><h3>Appendixes</h3><dl><dt>A <a href="#IDAP2YR">RELAX NG schema</a></dt><dt><a href="#IDA12YR">References</a></dt></dl></div><hr><div class="section"><a name="IDACDYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDACDYR"></a>1. Introduction</h2></div></div><p>RELAX NG <a href="#spec" title="[RELAX NG]">[RELAX NG]</a> provides two mechanisms for
+extensibility:</p><div class="itemizedlist"><ul><li><a name="IDALDYR"></a>RELAX NG schemas can reference external
+libraries of datatypes;</li><li><a name="IDAODYR"></a>in a RELAX NG schema, RELAX NG-defined elements can be
+annotated with child elements and attributes from other
+namespaces.</li></ul></div><p>The goal of this specification is to facilitate transition from
+XML 1.0 DTDs to RELAX NG schemas by using these extensibility
+mechanisms to support some of the features of XML 1.0 DTDs that are
+not supported by RELAX NG.</p><p>The annotations defined in this specification have the namespace
+URI:</p><pre class="programlisting">http://relaxng.org/ns/compatibility/annotations/1.0</pre><p>This rest of this specification follows the convention of using
+the prefix <tt>a</tt> to refer to this namespace URI.</p><p>Annotations with the above namespace URI can be used in
+conjunction with annotations with other namespace URIs.  Annotations
+with other namespace URIs are allowed wherever <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>
+specifies that they are allowed.</p><div class="section"><a name="IDABEYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDABEYR"></a>1.1. Example</h3></div></div><p>The following DTD</p><pre class="programlisting">&lt;!DOCTYPE employees [
+&lt;!-- A list of employees. --&gt;
+&lt;!ELEMENT employees (employee*)&gt;
+&lt;!-- An individual employee. --&gt;
+&lt;!ELEMENT employee (#PCDATA)&gt;
+&lt;!ATTLIST employee
+  id ID #REQUIRED
+  manages IDREFS #IMPLIED
+  managedBy IDREF #IMPLIED
+  country (US|JP) "US"
+&gt;
+]&gt;</pre><p>could be translated to the following RELAX NG schema:</p><pre class="programlisting">&lt;element name="employees"
+    xmlns="http://relaxng.org/ns/structure/1.0"
+    xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
+    datatypeLibrary="http://relaxng.org/ns/compatibility/datatypes/1.0"&gt;
+  &lt;a:documentation&gt;A list of employees.&lt;/a:documentation&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="employee"&gt;
+      &lt;a:documentation&gt;An individual employee.&lt;/a:documentation&gt;
+      &lt;attribute name="id"&gt;
+        &lt;data type="ID"/&gt;
+      &lt;/attribute&gt; 
+      &lt;optional&gt;
+        &lt;attribute name="manages"&gt;
+          &lt;data type="IDREFS"/&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+      &lt;optional&gt;
+        &lt;attribute name="managedBy"&gt;
+          &lt;data type="IDREF"/&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+      &lt;optional&gt;
+        &lt;attribute name="country" a:defaultValue="US"&gt;
+          &lt;choice&gt;
+            &lt;value&gt;US&lt;/value&gt;
+            &lt;value&gt;JP&lt;/value&gt;
+          &lt;/choice&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre></div><div class="section"><a name="IDAPEYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAPEYR"></a>1.2. Infoset modification</h3></div></div><p>RELAX NG itself performs only validation: it does not change the
+infoset <a href="#infoset" title="[XML Infoset]">[XML Infoset]</a> of an XML document.  Most of the
+features of XML 1.0 DTDs that are not supported by RELAX NG involve
+modification to the infoset.  In XML 1.0, validation and infoset
+modification are combined in a monolithic XML processor.  It is a goal
+of this specification to provide a clean separation between validation
+and infoset modification, so that a wide variety of implementation
+scenarios are possible. In particular, it should be possible to make
+the infoset modifications either before performing RELAX NG validation
+or after performing RELAX NG validation or without performing RELAX NG
+validation at all.  It should also be possible for an implementation
+of this specification not to modify the infoset at all and instead
+provide the application with a description of the modifications
+implied by the annotations, independently of any particular
+instance.</p><p>This specification does not provide any support for features of
+XML 1.0 DTDs, such as entity declarations, that cannot be cleanly
+separated from validation.</p></div><div class="section"><a name="IDA0EYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA0EYR"></a>1.3. Ambiguity</h3></div></div><p>In an XML 1.0 document that is valid with respect to a DTD, each
+element or attribute in the instance has a unique corresponding
+element or attribute declaration in the DTD.  With RELAX NG this is
+not always the case: it may be ambiguous which
+<tt>element</tt> or <tt>attribute</tt> pattern any
+particular element or attribute in the instance matches.  In addition,
+it is non-trivial to determine when a RELAX NG schema is ambiguous.  A
+further complication is that even when cases where it is not
+ambiguous, it may require multiple passes or lookahead to determine
+which <tt>element</tt> or <tt>attribute</tt>
+pattern a particular element or attribute matches.  Detecting this
+situation is also non-trivial.</p><p>Some features of XML 1.0 DTDs, in particular default attribute
+values and ID/IDREF/IDREFS validation, depend crucially on this
+unambiguous correspondence between elements or attributes in the
+instance and their corresponding declarations.  In order to support
+these features in RELAX NG schemas by means of datatypes and
+annotations, it is therefore necessary to impose restrictions on the
+use of these datatypes and annotations.  The goals in framing these
+restrictions were as follows:</p><div class="orderedlist"><ol type="1"><li><a name="IDAKFYR"></a>It must be possible to determine whether a schema
+satisfies the restrictions independently of any particular
+instance.</li><li><a name="IDANFYR"></a>Processing of the instance must not require lookahead
+or multiple passes.</li><li><a name="IDAQFYR"></a>The modified infoset must be XML 1.0 compatible: it
+must be an infoset that could have been produced by a validating XML
+1.0 parser for some DTD.</li><li><a name="IDATFYR"></a>Implementation of the restrictions should be
+straightforward.</li><li><a name="IDAWFYR"></a>The restrictions should not be any more restrictive
+than necessary.</li></ol></div></div></div><div class="section"><a name="IDA2FYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA2FYR"></a>2. Conformance</h2></div></div><p>This specification defines three features:</p><div class="itemizedlist"><ul><li><a name="IDACGYR"></a>attribute default values</li><li><a name="IDAFGYR"></a>ID/IDREF/IDREFS</li><li><a name="IDAIGYR"></a>documentation</li></ul></div><p>Conformance is defined separately for each feature.  A
+conformant implementation can support any combination of features. For
+each feature, this specification defines</p><div class="itemizedlist"><ul><li><a name="IDAPGYR"></a>a <i>compatibility</i> property; this
+is a property that may hold for a correct RELAX NG schema; it is
+analogous to correctness for RELAX NG;</li><li><a name="IDAUGYR"></a>a <i>soundness</i> relationship; this
+is a relationship that may hold between a RELAX NG schema for which
+the compatibility property holds and an XML instance; it is analogous
+to validity for RELAX NG;</li><li><a name="IDAZGYR"></a>for an instance and schema between which the soundness
+relationship holds, a modification of the infoset of the instance;
+there is nothing analogous to this in RELAX NG.</li></ul></div><p>For each feature, there are two levels of conformance.</p><div class="orderedlist"><ol type="1"><li><a name="IDAAHYR"></a>Level 1 is similar to RELAX NG conformance.  It has
+two parts: determining whether the compatibility property holds of a
+schema, and determining whether the soundness relationship holds
+between a compatible schema and an instance.</li><li><a name="IDADHYR"></a>Level 2 requires that an implementation provide
+information about the modification of the infoset defined for the
+feature.  An implementation can provide the application either with a
+modified infoset or with sufficient information that would allow the
+application to modify the infoset itself.</li></ol></div><p>The following table shows which aspects of conformance are
+applicable to each feature:</p><div class="informaltable" id="IDAJHYR"><a name="IDAJHYR"></a><table border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Feature</th><th>Compatibility</th><th>Soundness</th><th>Infoset modification</th></tr></thead><tbody><tr><td>attribute default values</td><td>yes</td><td>no</td><td>yes</td></tr><tr><td>ID/IDREF/IDREFS</td><td>yes</td><td>yes</td><td>yes</td></tr><tr><td>documentation</td><td>yes</td><td>no</td><td>no</td></tr></tbody></table></div><p>A conformant implementation may support different features at
+different levels.</p><p>A conformant implementation may be an integral part of a RELAX
+NG validator or may be a separate software module.</p><p>Note that compatibility does not affect RELAX NG correctness.
+Thus, a conforming RELAX NG validator is required to be able to
+validate an instance against a correct RELAX NG schema even if that
+schema is not compatible with one or more of the features defined in
+this specification. Furthermore, soundness is completely independent
+of validity. A conforming RELAX NG validator must be able to determine
+whether an instance is valid with respect to a correct RELAX NG schema
+regardless of whether it is sound with respect to that schema for any
+of the features defined in this specifcation. A conforming
+implementation of a feature defined by this specification must be able
+to determine whether a instance is sound with respect to a compatible
+schema, regardless of whether the instance is valid with respect to
+that schema.</p></div><div class="section"><a name="default-value"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="default-value"></a>3. Attribute default values</h2></div></div><p>This feature is specified by an annotation attribute. An
+<tt>a:defaultValue</tt> attribute on a RELAX NG
+<tt>attribute</tt> element specifies the default value for
+the attribute.</p><p>A correct RELAX NG schema is compatible with this feature if
+after schema simplification, for each <tt>attribute</tt>
+element that has an <tt>a:defaultValue</tt> attribute, all
+of the following hold:</p><div class="itemizedlist"><ul><li><a name="IDAZRYR"></a>its first child is a <tt>name</tt>
+element</li><li><a name="IDA4RYR"></a>the first child of the containing
+<tt>element</tt> element is a <tt>name</tt>
+element</li><li><a name="IDAFSYR"></a>the value of the <tt>a:defaultValue</tt>
+attribute matches the pattern contained in the
+<tt>attribute</tt> element</li><li><a name="IDAMSYR"></a>the pattern in the <tt>attribute</tt>
+element does not contain a <tt>data</tt> or
+<tt>value</tt> element with a context-dependent datatype; a
+context-dependent datatype is one for which there is a string for
+which the datatypeAllows function (defined in <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>)
+returns both true and false according to the context</li><li><a name="IDAYSYR"></a>any ancestor that is a <tt>choice</tt>
+element has one child that is an <tt>empty</tt>
+element</li><li><a name="IDA5SYR"></a>it has at least one <tt>choice</tt>
+ancestor</li><li><a name="IDAETYR"></a>if the containing definition competes with another
+definition, then that other definition also contains an
+<tt>attribute</tt> element with the same name and with an
+<tt>a:defaultValue</tt> attribute with the same
+value.  A definition<pre class="programlisting">&lt;define name="<i><tt>ln1</tt></i>"&gt;
+  &lt;element&gt;
+    <i><tt>nc1</tt></i>
+    <i><tt>p1</tt></i>
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>competes with a definition</p><pre class="programlisting">&lt;define name="<i><tt>ln2</tt></i>"&gt;
+  &lt;element&gt;
+    <i><tt>nc2</tt></i>
+    <i><tt>p2</tt></i>
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>if there is a name <i><tt>n</tt></i> that belongs to
+both <i><tt>nc1</tt></i> and
+<i><tt>nc2</tt></i>.</p></li></ul></div><p>Schema simplification as defined in <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>
+removes all foreign attributes as well as foreign elements.  However,
+when checking compatibility of a schema with this feature, schema
+simplification must preserve <tt>a:defaultValue</tt>
+attributes on <tt>attribute</tt> elements.</p><p>There is no soundness relationship for this feature.</p><p>The modification of the infoset for this feature adds attribute
+information items to element information items.  An attribute
+information item with [local name] <i><tt>x</tt></i>,
+[namespace name] <i><tt>y</tt></i> and [normalized value]
+<i><tt>z</tt></i> is added to an element information item
+<i><tt>e</tt></i>, if and only if:</p><div class="itemizedlist"><ul><li><a name="IDA2UYR"></a><i><tt>e</tt></i> does not already have any attribute
+information item with [local name] <i><tt>x</tt></i> and
+[namespace name] <i><tt>y</tt></i>, and</li><li><a name="IDAFVYR"></a>after schema simplification, the schema contains an
+<tt>attribute</tt> element with<div class="itemizedlist"><ul><li><a name="IDALVYR"></a>a <tt>name</tt> child with content
+<i><tt>x</tt></i> and an <tt>ns</tt> attribute
+with value <i><tt>y</tt></i>,</li><li><a name="IDAWVYR"></a>an <tt>a:defaultValue</tt>
+attribute with value <i><tt>z</tt></i>, and</li><li><a name="IDA3VYR"></a>a containing <tt>element</tt> element that
+has a <tt>name</tt> child with content equal to the [local
+name] of <i><tt>e</tt></i> and an <tt>ns</tt>
+attribute with value equal to the the [namespace name] of
+<i><tt>e</tt></i>.</li></ul></div></li></ul></div></div><div class="section"><a name="id"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id"></a>4. ID, IDREF and IDREFS</h2></div></div><p>A RELAX NG schema makes use of this feature by using datatypes.
+Each datatype is associated with an <i>ID-type</i>,
+which is one of ID, IDREF or IDREFS or null. The datatype library with
+URI</p><pre class="programlisting">http://relaxng.org/ns/compatibility/datatypes/1.0</pre><p>contains datatypes named <tt>ID</tt>,
+<tt>IDREF</tt> and <tt>IDREFS</tt> associated with
+ID-types of ID, IDREF and IDREFS respectively. The datatypes in other
+datatype libraries are associated with a null ID-type, unless the
+datatype library specifies otherwise.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAAXYR"></a>Note</h3><p><a href="#guidelines" title="[Guidelines]">[Guidelines]</a> recommends that the
+<tt>ID</tt>, <tt>IDREF</tt> and
+<tt>IDREFS</tt> datatypes of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>
+should have ID-types ID, IDREF, and IDREFS respectively.</p></div><p>A RELAX NG schema is compatible with this feature if and only
+if, after schema simplification, for each <tt>data</tt> or
+<tt>value</tt> element that specifies a datatype associated
+with a non-null ID-type, all of the following hold:</p><div class="itemizedlist"><ul><li><a name="IDAWXYR"></a>its parent is an <tt>attribute</tt>
+element</li><li><a name="IDA1XYR"></a>the first child of its <tt>attribute</tt>
+parent is a <tt>name</tt> element</li><li><a name="IDAFYYR"></a>the first child of the <tt>element</tt>
+ancestor is a <tt>name</tt> element</li><li><a name="IDAMYYR"></a> if its <tt>attribute</tt> parent has any
+competing <tt>attribute</tt> elements, then each such
+competing <tt>attribute</tt> element has a
+<tt>data</tt> or <tt>value</tt> child specifying a
+datatype associated with the same ID-type. Two attribute
+elements<pre class="programlisting">&lt;attribute&gt; <i><tt>nc1</tt></i> <i><tt>p1</tt></i> &lt;/attribute&gt;</pre><p>and</p><pre class="programlisting">&lt;attribute&gt; <i><tt>nc2</tt></i> <i><tt>p2</tt></i> &lt;/attribute&gt;</pre><p>compete if and only if the containing definitions compete and
+there is a name <i><tt>n</tt></i> that belongs to both
+<i><tt>nc1</tt></i> and <i><tt>nc2</tt></i>.  Note
+that a definition competes with itself.</p></li></ul></div><p>Thus, a RELAX NG schema that is compatible with this feature
+implies a mapping from element/attribute name pairs onto an ID-type,
+and hence a mapping from attributes in the instance onto
+ID-types.</p><p>An instance is sound for this feature with respect to a
+compatible RELAX NG schema if and only if</p><div class="itemizedlist"><ul><li><a name="IDAWZYR"></a>when the value of each attribute in the instance whose
+ID-type is not null is split into a sequence of whitespace-separated
+tokens, the length of the sequence is 1 if the ID-type is ID or IDREF
+and greater than or equal to 1 if the ID-type is
+IDREFS, and</li><li><a name="IDAZZYR"></a>no two distinct tokens in attributes of ID-type ID
+have the same value, and</li><li><a name="IDA2ZYR"></a>for each token in an attribute of ID-type IDREF or
+IDREFS, there is a token in an attribute of ID-type ID with the same
+value</li></ul></div><p>The modification of the infoset for this feature changes the
+[attribute type] property of attribute information items to
+<tt>ID</tt>, <tt>IDREF</tt> or
+<tt>IDREFS</tt> according to the ID-type of the attribute
+and modifies the [normalized value] by applying the
+normalizeWhiteSpace function.</p><p>The semantics needed for RELAX NG validation are defined for
+the datatype library</p><pre class="programlisting">http://relaxng.org/ns/compatibility/datatypes/1.0</pre><p>as follows:</p><div class="itemizedlist"><ul><li><a name="IDAP0YR"></a>for <tt>ID</tt> and <tt>IDREF</tt>
+a string is an allowed representation if it is a single NCName (as
+defined in <a href="#xml-names" title="[XML Namespaces]">[XML Namespaces]</a>) with optional leading and
+trailing whitespace; for <tt>IDREFS</tt> a string is an
+allowed representation if it is a a whitespace-separated list of one
+or more NCNames;</li><li><a name="IDA10YR"></a>values are tested for equality in the same way as for
+the builtin <tt>token</tt> datatype</li></ul></div></div><div class="section"><a name="IDAC1YR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAC1YR"></a>5. Documentation</h2></div></div><p>The <tt>a:documentation</tt> element can be used to
+specify human-readable documentation.  The functionality provided by
+an <tt>a:documentation</tt> element in a RELAX NG schema
+would be provided by a comment in an XML 1.0 DTD.  The
+<tt>a:documentation</tt> element contains text specifying
+documentation. It can also have namespace-qualified attributes such as
+<tt>xml:lang</tt>.</p><p>If an <tt>a:documentation</tt> element does not have a
+preceding sibling element from the RELAX NG namespace, then the
+specified documentation applies to the parent element.  Otherwise, the
+specified documentation applies to the nearest preceding sibling
+element from the RELAX NG namespace.  There may be multiple
+<tt>a:documentation</tt> elements specifying documentation
+that apply to the same RELAX NG element.</p><p>A correct RELAX NG schema is compatible with this feature if and
+only if, for each <tt>a:documentation</tt> element, all of
+the following hold:</p><div class="itemizedlist"><ul><li><a name="IDA01YR"></a>it does not have any child elements</li><li><a name="IDA31YR"></a>it does not have any attribute whose namespace URI is
+the empty string, the RELAX NG namespace URI or the compatibility
+annotations namespace URI</li><li><a name="IDAA2YR"></a>if it has a preceding sibling element from the RELAX
+NG namespace, then the nearest such preceding sibling element is an
+element that does not allow child elements
+(i.e. <tt>value</tt>, <tt>param</tt> or
+<tt>name</tt>)</li></ul></div><p>There is no soundness relationship for this feature.</p><p>There is no infoset modification for this feature.</p></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAP2YR"></a>A. RELAX NG schema</h2><p>A RELAX NG schema that is compatible with the features of this
+specification must, in addition to being valid with respect to the
+RELAX NG schema for RELAX NG specified in <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>, be
+valid with respect to the following schema:</p><pre>&lt;grammar xmlns="http://relaxng.org/ns/structure/1.0"
+  xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
+  xmlns:rng="http://relaxng.org/ns/structure/1.0"&gt;
+
+  &lt;start&gt;
+    &lt;choice&gt;
+      &lt;ref name="<a href="#:normal">normal</a>"/&gt;
+      &lt;ref name="<a href="#:attribute">attribute</a>"/&gt;
+      &lt;ref name="<a href="#:atomic">atomic</a>"/&gt;
+    &lt;/choice&gt;
+  &lt;/start&gt;
+
+  <a name=":normal"></a>&lt;define name="normal"&gt;
+    &lt;element&gt;
+      &lt;nsName ns="http://relaxng.org/ns/structure/1.0"&gt;
+        &lt;except&gt;
+          &lt;name&gt;rng:attribute&lt;/name&gt;
+          &lt;name&gt;rng:value&lt;/name&gt;
+          &lt;name&gt;rng:param&lt;/name&gt;
+          &lt;name&gt;rng:name&lt;/name&gt;
+        &lt;/except&gt;
+      &lt;/nsName&gt;
+      &lt;ref name="<a href="#:normalAtts">normalAtts</a>"/&gt;
+      &lt;ref name="<a href="#:normalContent">normalContent</a>"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":attribute"></a>&lt;define name="attribute"&gt;
+    &lt;element name="rng:attribute"&gt;
+      &lt;ref name="<a href="#:normalAtts">normalAtts</a>"/&gt;
+      &lt;optional&gt;
+        &lt;attribute name="a:defaultValue"&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+      &lt;ref name="<a href="#:normalContent">normalContent</a>"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":atomic"></a>&lt;define name="atomic"&gt;
+    &lt;element&gt;
+      &lt;choice&gt;
+        &lt;name&gt;rng:value&lt;/name&gt;
+        &lt;name&gt;rng:param&lt;/name&gt;
+        &lt;name&gt;rng:name&lt;/name&gt;
+      &lt;/choice&gt;
+      &lt;ref name="<a href="#:normalAtts">normalAtts</a>"/&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":normalAtts"></a>&lt;define name="normalAtts"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;attribute&gt;
+        &lt;anyName&gt;
+          &lt;except&gt;
+            &lt;nsName ns="http://relaxng.org/ns/compatibility/annotations/1.0"/&gt;
+          &lt;/except&gt;
+        &lt;/anyName&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  <a name=":normalContent"></a>&lt;define name="normalContent"&gt;
+    &lt;interleave&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="<a href="#:foreign">foreign</a>"/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;group&gt;
+        &lt;zeroOrMore&gt;
+          &lt;ref name="<a href="#:doc">doc</a>"/&gt;
+        &lt;/zeroOrMore&gt;
+        &lt;zeroOrMore&gt;
+          &lt;choice&gt;
+            &lt;group&gt;
+              &lt;ref name="<a href="#:atomic">atomic</a>"/&gt;
+              &lt;zeroOrMore&gt;
+                &lt;ref name="<a href="#:doc">doc</a>"/&gt;
+              &lt;/zeroOrMore&gt;
+            &lt;/group&gt;
+            &lt;ref name="<a href="#:attribute">attribute</a>"/&gt;
+            &lt;ref name="<a href="#:normal">normal</a>"/&gt;
+          &lt;/choice&gt;
+        &lt;/zeroOrMore&gt;
+      &lt;/group&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":foreign"></a>&lt;define name="foreign"&gt;
+    &lt;element&gt;
+      &lt;anyName&gt;
+        &lt;except&gt;
+          &lt;nsName ns="http://relaxng.org/ns/structure/1.0"/&gt;
+          &lt;nsName ns="http://relaxng.org/ns/compatibility/annotations/1.0"/&gt;
+        &lt;/except&gt;
+      &lt;/anyName&gt;
+      &lt;ref name="<a href="#:any">any</a>"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":any"></a>&lt;define name="any"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+        &lt;attribute&gt;
+          &lt;anyName/&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+        &lt;element&gt;
+          &lt;anyName/&gt;
+          &lt;ref name="<a href="#:any">any</a>"/&gt;
+        &lt;/element&gt;
+        &lt;text/&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  <a name=":doc"></a>&lt;define name="doc"&gt;
+    &lt;element name="a:documentation"&gt;
+      &lt;zeroOrMore&gt;
+        &lt;attribute&gt;
+          &lt;anyName&gt;
+            &lt;except&gt;
+              &lt;nsName ns="http://relaxng.org/ns/structure/1.0"/&gt;
+              &lt;nsName ns="http://relaxng.org/ns/compatibility/annotations/1.0"/&gt;
+              &lt;nsName ns=""/&gt;
+            &lt;/except&gt;
+          &lt;/anyName&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre></div><div id="IDA12YR" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="IDA12YR"></a>References</h2></div></div><dl><dt>Guidelines</dt><dd id="guidelines" class="bibliomixed"><a name="guidelines"></a>James Clark, Kohsuke
+KAWAGUCHI, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/xsd.html" target="_top">Guidelines
+for using W3C XML Schema Datatypes with RELAX NG</a></i></span>.
+OASIS, 2001.</dd><dt>RELAX NG</dt><dd id="spec" class="bibliomixed"><a name="spec"></a>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</dd><dt>W3C XML Schema Datatypes</dt><dd id="xmlschema-2" class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XML 1.0</dt><dd id="xml-rec" class="bibliomixed"><a name="xml-rec"></a>Tim Bray,
+Jean Paoli, and
+C. M. Sperberg-McQueen, Eve Maler, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml" target="_top">Extensible Markup
+Language (XML) 1.0 Second Edition</a></i></span>.
+W3C (World Wide Web Consortium), 2000.</dd><dt>XML Infoset</dt><dd id="infoset" class="bibliomixed"><a name="infoset"></a>John Cowan, Richard Tobin,
+editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xml-infoset/" target="_top">XML
+Information Set</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XML Namespaces</dt><dd id="xml-names" class="bibliomixed"><a name="xml-names"></a>Tim Bray,
+Dave Hollander,
+and Andrew Layman, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml-names/" target="_top">Namespaces in
+XML</a></i></span>.
+W3C (World Wide Web Consortium), 1999.</dd></dl></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/compatibility-20011203.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,184 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+<head>
+<title>RELAX NG Specification Errata</title>
+<link rel="stylesheet" href="tr.css" type="text/css">
+</head>
+<body>
+<div class="article">
+
+<div class="titlepage"><p class="logo"><a
+href="http://www.oasis-open.org/"><img src="http://www.oasis-open.org/committees/relax-ng/oasis.png" alt="OASIS"
+border="0"></a></p></div>
+
+<h1 class="title">RELAX NG Specification Errata</h1>
+
+<p>This document lists errata in the <a
+href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html"
+>RELAX NG Specification</a>.</p>
+
+<p>The errata are numbered, classified as Substantive, Editorial or Clarification and listed in reverse chronological order of their date of publication. 
+<hr>
+
+<h2>Errata as of 2002-06-06<a href="http://lists.oasis-open.org/archives/relax-ng/200206/msg00010.html">(meeting report)</a></h2>
+
+<h3>E7 (editorial)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDAGHZR">Section 4.15</a></p>
+
+<div class="instruction">
+<P>Replace "transformed into a choice between <tt>oneOrMore</tt> and
+<tt>empty</tt>" with "transformed into a <tt>choice</tt> element with
+one child being an <code>&lt;oneOrMore&gt; <i><tt>p</tt></i>
+&lt;/oneOrMore&gt;</code> element and the other child being an <tt>empty</tt> element, where
+<i><tt>p</tt></i> is the child of the
+<tt>zeroOrMore</tt> element".</p>
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html">http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html</a></p>
+
+
+<h3>E6 (editorial)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDAQGZR">Section 4.14</a></p>
+
+<div class="instruction">
+<P>Replace "transformed into a choice with <tt>empty</tt>" 
+with "transformed into a <tt>choice</tt> element with one child being
+	the child of the <tt>optional</tt> element and the other child
+	being <tt>empty</tt>".</p>
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html">http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html</a></p>
+
+<h3>E5 (editorial)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDAJ2YR">Section 4.6</a></p>
+
+<div class="instruction">
+<p>Replace
+"an <tt>externalRef</tt> attribute" in the first paragraph 
+with 
+"an <tt>externalRef</tt> element".</p>
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html">http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html</a></p>
+
+<h3>E4 (editorial)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDAG3YR">Section 4.7</a></p>
+
+<div class="instruction">
+<p>Replace
+"an <tt>include</tt> attribute" in the second paragraph 
+with 
+"an <tt>include</tt> element".</p>
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html">http://lists.oasis-open.org/archives/relax-ng/200206/msg00007.html</a></p>
+
+<h3>E3 (sustantiative)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDA5MCS">Appendix A</a></p>
+
+<div class="instruction">
+<p>Replace</p>
+
+<pre>      &lt;element name="ref"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="common-atts"/&gt;
+      &lt;/element&gt;
+</pre>
+<p>with</p>
+
+<pre>      &lt;element name="ref"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="common-atts"/&gt;
+        &lt;ref name="other"/&gt;
+      &lt;/element&gt;
+</pre>
+<p>and replace</p>
+
+<pre>      &lt;element name="parentRef"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="common-atts"/&gt;
+      &lt;/element&gt;
+</pre>
+<p>with</p>
+<pre>      &lt;element name="parentRef"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="common-atts"/&gt;
+        &lt;ref name="other"/&gt;
+      &lt;/element&gt;
+</pre>
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200205/msg00042.html">http://lists.oasis-open.org/archives/relax-ng/200205/msg00042.html</a></p>
+
+<h2>Errata as of 2002-02-28<a href="http://lists.oasis-open.org/archives/relax-ng/200202/msg00049.html">(meeting report)</a></h2>
+
+
+<h3>E2 (substantive)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDA5MCS">Appendix A</a></p>
+
+<div class="instruction">
+<p>Replace</p>
+
+<pre>
+              &lt;element name="param"&gt;
+                &lt;attribute name="name"&gt;
+                  &lt;data type="NCName"/&gt;
+                &lt;/attribute&gt;
+                &lt;text/&gt;
+              &lt;/element&gt;</pre>
+
+<p> with </p>
+
+<pre>
+              &lt;element name="param"&gt;
+                &lt;attribute name="name"&gt;
+                  &lt;data type="NCName"/&gt;
+                &lt;/attribute&gt;
+                &lt;ref name="common-atts"/&gt;
+                &lt;text/&gt;
+              &lt;/element&gt;.</pre>
+
+</div>
+
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200112/msg00044.html">http://lists.oasis-open.org/archives/relax-ng/200112/msg00044.html</a>
+</p>
+
+<h3>E1 (editorial)</h3>
+
+<p><a
+href="http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#full-syntax-example">Section 3.1</a></p>
+
+<div class="instruction">
+<p>In the example, replace <code>&lt;/a:document&gt;</code> by
+<code>&lt;/a:documentation&gt;</code>.
+</p>
+</div>
+
+<p>Source: <a href="http://lists.oasis-open.org/archives/relax-ng/200112/msg00024.html">http://lists.oasis-open.org/archives/relax-ng/200112/msg00024.html</a></p>
+
+
+</div>
+<hr>
+<p>Last updated $Date: 2003/03/27 03:08:33 $ by $Author: jjc $.</p>
+</body>
+</html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203-errata.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,1389 @@
+<html><head>
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>RELAX NG Specification</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.40"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="IDAHAYR"></a>RELAX NG Specification</h1></div><div><h2>Committee Specification 3 December 2001</h2></div><div><dl><dt>This version:</dt><dd>Committee Specification: 3 December 2001</dd></dl><dl><dt>Previous versions:</dt><dd>Committee Specification: 11 August 2001</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt>&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, MURATA Makoto <tt>&lt;<a href="mailto:EB2M-MRT at asahi-net.or.jp">EB2M-MRT at asahi-net.or.jp</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="IDANCYR"></a>Abstract</h2><p>This is the definitive specification of RELAX NG, a simple
+schema language for XML, based on <a href="#relax" title="[RELAX]">[RELAX]</a> and <a href="#trex" title="[TREX]">[TREX]</a>. A RELAX NG schema specifies a pattern for the
+structure and content of an XML document. A RELAX NG schema is itself
+an XML document.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This Committee Specification was approved for publication by the
+OASIS RELAX NG technical committee. It is a stable document which
+represents the consensus of the committee. Comments on this document
+may be sent to <a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p><p>A list of known errors in this document is available at <a href="http://www.oasis-open.org/committees/relax-ng/spec-20011203-errata.html" target="_top">http://www.oasis-open.org/committees/relax-ng/spec-20011203-errata.html</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1 <a href="#IDAGDYR">Introduction</a></dt><dt>2 <a href="#data-model">Data model</a></dt><dd><dl><dt>2.1 <a href="#data-model-example">Example</a></dt></dl></dd><dt>3 <a href="#full-syntax">Full syntax</a></dt><dd><dl><dt>3.1 <a href="#full-syntax-example">Example</a></dt></dl></dd><dt>4 <a href="#simplification">Simplification</a></dt><dd><dl><dt>4.1 <a href="#IDARXYR">Annotations</a></dt><dt>4.2 <a href="#IDADYYR">Whitespace</a></dt><dt>4.3 <a href="#IDAXYYR"><tt>datatypeLibrary</tt> attribute</a></dt><dt>4.4 <a href="#IDA0ZYR"><tt>type</tt> attribute of <tt>value</tt> element</a></dt><dt>4.5 <a href="#href"><tt>href</tt> attribute</a></dt><dt>4.6 <a href="#IDAJ2YR"><tt>externalRef</tt> element</a></dt><dt>4.7 <a href="#IDAG3YR"><tt>include</tt> element</a></dt><dt>4.8 <a href="#IDAEAZR"><tt>name</tt> attribute of <tt>element</tt>
+and <tt>attribute</tt> elements</a></dt><dt>4.9 <a href="#IDAEBZR"><tt>ns</tt> attribute</a></dt><dt>4.10 <a href="#IDA4CZR">QNames</a></dt><dt>4.11 <a href="#IDAODZR"><tt>div</tt> element</a></dt><dt>4.12 <a href="#number-child-elements">Number of child elements</a></dt><dt>4.13 <a href="#IDA0FZR"><tt>mixed</tt> element</a></dt><dt>4.14 <a href="#IDAQGZR"><tt>optional</tt> element</a></dt><dt>4.15 <a href="#IDAGHZR"><tt>zeroOrMore</tt> element</a></dt><dt>4.16 <a href="#constraints">Constraints</a></dt><dt>4.17 <a href="#IDA0KZR"><tt>combine</tt> attribute</a></dt><dt>4.18 <a href="#IDASNZR"><tt>grammar</tt> element</a></dt><dt>4.19 <a href="#define-ref"><tt>define</tt> and <tt>ref</tt> elements</a></dt><dt>4.20 <a href="#notAllowed"><tt>notAllowed</tt> element</a></dt><dt>4.21 <a href="#IDA1UZR"><tt>empty</tt> element</a></dt></dl></dd><dt>5 <a href="#simple-syntax">Simple syntax</a></dt><dd><dl><dt>5.1 <a href="#simple-syntax-example">Example</a></dt></dl></dd><dt>6 <a href="#semantics">Semantics</a></dt><dd><dl><dt>6.1 <a href="#name-classes">Name classes</a></dt><dt>6.2 <a href="#IDAME0R">Patterns</a></dt><dd><dl><dt>6.2.1 <a href="#choice-pattern"><tt>choice</tt> pattern</a></dt><dt>6.2.2 <a href="#IDAEK0R"><tt>group</tt> pattern</a></dt><dt>6.2.3 <a href="#empty-pattern"><tt>empty</tt> pattern</a></dt><dt>6.2.4 <a href="#text-pattern"><tt>text</tt> pattern</a></dt><dt>6.2.5 <a href="#IDALU0R"><tt>oneOrMore</tt> pattern</a></dt><dt>6.2.6 <a href="#IDA2Z0R"><tt>interleave</tt> pattern</a></dt><dt>6.2.7 <a href="#element-pattern"><tt>element</tt> and <tt>attribute</tt> pattern</a></dt><dt>6.2.8 <a href="#data-pattern"><tt>data</tt> and <tt>value</tt> pattern</a></dt><dt>6.2.9 <a href="#built-in-datatype">Built-in datatype library</a></dt><dt>6.2.10 <a href="#IDACKAS"><tt>list</tt> pattern</a></dt></dl></dd><dt>6.3 <a href="#validity">Validity</a></dt><dt>6.4 <a href="#IDAHPAS">Example</a></dt></dl></dd><dt>7 <a href="#restriction">Restrictions</a></dt><dd><dl><dt>7.1 <a href="#contextual-restriction">Contextual restrictions</a></dt><dd><dl><dt>7.1.1 <a href="#IDA3LBS"><tt>attribute</tt> pattern</a></dt><dt>7.1.2 <a href="#IDAPMBS"><tt>oneOrMore</tt> pattern</a></dt><dt>7.1.3 <a href="#list-restrictions"><tt>list</tt> pattern</a></dt><dt>7.1.4 <a href="#context-data-except"><tt>except</tt> in <tt>data</tt> pattern</a></dt><dt>7.1.5 <a href="#context-start"><tt>start</tt> element</a></dt></dl></dd><dt>7.2 <a href="#string-sequences">String sequences</a></dt><dt>7.3 <a href="#attribute-restrictions">Restrictions on attributes</a></dt><dt>7.4 <a href="#interleave-restrictions">Restrictions on <tt>interleave</tt></a></dt></dl></dd><dt>8 <a href="#conformance">Conformance</a></dt></dl><h3>Appendixes</h3><dl><dt>A <a href="#IDA5MCS">RELAX NG schema for RELAX NG</a></dt><dt>B <a href="#IDAGNCS">Changes since version 0.9</a></dt><dt>C <a href="#IDAPRCS">RELAX NG TC (Non-Normative)</a></dt><dt><a href="#IDAPSCS">References</a></dt></dl></div><hr><div class="section"><a name="IDAGDYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAGDYR"></a>1. Introduction</h2></div></div><p>This document specifies</p><div class="itemizedlist"><ul><li><a name="IDAMDYR"></a>when an XML document is a correct RELAX NG
+schema</li><li><a name="IDAPDYR"></a>when an XML document is valid with respect to a
+correct RELAX NG schema</li></ul></div><p>An XML document that is being validated with respect to a RELAX NG
+schema is referred to as an instance.</p><p>The structure of this document is as follows.  <a href="#data-model" title="2. Data model">Section 2</a> describes the data model, which is the
+abstraction of an XML document used throughout the rest of the
+document.  <a href="#full-syntax" title="3. Full syntax">Section 3</a> describes the syntax of a
+RELAX NG schema; any correct RELAX NG schema must conform to this
+syntax.  <a href="#simplification" title="4. Simplification">Section 4</a> describes a sequence of
+transformations that are applied to simplify a RELAX NG schema;
+applying the transformations also involves checking certain
+restrictions that must be satisfied by a correct RELAX NG
+schema. <a href="#simple-syntax" title="5. Simple syntax">Section 5</a> describes the syntax that
+results from applying the transformations; this simple syntax is a
+subset of the full syntax.  <a href="#semantics" title="6. Semantics">Section 6</a> describes the
+semantics of a correct RELAX NG schema that uses the simple syntax;
+the semantics specify when an element is valid with respect to a RELAX
+NG schema.  <a href="#restriction" title="7. Restrictions">Section 7</a> describes restrictions in
+terms of the simple syntax; a correct RELAX NG schema must be such
+that, after transformation into the simple form, it satisfies these
+restrictions. Finally, <a href="#conformance" title="8. Conformance">Section 8</a> describes
+conformance requirements for RELAX NG validators.</p><p>A tutorial is available separately (see <a href="#tutorial" title="[Tutorial]">[Tutorial]</a>).</p></div><div class="section"><a name="data-model"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="data-model"></a>2. Data model</h2></div></div><p>RELAX NG deals with XML documents representing both schemas and
+instances through an abstract data model.  XML documents representing
+schemas and instances must be well-formed in conformance with <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a> and must conform to the constraints of <a href="#xml-names" title="[XML Namespaces]">[XML Namespaces]</a>.</p><p>An XML document is represented by an element.  An element consists
+of</p><div class="itemizedlist"><ul><li><a name="IDACFYR"></a>a name</li><li><a name="IDAFFYR"></a>a context</li><li><a name="IDAIFYR"></a>a set of attributes</li><li><a name="IDALFYR"></a>an ordered sequence of zero or more children; each
+child is either an element or a non-empty string; the sequence never contains
+two consecutive strings</li></ul></div><p>A name consists of</p><div class="itemizedlist"><ul><li><a name="IDASFYR"></a>a string representing the namespace URI; the empty
+string has special significance, representing the absence of any
+namespace</li><li><a name="IDAVFYR"></a>a string representing the local name; this string matches the NCName
+production of <a href="#xml-names" title="[XML Namespaces]">[XML Namespaces]</a></li></ul></div><p>A context consists of</p><div class="itemizedlist"><ul><li><a name="IDA4FYR"></a>a base URI</li><li><a name="IDABGYR"></a>a namespace map; this maps prefixes to namespace URIs,
+and also may specify a default namespace URI (as declared
+by the <tt>xmlns</tt> attribute)</li></ul></div><p>An attribute consists of</p><div class="itemizedlist"><ul><li><a name="IDAKGYR"></a>a name</li><li><a name="IDANGYR"></a>a string representing the value</li></ul></div><p>A string consists of a sequence of zero or more characters,
+where a character is as defined in <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a>.</p><p>The element for an XML document is constructed from an instance
+of the <a href="#infoset" title="[XML Infoset]">[XML Infoset]</a> as follows.  We use the notation
+[<i><tt>x</tt></i>] to refer to the value of the
+<i><tt>x</tt></i> property of an information item. An
+element is constructed from a document information item by
+constructing an element from the [document element].  An element is
+constructed from an element information item by constructing the name
+from the [namespace name] and [local name], the context from the [base
+URI] and [in-scope namespaces], the attributes from the [attributes],
+and the children from the [children].  The attributes of an element
+are constructed from the unordered set of attribute information items
+by constructing an attribute for each attribute information item.  The
+children of an element are constructed from the list of child
+information items first by removing information items other than
+element information items and character information items, and then by
+constructing an element for each element information item in the list
+and a string for each maximal sequence of character information items.
+An attribute is constructed from an attribute information item by
+constructing the name from the [namespace name] and [local name], and
+the value from the [normalized value].  When constructing the name of
+an element or attribute from the [namespace name] and [local name], if
+the [namespace name] property is not present, then the name is
+constructed from an empty string and the [local name]. A string is
+constructed from a sequence of character information items by
+constructing a character from the [character code] of each character
+information item.</p><p>It is possible for there to be multiple distinct infosets for a
+single XML document.  This is because XML parsers are not required to
+process all DTD declarations or expand all external parsed general
+entities.  Amongst these multiple infosets, there is exactly one
+infoset for which [all declarations processed] is true and which does
+not contain any unexpanded entity reference information items.  This
+is the infoset that is the basis for defining the RELAX NG data
+model.</p><div class="section"><a name="data-model-example"></a><div class="titlepage"><div><h3 class="title"><a name="data-model-example"></a>2.1. Example</h3></div></div><p>Suppose the document
+<tt>http://www.example.com/doc.xml</tt> is as
+follows:</p><pre class="programlisting">&lt;?xml version="1.0"?&gt;
+&lt;foo&gt;&lt;pre1:bar1 xmlns:pre1="http://www.example.com/n1"/&gt;&lt;pre2:bar2
+  xmlns:pre2="http://www.example.com/n2"/&gt;&lt;/foo&gt;
+</pre><p>The element representing this document has</p><div class="itemizedlist"><ul><li><a name="IDAQHYR"></a>a name which has<div class="itemizedlist"><ul><li><a name="IDAUHYR"></a>the empty string as the namespace URI, representing
+the absence of any namespace</li><li><a name="IDAXHYR"></a><tt>foo</tt> as the local
+name</li></ul></div></li><li><a name="IDA4HYR"></a>a context which has<div class="itemizedlist"><ul><li><a name="IDAFQYR"></a><tt>http://www.example.com/doc.xml</tt> as the base
+URI</li><li><a name="IDAKQYR"></a>a namespace map which<div class="itemizedlist"><ul><li><a name="IDAOQYR"></a>maps the prefix <tt>xml</tt> to the
+namespace URI
+<tt>http://www.w3.org/XML/1998/namespace</tt>
+(the <tt>xml</tt> prefix is implicitly declared
+by every XML document)</li><li><a name="IDAXQYR"></a>specifies the empty string as the default namespace
+URI</li></ul></div></li></ul></div></li><li><a name="IDA4QYR"></a>an empty set of attributes</li><li><a name="IDABRYR"></a>a sequence of children consisting
+of an element which has<div class="itemizedlist"><ul><li><a name="IDAFRYR"></a>a name which has<div class="itemizedlist"><ul><li><a name="IDAJRYR"></a><tt>http://www.example.com/n1</tt> as the
+namespace URI</li><li><a name="IDAORYR"></a><tt>bar1</tt> as the local
+name</li></ul></div></li><li><a name="IDAVRYR"></a>a context which has<div class="itemizedlist"><ul><li><a name="IDAZRYR"></a><tt>http://www.example.com/doc.xml</tt> as the base
+URI</li><li><a name="IDA4RYR"></a>a namespace map which<div class="itemizedlist"><ul><li><a name="IDACSYR"></a>maps the prefix <tt>pre1</tt> to the
+namespace URI
+<tt>http://www.example.com/n1</tt></li><li><a name="IDAISYR"></a>maps the prefix <tt>xml</tt> to the
+namespace URI
+<tt>http://www.w3.org/XML/1998/namespace</tt></li><li><a name="IDAOSYR"></a>specifies the empty string as the default namespace
+URI</li></ul></div></li></ul></div></li><li><a name="IDAVSYR"></a>an empty set of attributes</li><li><a name="IDAYSYR"></a>an empty sequence of children</li></ul></div><p>followed by an element which has</p><div class="itemizedlist"><ul><li><a name="IDA5SYR"></a>a name which has<div class="itemizedlist"><ul><li><a name="IDADTYR"></a><tt>http://www.example.com/n2</tt> as the
+namespace URI</li><li><a name="IDAITYR"></a><tt>bar2</tt> as the local
+name</li></ul></div></li><li><a name="IDAPTYR"></a>a context which has<div class="itemizedlist"><ul><li><a name="IDATTYR"></a><tt>http://www.example.com/doc.xml</tt> as the base
+URI</li><li><a name="IDAYTYR"></a>a namespace map which<div class="itemizedlist"><ul><li><a name="IDA2TYR"></a>maps the prefix <tt>pre2</tt> to the
+namespace URI
+<tt>http://www.example.com/n2</tt></li><li><a name="IDACUYR"></a>maps the prefix <tt>xml</tt> to the
+namespace URI
+<tt>http://www.w3.org/XML/1998/namespace</tt></li><li><a name="IDAIUYR"></a>specifies the empty string as the default namespace
+URI</li></ul></div></li></ul></div></li><li><a name="IDAPUYR"></a>an empty set of attributes</li><li><a name="IDASUYR"></a>an empty sequence of children</li></ul></div></li></ul></div></div></div><div class="section"><a name="full-syntax"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="full-syntax"></a>3. Full syntax</h2></div></div><p>The following grammar summarizes the syntax of RELAX NG.
+Although we use a notation based on the XML representation of an RELAX
+NG schema as a sequence of characters, the grammar must be understood
+as operating at the data model level.  For example, although the
+syntax uses <tt>&lt;text/&gt;</tt>, an instance or
+schema can use <tt>&lt;text&gt;&lt;/text&gt;</tt> instead,
+because they both represent the same element at the data model level.
+All elements shown in the grammar are qualified with the namespace
+URI:</p><pre class="programlisting">http://relaxng.org/ns/structure/1.0</pre><p>The symbols QName and NCName are defined in <a href="#xml-names" title="[XML Namespaces]">[XML Namespaces]</a>.  The anyURI symbol has the same meaning as the
+anyURI datatype of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>: it indicates a
+string that, after escaping of disallowed values as described in
+Section 5.4 of <a href="#xlink" title="[XLink]">[XLink]</a>, is a URI reference as defined
+in <a href="#rfc2396" title="[RFC 2396]">[RFC 2396]</a> (as modified by <a href="#rfc2732" title="[RFC 2732]">[RFC 2732]</a>).  The symbol string matches any string.</p><p>In addition to the attributes shown explicitly, any element can
+have an <tt>ns</tt> attribute and any element can have a
+<tt>datatypeLibrary</tt> attribute. The
+<tt>ns</tt> attribute can have any value.  The value of the
+<tt>datatypeLibrary</tt> attribute must match the anyURI
+symbol as described in the previous paragraph; in addition, it must
+not use the relative form of URI reference and must not have a
+fragment identifier; as an exception to this, the value may be the
+empty string.</p><p>Any element can also have foreign attributes in addition to the
+attributes shown in the grammar. A foreign attribute is an attribute
+with a name whose namespace URI is neither the empty string nor the
+RELAX NG namespace URI.  Any element that cannot have string children
+(that is, any element other than <tt>value</tt>, <tt>param</tt>
+and <tt>name</tt>) may have foreign child elements in addition
+to the child elements shown in the grammar. A foreign element is an
+element with a name whose namespace URI is not the RELAX NG namespace
+URI.  There are no constraints on the relative position of foreign
+child elements with respect to other child elements.</p><p>Any element can also have as children strings that consist
+entirely of whitespace characters, where a whitespace character is one
+of #x20, #x9, #xD or #xA. There are no constraints on the relative
+position of whitespace string children with respect to child
+elements.</p><p>Leading and trailing whitespace is allowed for value of each
+<tt>name</tt>, <tt>type</tt> and
+<tt>combine</tt> attribute and for the content of each
+<tt>name</tt> element.</p><table><tr valign="baseline"><td>pattern</td><td>  ::=  </td><td><code>&lt;element</code> <code>name="</code><i>QName</i><code>"</code><code>&gt; </code><i>pattern</i>+<code> &lt;/element&gt;</code><br>| <code>&lt;element</code><code>&gt; </code><i>nameClass</i> <i>pattern</i>+<code> &lt;/element&gt;</code><br>| <code>&lt;attribute</code> <code>name="</code><i>QName</i><code>"</code><code>&gt; </code>[<i>pattern</i>]<code> &lt;/attribute&gt;</code><br>| <code>&lt;attribute</code><code>&gt; </code><i>nameClass</i> [<i>pattern</i>]<code> &lt;/attribute&gt;</code><br>| <code>&lt;group</code><code>&gt; </code><i>pattern</i>+<code> &lt;/group&gt;</code><br>| <code>&lt;interleave</code><code>&gt; </code><i>pattern</i>+<code> &lt;/interleave&gt;</code><br>| <code>&lt;choice</code><code>&gt; </code><i>pattern</i>+<code> &lt;/choice&gt;</code><br>| <code>&lt;optional</code><code>&gt; </code><i>pattern</i>+<code> &lt;/optional&gt;</code><br>| <code>&lt;zeroOrMore</code><code>&gt; </code><i>pattern</i>+<code> &lt;/zeroOrMore&gt;</code><br>| <code>&lt;oneOrMore</code><code>&gt; </code><i>pattern</i>+<code> &lt;/oneOrMore&gt;</code><br>| <code>&lt;list</code><code>&gt; </code><i>pattern</i>+<code> &lt;/list&gt;</code><br>| <code>&lt;mixed</code><code>&gt; </code><i>pattern</i>+<code> &lt;/mixed&gt;</code><br>| <code>&lt;ref</code> <code>name="</code><i>NCName</i><code>"</code><code>/&gt;</code><br>| <code>&lt;parentRef</code> <code>name="</code><i>NCName</i><code>"</code><code>/&gt;</code><br>| <code>&lt;empty</code><code>/&gt;</code><br>| <code>&lt;text</code><code>/&gt;</code><br>| <code>&lt;value</code> [<code>type="</code><i>NCName</i><code>"</code>]<code>&gt; </code><i>string</i><code> &lt;/value&gt;</code><br>| <code>&lt;data</code> <code>type="</code><i>NCName</i><code>"</code><code>&gt; </code><i>param</i>* [<i>exceptPattern</i>]<code> &lt;/data&gt;</code><br>| <code>&lt;notAllowed</code><code>/&gt;</code><br>| <code>&lt;externalRef</code> <code>href="</code><i>anyURI</i><code>"</code><code>/&gt;</code><br>| <code>&lt;grammar</code><code>&gt; </code><i>grammarContent</i>*<code> &lt;/grammar&gt;</code></td></tr><tr valign="baseline"><td>param</td><td>  ::=  </td><td><code>&lt;param</code> <code>name="</code><i>NCName</i><code>"</code><code>&gt; </code><i>string</i><code> &lt;/param&gt;</code></td></tr><tr valign="baseline"><td>exceptPattern</td><td>  ::=  </td><td><code>&lt;except</code><code>&gt; </code><i>pattern</i>+<code> &lt;/except&gt;</code></td></tr><tr valign="baseline"><td>grammarContent</td><td>  ::=  </td><td><i>start</i><br>| <i>define</i><br>| <code>&lt;div</code><code>&gt; </code><i>grammarContent</i>*<code> &lt;/div&gt;</code><br>| <code>&lt;include</code> <code>href="</code><i>anyURI</i><code>"</code><code>&gt; </code><i>includeContent</i>*<code> &lt;/include&gt;</code></td></tr><tr valign="baseline"><td>includeContent</td><td>  ::=  </td><td><i>start</i><br>| <i>define</i><br>| <code>&lt;div</code><code>&gt; </code><i>includeContent</i>*<code> &lt;/div&gt;</code></td></tr><tr valign="baseline"><td>start</td><td>  ::=  </td><td><code>&lt;start</code> [<code>combine="</code><i>method</i><code>"</code>]<code>&gt; </code><i>pattern</i><code> &lt;/start&gt;</code></td></tr><tr valign="baseline"><td>define</td><td>  ::=  </td><td><code>&lt;define</code> <code>name="</code><i>NCName</i><code>"</code> [<code>combine="</code><i>method</i><code>"</code>]<code>&gt; </code><i>pattern</i>+<code> &lt;/define&gt;</code></td></tr><tr valign="baseline"><td>method</td><td>  ::=  </td><td><code>choice</code><br>| <code>interleave</code></td></tr><tr valign="baseline"><td>nameClass</td><td>  ::=  </td><td><code>&lt;name</code><code>&gt; </code><i>QName</i><code> &lt;/name&gt;</code><br>| <code>&lt;anyName</code><code>&gt; </code>[<i>exceptNameClass</i>]<code> &lt;/anyName&gt;</code><br>| <code>&lt;nsName</code><code>&gt; </code>[<i>exceptNameClass</i>]<code> &lt;/nsName&gt;</code><br>| <code>&lt;choice</code><code>&gt; </code><i>nameClass</i>+<code> &lt;/choice&gt;</code></td></tr><tr valign="baseline"><td>exceptNameClass</td><td>  ::=  </td><td><code>&lt;except</code><code>&gt; </code><i>nameClass</i>+<code> &lt;/except&gt;</code></td></tr></table><div class="section"><a name="full-syntax-example"></a><div class="titlepage"><div><h3 class="title"><a name="full-syntax-example"></a>3.1. Example</h3></div></div><p>Here is an example of a schema in the full syntax for the
+document in <a href="#data-model-example" title="2.1. Example">Section 2.1</a>.</p><pre class="programlisting">&lt;?xml version="1.0"?&gt;
+&lt;element name="foo"
+         xmlns="http://relaxng.org/ns/structure/1.0"
+         xmlns:a="http://relaxng.org/ns/annotation/1.0"
+         xmlns:ex1="http://www.example.com/n1"
+         xmlns:ex2="http://www.example.com/n2"&gt;
+  &lt;a:documentation&gt;A foo element.&lt;/a:document&gt;
+  &lt;element name="ex1:bar1"&gt;
+    &lt;empty/&gt;
+  &lt;/element&gt;
+  &lt;element name="ex2:bar2"&gt;
+    &lt;empty/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre></div></div><div class="section"><a name="simplification"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="simplification"></a>4. Simplification</h2></div></div><p>The full syntax given in the previous section is transformed
+into a simpler syntax by applying the following transformation rules
+in order. The effect must be as if each rule was applied to all
+elements in the schema before the next rule is applied.  A
+transformation rule may also specify constraints that must be
+satisfied by a correct schema. The transformation rules are applied
+at the data model level.  Before the transformations are applied, the
+schema is parsed into an instance of the data model.</p><div class="section"><a name="IDARXYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDARXYR"></a>4.1. Annotations</h3></div></div><p>Foreign attributes and elements are removed.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAWXYR"></a>Note</h3><p>It is safe to remove <tt>xml:base</tt>
+attributes at this stage because <tt>xml:base</tt>
+attributes are used in determining the [base URI] of an element
+information item, which is in turn used to construct the base URI of
+the context of an element.  Thus, after a document has been parsed
+into an instance of the data model, <tt>xml:base</tt>
+attributes can be discarded.</p></div></div><div class="section"><a name="IDADYYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDADYYR"></a>4.2. Whitespace</h3></div></div><p>For each element other than <tt>value</tt> and
+<tt>param</tt>, each child that is a string containing only
+whitespace characters is removed.</p><p>Leading and trailing whitespace characters are removed from the
+value of each <tt>name</tt>, <tt>type</tt> and
+<tt>combine</tt> attribute and from the content of each
+<tt>name</tt> element.</p></div><div class="section"><a name="IDAXYYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAXYYR"></a>4.3. <tt>datatypeLibrary</tt> attribute</h3></div></div><p>The value of each <tt>datatypeLibary</tt> attribute is
+transformed by escaping disallowed characters as specified in Section
+5.4 of <a href="#xlink" title="[XLink]">[XLink]</a>.</p><p>For any <tt>data</tt> or <tt>value</tt>
+element that does not have a <tt>datatypeLibrary</tt>
+attribute, a <tt>datatypeLibrary</tt> attribute is
+added. The value of the added <tt>datatypeLibrary</tt>
+attribute is the value of the <tt>datatypeLibrary</tt>
+attribute of the nearest ancestor element that has a
+<tt>datatypeLibrary</tt> attribute, or the empty string if
+there is no such ancestor. Then, any <tt>datatypeLibrary</tt>
+attribute that is on an element other than <tt>data</tt> or
+<tt>value</tt> is removed.</p></div><div class="section"><a name="IDA0ZYR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA0ZYR"></a>4.4. <tt>type</tt> attribute of <tt>value</tt> element</h3></div></div><p>For any <tt>value</tt> element that does not have a
+<tt>type</tt> attribute, a <tt>type</tt> attribute
+is added with value <tt>token</tt> and the value of the
+<tt>datatypeLibrary</tt> attribute is changed to the empty
+string.</p></div><div class="section"><a name="href"></a><div class="titlepage"><div><h3 class="title"><a name="href"></a>4.5. <tt>href</tt> attribute</h3></div></div><p>The value of the <tt>href</tt> attribute on an
+<tt>externalRef</tt> or <tt>include</tt> element
+is first transformed by escaping disallowed characters as specified in
+Section 5.4 of <a href="#xlink" title="[XLink]">[XLink]</a>.  The URI reference is then
+resolved into an absolute form as described in section 5.2 of <a href="#rfc2396" title="[RFC 2396]">[RFC 2396]</a> using the base URI from the context of the element
+that bears the <tt>href</tt> attribute.</p><p>The value of the <tt>href</tt> attribute will be used
+to construct an element (as specified in <a href="#data-model" title="2. Data model">Section 2</a>). This must be done as follows.  The URI
+reference consists of the URI itself and an optional fragment
+identifier. The resource identified by the URI is retrieved.  The
+result is a MIME entity: a sequence of bytes labeled with a MIME
+media type.  The media type determines how an element is constructed
+from the MIME entity and optional fragment identifier.  When the media
+type is <tt>application/xml</tt> or
+<tt>text/xml</tt>, the MIME entity must be parsed as an XML
+document in accordance with the applicable RFC (at the term of writing
+<a href="#rfc3023" title="[RFC 3023]">[RFC 3023]</a>) and an element constructed from the result
+of the parse as specified in <a href="#data-model" title="2. Data model">Section 2</a>.  In
+particular, the <tt>charset</tt> parameter must be handled
+as specified by the RFC. This specification does not define the
+handling of media types other than <tt>application/xml</tt>
+and <tt>text/xml</tt>. The <tt>href</tt> attribute
+must not include a fragment identifier unless the registration of the
+media type of the resource identified by the attribute defines the
+interpretation of fragment identifiers for that media type.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDA41YR"></a>Note</h3><p><a href="#rfc3023" title="[RFC 3023]">[RFC 3023]</a> does not define the
+interpretation of fragment identifiers for
+<tt>application/xml</tt> or
+<tt>text/xml</tt>.</p></div></div><div class="section"><a name="IDAJ2YR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAJ2YR"></a>4.6. <tt>externalRef</tt> element</h3></div></div><p>An <tt>externalRef</tt> element is transformed as
+follows.  An element is constructed using the URI reference that is
+the value of <tt>href</tt> attribute as specified in <a href="#href" title="4.5. href attribute">Section 4.5</a>. This element must match the syntax for pattern.  The
+element is transformed by recursively applying the rules from this
+subsection and from previous subsections of this section. This must
+not result in a loop. In other words, the transformation of the
+referenced element must not require the dereferencing of an
+<tt>externalRef</tt> attribute with an
+<tt>href</tt> attribute with the same value.</p><p>Any <tt>ns</tt> attribute on the
+<tt>externalRef</tt> element is transferred to the
+referenced element if the referenced element does not already have an
+<tt>ns</tt> attribute.  The <tt>externalRef</tt>
+element is then replaced by the referenced element.</p></div><div class="section"><a name="IDAG3YR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAG3YR"></a>4.7. <tt>include</tt> element</h3></div></div><p>An <tt>include</tt> element is transformed as follows.
+An element is constructed using the URI reference that is the value of
+<tt>href</tt> attribute as specified in <a href="#href" title="4.5. href attribute">Section 4.5</a>.  This element must be a <tt>grammar</tt>
+element, matching the syntax for grammar.</p><p>This <tt>grammar</tt> element is transformed by
+recursively applying the rules from this subsection and from previous
+subsections of this section.  This must not result in a loop. In other
+words, the transformation of the <tt>grammar</tt> element
+must not require the dereferencing of an <tt>include</tt>
+attribute with an <tt>href</tt> attribute with the same
+value.</p><p>Define the <i>components</i> of an element to
+be the children of the element together with the components of any
+<tt>div</tt> child elements.  If the
+<tt>include</tt> element has a <tt>start</tt>
+component, then the <tt>grammar</tt> element must have a
+<tt>start</tt> component.  If the <tt>include</tt>
+element has a <tt>start</tt> component, then all
+<tt>start</tt> components are removed from the
+<tt>grammar</tt> element.  If the <tt>include</tt>
+element has a <tt>define</tt> component, then the
+<tt>grammar</tt> element must have a
+<tt>define</tt> component with the same name.  For every
+<tt>define</tt> component of the <tt>include</tt>
+element, all <tt>define</tt> components with the same name
+are removed from the <tt>grammar</tt> element.</p><p>The <tt>include</tt> element is transformed into a
+<tt>div</tt> element.  The attributes of the
+<tt>div</tt> element are the attributes of the
+<tt>include</tt> element other than the
+<tt>href</tt> attribute.  The children of the
+<tt>div</tt> element are the <tt>grammar</tt>
+element (after the removal of the <tt>start</tt> and
+<tt>define</tt> components described by the preceding
+paragraph) followed by the children of the <tt>include</tt>
+element.  The <tt>grammar</tt> element is then renamed to
+<tt>div</tt>.</p></div><div class="section"><a name="IDAEAZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAEAZR"></a>4.8. <tt>name</tt> attribute of <tt>element</tt>
+and <tt>attribute</tt> elements</h3></div></div><p>The <tt>name</tt> attribute on an
+<tt>element</tt> or <tt>attribute</tt> element is
+transformed into a <tt>name</tt> child element.</p><p>If an <tt>attribute</tt> element has a
+<tt>name</tt> attribute but no <tt>ns</tt>
+attribute, then an <tt>ns=""</tt> attribute is added to the
+<tt>name</tt> child element.</p></div><div class="section"><a name="IDAEBZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAEBZR"></a>4.9. <tt>ns</tt> attribute</h3></div></div><p>For any <tt>name</tt>, <tt>nsName</tt> or
+<tt>value</tt> element that does not have an
+<tt>ns</tt> attribute, an <tt>ns</tt> attribute is
+added. The value of the added <tt>ns</tt> attribute is the
+value of the <tt>ns</tt> attribute of the nearest ancestor
+element that has an <tt>ns</tt> attribute, or the empty
+string if there is no such ancestor. Then, any <tt>ns</tt>
+attribute that is on an element other than <tt>name</tt>,
+<tt>nsName</tt> or <tt>value</tt> is
+removed.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDADCZR"></a>Note</h3><p>The value of the <tt>ns</tt> attribute is
+<i>not</i> transformed either by escaping
+disallowed characters, or in any other way, because the value of the
+<tt>ns</tt> attribute is compared against namespace URIs in
+the instance, which are not subject to any
+transformation.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAOCZR"></a>Note</h3><p>Since <tt>include</tt> and
+<tt>externalRef</tt> elements are resolved after
+<tt>datatypeLibrary</tt> attributes are added but before
+<tt>ns</tt> attributes are added, <tt>ns</tt>
+attributes are inherited into external schemas but
+<tt>datatypeLibrary</tt> attributes are not.</p></div></div><div class="section"><a name="IDA4CZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA4CZR"></a>4.10. QNames</h3></div></div><p>For any <tt>name</tt> element containing a prefix, the
+prefix is removed and an <tt>ns</tt> attribute is added
+replacing any existing <tt>ns</tt> attribute. The value of
+the added <tt>ns</tt> attribute is the value to which the
+namespace map of the context of the <tt>name</tt> element
+maps the prefix.  The context must have a mapping for the
+prefix.</p></div><div class="section"><a name="IDAODZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAODZR"></a>4.11. <tt>div</tt> element</h3></div></div><p>Each <tt>div</tt> element is replaced by its
+children.</p></div><div class="section"><a name="number-child-elements"></a><div class="titlepage"><div><h3 class="title"><a name="number-child-elements"></a>4.12. Number of child elements</h3></div></div><p>A <tt>define</tt>, <tt>oneOrMore</tt>,
+<tt>zeroOrMore</tt>, <tt>optional</tt>, <tt>list</tt> or
+<tt>mixed</tt> element is transformed so that it has exactly
+one child element.  If it has more than one child element, then its
+child elements are wrapped in a <tt>group</tt>
+element. Similarly, an <tt>element</tt> element is transformed so
+that it has exactly two child elements, the first being a name class
+and the second being a pattern. If it has more than two child elements,
+then the child elements other than the first are wrapped in a
+<tt>group</tt> element.</p><p>A <tt>except</tt> element is transformed
+so that it has exactly one child element. If it has more
+than one child element, then its child elements are wrapped
+in a <tt>choice</tt> element.</p><p>If an <tt>attribute</tt> element has only one child
+element (a name class), then a <tt>text</tt> element is
+added.</p><p>A <tt>choice</tt>, <tt>group</tt> or
+<tt>interleave</tt> element is transformed so that it has
+exactly two child elements. If it has one child element, then it is
+replaced by its child element.  If it has more than two child
+elements, then the first two child elements are combined into a new
+element with the same name as the parent element and with the first
+two child elements as its children.  For example,</p><pre class="programlisting">&lt;choice&gt; <i><tt>p1</tt></i> <i><tt>p2</tt></i> <i><tt>p3</tt></i> &lt;/choice&gt;</pre><p>is transformed to</p><pre class="programlisting">&lt;choice&gt; &lt;choice&gt; <i><tt>p1</tt></i> <i><tt>p2</tt></i> &lt;/choice&gt; <i><tt>p3</tt></i> &lt;/choice&gt;</pre><p>This reduces the number of child elements by one. The
+transformation is applied repeatedly until there are exactly two child
+elements.</p></div><div class="section"><a name="IDA0FZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA0FZR"></a>4.13. <tt>mixed</tt> element</h3></div></div><p>A <tt>mixed</tt> element is transformed into an
+interleaving with a <tt>text</tt> element:</p><pre class="programlisting">&lt;mixed&gt; <i><tt>p</tt></i> &lt;/mixed&gt;</pre><p>is transformed into</p><pre class="programlisting">&lt;interleave&gt; <i><tt>p</tt></i> &lt;text/&gt; &lt;/interleave&gt;</pre></div><div class="section"><a name="IDAQGZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAQGZR"></a>4.14. <tt>optional</tt> element</h3></div></div><p>An <tt>optional</tt> element is transformed into
+a choice with <tt>empty</tt>:</p><pre class="programlisting">&lt;optional&gt; <i><tt>p</tt></i> &lt;/optional&gt;</pre><p>is transformed into</p><pre class="programlisting">&lt;choice&gt; <i><tt>p</tt></i> &lt;empty/&gt; &lt;/choice&gt;</pre></div><div class="section"><a name="IDAGHZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAGHZR"></a>4.15. <tt>zeroOrMore</tt> element</h3></div></div><p>A <tt>zeroOrMore</tt> element is transformed into a choice
+between <tt>oneOrMore</tt> and
+<tt>empty</tt>:</p><pre class="programlisting">&lt;zeroOrMore&gt; <i><tt>p</tt></i> &lt;/zeroOrMore&gt;</pre><p>is transformed into</p><pre class="programlisting">&lt;choice&gt; &lt;oneOrMore&gt; <i><tt>p</tt></i> &lt;/oneOrMore&gt; &lt;empty/&gt; &lt;/choice&gt;</pre></div><div class="section"><a name="constraints"></a><div class="titlepage"><div><h3 class="title"><a name="constraints"></a>4.16. Constraints</h3></div></div><p>In this rule, no transformation is performed, but various
+constraints are checked.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAIIZR"></a>Note</h3><p>The constraints in this section, unlike the constraints
+specified in <a href="#restriction" title="7. Restrictions">Section 7</a>, can be checked without
+resolving any <tt>ref</tt> elements, and are accordingly
+applied even to patterns that will disappear during later stages of
+simplification because they are not reachable (see <a href="#define-ref" title="4.19. define and ref elements">Section 4.19</a>) or because of <tt>notAllowed</tt>
+(see <a href="#notAllowed" title="4.20. notAllowed element">Section 4.20</a>).</p></div><p>An <tt>except</tt> element that is a child of an
+<tt>anyName</tt> element must not have any
+<tt>anyName</tt> descendant elements. An
+<tt>except</tt> element that is a child of an
+<tt>nsName</tt> element must not have any
+<tt>nsName</tt> or <tt>anyName</tt> descendant
+elements.</p><p>A <tt>name</tt> element that occurs as the first child
+of an <tt>attribute</tt> element or as the descendant of the
+first child of an <tt>attribute</tt> element and that has an
+<tt>ns</tt> attribute with value equal to the empty string
+must not have content equal to <tt>xmlns</tt>.</p><p>A <tt>name</tt> or <tt>nsName</tt> element
+that occurs as the first child of an <tt>attribute</tt>
+element or as the descendant of the first child of an
+<tt>attribute</tt> element must not have an
+<tt>ns</tt> attribute with value
+<tt>http://www.w3.org/2000/xmlns</tt>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDACKZR"></a>Note</h3><p>The <a href="#infoset" title="[XML Infoset]">[XML Infoset]</a> defines the namespace URI of
+namespace declaration attributes to be
+<tt>http://www.w3.org/2000/xmlns</tt>.</p></div><p>A <tt>data</tt> or <tt>value</tt> element
+must be correct in its use of datatypes. Specifically, the
+<tt>type</tt> attribute must identify a datatype within the
+datatype library identified by the value of the
+<tt>datatypeLibrary</tt> attribute.  For a
+<tt>data</tt> element, the parameter list must be one that
+is allowed by the datatype (see <a href="#data-pattern" title="6.2.8. data and value pattern">Section 6.2.8</a>).</p></div><div class="section"><a name="IDA0KZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA0KZR"></a>4.17. <tt>combine</tt> attribute</h3></div></div><p>For each <tt>grammar</tt> element, all
+<tt>define</tt> elements with the same name are combined
+together.  For any name, there must not be more than one
+<tt>define</tt> element with that name that does not have a
+<tt>combine</tt> attribute.  For any name, if there is a
+<tt>define</tt> element with that name that has a
+<tt>combine</tt> attribute with the value
+<tt>choice</tt>, then there must not also be a
+<tt>define</tt> element with that name that has a
+<tt>combine</tt> attribute with the value
+<tt>interleave</tt>. Thus, for any name, if there is more
+than one <tt>define</tt> element with that name, then there
+is a unique value for the <tt>combine</tt> attribute for
+that name.  After determining this unique value, the
+<tt>combine</tt> attributes are removed.  A pair of
+definitions</p><pre class="programlisting">&lt;define name="<i><tt>n</tt></i>"&gt;
+  <i><tt>p1</tt></i>
+&lt;/define&gt;
+&lt;define name="<i><tt>n</tt></i>"&gt;
+  <i><tt>p2</tt></i>
+&lt;/define&gt;</pre><p>is combined into</p><pre class="programlisting">&lt;define name="<i><tt>n</tt></i>"&gt;
+  &lt;<i><tt>c</tt></i>&gt;
+    <i><tt>p1</tt></i>
+    <i><tt>p2</tt></i>
+  &lt;/<i><tt>c</tt></i>&gt;
+&lt;/define&gt;</pre><p>where <i><tt>c</tt></i> is the value of the
+<tt>combine</tt> attribute. Pairs of definitions are
+combined until there is exactly one <tt>define</tt> element
+for each name.</p><p>Similarly, for each <tt>grammar</tt> element all
+<tt>start</tt> elements are combined together.  There must
+not be more than one <tt>start</tt> element that does not
+have a <tt>combine</tt> attribute.  If there is a
+<tt>start</tt> element that has a <tt>combine</tt>
+attribute with the value <tt>choice</tt>, there must not
+also be a <tt>start</tt> element that has a
+<tt>combine</tt> attribute with the value
+<tt>interleave</tt>.</p></div><div class="section"><a name="IDASNZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDASNZR"></a>4.18. <tt>grammar</tt> element</h3></div></div><p>In this rule, the schema is transformed so that its top-level
+element is <tt>grammar</tt> and so that it has no other
+<tt>grammar</tt> elements.</p><p>Define the <i>in-scope grammar</i> for an
+element to be the nearest ancestor <tt>grammar</tt> element.  A
+<tt>ref</tt> element <i>refers to</i> a
+<tt>define</tt> element if the value of their
+<tt>name</tt> attributes is the same and their in-scope
+grammars are the same.  A <tt>parentRef</tt> element
+<i>refers to</i> a <tt>define</tt> element
+if the value of their <tt>name</tt> attributes is the same
+and the in-scope grammar of the in-scope grammar of the
+<tt>parentRef</tt> element is the same as the in-scope
+grammar of the <tt>define</tt> element. Every
+<tt>ref</tt> or <tt>parentRef</tt> element must
+refer to a <tt>define</tt> element.  A
+<tt>grammar</tt> must have a <tt>start</tt> child
+element.</p><p>First, transform the top-level pattern
+<i><tt>p</tt></i> into
+<tt>&lt;grammar&gt;&lt;start&gt;<i><tt>p</tt></i>&lt;/start&gt;&lt;/grammar&gt;</tt>.
+Next, rename <tt>define</tt> elements so that no two
+<tt>define</tt> elements anywhere in the schema have the
+same name.  To rename a <tt>define</tt> element, change the
+value of its <tt>name</tt> attribute and change the value of
+the <tt>name</tt> attribute of all <tt>ref</tt>
+and <tt>parentRef</tt> elements that refer to that
+<tt>define</tt> element. Next, move all
+<tt>define</tt> elements to be children of the top-level
+<tt>grammar</tt> element, replace each nested
+<tt>grammar</tt> element by the child of its
+<tt>start</tt> element and rename each
+<tt>parentRef</tt> element to <tt>ref</tt>.</p></div><div class="section"><a name="define-ref"></a><div class="titlepage"><div><h3 class="title"><a name="define-ref"></a>4.19. <tt>define</tt> and <tt>ref</tt> elements</h3></div></div><p>In this rule, the grammar is transformed so that every
+<tt>element</tt> element is the child of a
+<tt>define</tt> element, and the child of every
+<tt>define</tt> element is an <tt>element</tt>
+element.</p><p>First, remove any <tt>define</tt> element that is not
+<i>reachable</i>.  A <tt>define</tt> element
+is reachable if there is reachable <tt>ref</tt> element
+referring to it.  A <tt>ref</tt> element is reachable if it
+is the descendant of the <tt>start</tt> element or of a
+reachable <tt>define</tt> element. Now, for
+each <tt>element</tt> element that is not the child of a
+<tt>define</tt> element, add a <tt>define</tt>
+element to the <tt>grammar</tt> element, and replace the
+<tt>element</tt> element by a <tt>ref</tt> element
+referring to the added <tt>define</tt> element. The value of
+the <tt>name</tt> attribute of the added
+<tt>define</tt> element must be different from value of the
+<tt>name</tt> attribute of all other
+<tt>define</tt> elements. The child of the added
+<tt>define</tt> element is the <tt>element</tt>
+element.</p><p>Define a <tt>ref</tt> element to be
+<i>expandable</i> if it refers to a
+<tt>define</tt> element whose child is not an
+<tt>element</tt> element.  For each <tt>ref</tt>
+element that is expandable and is a descendant of a
+<tt>start</tt> element or an <tt>element</tt>
+element, expand it by replacing the <tt>ref</tt> element by
+the child of the <tt>define</tt> element to which it refers and
+then recursively expanding any expandable <tt>ref</tt>
+elements in this replacement.  This must not result in a loop.
+In other words expanding the replacement of a
+<tt>ref</tt> element having a <tt>name</tt> with
+value <i><tt>n</tt></i> must not require the expansion of
+<tt>ref</tt> element also having a <tt>name</tt>
+with value <i><tt>n</tt></i>.  Finally, remove any
+<tt>define</tt> element whose child is not an
+<tt>element</tt> element.</p></div><div class="section"><a name="notAllowed"></a><div class="titlepage"><div><h3 class="title"><a name="notAllowed"></a>4.20. <tt>notAllowed</tt> element</h3></div></div><p>In this rule, the grammar is transformed so that a
+<tt>notAllowed</tt> element occurs only as the child of
+a <tt>start</tt> or <tt>element</tt> element.  An
+<tt>attribute</tt>, <tt>list</tt>,
+<tt>group</tt>, <tt>interleave</tt>,
+or <tt>oneOrMore</tt> element that has a
+<tt>notAllowed</tt> child element is transformed into a
+<tt>notAllowed</tt> element.  A <tt>choice</tt>
+element that has two <tt>notAllowed</tt> child elements is
+transformed into a <tt>notAllowed</tt> element.  A
+<tt>choice</tt> element that has one
+<tt>notAllowed</tt> child element is transformed into its
+other child element. An <tt>except</tt> element that has a
+<tt>notAllowed</tt> child element is removed.
+The preceding transformations are applied
+repeatedly until none of them is applicable any more.
+Any <tt>define</tt> element that is no longer reachable
+is removed.</p></div><div class="section"><a name="IDA1UZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA1UZR"></a>4.21. <tt>empty</tt> element</h3></div></div><p>In this rule, the grammar is transformed so that an
+<tt>empty</tt> element does not occur as a child of a
+<tt>group</tt>, <tt>interleave</tt>, or
+<tt>oneOrMore</tt> element or as the second child of
+a <tt>choice</tt> element. A <tt>group</tt>,
+<tt>interleave</tt> or <tt>choice</tt> element
+that has two <tt>empty</tt> child elements is transformed
+into an <tt>empty</tt> element.  A <tt>group</tt>
+or <tt>interleave</tt> element that has one
+<tt>empty</tt> child element is transformed into its other
+child element.  A <tt>choice</tt> element whose
+second child element is an <tt>empty</tt> element is
+transformed by interchanging its two child elements.  A
+<tt>oneOrMore</tt> element that has an
+<tt>empty</tt> child element is transformed into an
+<tt>empty</tt> element. The preceding transformations are applied
+repeatedly until none of them is applicable any more.</p></div></div><div class="section"><a name="simple-syntax"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="simple-syntax"></a>5. Simple syntax</h2></div></div><p>After applying all the rules in <a href="#simplification" title="4. Simplification">Section 4</a>, the schema will match the following
+grammar:</p><table><tr valign="baseline"><td>grammar</td><td>  ::=  </td><td><code>&lt;grammar</code><code>&gt; </code><code>&lt;start</code><code>&gt; </code><i>top</i><code> &lt;/start&gt;</code> <i>define</i>*<code> &lt;/grammar&gt;</code></td></tr><tr valign="baseline"><td>define</td><td>  ::=  </td><td><code>&lt;define</code> <code>name="</code><i>NCName</i><code>"</code><code>&gt; </code><code>&lt;element</code><code>&gt; </code><i>nameClass</i> <i>top</i><code> &lt;/element&gt;</code><code> &lt;/define&gt;</code></td></tr><tr valign="baseline"><td>top</td><td>  ::=  </td><td><code>&lt;notAllowed</code><code>/&gt;</code><br>| <i>pattern</i></td></tr><tr valign="baseline"><td>pattern</td><td>  ::=  </td><td><code>&lt;empty</code><code>/&gt;</code><br>| <i>nonEmptyPattern</i></td></tr><tr valign="baseline"><td>nonEmptyPattern</td><td>  ::=  </td><td><code>&lt;text</code><code>/&gt;</code><br>| <code>&lt;data</code> <code>type="</code><i>NCName</i><code>"</code> <code>datatypeLibrary="</code><i>anyURI</i><code>"</code><code>&gt; </code><i>param</i>* [<i>exceptPattern</i>]<code> &lt;/data&gt;</code><br>| <code>&lt;value</code> <code>datatypeLibrary="</code><i>anyURI</i><code>"</code> <code>type="</code><i>NCName</i><code>"</code> <code>ns="</code><i>string</i><code>"</code><code>&gt; </code><i>string</i><code> &lt;/value&gt;</code><br>| <code>&lt;list</code><code>&gt; </code><i>pattern</i><code> &lt;/list&gt;</code><br>| <code>&lt;attribute</code><code>&gt; </code><i>nameClass</i> <i>pattern</i><code> &lt;/attribute&gt;</code><br>| <code>&lt;ref</code> <code>name="</code><i>NCName</i><code>"</code><code>/&gt;</code><br>| <code>&lt;oneOrMore</code><code>&gt; </code><i>nonEmptyPattern</i><code> &lt;/oneOrMore&gt;</code><br>| <code>&lt;choice</code><code>&gt; </code><i>pattern</i> <i>nonEmptyPattern</i><code> &lt;/choice&gt;</code><br>| <code>&lt;group</code><code>&gt; </code><i>nonEmptyPattern</i> <i>nonEmptyPattern</i><code> &lt;/group&gt;</code><br>| <code>&lt;interleave</code><code>&gt; </code><i>nonEmptyPattern</i> <i>nonEmptyPattern</i><code> &lt;/interleave&gt;</code></td></tr><tr valign="baseline"><td>param</td><td>  ::=  </td><td><code>&lt;param</code> <code>name="</code><i>NCName</i><code>"</code><code>&gt; </code><i>string</i><code> &lt;/param&gt;</code></td></tr><tr valign="baseline"><td>exceptPattern</td><td>  ::=  </td><td><code>&lt;except</code><code>&gt; </code><i>pattern</i><code> &lt;/except&gt;</code></td></tr><tr valign="baseline"><td>nameClass</td><td>  ::=  </td><td><code>&lt;anyName</code><code>&gt; </code>[<i>exceptNameClass</i>]<code> &lt;/anyName&gt;</code><br>| <code>&lt;nsName</code> <code>ns="</code><i>string</i><code>"</code><code>&gt; </code>[<i>exceptNameClass</i>]<code> &lt;/nsName&gt;</code><br>| <code>&lt;name</code> <code>ns="</code><i>string</i><code>"</code><code>&gt; </code><i>NCName</i><code> &lt;/name&gt;</code><br>| <code>&lt;choice</code><code>&gt; </code><i>nameClass</i> <i>nameClass</i><code> &lt;/choice&gt;</code></td></tr><tr valign="baseline"><td>exceptNameClass</td><td>  ::=  </td><td><code>&lt;except</code><code>&gt; </code><i>nameClass</i><code> &lt;/except&gt;</code></td></tr></table><p>With this grammar, no elements or attributes are allowed other
+than those explicitly shown.</p><div class="section"><a name="simple-syntax-example"></a><div class="titlepage"><div><h3 class="title"><a name="simple-syntax-example"></a>5.1. Example</h3></div></div><p>The following is an example of how the schema in <a href="#full-syntax-example" title="3.1. Example">Section 3.1</a> can be transformed into the simple
+syntax:</p><pre class="programlisting">&lt;?xml version="1.0"?&gt;
+&lt;grammar xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;start&gt;
+    &lt;ref name="foo.element"/&gt;
+  &lt;/start&gt;
+
+  &lt;define name="foo.element"&gt;
+    &lt;element&gt;
+      &lt;name ns=""&gt;foo&lt;/name&gt;
+      &lt;group&gt;
+        &lt;ref name="bar1.element"/&gt;
+        &lt;ref name="bar2.element"/&gt;
+      &lt;/group&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="bar1.element"&gt;
+    &lt;element&gt;
+      &lt;name ns="http://www.example.com/n1"&gt;bar1&lt;/name&gt;
+      &lt;empty/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="bar2.element"&gt;
+    &lt;element&gt;
+      &lt;name ns="http://www.example.com/n2"&gt;bar2&lt;/name&gt;
+      &lt;empty/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+&lt;/grammar&gt;</pre><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAEXZR"></a>Note</h3><p>Strictly speaking, the result of simplification is an
+instance of the data model rather than an XML document.  For
+convenience, we use an XML document to represent an instance of the
+data model.</p></div></div></div><div class="section"><a name="semantics"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="semantics"></a>6. Semantics</h2></div></div><p>In this section, we define the semantics of a correct RELAX NG
+schema that has been transformed into the simple syntax.  The
+semantics of a RELAX NG schema consist of a specification of what XML
+documents are valid with respect to that schema.  The semantics are
+described formally.  The formalism uses axioms and inference rules.
+Axioms are propositions that are provable unconditionally.  An
+inference rule consists of one or more antecedents and exactly one
+consequent.  An antecedent is either positive or negative.  If all the
+positive antecedents of an inference rule are provable and none of the
+negative antecedents are provable, then the consequent of the
+inference rule is provable. An XML document is valid with respect to a
+RELAX NG schema if and only if the proposition that it is valid is
+provable in the formalism specified in this section.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAQXZR"></a>Note</h3><p>This kind of formalism is similar to a proof system.
+However, a traditional proof system only has positive
+antecedents.</p></div><p>The notation for inference rules separates the antecedents from
+the consequent by a horizontal line: the antecedents are above the
+line; the consequent is below the line.  If an antecedent is of the
+form not(<i><tt>p</tt></i>), then it is a negative
+antecedent; otherwise, it is a positive antecedent.  Both axioms and
+inferences
+rules may use variables.  A variable has a name and optionally a
+subscript.  The name of a variable is italicized.  Each variable has a
+range that is determined by its name.  Axioms and inference rules are
+implicitly universally quantified over the variables they contain.  We
+explain this further below.</p><p>The possibility that an inference rule or axiom may contain more
+than one occurrence of a particular variable requires that an identity
+relation be defined on each kind of object over which a variable can
+range.  The identity relation for all kinds of object is value-based.
+Two objects of a particular kind are identical if the constituents of
+the objects are identical.  For example, two attributes are considered
+the same if they have the same name and the same value. Two characters
+are identical if their Unicode character codes are the same.</p><div class="section"><a name="name-classes"></a><div class="titlepage"><div><h3 class="title"><a name="name-classes"></a>6.1. Name classes</h3></div></div><p>The main semantic concept for name classes is that of a name
+belonging to a name class. A name class is an element that matches the
+production nameClass. A name is as defined in <a href="#data-model" title="2. Data model">Section 2</a>: it consists of a namespace URI and a local
+name.</p><p>We use the following notation:</p><div class="variablelist"><dl><dt><a name="IDAJYZR"></a><span class="term"><i>n</i></span></dt><dd><a name="IDANYZR"></a>is a variable
+that ranges over names</dd><dt><a name="IDAQYZR"></a><span class="term"><i>nc</i></span></dt><dd><a name="IDAUYZR"></a>ranges over name classes</dd><dt><a name="IDAXYZR"></a><span class="term"><i>n</i> in <i>nc</i></span></dt><dd><a name="IDACZZR"></a>
+    
+asserts that name <i>n</i> is a member of name class <i>nc</i>
+
+</dd></dl></div><p>We are now ready for our first axiom, which is called "anyName
+1":</p>
+  <table cellspacing="20"><tr valign="middle"><td>(anyName 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><i>n</i> in <code>&lt;anyName</code><code>/&gt;</code></td></tr></table></td></tr></table>
+<p>This says for any name <i>n</i>, <i>n</i> belongs to the name class <code>&lt;anyName</code><code>/&gt;</code>,
+in other words <code>&lt;anyName</code><code>/&gt;</code> matches any name. Note the
+effect of the implicit universal quantification over the variables in
+the axiom: this is what makes the axiom apply for any name <i>n</i>.</p><p>Our first inference rule is almost as simple:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(anyName 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>not(<i>n</i> in <i>nc</i>)</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>n</i> in <code>&lt;anyName</code><code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>nc</i> <code>&lt;/except&gt;</code> <code>&lt;/anyName&gt;</code></td></tr></table></td></tr></table>
+
+<p>This says that for any name <i>n</i>
+and for any name class 	<i>nc</i>,
+if <i>n</i> does not belong to <i>nc</i>,
+then <i>n</i> belongs to 
+      <code>&lt;anyName</code><code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>nc</i> <code>&lt;/except&gt;</code> <code>&lt;/anyName&gt;</code>. In other words,       <code>&lt;anyName</code><code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>nc</i> <code>&lt;/except&gt;</code> <code>&lt;/anyName&gt;</code> matches any name that does not match <i>nc</i>.</p><p>We now need the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAC3ZR"></a><span class="term"><i>ln</i></span></dt><dd><a name="IDAH3ZR"></a>ranges over local names; a local name is a string that
+matches the NCName production of <a href="#xml-names" title="[XML Namespaces]">[XML Namespaces]</a>, that is,
+a name with no colons</dd><dt><a name="IDAO3ZR"></a><span class="term"><i>u</i></span></dt><dd><a name="IDAS3ZR"></a>ranges over URIs</dd><dt><a name="IDAV3ZR"></a><span class="term">
+  name( <i>u</i>, <i>ln</i> )
+</span></dt><dd><a name="IDAC4ZR"></a>constructs a name with URI <i>u</i> and local
+name <i>ln</i></dd></dl></div><p>The remaining axioms and inference rules for name classes are as
+follows:</p>
+
+  <table cellspacing="20"><tr valign="middle"><td>(nsName 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">name( <i>u</i>, <i>ln</i> ) in <code>&lt;nsName</code><code> ns="</code><i>u</i><code>"</code><code>/&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(nsName 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>not(name( <i>u</i>, <i>ln</i> ) in <i>nc</i>)</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1">name( <i>u</i>, <i>ln</i> ) in <code>&lt;nsName</code><code> ns="</code><i>u</i><code>"</code><code>&gt;</code> <code>&lt;except</code><code>&gt;</code> <i>nc</i> <code>&lt;/except&gt;</code> <code>&lt;/nsName&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(name)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">name( <i>u</i>, <i>ln</i> ) in <code>&lt;name</code><code> ns="</code><i>u</i><code>"</code><code>&gt;</code> <i>ln</i> <code>&lt;/name&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(name choice 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>n</i> in <i>nc</i><sub>1</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>n</i> in <code>&lt;choice</code><code>&gt;</code> <i>nc</i><sub>1</sub> <i>nc</i><sub>2</sub> <code>&lt;/choice&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(name choice 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>n</i> in <i>nc</i><sub>2</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>n</i> in <code>&lt;choice</code><code>&gt;</code> <i>nc</i><sub>1</sub> <i>nc</i><sub>2</sub> <code>&lt;/choice&gt;</code></td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="IDAME0R"></a><div class="titlepage"><div><h3 class="title"><a name="IDAME0R"></a>6.2. Patterns</h3></div></div><p>The axioms and inference rules for patterns use the following
+notation:</p><div class="variablelist"><dl><dt><a name="IDASE0R"></a><span class="term"><i>cx</i></span></dt><dd><a name="IDAWE0R"></a>ranges
+over contexts (as defined in <a href="#data-model" title="2. Data model">Section 2</a>)</dd><dt><a name="IDA2E0R"></a><span class="term"><i>a</i></span></dt><dd><a name="IDAAF0R"></a>ranges over
+sets of attributes; a set with a single member
+is considered the same as that member</dd><dt><a name="IDADF0R"></a><span class="term"><i>m</i></span></dt><dd><a name="IDAHF0R"></a>ranges over sequences of
+elements and strings; a sequence with a single member is considered
+the same as that member; the sequences ranged over by <i>m</i> may contain consecutive strings and may contain strings
+that are empty; thus, there are sequences ranged over by <i>m</i> that cannot occur as the children of an
+element</dd><dt><a name="IDAQF0R"></a><span class="term"><i>p</i></span></dt><dd><a name="IDAUF0R"></a>ranges
+over patterns (elements matching the pattern
+production)</dd><dt><a name="IDAXF0R"></a><span class="term"><i>cx</i> |- <i>a</i>; <i>m</i> =~ <i>p</i></span></dt><dd><a name="IDAIG0R"></a>
+    
+asserts that with respect to context <i>cx</i>, the
+attributes <i>a</i> and the sequence of elements and
+strings <i>m</i> matches the pattern <i>p</i></dd></dl></div><div class="section"><a name="choice-pattern"></a><div class="titlepage"><div><h4 class="title"><a name="choice-pattern"></a>6.2.1. <tt>choice</tt> pattern</h4></div></div><p>The semantics of the <tt>choice</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(choice 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; <i>m</i> =~ <i>p</i><sub>1</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; <i>m</i> =~ <code>&lt;choice</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/choice&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(choice 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; <i>m</i> =~ <i>p</i><sub>2</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; <i>m</i> =~ <code>&lt;choice</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/choice&gt;</code></td></tr></table></td></tr></table>
+
+
+</div><div class="section"><a name="IDAEK0R"></a><div class="titlepage"><div><h4 class="title"><a name="IDAEK0R"></a>6.2.2. <tt>group</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAMK0R"></a><span class="term"><i>m</i><sub>1</sub>, <i>m</i><sub>2</sub></span></dt><dd><a name="IDAZK0R"></a>represents the concatenation of the sequences <i>m</i><sub>1</sub> and <i>m</i><sub>2</sub>
+
+</dd><dt><a name="IDAEL0R"></a><span class="term"><i>a</i><sub>1</sub> + <i>a</i><sub>2</sub></span></dt><dd><a name="IDARL0R"></a>represents the union of <i>a</i><sub>1</sub>
+and <i>a</i><sub>2</sub></dd></dl></div><p>The semantics of the <tt>group</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(group)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i><sub>1</sub>; <i>m</i><sub>1</sub> =~ <i>p</i><sub>1</sub></td><td>    <i>cx</i> |- <i>a</i><sub>2</sub>; <i>m</i><sub>2</sub> =~ <i>p</i><sub>2</sub></td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2"><i>cx</i> |- <i>a</i><sub>1</sub> + <i>a</i><sub>2</sub>; <i>m</i><sub>1</sub>, <i>m</i><sub>2</sub> =~ <code>&lt;group</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/group&gt;</code></td></tr></table></td></tr></table>
+
+<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAZO0R"></a>Note</h3><p>The restriction in <a href="#attribute-restrictions" title="7.3. Restrictions on attributes">Section 7.3</a>
+ensures that the set of attributes constructed in the consequent will
+not have multiple attributes with the same name.</p></div></div><div class="section"><a name="empty-pattern"></a><div class="titlepage"><div><h4 class="title"><a name="empty-pattern"></a>6.2.3. <tt>empty</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAKP0R"></a><span class="term">( )</span></dt><dd><a name="IDAOP0R"></a>represents an empty sequence</dd><dt><a name="IDARP0R"></a><span class="term">{ }</span></dt><dd><a name="IDAVP0R"></a>represents an empty set</dd></dl></div><p>The semantics of the <tt>empty</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(empty)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><i>cx</i> |- { }; ( ) =~ <code>&lt;empty</code><code>/&gt;</code></td></tr></table></td></tr></table>
+</div><div class="section"><a name="text-pattern"></a><div class="titlepage"><div><h4 class="title"><a name="text-pattern"></a>6.2.4. <tt>text</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAHR0R"></a><span class="term"><i>s</i></span></dt><dd><a name="IDALR0R"></a>ranges
+over strings</dd></dl></div><p>The semantics of the <tt>text</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(text 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><i>cx</i> |- { }; ( ) =~ <code>&lt;text</code><code>/&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(text 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- { }; <i>m</i> =~ <code>&lt;text</code><code>/&gt;</code></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- { }; <i>m</i>, <i>s</i> =~ <code>&lt;text</code><code>/&gt;</code></td></tr></table></td></tr></table>
+
+<p>The effect of the above rule is that a <tt>text</tt>
+element matches zero or more strings.</p></div><div class="section"><a name="IDALU0R"></a><div class="titlepage"><div><h4 class="title"><a name="IDALU0R"></a>6.2.5. <tt>oneOrMore</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDATU0R"></a><span class="term">disjoint(<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>)</span></dt><dd><a name="IDAAV0R"></a>
+asserts that there is no name that is
+the name of both an attribute in <i>a</i><sub>1</sub>
+and of an attribute in <i>a</i><sub>2</sub>
+</dd></dl></div><p>The semantics of the <tt>oneOrMore</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(oneOrMore 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; <i>m</i> =~ <i>p</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; <i>m</i> =~ <code>&lt;oneOrMore</code><code>&gt;</code> <i>p</i> <code>&lt;/oneOrMore&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(oneOrMore 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i><sub>1</sub>; <i>m</i><sub>1</sub> =~ <i>p</i></td><td>    <i>cx</i> |- <i>a</i><sub>2</sub>; <i>m</i><sub>2</sub> =~ <code>&lt;oneOrMore</code><code>&gt;</code> <i>p</i> <code>&lt;/oneOrMore&gt;</code></td><td>    disjoint(<i>a</i><sub>1</sub>, <i>a</i><sub>2</sub>)</td></tr><tr><td colspan="3"><hr noshade></td></tr><tr align="center"><td colspan="3"><i>cx</i> |- <i>a</i><sub>1</sub> + <i>a</i><sub>2</sub>; <i>m</i><sub>1</sub>, <i>m</i><sub>2</sub> =~ <code>&lt;oneOrMore</code><code>&gt;</code> <i>p</i> <code>&lt;/oneOrMore&gt;</code></td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="IDA2Z0R"></a><div class="titlepage"><div><h4 class="title"><a name="IDA2Z0R"></a>6.2.6. <tt>interleave</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAE00R"></a><span class="term"><i>m</i><sub>1</sub> interleaves <i>m</i><sub>2</sub>; <i>m</i><sub>3</sub></span></dt><dd><a name="IDAV00R"></a>
+    
+asserts that <i>m</i><sub>1</sub>
+is an interleaving of <i>m</i><sub>2</sub>
+and <i>m</i><sub>3</sub>
+</dd></dl></div><p>The semantics of interleaving are defined by the following rules.</p>
+  <table cellspacing="20"><tr valign="middle"><td>(interleaves 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">( ) interleaves ( ); ( )</td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(interleaves 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>m</i><sub>1</sub> interleaves <i>m</i><sub>2</sub>; <i>m</i><sub>3</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>m</i><sub>4</sub>, <i>m</i><sub>1</sub> interleaves <i>m</i><sub>4</sub>, <i>m</i><sub>2</sub>; <i>m</i><sub>3</sub></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(interleaves 3)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>m</i><sub>1</sub> interleaves <i>m</i><sub>2</sub>; <i>m</i><sub>3</sub></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>m</i><sub>4</sub>, <i>m</i><sub>1</sub> interleaves <i>m</i><sub>2</sub>; <i>m</i><sub>4</sub>, <i>m</i><sub>3</sub></td></tr></table></td></tr></table>
+
+<p>For example, the interleavings of
+<tt>&lt;a/&gt;&lt;a/&gt;</tt> and
+<tt>&lt;b/&gt;</tt> are
+<tt>&lt;a/&gt;&lt;a/&gt;&lt;b/&gt;</tt>,
+<tt>&lt;a/&gt;&lt;b/&gt;&lt;a/&gt;</tt>, and
+<tt>&lt;b/&gt;&lt;a/&gt;&lt;a/&gt;</tt>.</p><p>The semantics of the <tt>interleave</tt> pattern are
+as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(interleave)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i><sub>1</sub>; <i>m</i><sub>1</sub> =~ <i>p</i><sub>1</sub></td><td>    <i>cx</i> |- <i>a</i><sub>2</sub>; <i>m</i><sub>2</sub> =~ <i>p</i><sub>2</sub></td><td>    <i>m</i><sub>3</sub> interleaves <i>m</i><sub>1</sub>; <i>m</i><sub>2</sub></td></tr><tr><td colspan="3"><hr noshade></td></tr><tr align="center"><td colspan="3"><i>cx</i> |- <i>a</i><sub>1</sub> + <i>a</i><sub>2</sub>; <i>m</i><sub>3</sub> =~ <code>&lt;interleave</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/interleave&gt;</code></td></tr></table></td></tr></table>
+
+<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAZC1R"></a>Note</h3><p>The restriction in <a href="#attribute-restrictions" title="7.3. Restrictions on attributes">Section 7.3</a>
+ensures that the set of attributes constructed in the consequent will
+not have multiple attributes with the same name.</p></div></div><div class="section"><a name="element-pattern"></a><div class="titlepage"><div><h4 class="title"><a name="element-pattern"></a>6.2.7. <tt>element</tt> and <tt>attribute</tt> pattern</h4></div></div><p>The value of an attribute is always a single string, which may
+be empty.  Thus, the empty sequence is not a possible attribute value.
+On the hand, the children of an element can be an empty sequence and
+cannot consist of an empty string.  In order to ensure that validation
+handles attributes and elements consistently, we introduce a variant
+of matching called <i>weak matching</i>.  Weak
+matching is used when matching the pattern for the value of an
+attribute or for the attributes and children of an element.  We use
+the following notation to define weak matching.</p><div class="variablelist"><dl><dt><a name="IDAOD1R"></a><span class="term"><code>""</code></span></dt><dd><a name="IDASD1R"></a>represents an empty
+string</dd><dt><a name="IDAVD1R"></a><span class="term"><i>ws</i></span></dt><dd><a name="IDAZD1R"></a>ranges over the empty
+sequence and strings that consist entirely of
+whitespace</dd><dt><a name="IDA2D1R"></a><span class="term"><i>cx</i> |- <i>a</i>; <i>m</i> =~<sub>weak</sub> <i>p</i></span></dt><dd><a name="IDANE1R"></a>
+    
+asserts that with respect to context <i>cx</i>, the
+attributes <i>a</i> and the sequence of elements and
+strings <i>m</i> weakly matches the pattern <i>p</i></dd></dl></div><p>The semantics of weak matching are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(weak match 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; <i>m</i> =~ <i>p</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; <i>m</i> =~<sub>weak</sub> <i>p</i></td></tr></table></td></tr></table>
+  <table cellspacing="20"><tr valign="middle"><td>(weak match 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; ( ) =~ <i>p</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; <i>ws</i> =~<sub>weak</sub> <i>p</i></td></tr></table></td></tr></table>
+  <table cellspacing="20"><tr valign="middle"><td>(weak match 3)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- <i>a</i>; <code>""</code> =~ <i>p</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- <i>a</i>; ( ) =~<sub>weak</sub> <i>p</i></td></tr></table></td></tr></table>
+<p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDASI1R"></a><span class="term">attribute( <i>n</i>, <i>s</i> )</span></dt><dd><a name="IDA3I1R"></a>
+      
+constructs an attribute with name <i>n</i>
+and value <i>s</i>
+</dd><dt><a name="IDAGJ1R"></a><span class="term">element( <i>n</i>, <i>cx</i>, <i>a</i>, <i>m</i> )</span></dt><dd><a name="IDAXJ1R"></a>
+      
+constructs an element with name <i>n</i>,
+context <i>cx</i>,
+attributes <i>a</i>
+and mixed sequence <i>m</i> as children
+</dd><dt><a name="IDAGK1R"></a><span class="term">okAsChildren(<i>m</i>)</span></dt><dd><a name="IDAOK1R"></a>
+    
+asserts that the mixed sequence <i>m</i> can occur as
+the children of an element: it does not contain any member that is an
+empty string, nor does it contain two consecutive members that are
+both strings</dd><dt><a name="IDAUK1R"></a><span class="term">deref(<i>ln</i>) = <code>&lt;element&gt; </code><i>nc</i> <i>p</i><code> &lt;/element&gt;</code></span></dt><dd><a name="IDACL1R"></a>
+    
+asserts that the grammar contains
+<code>&lt;define</code><code> name="</code><i>ln</i><code>"</code><code>&gt;</code> <code>&lt;element</code><code>&gt;</code> <i>nc</i> <i>p</i> <code>&lt;/element&gt;</code> <code>&lt;/define&gt;</code>
+</dd></dl></div><p>The semantics of the <tt>attribute</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(attribute)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- { }; <i>s</i> =~<sub>weak</sub> <i>p</i></td><td>    <i>n</i> in <i>nc</i></td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2"><i>cx</i> |- attribute( <i>n</i>, <i>s</i> ); ( ) =~ <code>&lt;attribute</code><code>&gt;</code> <i>nc</i> <i>p</i> <code>&lt;/attribute&gt;</code></td></tr></table></td></tr></table>
+
+<p>The semantics of the <tt>element</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(element)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i><sub>1</sub> |- <i>a</i>; <i>m</i> =~<sub>weak</sub> <i>p</i></td><td>    <i>n</i> in <i>nc</i></td><td>    okAsChildren(<i>m</i>)</td><td>    deref(<i>ln</i>) = <code>&lt;element&gt; </code><i>nc</i> <i>p</i><code> &lt;/element&gt;</code></td></tr><tr><td colspan="4"><hr noshade></td></tr><tr align="center"><td colspan="4"><i>cx</i><sub>2</sub> |- { }; <i>ws</i><sub>1</sub>, element( <i>n</i>, <i>cx</i><sub>1</sub>, <i>a</i>, <i>m</i> ), <i>ws</i><sub>2</sub> =~ <code>&lt;ref</code><code> name="</code><i>ln</i><code>"</code><code>/&gt;</code></td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="data-pattern"></a><div class="titlepage"><div><h4 class="title"><a name="data-pattern"></a>6.2.8. <tt>data</tt> and <tt>value</tt> pattern</h4></div></div><p>RELAX NG relies on datatype libraries to perform datatyping.
+A datatype library is identified by a URI.  A datatype within a
+datatype library is identified by an NCName.  A datatype library
+provides two services.</p><div class="itemizedlist"><ul><li><a name="IDAZR1R"></a>It can determine whether a string is a legal
+representation of a datatype. This service accepts a list of zero or
+more parameters. For example, a string datatype might have a parameter
+specifying the length of a string.  The datatype library determines
+what parameters are applicable for each datatype.</li><li><a name="IDA2R1R"></a>It can determine whether two strings represent the
+same value of a datatype.  This service does not have any
+parameters.</li></ul></div><p>Both services may make use of the context of a string.  For
+example, a datatype representing a QName would use the namespace
+map.</p><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAFS1R"></a><span class="term">datatypeAllows(<i>u</i>, <i>ln</i>, <i>params</i>, <i>s</i>, <i>cx</i>)</span></dt><dd><a name="IDAZS1R"></a>
+    
+asserts that in the datatype library identified by URI <i>u</i>, the string <i>s</i> interpreted with
+context <i>cx</i> is a legal
+value of datatype <i>ln</i> with parameters <i>params</i></dd><dt><a name="IDAKT1R"></a><span class="term">datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>2</sub>, <i>cx</i><sub>2</sub>)</span></dt><dd><a name="IDAFU1R"></a>
+    
+asserts that in the datatype library identified by URI <i>u</i>, string <i>s</i><sub>1</sub> interpreted with
+context <i>cx</i><sub>1</sub> represents the same value of
+the datatype <i>ln</i> as the string <i>s</i><sub>2</sub> interpreted in the context of <i>cx</i><sub>2</sub>
+</dd><dt><a name="IDA4U1R"></a><span class="term"><i>params</i></span></dt><dd><a name="IDACV1R"></a>ranges over sequences of parameters</dd><dt><a name="IDAFV1R"></a><span class="term">[<i>cx</i>]</span></dt><dd><a name="IDALV1R"></a>
+   
+within the start-tag of a pattern refers to the context
+of the pattern element
+</dd><dt><a name="IDAOV1R"></a><span class="term">
+  context( <i>u</i>, <i>cx</i> )
+</span></dt><dd><a name="IDA1V1R"></a>constructs a context which is the same as <i>cx</i>
+except that the default namespace is <i>u</i>; if <i>u</i> is the empty string, then there is no default namespace
+in the constructed context</dd></dl></div><p>The datatypeEqual function must be reflexive, transitive
+and symmetric, that is, the following inference rules must hold:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(datatypeEqual reflexive)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeAllows(<i>u</i>, <i>ln</i>, <i>params</i>, <i>s</i>, <i>cx</i>)</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1">datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i>, <i>cx</i>, <i>s</i>, <i>cx</i>)</td></tr></table></td></tr></table>
+  <table cellspacing="20"><tr valign="middle"><td>(datatypeEqual transitive)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>2</sub>, <i>cx</i><sub>2</sub>)</td><td>    datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>2</sub>, <i>cx</i><sub>3</sub>, <i>s</i><sub>3</sub>, <i>cx</i><sub>3</sub>)</td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2">datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>3</sub>, <i>cx</i><sub>3</sub>)</td></tr></table></td></tr></table>
+  <table cellspacing="20"><tr valign="middle"><td>(datatypeEqual symmetric)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>2</sub>, <i>cx</i><sub>2</sub>)</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1">datatypeEqual(<i>u</i>, <i>ln</i>, <i>s</i><sub>2</sub>, <i>cx</i><sub>2</sub>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>)</td></tr></table></td></tr></table>
+<p>The semantics of the <tt>data</tt> and
+<tt>value</tt> patterns are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(value)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeEqual(<i>u</i><sub>1</sub>, <i>ln</i>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>2</sub>, context( <i>u</i><sub>2</sub>, <i>cx</i><sub>2</sub> ))</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i><sub>1</sub> |- { }; <i>s</i><sub>1</sub> =~ <code>&lt;value</code><code> datatypeLibrary="</code><i>u</i><sub>1</sub><code>"</code><code> type="</code><i>ln</i><code>"</code><code> ns="</code><i>u</i><sub>2</sub><code>"</code><code> </code>[<i>cx</i><sub>2</sub>]<code>&gt;</code> <i>s</i><sub>2</sub> <code>&lt;/value&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(data 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeAllows(<i>u</i>, <i>ln</i>, <i>params</i>, <i>s</i>, <i>cx</i>)</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- { }; <i>s</i> =~ <code>&lt;data</code><code> datatypeLibrary="</code><i>u</i><code>"</code><code> type="</code><i>ln</i><code>"</code><code>&gt;</code> <i>params</i> <code>&lt;/data&gt;</code></td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(data 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>datatypeAllows(<i>u</i>, <i>ln</i>, <i>params</i>, <i>s</i>, <i>cx</i>)</td><td>    not(<i>cx</i> |- <i>a</i>; <i>s</i> =~ <i>p</i>)</td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2"><i>cx</i> |- { }; <i>s</i> =~ <code>&lt;data</code><code> datatypeLibrary="</code><i>u</i><code>"</code><code> type="</code><i>ln</i><code>"</code><code>&gt;</code> <i>params</i> <code>&lt;except</code><code>&gt;</code> <i>p</i> <code>&lt;/except&gt;</code> <code>&lt;/data&gt;</code></td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="built-in-datatype"></a><div class="titlepage"><div><h4 class="title"><a name="built-in-datatype"></a>6.2.9. Built-in datatype library</h4></div></div><p>The empty URI identifies a special built-in datatype library.
+This provides two datatypes, <tt>string</tt> and
+<tt>token</tt>.  No parameters are allowed for either of
+these datatypes.</p><div class="variablelist"><dl><dt><a name="IDAWEAS"></a><span class="term">
+    <i>s</i><sub>1</sub> = <i>s</i><sub>2</sub></span></dt><dd><a name="IDAEFAS"></a>asserts that <i>s</i><sub>1</sub>
+and <i>s</i><sub>2</sub> are identical</dd><dt><a name="IDAQFAS"></a><span class="term">
+      normalizeWhiteSpace( <i>s</i> )
+</span></dt><dd><a name="IDA0FAS"></a>returns the string <i>s</i>,
+with leading and trailing whitespace characters removed,
+and with each other maximal sequence of whitespace characters
+replaced by a single space character </dd></dl></div><p>The semantics of the two built-in datatypes are as
+follows:</p>
+
+  <table cellspacing="20"><tr valign="middle"><td>(string allows)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">datatypeAllows(<code>""</code>, <code>"string"</code>, ( ), <i>s</i>, <i>cx</i>)</td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(string equal)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">datatypeEqual(<code>""</code>, <code>"string"</code>, <i>s</i>, <i>cx</i><sub>1</sub>, <i>s</i>, <i>cx</i><sub>2</sub>)</td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(token allows)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">datatypeAllows(<code>""</code>, <code>"token"</code>, ( ), <i>s</i>, <i>cx</i>)</td></tr></table></td></tr></table>
+
+  <table cellspacing="20"><tr valign="middle"><td>(token equal)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>normalizeWhiteSpace( <i>s</i><sub>1</sub> ) = normalizeWhiteSpace( <i>s</i><sub>2</sub> )</td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1">datatypeEqual(<code>""</code>, <code>"token"</code>, <i>s</i><sub>1</sub>, <i>cx</i><sub>1</sub>, <i>s</i><sub>2</sub>, <i>cx</i><sub>2</sub>)</td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="IDACKAS"></a><div class="titlepage"><div><h4 class="title"><a name="IDACKAS"></a>6.2.10. <tt>list</tt> pattern</h4></div></div><p>We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAKKAS"></a><span class="term">split( <i>s</i> )</span></dt><dd><a name="IDASKAS"></a>
+      
+returns a sequence of strings one for each whitespace delimited token
+of <i>s</i>; each string in the returned sequence will
+be non-empty and will not contain any
+whitespace</dd></dl></div><p>The semantics of the <tt>list</tt> pattern are as follows:</p>
+  <table cellspacing="20"><tr valign="middle"><td>(list)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>cx</i> |- { }; split( <i>s</i> ) =~ <i>p</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><i>cx</i> |- { }; <i>s</i> =~ <code>&lt;list</code><code>&gt;</code> <i>p</i> <code>&lt;/list&gt;</code></td></tr></table></td></tr></table>
+<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDALMAS"></a>Note</h3><p>It is crucial in the above inference rule that the
+sequence that is matched against a pattern can contain consecutive
+strings.</p></div></div></div><div class="section"><a name="validity"></a><div class="titlepage"><div><h3 class="title"><a name="validity"></a>6.3. Validity</h3></div></div><p>Now we can define when an element is valid with respect to a
+schema.  We use the following additional notation:</p><div class="variablelist"><dl><dt><a name="IDAYMAS"></a><span class="term"><i>e</i></span></dt><dd><a name="IDA2MAS"></a>ranges over elements</dd><dt><a name="IDA5MAS"></a><span class="term">valid(<i>e</i>)</span></dt><dd><a name="IDAHNAS"></a>
+    
+asserts that the element <i>e</i> is valid with
+respect to the grammar</dd><dt><a name="IDANNAS"></a><span class="term">start() = <i>p</i></span></dt><dd><a name="IDAVNAS"></a>
+asserts that the grammar contains
+<code>&lt;start</code><code>&gt;</code> <i>p</i> <code>&lt;/start&gt;</code></dd></dl></div><p>An element is valid if together with an empty set of attributes
+it matches the <tt>start</tt> pattern of the grammar.</p>
+  <table cellspacing="20"><tr valign="middle"><td>(valid)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>start() = <i>p</i></td><td>    <i>cx</i> |- { }; <i>e</i> =~ <i>p</i></td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2">valid(<i>e</i>)</td></tr></table></td></tr></table>
+      
+
+</div><div class="section"><a name="IDAHPAS"></a><div class="titlepage"><div><h3 class="title"><a name="IDAHPAS"></a>6.4. Example</h3></div></div><p>Let <i>e</i><sub>0</sub> be</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+
+element( name( <code>""</code>, <code>"foo"</code> ), <i>cx</i><sub>0</sub>, { }, <i>m</i> )
+
+</div><p>where <i>m</i> is</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>e</i><sub>1</sub>, <i>e</i><sub>2</sub>
+</div><p>and <i>e</i><sub>1</sub> is</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  element( name( <code>"http://www.example.com/n1"</code>, <code>"bar1"</code> ), <i>cx</i><sub>1</sub>, { }, ( ) )
+</div><p>and <i>e</i><sub>2</sub> is</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  element( name( <code>"http://www.example.com/n2"</code>, <code>"bar2"</code> ), <i>cx</i><sub>2</sub>, { }, ( ) )
+</div><p>Assuming appropriate definitions of <i>cx</i><sub>0</sub>, <i>cx</i><sub>1</sub> and <i>cx</i><sub>2</sub>, this represents the document in <a href="#data-model-example" title="2.1. Example">Section 2.1</a>.</p><p>We now show how <i>e</i><sub>0</sub> can be shown to
+be valid with respect to the schema in <a href="#simple-syntax-example" title="5.1. Example">Section 5.1</a>.  The schema is equivalent to the
+following propositions:</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  start() = <code>&lt;ref</code><code> name="</code><code>foo</code><code>"</code><code>/&gt;</code>
+</div><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  deref(<code>"foo.element"</code>) = <code>&lt;element&gt; </code><code>&lt;name</code><code> ns="</code><code>"</code><code>&gt;</code> <code>"foo"</code> <code>&lt;/name&gt;</code> <code>&lt;group</code><code>&gt;</code> <code>&lt;ref</code><code> name="</code><code>bar1</code><code>"</code><code>/&gt;</code> <code>&lt;ref</code><code> name="</code><code>bar2</code><code>"</code><code>/&gt;</code> <code>&lt;/group&gt;</code><code> &lt;/element&gt;</code>
+</div><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  deref(<code>"bar1.element"</code>) = <code>&lt;element&gt; </code><code>&lt;name</code><code> ns="</code><code>http://www.example.com/n1</code><code>"</code><code>&gt;</code> <code>"bar1"</code> <code>&lt;/name&gt;</code> <code>&lt;empty</code><code>/&gt;</code><code> &lt;/element&gt;</code>
+</div><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  deref(<code>"bar2.element"</code>) = <code>&lt;element&gt; </code><code>&lt;name</code><code> ns="</code><code>http://www.example.com/n2</code><code>"</code><code>&gt;</code> <code>"bar2"</code> <code>&lt;/name&gt;</code> <code>&lt;empty</code><code>/&gt;</code><code> &lt;/element&gt;</code>
+</div><p>Let name class <i>nc</i><sub>1</sub> be</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <code>&lt;name</code><code> ns="</code><code>http://www.example.com/n1</code><code>"</code><code>&gt;</code> <code>"bar1"</code> <code>&lt;/name&gt;</code>
+</div><p>and let <i>nc</i><sub>2</sub> be</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <code>&lt;name</code><code> ns="</code><code>http://www.example.com/n2</code><code>"</code><code>&gt;</code> <code>"bar2"</code> <code>&lt;/name&gt;</code>
+</div><p>Then, by the inference rule (name) in <a href="#name-classes" title="6.1. Name classes">Section 6.1</a>, we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  name( <code>"http://www.example.com/n1"</code>, <code>"bar1"</code> ) in <i>nc</i><sub>1</sub>
+</div><p>and</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  name( <code>"http://www.example.com/n2"</code>, <code>"bar2"</code> ) in <i>nc</i><sub>2</sub>
+</div><p>By the inference rule (empty) in <a href="#empty-pattern" title="6.2.3. empty pattern">Section 6.2.3</a>,
+we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>1</sub> |- { }; ( ) =~ <code>&lt;empty</code><code>/&gt;</code>
+</div><p>and</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>2</sub> |- { }; ( ) =~ <code>&lt;empty</code><code>/&gt;</code>
+</div><p>Thus by the inference rule (element) in <a href="#element-pattern" title="6.2.7. element and attribute pattern">Section 6.2.7</a>, we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>0</sub> |- { }; <i>e</i><sub>1</sub> =~ <code>&lt;ref</code><code> name="</code><code>bar1</code><code>"</code><code>/&gt;</code>
+</div><p>Note that we have chosen <i>cx</i><sub>0</sub>, since any context is allowed.</p><p>Likewise, we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>0</sub> |- { }; <i>e</i><sub>2</sub> =~ <code>&lt;ref</code><code> name="</code><code>bar2</code><code>"</code><code>/&gt;</code>
+</div><p>By the inference rule (group) in <a href="#choice-pattern" title="6.2.1. choice pattern">Section 6.2.1</a>, we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>0</sub> |- { }; <i>e</i><sub>1</sub>, <i>e</i><sub>2</sub> =~ <code>&lt;group</code><code>&gt;</code> <code>&lt;ref</code><code> name="</code><code>bar1</code><code>"</code><code>/&gt;</code> <code>&lt;ref</code><code> name="</code><code>bar2</code><code>"</code><code>/&gt;</code> <code>&lt;/group&gt;</code>
+</div><p>By the inference rule (element) in <a href="#element-pattern" title="6.2.7. element and attribute pattern">Section 6.2.7</a>, we have</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  <i>cx</i><sub>3</sub> |- { }; element( name( <code>""</code>, <code>"foo"</code> ), <i>cx</i><sub>0</sub>, { }, <i>m</i> ) =~ <code>&lt;ref</code><code> name="</code><code>foo</code><code>"</code><code>/&gt;</code>
+</div><p>Here <i>cx</i><sub>3</sub> is an arbitrary
+context.</p><p>Thus we can apply the inference rule (valid) in <a href="#validity" title="6.3. Validity">Section 6.3</a> and obtain</p><div class="formula" style="margin-left: 0.5in; margin-right: 0.5in;">
+  valid(<i>e</i><sub>0</sub>)
+</div></div></div><div class="section"><a name="restriction"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="restriction"></a>7. Restrictions</h2></div></div><p>The following constraints are all checked after the grammar has
+been transformed to the simple form described in <a href="#simple-syntax" title="5. Simple syntax">Section 5</a>. The purpose of these restrictions is to
+catch user errors and to facilitate implementation.</p><div class="section"><a name="contextual-restriction"></a><div class="titlepage"><div><h3 class="title"><a name="contextual-restriction"></a>7.1. Contextual restrictions</h3></div></div><p>In this section we describe restrictions on where elements are
+allowed in the schema based on the names of the ancestor elements. We
+use the concept of a <i>prohibited path</i> to
+describe these restrictions. A path is a sequence of NCNames separated
+by <tt>/</tt> or <tt>//</tt>.</p><div class="itemizedlist"><ul><li><a name="IDA3JBS"></a>An element matches a path
+<i><tt>x</tt></i>, where <i><tt>x</tt></i> is an
+NCName, if and only if the local name of the element is
+<i><tt>x</tt></i></li><li><a name="IDAFKBS"></a>An element matches a path
+<i><tt>x</tt></i><tt>/</tt><i><tt>p</tt></i>,
+where <i><tt>x</tt></i> is an NCName and
+<i><tt>p</tt></i> is a path, if and only if the local name
+of the element is <i><tt>x</tt></i> and the element has a
+child that matches <i><tt>p</tt></i></li><li><a name="IDATKBS"></a>An element matches a path
+<i><tt>x</tt></i><tt>//</tt><i><tt>p</tt></i>,
+where <i><tt>x</tt></i> is an NCName and
+<i><tt>p</tt></i> is a path, if and only if the local name
+of the element is <i><tt>x</tt></i> and the element has a
+descendant that matches <i><tt>p</tt></i></li></ul></div><p>For example, the element</p><pre class="programlisting">&lt;foo&gt;
+  &lt;bar&gt;
+    &lt;baz/&gt;
+  &lt;/bar&gt;
+&lt;/foo&gt;</pre><p>matches the paths <tt>foo</tt>,
+<tt>foo/bar</tt>, <tt>foo//bar</tt>,
+<tt>foo//baz</tt>, <tt>foo/bar/baz</tt>,
+<tt>foo/bar//baz</tt> and <tt>foo//bar/baz</tt>,
+but not <tt>foo/baz</tt> or
+<tt>foobar</tt>.</p><p>A correct RELAX NG schema must be such that, after
+transformation to the simple form, it does not contain any element
+that matches a prohibited path.</p><div class="section"><a name="IDA3LBS"></a><div class="titlepage"><div><h4 class="title"><a name="IDA3LBS"></a>7.1.1. <tt>attribute</tt> pattern</h4></div></div><p>The following paths are prohibited:</p><div class="itemizedlist"><ul><li><a name="IDAFMBS"></a><tt>attribute//ref</tt></li><li><a name="IDAJMBS"></a><tt>attribute//attribute</tt></li></ul></div></div><div class="section"><a name="IDAPMBS"></a><div class="titlepage"><div><h4 class="title"><a name="IDAPMBS"></a>7.1.2. <tt>oneOrMore</tt> pattern</h4></div></div><p>The following paths are prohibited:</p><div class="itemizedlist"><ul><li><a name="IDAXMBS"></a><tt>oneOrMore//group//attribute</tt></li><li><a name="IDA1MBS"></a><tt>oneOrMore//interleave//attribute</tt></li></ul></div></div><div class="section"><a name="list-restrictions"></a><div class="titlepage"><div><h4 class="title"><a name="list-restrictions"></a>7.1.3. <tt>list</tt> pattern</h4></div></div><p>The following paths are prohibited:</p><div class="itemizedlist"><ul><li><a name="IDALNBS"></a><tt>list//list</tt></li><li><a name="IDAPNBS"></a><tt>list//ref</tt></li><li><a name="IDATNBS"></a><tt>list//attribute</tt></li><li><a name="IDAXNBS"></a><tt>list//text</tt></li><li><a name="IDA1NBS"></a><tt>list//interleave</tt></li></ul></div></div><div class="section"><a name="context-data-except"></a><div class="titlepage"><div><h4 class="title"><a name="context-data-except"></a>7.1.4. <tt>except</tt> in <tt>data</tt> pattern</h4></div></div><p>The following paths are prohibited:</p><div class="itemizedlist"><ul><li><a name="IDANOBS"></a><tt>data/except//attribute</tt></li><li><a name="IDAROBS"></a><tt>data/except//ref</tt></li><li><a name="IDAVOBS"></a><tt>data/except//text</tt></li><li><a name="IDAZOBS"></a><tt>data/except//list</tt></li><li><a name="IDA3OBS"></a><tt>data/except//group</tt></li><li><a name="IDABPBS"></a><tt>data/except//interleave</tt></li><li><a name="IDAFPBS"></a><tt>data/except//oneOrMore</tt></li><li><a name="IDAJPBS"></a><tt>data/except//empty</tt></li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDAOPBS"></a>Note</h3><p>This implies that an <tt>except</tt> element
+with a <tt>data</tt> parent can contain only
+<tt>data</tt>, <tt>value</tt> and
+<tt>choice</tt> elements.</p></div></div><div class="section"><a name="context-start"></a><div class="titlepage"><div><h4 class="title"><a name="context-start"></a>7.1.5. <tt>start</tt> element</h4></div></div><p>The following paths are prohibited:</p><div class="itemizedlist"><ul><li><a name="IDAJQBS"></a><tt>start//attribute</tt></li><li><a name="IDANQBS"></a><tt>start//data</tt></li><li><a name="IDARQBS"></a><tt>start//value</tt></li><li><a name="IDAVQBS"></a><tt>start//text</tt></li><li><a name="IDAZQBS"></a><tt>start//list</tt></li><li><a name="IDA3QBS"></a><tt>start//group</tt></li><li><a name="IDABRBS"></a><tt>start//interleave</tt></li><li><a name="IDAFRBS"></a><tt>start//oneOrMore</tt></li><li><a name="IDAJRBS"></a><tt>start//empty</tt></li></ul></div></div></div><div class="section"><a name="string-sequences"></a><div class="titlepage"><div><h3 class="title"><a name="string-sequences"></a>7.2. String sequences</h3></div></div><p>RELAX NG does not allow a pattern such as:</p><pre class="programlisting">&lt;element name="foo"&gt;
+  &lt;group&gt;
+    &lt;data type="int"/&gt;
+    &lt;element name="bar"&gt;
+      &lt;empty/&gt;
+    &lt;/element&gt;
+  &lt;/group&gt;
+&lt;/element&gt;</pre><p>Nor does it allow a pattern such as:</p><pre class="programlisting">&lt;element name="foo"&gt;
+  &lt;group&gt;
+    &lt;data type="int"/&gt;
+    &lt;text/&gt;
+  &lt;/group&gt;
+&lt;/element&gt;</pre><p>More generally, if the pattern for the content of an element or
+attribute contains</p><div class="itemizedlist"><ul><li><a name="IDACSBS"></a>a pattern that can match a child
+(that is, an <tt>element</tt>, <tt>data</tt>,
+<tt>value</tt>, <tt>list</tt> or
+<tt>text</tt> pattern), and</li><li><a name="IDAPSBS"></a>a pattern that matches a single string (that is, a
+<tt>data</tt>, <tt>value</tt> or
+<tt>list</tt> pattern),</li></ul></div><p>then the two patterns must be alternatives to each other.</p><p>This rule does not apply to patterns occurring within a
+<tt>list</tt> pattern.</p><p>To formalize this, we use the concept of a content-type.  A
+pattern that is allowable as the content of an element has one of
+three content-types: empty, complex and simple.  We use the following
+notation.</p><div class="variablelist"><dl><dt><a name="IDACTBS"></a><span class="term">empty(  )</span></dt><dd><a name="IDAHTBS"></a>returns the empty content-type</dd><dt><a name="IDALTBS"></a><span class="term">complex(  )</span></dt><dd><a name="IDAQTBS"></a>returns the complex content-type</dd><dt><a name="IDAUTBS"></a><span class="term">simple(  )</span></dt><dd><a name="IDAZTBS"></a>returns the simple content-type</dd><dt><a name="IDA3TBS"></a><span class="term"><i>ct</i></span></dt><dd><a name="IDACUBS"></a>ranges over content-types</dd><dt><a name="IDAGUBS"></a><span class="term">
+  groupable(<i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub>)
+</span></dt><dd><a name="IDAVUBS"></a>asserts that the content-types <i>ct</i><sub>1</sub> and <i>ct</i><sub>2</sub>
+are groupable</dd></dl></div><p>The empty content-type is groupable with anything.  In addition,
+the complex content-type is groupable with the complex content-type. The
+following rules formalize this.</p>
+<table cellspacing="20"><tr valign="middle"><td>(group empty 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">groupable(empty(  ), <i>ct</i>)</td></tr></table></td></tr></table>
+<table cellspacing="20"><tr valign="middle"><td>(group empty 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">groupable(<i>ct</i>, empty(  ))</td></tr></table></td></tr></table>
+<table cellspacing="20"><tr valign="middle"><td>(group complex)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0">groupable(complex(  ), complex(  ))</td></tr></table></td></tr></table>
+<p>Some patterns have a content-type. We use the following
+additional notation.</p><div class="variablelist"><dl><dt><a name="IDATWBS"></a><span class="term">
+  <i>p</i> <b>:</b><sub>c</sub> <i>ct</i>
+</span></dt><dd><a name="IDAAXBS"></a>asserts that pattern <i>p</i> has
+content-type <i>ct</i></dd><dt><a name="IDAJXBS"></a><span class="term">
+  max( <i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub> )
+</span></dt><dd><a name="IDAYXBS"></a>returns the maximum of <i>ct</i><sub>1</sub> and <i>ct</i><sub>2</sub> where the
+content-types in increasing order are empty(  ),
+complex(  ), simple(  )</dd></dl></div><p>The following rules define when a pattern has a content-type and,
+if so, what it is.</p>
+<table cellspacing="20"><tr valign="middle"><td>(value)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;value</code><code> datatypeLibrary="</code><i>u</i><sub>1</sub><code>"</code><code> type="</code><i>ln</i><code>"</code><code> ns="</code><i>u</i><sub>2</sub><code>"</code><code>&gt;</code> <i>s</i> <code>&lt;/value&gt;</code> <b>:</b><sub>c</sub> simple(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(data 1)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;data</code><code> datatypeLibrary="</code><i>u</i><code>"</code><code> type="</code><i>ln</i><code>"</code><code>&gt;</code> <i>params</i> <code>&lt;/data&gt;</code> <b>:</b><sub>c</sub> simple(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(data 2)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i> <b>:</b><sub>c</sub> <i>ct</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><code>&lt;data</code><code> datatypeLibrary="</code><i>u</i><code>"</code><code> type="</code><i>ln</i><code>"</code><code>&gt;</code> <i>params</i> <code>&lt;except</code><code>&gt;</code> <i>p</i> <code>&lt;/except&gt;</code> <code>&lt;/data&gt;</code> <b>:</b><sub>c</sub> simple(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(list)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;list</code><code>&gt;</code> <i>p</i> <code>&lt;/list&gt;</code> <b>:</b><sub>c</sub> simple(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(text)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;text</code><code>/&gt;</code> <b>:</b><sub>c</sub> complex(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(ref)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;ref</code><code> name="</code><i>ln</i><code>"</code><code>/&gt;</code> <b>:</b><sub>c</sub> complex(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(empty)</td><td><table cellpadding="0" cellspacing="0"><tr align="center"><td colspan="0"><code>&lt;empty</code><code>/&gt;</code> <b>:</b><sub>c</sub> empty(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(attribute)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i> <b>:</b><sub>c</sub> <i>ct</i></td></tr><tr><td colspan="1"><hr noshade></td></tr><tr align="center"><td colspan="1"><code>&lt;attribute</code><code>&gt;</code> <i>nc</i> <i>p</i> <code>&lt;/attribute&gt;</code> <b>:</b><sub>c</sub> empty(  )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(group)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i><sub>1</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>1</sub></td><td>    <i>p</i><sub>2</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>2</sub></td><td>    groupable(<i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub>)</td></tr><tr><td colspan="3"><hr noshade></td></tr><tr align="center"><td colspan="3"><code>&lt;group</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/group&gt;</code> <b>:</b><sub>c</sub> max( <i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub> )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(interleave)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i><sub>1</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>1</sub></td><td>    <i>p</i><sub>2</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>2</sub></td><td>    groupable(<i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub>)</td></tr><tr><td colspan="3"><hr noshade></td></tr><tr align="center"><td colspan="3"><code>&lt;interleave</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/interleave&gt;</code> <b>:</b><sub>c</sub> max( <i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub> )</td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(oneOrMore)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i> <b>:</b><sub>c</sub> <i>ct</i></td><td>    groupable(<i>ct</i>, <i>ct</i>)</td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2"><code>&lt;oneOrMore</code><code>&gt;</code> <i>p</i> <code>&lt;/oneOrMore&gt;</code> <b>:</b><sub>c</sub> <i>ct</i></td></tr></table></td></tr></table>
+
+<table cellspacing="20"><tr valign="middle"><td>(choice)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td><i>p</i><sub>1</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>1</sub></td><td>    <i>p</i><sub>2</sub> <b>:</b><sub>c</sub> <i>ct</i><sub>2</sub></td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2"><code>&lt;choice</code><code>&gt;</code> <i>p</i><sub>1</sub> <i>p</i><sub>2</sub> <code>&lt;/choice&gt;</code> <b>:</b><sub>c</sub> max( <i>ct</i><sub>1</sub>, <i>ct</i><sub>2</sub> )</td></tr></table></td></tr></table>
+
+<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDA0GCS"></a>Note</h3><p>The antecedent in the (data 2) rule above is in fact
+redundant because of the prohibited paths in <a href="#context-data-except" title="7.1.4. except in data pattern">Section 7.1.4</a>.</p></div><p>Now we can describe the restriction. We use the following
+notation.</p><div class="variablelist"><dl><dt><a name="IDADHCS"></a><span class="term">
+  incorrectSchema()
+</span></dt><dd><a name="IDAJHCS"></a>asserts that the schema is incorrect</dd></dl></div><p>All patterns occurring as the content of an element pattern must
+have a content-type.</p>
+
+<table cellspacing="20"><tr valign="middle"><td>(element)</td><td><table cellpadding="0" cellspacing="0"><tr align="center" valign="baseline"><td>deref(<i>ln</i>) = <code>&lt;element&gt; </code><i>nc</i> <i>p</i><code> &lt;/element&gt;</code></td><td>    not(<i>p</i> <b>:</b><sub>c</sub> <i>ct</i>)</td></tr><tr><td colspan="2"><hr noshade></td></tr><tr align="center"><td colspan="2">incorrectSchema()</td></tr></table></td></tr></table>
+
+</div><div class="section"><a name="attribute-restrictions"></a><div class="titlepage"><div><h3 class="title"><a name="attribute-restrictions"></a>7.3. Restrictions on attributes</h3></div></div><p>Duplicate attributes are not allowed.  More precisely, for a
+pattern <tt>&lt;group&gt; <i><tt>p1</tt></i>
+<i><tt>p2</tt></i> &lt;/group&gt;</tt> or
+<tt>&lt;interleave&gt; <i><tt>p1</tt></i>
+<i><tt>p2</tt></i> &lt;/interleave&gt;</tt>, there must
+not be a name that belongs to both the name class of an
+<tt>attribute</tt> pattern occurring in
+<i><tt>p1</tt></i> and the name class of an
+<tt>attribute</tt> pattern occurring in
+<i><tt>p2</tt></i>. A pattern <i><tt>p1</tt></i>
+is defined to <i>occur in</i> a pattern
+<i><tt>p2</tt></i> if</p><div class="itemizedlist"><ul><li><a name="IDAYJCS"></a><i><tt>p1</tt></i> is
+<i><tt>p2</tt></i>, or</li><li><a name="IDA5JCS"></a><i><tt>p2</tt></i> is a
+<tt>choice</tt>, <tt>interleave</tt>,
+<tt>group</tt> or <tt>oneOrMore</tt> element and
+<i><tt>p1</tt></i> occurs in one or more children of
+<i><tt>p2</tt></i>.</li></ul></div><p>Attributes using infinite name classes must be repeated.  More
+precisely, an <tt>attribute</tt> element that has an
+<tt>anyName</tt> or <tt>nsName</tt> descendant
+element must have a <tt>oneOrMore</tt> ancestor
+element.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a name="IDA1KCS"></a>Note</h3><p>This restriction is necessary for closure under
+negation.</p></div></div><div class="section"><a name="interleave-restrictions"></a><div class="titlepage"><div><h3 class="title"><a name="interleave-restrictions"></a>7.4. Restrictions on <tt>interleave</tt></h3></div></div><p>For a pattern <tt>&lt;interleave&gt;
+<i><tt>p1</tt></i> <i><tt>p2</tt></i>
+&lt;/interleave&gt;</tt>,</p><div class="itemizedlist"><ul><li><a name="IDAOLCS"></a>there must not be a name that belongs to both the name
+class of an <tt>element</tt> pattern referenced by a
+<tt>ref</tt> pattern occurring in
+<i><tt>p1</tt></i> and the name class of an
+<tt>element</tt> pattern referenced by a
+<tt>ref</tt> pattern occurring in
+<i><tt>p2</tt></i>, and</li><li><a name="IDA3LCS"></a>a <tt>text</tt> pattern must not occur in
+both <i><tt>p1</tt></i> and
+<i><tt>p2</tt></i>.</li></ul></div><p><a href="#attribute-restrictions" title="7.3. Restrictions on attributes">Section 7.3</a> defines when one
+pattern is considered to occur in another pattern.</p></div></div><div class="section"><a name="conformance"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="conformance"></a>8. Conformance</h2></div></div><p>A conforming RELAX NG validator must be able to determine for
+any XML document whether it is a correct RELAX NG schema.  A
+conforming RELAX NG validator must be able to determine for any XML
+document and for any correct RELAX NG schema whether the document is
+valid with respect to the schema.</p><p>However, the requirements in the preceding paragraph do not
+apply if the schema uses a datatype library that the validator does
+not support.  A conforming RELAX NG validator is only required to
+support the built-in datatype library described in <a href="#built-in-datatype" title="6.2.9. Built-in datatype library">Section 6.2.9</a>.  A validator that claims conformance to
+RELAX NG should document which datatype libraries it supports.  The
+requirements in the preceding paragraph also do not apply if the
+schema includes <tt>externalRef</tt> or
+<tt>include</tt> elements and the validator is unable to
+retrieve the resource identified by the URI or is unable to construct
+an element from the retrieved resource.  A validator that claims
+conformance to RELAX NG should document its capabilities for handling
+URI references.</p></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDA5MCS"></a>A. RELAX NG schema for RELAX NG</h2><pre>&lt;grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
+  ns="http://relaxng.org/ns/structure/1.0"
+  xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+
+  &lt;start&gt;
+    &lt;ref name="<a href="#:pattern">pattern</a>"/&gt;
+  &lt;/start&gt;
+
+  <a name=":pattern"></a>&lt;define name="pattern"&gt;
+    &lt;choice&gt;
+      &lt;element name="element"&gt;
+        &lt;choice&gt;
+          &lt;attribute name="name"&gt;
+            &lt;data type="QName"/&gt;
+          &lt;/attribute&gt;
+          &lt;ref name="<a href="#:open-name-class">open-name-class</a>"/&gt;
+        &lt;/choice&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="attribute"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;choice&gt;
+          &lt;attribute name="name"&gt;
+            &lt;data type="QName"/&gt;
+          &lt;/attribute&gt;
+          &lt;ref name="<a href="#:open-name-class">open-name-class</a>"/&gt;
+        &lt;/choice&gt;
+        &lt;interleave&gt;
+          &lt;ref name="<a href="#:other">other</a>"/&gt;
+          &lt;optional&gt;
+            &lt;ref name="<a href="#:pattern">pattern</a>"/&gt;
+          &lt;/optional&gt;
+        &lt;/interleave&gt;
+      &lt;/element&gt;
+      &lt;element name="group"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="interleave"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="choice"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="optional"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="zeroOrMore"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="oneOrMore"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="list"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="mixed"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="ref"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="parentRef"&gt;
+        &lt;attribute name="name"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="empty"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="text"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="value"&gt;
+        &lt;optional&gt;
+          &lt;attribute name="type"&gt;
+            &lt;data type="NCName"/&gt;
+          &lt;/attribute&gt;
+        &lt;/optional&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="data"&gt;
+        &lt;attribute name="type"&gt;
+          &lt;data type="NCName"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;interleave&gt;
+          &lt;ref name="<a href="#:other">other</a>"/&gt;
+          &lt;group&gt;
+            &lt;zeroOrMore&gt;
+              &lt;element name="param"&gt;
+                &lt;attribute name="name"&gt;
+                  &lt;data type="NCName"/&gt;
+                &lt;/attribute&gt;
+                &lt;text/&gt;
+              &lt;/element&gt;
+            &lt;/zeroOrMore&gt;
+            &lt;optional&gt;
+              &lt;element name="except"&gt;
+                &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+                &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+              &lt;/element&gt;
+            &lt;/optional&gt;
+          &lt;/group&gt;
+        &lt;/interleave&gt;
+      &lt;/element&gt;
+      &lt;element name="notAllowed"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="externalRef"&gt;
+        &lt;attribute name="href"&gt;
+          &lt;data type="anyURI"/&gt;
+        &lt;/attribute&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="grammar"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:grammar-content">grammar-content</a>"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  <a name=":grammar-content"></a>&lt;define name="grammar-content"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;zeroOrMore&gt;
+        &lt;choice&gt;
+          &lt;ref name="<a href="#:start-element">start-element</a>"/&gt;
+          &lt;ref name="<a href="#:define-element">define-element</a>"/&gt;
+          &lt;element name="div"&gt;
+            &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+            &lt;ref name="<a href="#:grammar-content">grammar-content</a>"/&gt;
+          &lt;/element&gt;
+          &lt;element name="include"&gt;
+            &lt;attribute name="href"&gt;
+              &lt;data type="anyURI"/&gt;
+            &lt;/attribute&gt;
+            &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+            &lt;ref name="<a href="#:include-content">include-content</a>"/&gt;
+          &lt;/element&gt;
+        &lt;/choice&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":include-content"></a>&lt;define name="include-content"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;zeroOrMore&gt;
+        &lt;choice&gt;
+          &lt;ref name="<a href="#:start-element">start-element</a>"/&gt;
+          &lt;ref name="<a href="#:define-element">define-element</a>"/&gt;
+          &lt;element name="div"&gt;
+            &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+            &lt;ref name="<a href="#:include-content">include-content</a>"/&gt;
+          &lt;/element&gt;
+        &lt;/choice&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":start-element"></a>&lt;define name="start-element"&gt;
+    &lt;element name="start"&gt;
+      &lt;ref name="<a href="#:combine-att">combine-att</a>"/&gt;
+      &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+      &lt;ref name="<a href="#:open-pattern">open-pattern</a>"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":define-element"></a>&lt;define name="define-element"&gt;
+    &lt;element name="define"&gt;
+      &lt;attribute name="name"&gt;
+        &lt;data type="NCName"/&gt;
+      &lt;/attribute&gt;
+      &lt;ref name="<a href="#:combine-att">combine-att</a>"/&gt;
+      &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+      &lt;ref name="<a href="#:open-patterns">open-patterns</a>"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  <a name=":combine-att"></a>&lt;define name="combine-att"&gt;
+    &lt;optional&gt;
+      &lt;attribute name="combine"&gt;
+        &lt;choice&gt;
+          &lt;value&gt;choice&lt;/value&gt;
+          &lt;value&gt;interleave&lt;/value&gt;
+        &lt;/choice&gt;
+      &lt;/attribute&gt;
+    &lt;/optional&gt;
+  &lt;/define&gt;
+
+  <a name=":open-patterns"></a>&lt;define name="open-patterns"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;oneOrMore&gt;
+        &lt;ref name="<a href="#:pattern">pattern</a>"/&gt;
+      &lt;/oneOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":open-pattern"></a>&lt;define name="open-pattern"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;ref name="<a href="#:pattern">pattern</a>"/&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":name-class"></a>&lt;define name="name-class"&gt;
+    &lt;choice&gt;
+      &lt;element name="name"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;data type="QName"/&gt;
+      &lt;/element&gt;
+      &lt;element name="anyName"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:except-name-class">except-name-class</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="nsName"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:except-name-class">except-name-class</a>"/&gt;
+      &lt;/element&gt;
+      &lt;element name="choice"&gt;
+        &lt;ref name="<a href="#:common-atts">common-atts</a>"/&gt;
+        &lt;ref name="<a href="#:open-name-classes">open-name-classes</a>"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  <a name=":except-name-class"></a>&lt;define name="except-name-class"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;optional&gt;
+        &lt;element name="except"&gt;
+          &lt;ref name="<a href="#:open-name-classes">open-name-classes</a>"/&gt;
+        &lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":open-name-classes"></a>&lt;define name="open-name-classes"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;oneOrMore&gt;
+        &lt;ref name="<a href="#:name-class">name-class</a>"/&gt;
+      &lt;/oneOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":open-name-class"></a>&lt;define name="open-name-class"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="<a href="#:other">other</a>"/&gt;
+      &lt;ref name="<a href="#:name-class">name-class</a>"/&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+  <a name=":common-atts"></a>&lt;define name="common-atts"&gt;
+    &lt;optional&gt;
+      &lt;attribute name="ns"/&gt;
+    &lt;/optional&gt;
+    &lt;optional&gt;
+      &lt;attribute name="datatypeLibrary"&gt;
+        &lt;data type="anyURI"/&gt;
+      &lt;/attribute&gt;
+    &lt;/optional&gt;
+    &lt;zeroOrMore&gt;
+      &lt;attribute&gt;
+        &lt;anyName&gt;
+          &lt;except&gt;
+            &lt;nsName/&gt;
+            &lt;nsName ns=""/&gt;
+          &lt;/except&gt;
+        &lt;/anyName&gt;
+      &lt;/attribute&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  <a name=":other"></a>&lt;define name="other"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;element&gt;
+        &lt;anyName&gt;
+          &lt;except&gt;
+            &lt;nsName/&gt;
+          &lt;/except&gt;
+        &lt;/anyName&gt;
+        &lt;zeroOrMore&gt;
+          &lt;choice&gt;
+            &lt;attribute&gt;
+              &lt;anyName/&gt;
+            &lt;/attribute&gt;
+            &lt;text/&gt;
+            &lt;ref name="<a href="#:any">any</a>"/&gt;
+          &lt;/choice&gt;
+        &lt;/zeroOrMore&gt;
+      &lt;/element&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  <a name=":any"></a>&lt;define name="any"&gt;
+    &lt;element&gt;
+      &lt;anyName/&gt;
+      &lt;zeroOrMore&gt;
+        &lt;choice&gt;
+          &lt;attribute&gt;
+            &lt;anyName/&gt;
+          &lt;/attribute&gt;
+          &lt;text/&gt;
+          &lt;ref name="<a href="#:any">any</a>"/&gt;
+        &lt;/choice&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAGNCS"></a>B. Changes since version 0.9</h2><p>The changes in this version relative to version 0.9
+are as follows:</p><div class="itemizedlist"><ul><li><a name="IDAMNCS"></a>in the namespace URI, <tt>0.9</tt> has been
+changed to <tt>1.0</tt></li><li><a name="IDASNCS"></a><tt>data/except//empty</tt> has been added
+as a prohibited path (see <a href="#context-data-except" title="7.1.4. except in data pattern">Section 7.1.4</a>)</li><li><a name="IDA0NCS"></a><tt>start//empty</tt> has been added
+as a prohibited path (see <a href="#context-start" title="7.1.5. start element">Section 7.1.5</a>)</li><li><a name="IDACOCS"></a><a href="#number-child-elements" title="4.12. Number of child elements">Section 4.12</a> now specifies how a
+<tt>list</tt> element with more than one child element is
+transformed</li><li><a name="IDAKOCS"></a><a href="#notAllowed" title="4.20. notAllowed element">Section 4.20</a> now specifies how a
+<tt>notAllowed</tt> element occurring in an
+<tt>except</tt> element is transformed</li><li><a name="IDAUOCS"></a>although a relative URI is not allowed as the value of
+the <tt>ns</tt> and <tt>datatypeLibrary</tt>
+attributes, an empty string is allowed (see <a href="#full-syntax" title="3. Full syntax">Section 3</a>)</li><li><a name="IDA4OCS"></a>the removal of unreachable definitions in <a href="#define-ref" title="4.19. define and ref elements">Section 4.19</a> is now correctly specified</li><li><a name="IDAEPCS"></a><a href="#notAllowed" title="4.20. notAllowed element">Section 4.20</a> now specifies that
+<tt>define</tt> elements that are no longer reachable are
+removed</li><li><a name="IDAMPCS"></a><a href="#constraints" title="4.16. Constraints">Section 4.16</a> has been added; the
+restrictions on the contents of <tt>except</tt> in name
+classes that are now specified in the newly added section were
+previously specified in a subsection of <a href="#contextual-restriction" title="7.1. Contextual restrictions">Section 7.1</a>, which has been
+removed</li><li><a name="IDAXPCS"></a>the treatment of element and attribute values that
+consist only of whitespace has been refined (see <a href="#element-pattern" title="6.2.7. element and attribute pattern">Section 6.2.7</a> and <a href="#data-pattern" title="6.2.8. data and value pattern">Section 6.2.8</a>)</li><li><a name="IDADQCS"></a>attributes with infinite name classes are now required
+to be repeated (see <a href="#attribute-restrictions" title="7.3. Restrictions on attributes">Section 7.3</a>)</li><li><a name="IDAJQCS"></a>restrictions have been imposed on
+<tt>interleave</tt> (see <a href="#interleave-restrictions" title="7.4. Restrictions on interleave">Section 7.4</a>); <tt>list//interleave</tt>
+has been added as a prohibited path (see <a href="#list-restrictions" title="7.1.3. list pattern">Section 7.1.3</a>)</li><li><a name="IDAWQCS"></a>some of the prohibited paths in <a href="#contextual-restriction" title="7.1. Contextual restrictions">Section 7.1</a> have been corrected to use
+<tt>ref</tt> rather than
+<tt>element</tt></li><li><a name="IDA5QCS"></a>an error in the inference rule (text 1) in <a href="#text-pattern" title="6.2.4. text pattern">Section 6.2.4</a> has been corrected</li><li><a name="IDAFRCS"></a>the value of the <tt>ns</tt> attribute is
+now unconstrained (see <a href="#full-syntax" title="3. Full syntax">Section 3</a>)</li></ul></div></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAPRCS"></a>C. RELAX NG TC (Non-Normative)</h2><p>This specification was prepared and approved for publication by
+the RELAX NG TC. The current members of the TC are:</p><div class="itemizedlist"><ul><li><a name="IDAVRCS"></a>Fabio Arciniegas</li><li><a name="IDAYRCS"></a>James Clark</li><li><a name="IDA1RCS"></a>Mike Fitzgerald</li><li><a name="IDA4RCS"></a>KAWAGUCHI Kohsuke</li><li><a name="IDABSCS"></a>Josh Lubell</li><li><a name="IDAESCS"></a>MURATA Makoto</li><li><a name="IDAHSCS"></a>Norman Walsh</li><li><a name="IDAKSCS"></a>David Webber</li></ul></div></div><div id="IDAPSCS" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="IDAPSCS"></a>References</h2></div></div><div class="bibliodiv"><h3 class="title"><a name="IDASSCS">Normative</a></h3><dl><dt>RFC 2396</dt><dd id="rfc2396" class="bibliomixed"><a name="rfc2396"></a>T. Berners-Lee, R. Fielding, L. Masinter.
+<span class="citetitle"><i><a href="http://www.ietf.org/rfc/rfc2396.txt" target="_top">RFC 2396:
+Uniform Resource Identifiers (URI): Generic
+Syntax</a></i></span>.
+IETF (Internet Engineering Task Force). 1998.</dd><dt>RFC 2732</dt><dd id="rfc2732" class="bibliomixed"><a name="rfc2732"></a>R. Hinden, B. Carpenter, L. Masinter.
+<span class="citetitle"><i><a href="http://www.ietf.org/rfc/rfc2732.txt" target="_top">RFC 2732: Format for Literal IPv6 Addresses in URL's</a></i></span>.
+IETF (Internet Engineering Task Force), 1999.</dd><dt>RFC 3023</dt><dd id="rfc3023" class="bibliomixed"><a name="rfc3023"></a> M. Murata,
+S. St.Laurent, D. Kohn.  <span class="citetitle"><i><a href="http://www.ietf.org/rfc/rfc3023.txt" target="_top">RFC 3023: XML Media
+Types</a></i></span>. IETF (Internet Engineering Task Force),
+2001.</dd><dt>XLink</dt><dd id="xlink" class="bibliomixed"><a name="xlink"></a>Steve DeRose, Eve Maler
+and David Orchard, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xlink/" target="_top">XML Linking
+Language (XLink) Version 1.0</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XML 1.0</dt><dd id="xml-rec" class="bibliomixed"><a name="xml-rec"></a>Tim Bray,
+Jean Paoli, and
+C. M. Sperberg-McQueen, Eve Maler, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml" target="_top">Extensible Markup
+Language (XML) 1.0 Second Edition</a></i></span>.
+W3C (World Wide Web Consortium), 2000.</dd><dt>XML Infoset</dt><dd id="infoset" class="bibliomixed"><a name="infoset"></a>John Cowan, Richard Tobin,
+editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xml-infoset/" target="_top">XML
+Information Set</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XML Namespaces</dt><dd id="xml-names" class="bibliomixed"><a name="xml-names"></a>Tim Bray,
+Dave Hollander,
+and Andrew Layman, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml-names/" target="_top">Namespaces in
+XML</a></i></span>.
+W3C (World Wide Web Consortium), 1999.</dd></dl></div><div class="bibliodiv"><h3 class="title"><a name="IDA2UCS">Non-Normative</a></h3><dl><dt>RELAX</dt><dd id="relax" class="bibliomixed"><a name="relax"></a>MURATA Makoto.
+<span class="citetitle"><i><a href="http://www.xml.gr.jp/relax/" target="_top">RELAX (Regular
+Language description for XML)</a></i></span>.  INSTAC
+(Information Technology Research and Standardization Center), 2001.</dd><dt>TREX</dt><dd id="trex" class="bibliomixed"><a name="trex"></a>James Clark.
+<span class="citetitle"><i><a href="http://www.thaiopensource.com/trex/" target="_top">TREX - Tree Regular Expressions for XML</a></i></span>.
+Thai Open Source Software Center, 2001.</dd><dt>Tutorial</dt><dd id="tutorial" class="bibliomixed"><a name="tutorial"></a>James Clark,
+Makoto MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/tutorial.html" target="_top">RELAX
+NG Tutorial</a></i></span>.  OASIS, 2001.</dd><dt>W3C XML Schema Datatypes</dt><dd id="xmlschema-2" class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd><dt>XML Schema Formal</dt><dd id="xsfd" class="bibliomixed"><a name="xsfd"></a>Allen Brown,
+Matthew Fuchs, Jonathan Robie, Philip Wadler, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-formal/" target="_top">XML Schema: Formal Description</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd></dl></div></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/spec-20011203.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+<head>
+<title>RELAX NG Tutorial Errata</title>
+<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" >
+<meta http-equiv="Content-Style-Type" content="text/css" >
+<link rel="stylesheet" href="tr.css" type="text/css">
+</head>
+<body>
+<div class="article">
+
+<div class="titlepage"><p class="logo"><a
+href="http://www.oasis-open.org/"><img src="http://www.oasis-open.org/committees/relax-ng/oasis.png" alt="OASIS"
+border="0"></a></p></div>
+
+<h1 class="title">RELAX NG Tutorial Errata</h1>
+
+<p>This document lists errata in the <a
+href="http://www.oasis-open.org/committees/relax-ng/tutorial-20011203.html"
+>RELAX NG Tutorial</a>.</p>
+
+<hr>
+
+<h2>Errata at <a href="http://lists.oasis-open.org/archives/relax-ng/200202/msg00049.html">2002-02-28</a></h2>
+
+
+<h3>E1 (technical)</h3>
+
+<p><a href="http://www.oasis-open.org/committees/relax-ng/tutorial-20011203.html#IDAIRZR">Section 14</a></p>
+
+<div class="instruction">
+<p>Replace</p>
+<pre>            &lt;interleave&gt;
+              &lt;text/&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;givenName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;familyName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+            &lt;/interleave&gt;
+</pre>
+<p>by</p>
+<pre>            &lt;mixed&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;givenName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;familyName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+            &lt;/mixed&gt;
+</pre>
+</p>
+</div>
+<p>Source:
+<a href="http://lists.oasis-open.org/archives/relax-ng/200202/msg00007.html">http://lists.oasis-open.org/archives/relax-ng/200202/msg00007.html</a>
+</p>
+
+</div>
+<hr>
+<p>Last updated $Date: 2003/03/27 03:05:55 $ by $Author: jjc $.</p>
+</body>
+</html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203-errata.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,1724 @@
+<html><head>
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>RELAX NG Tutorial</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.40"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="IDAHAYR"></a>RELAX NG Tutorial</h1></div><div><h2>Committee Specification 3 December 2001</h2></div><div><dl><dt>This version:</dt><dd>Committee Specification: 3 December 2001</dd></dl><dl><dt>Previous versions:</dt><dd>Committee Specification: 10 August 2001</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt>&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, MURATA Makoto <tt>&lt;<a href="mailto:EB2M-MRT at asahi-net.or.jp">EB2M-MRT at asahi-net.or.jp</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="IDAMCYR"></a>Abstract</h2><p>RELAX NG is a simple schema language for XML, based on <a href="#relax" title="[RELAX]">[RELAX]</a> and <a href="#trex" title="[TREX]">[TREX]</a>. A RELAX NG schema
+specifies a pattern for the structure and content of an XML
+document. A RELAX NG schema thus identifies a class of XML documents
+consisting of those documents that match the pattern.  A RELAX NG
+schema is itself an XML document.</p><p>This document is a tutorial for RELAX NG version 1.0.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This Committee Specification was approved for publication by the
+OASIS RELAX NG technical committee.  It is a stable document which
+represents the consensus of the committee.  Comments on this document
+may be sent to <a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p><p>A list of known errors in this document is available at <a href="http://www.oasis-open.org/committees/relax-ng/tutorial-20011203-errata.html" target="_top">http://www.oasis-open.org/committees/relax-ng/tutorial-20011203-errata.html</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1 <a href="#IDAHDYR">Getting started</a></dt><dt>2 <a href="#IDA5EYR">Choice</a></dt><dt>3 <a href="#IDA0FYR">Attributes</a></dt><dt>4 <a href="#IDAETYR">Named patterns</a></dt><dt>5 <a href="#IDA5UYR">Datatyping</a></dt><dt>6 <a href="#IDAVXYR">Enumerations</a></dt><dt>7 <a href="#IDAK0YR">Lists</a></dt><dt>8 <a href="#IDAN1YR">Interleaving</a></dt><dt>9 <a href="#IDAX4YR">Modularity</a></dt><dd><dl><dt>9.1 <a href="#IDA04YR">Referencing external patterns</a></dt><dt>9.2 <a href="#IDACAZR">Combining definitions</a></dt><dt>9.3 <a href="#IDAXBZR">Merging grammars</a></dt><dt>9.4 <a href="#IDAVEZR">Replacing definitions</a></dt></dl></dd><dt>10 <a href="#IDADGZR">Namespaces</a></dt><dd><dl><dt>10.1 <a href="#IDAIGZR">Using the <tt>ns</tt> attribute</a></dt><dt>10.2 <a href="#IDAYJZR">Qualified names</a></dt></dl></dd><dt>11 <a href="#IDAFLZR">Name classes</a></dt><dt>12 <a href="#IDA1OZR">Annotations</a></dt><dt>13 <a href="#IDA3PZR">Nested grammars</a></dt><dt>14 <a href="#IDAIRZR">Non-restrictions</a></dt><dt>15 <a href="#IDA3RZR">Further information</a></dt></dl><h3>Appendixes</h3><dl><dt>A <a href="#IDAGSZR">Comparison with XML DTDs</a></dt><dt>B <a href="#IDAZTZR">Comparison with RELAX Core</a></dt><dd><dl><dt>B.1 <a href="#IDA4TZR">Mapping RELAX NG to RELAX Core</a></dt><dd><dl><dt>B.1.1 <a href="#IDABUZR"><tt>elementRule</tt>-<tt>tag</tt> pairs</a></dt><dt>B.1.2 <a href="#IDAJVZR"><tt>hedgeRule</tt></a></dt><dt>B.1.3 <a href="#IDACWZR"><tt>attPool</tt></a></dt><dt>B.1.4 <a href="#IDAVWZR">Hedge models</a></dt><dt>B.1.5 <a href="#IDAKYZR">Attribute declarations</a></dt></dl></dd><dt>B.2 <a href="#IDALZZR">Examples</a></dt><dd><dl><dt>B.2.1 <a href="#IDAOZZR">Ancestor-and-sibling-sensitive content models</a></dt><dt>B.2.2 <a href="#IDAC0ZR">Attribute-sensitive content model</a></dt></dl></dd><dt>B.3 <a href="#IDA10ZR">Features of RELAX NG beyond RELAX Core</a></dt></dl></dd><dt>C <a href="#IDAS2ZR">Comparison with TREX</a></dt><dt>D <a href="#IDA3A0R">Changes from 12 June 2001 version</a></dt><dt><a href="#IDACC0R">References</a></dt></dl></div><hr><div class="section"><a name="IDAHDYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAHDYR"></a>1. Getting started</h2></div></div><p>Consider a simple XML representation of an email address book:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;name&gt;John Smith&lt;/name&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>The DTD would be as follows:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card (name, email)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+]&gt;</pre><p>A RELAX NG pattern for this could be written as follows:</p><pre class="programlisting">&lt;element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>If the <tt>addressBook</tt> is required to be non-empty, then
+we can use <tt>oneOrMore</tt> instead of
+<tt>zeroOrMore</tt>:</p><pre class="programlisting">&lt;element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;oneOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/oneOrMore&gt;
+&lt;/element&gt;</pre><p>Now let's change it to allow each <tt>card</tt> to have an
+optional <tt>note</tt> element:</p><pre class="programlisting">&lt;element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name="note"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>Note that the <tt>text</tt> pattern matches arbitrary text,
+including empty text. Note also that whitespace separating tags is
+ignored when matching against a pattern.</p><p>All the elements specifying the pattern must be namespace qualified
+by the namespace URI:</p><pre class="programlisting">http://relaxng.org/ns/structure/1.0</pre><p>The examples above use a default namespace declaration
+<tt>xmlns="http://relaxng.org/ns/structure/1.0"</tt> for this. A
+namespace prefix is equally acceptable:</p><pre class="programlisting">&lt;rng:element name="addressBook" xmlns:rng="http://relaxng.org/ns/structure/1.0"&gt;
+  &lt;rng:zeroOrMore&gt;
+    &lt;rng:element name="card"&gt;
+      &lt;rng:element name="name"&gt;
+        &lt;rng:text/&gt;
+      &lt;/rng:element&gt;
+      &lt;rng:element name="email"&gt;
+        &lt;rng:text/&gt;
+      &lt;/rng:element&gt;
+    &lt;/rng:element&gt;
+  &lt;/rng:zeroOrMore&gt;
+&lt;/rng:element&gt;</pre><p>For the remainder of this document, the default namespace
+declaration will be left out of examples.</p></div><div class="section"><a name="IDA5EYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA5EYR"></a>2. Choice</h2></div></div><p>Now suppose we want to allow the <tt>name</tt> to be broken
+down into a <tt>givenName</tt> and a <tt>familyName</tt>,
+allowing an <tt>addressBook</tt> like this:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;givenName&gt;John&lt;/givenName&gt;
+    &lt;familyName&gt;Smith&lt;/familyName&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>We can use the following pattern:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;choice&gt;
+        &lt;element name="name"&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+        &lt;group&gt;
+          &lt;element name="givenName"&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+          &lt;element name="familyName"&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/group&gt;
+      &lt;/choice&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name="note"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>This corresponds to the following DTD:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card ((name | (givenName, familyName)), email, note?)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+&lt;!ELEMENT givenName (#PCDATA)&gt;
+&lt;!ELEMENT familyName (#PCDATA)&gt;
+&lt;!ELEMENT note (#PCDATA)&gt;
+]&gt;</pre></div><div class="section"><a name="IDA0FYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA0FYR"></a>3. Attributes</h2></div></div><p>Suppose we want the <tt>card</tt> element to have attributes
+rather than child elements. The DTD might look like this:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED&gt;
+]&gt;</pre><p>Just change each <tt>element</tt> pattern to an
+<tt>attribute</tt> pattern:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;attribute name="name"&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name="email"&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>In XML, the order of attributes is traditionally not significant.
+RELAX NG follows this tradition.  The above pattern would match both</p><pre class="programlisting">&lt;card name="John Smith" email="js at example.com"/&gt;</pre><p>and</p><pre class="programlisting">&lt;card email="js at example.com" name="John Smith"/&gt;</pre><p>In contrast, the order of elements is significant. The pattern</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;element name="name"&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name="email"&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>would <i>not</i> match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>Note that an <tt>attribute</tt> element by itself indicates a
+required attribute, just as an <tt>element</tt> element by itself
+indicates a required element. To specify an optional attribute, use
+<tt>optional</tt> just as with <tt>element</tt>:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;attribute name="name"&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name="email"&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;optional&gt;
+        &lt;attribute name="note"&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt>group</tt> and <tt>choice</tt> patterns can be
+applied to <tt>attribute</tt> patterns in the same way they are
+applied to <tt>element</tt> patterns.  For example, if we wanted
+to allow either a <tt>name</tt> attribute or both a
+<tt>givenName</tt> and a <tt>familyName</tt> attribute, we can
+specify this in the same way that we would if we were using
+elements:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;choice&gt;
+        &lt;attribute name="name"&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+        &lt;group&gt;
+          &lt;attribute name="givenName"&gt;
+            &lt;text/&gt;
+          &lt;/attribute&gt;
+          &lt;attribute name="familyName"&gt;
+            &lt;text/&gt;
+          &lt;/attribute&gt;
+        &lt;/group&gt;
+      &lt;/choice&gt;
+      &lt;attribute name="email"&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt>group</tt> and <tt>choice</tt>
+patterns can combine <tt>element</tt> and
+<tt>attribute</tt> patterns without restriction. For
+example, the following pattern would allow a choice of elements and
+attributes independently for both the <tt>name</tt> and the
+<tt>email</tt> part of a <tt>card</tt>:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;choice&gt;
+	&lt;element name="name"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;attribute name="name"&gt;
+	  &lt;text/&gt;
+	&lt;/attribute&gt;
+      &lt;/choice&gt;
+      &lt;choice&gt;
+	&lt;element name="email"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;attribute name="email"&gt;
+	  &lt;text/&gt;
+	&lt;/attribute&gt;
+      &lt;/choice&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>As usual, the relative order of elements is significant, but the
+relative order of attributes is not. Thus the above would match any
+of:</p><pre class="programlisting">&lt;card name="John Smith" email="js at example.com"/&gt;
+&lt;card email="js at example.com" name="John Smith"/&gt;
+&lt;card email="js at example.com"&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;
+&lt;card name="John Smith"&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;
+&lt;card&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;</pre><p>However, it would not match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>because the pattern for <tt>card</tt> requires any
+<tt>email</tt> child element to follow any <tt>name</tt> child
+element.</p><p>There is one difference between <tt>attribute</tt> and
+<tt>element</tt> patterns: <tt>&lt;text/&gt;</tt>
+is the default for the content of an <tt>attribute</tt> pattern,
+whereas an <tt>element</tt> pattern is not allowed to be
+empty. For example,</p><pre class="programlisting">&lt;attribute name="email"/&gt;</pre><p>is short for</p><pre class="programlisting">&lt;attribute name="email"&gt;
+  &lt;text/&gt;
+&lt;/attribute&gt;</pre><p>It might seem natural that</p><pre class="programlisting">&lt;element name="x"/&gt;</pre><p>matched an <tt>x</tt> element with no attributes and no
+content.  However, this would make the meaning of empty content
+inconsistent between the <tt>element</tt> pattern and the
+<tt>attribute</tt> pattern, so RELAX NG does not allow the
+<tt>element</tt> pattern to be empty. A pattern that matches an
+element with no attributes and no children must use
+<tt>&lt;empty/&gt;</tt> explicitly:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+        &lt;element name="prefersHTML"&gt;
+          &lt;empty/&gt;
+        &lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>Even if the pattern in an <tt>element</tt> pattern
+matches attributes only, there is no need to use
+<tt>empty</tt>. For example,</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;attribute name="email"&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;attribute name="email"&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre></div><div class="section"><a name="IDAETYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAETYR"></a>4. Named patterns</h2></div></div><p>For a non-trivial RELAX NG pattern, it is often convenient to be able
+to give names to parts of the pattern.  Instead of</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>we can write</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="cardContent"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="cardContent"&gt;
+    &lt;element name="name"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name="email"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>A <tt>grammar</tt> element has a single <tt>start</tt>
+child element, and zero or more <tt>define</tt> child elements.
+The <tt>start</tt> and <tt>define</tt> elements contain
+patterns. These patterns can contain <tt>ref</tt> elements that
+refer to patterns defined by any of the <tt>define</tt> elements
+in that <tt>grammar</tt> element. A <tt>grammar</tt> pattern
+is matched by matching the pattern contained in the <tt>start</tt>
+element.</p><p>We can use the <tt>grammar</tt> element to write patterns in a
+style similar to DTDs:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;ref name="AddressBook"/&gt;
+  &lt;/start&gt;
+
+  &lt;define name="AddressBook"&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="Card"/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="Card"&gt;
+    &lt;element name="card"&gt;
+      &lt;ref name="Name"/&gt;
+      &lt;ref name="Email"/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="Name"&gt;
+    &lt;element name="name"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="Email"&gt;
+    &lt;element name="email"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Recursive references are allowed.  For example,</p><pre class="programlisting">&lt;define name="inline"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name="bold"&gt;
+        &lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="italic"&gt;
+        &lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="span"&gt;
+        &lt;optional&gt;
+          &lt;attribute name="style"/&gt;
+        &lt;/optional&gt;
+        &lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/define&gt;</pre><p>However, recursive references must be within an
+<tt>element</tt>.  Thus, the following is <i>not</i>
+allowed:</p><pre class="programlisting">&lt;define name="inline"&gt;
+  &lt;choice&gt;
+    &lt;text/&gt;
+    &lt;element name="bold"&gt;
+      &lt;ref name="inline"/&gt;
+    &lt;/element&gt;
+    &lt;element name="italic"&gt;
+      &lt;ref name="inline"/&gt;
+    &lt;/element&gt;
+    &lt;element name="span"&gt;
+      &lt;optional&gt;
+	&lt;attribute name="style"/&gt;
+      &lt;/optional&gt;
+      &lt;ref name="inline"/&gt;
+    &lt;/element&gt;
+  &lt;/choice&gt;
+  &lt;optional&gt;
+    &lt;ref name="inline"/&gt;
+  &lt;/optional&gt;
+&lt;/define&gt;</pre></div><div class="section"><a name="IDA5UYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA5UYR"></a>5. Datatyping</h2></div></div><p>RELAX NG allows patterns to reference externally-defined
+datatypes, such as those defined by <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>.  RELAX NG
+implementations may differ in what datatypes they support.  You must
+use datatypes that are supported by the implementation you plan to
+use.</p><p>The <tt>data</tt> pattern matches a string that
+represents a value of a named datatype. The
+<tt>datatypeLibrary</tt> attribute contains a URI
+identifying the library of datatypes being used. The datatype
+library defined by <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> would be identified by the
+URI <tt>http://www.w3.org/2001/XMLSchema-datatypes</tt>.
+The <tt>type</tt> attribute specifies the name of the
+datatype in the library identified by the
+<tt>datatypeLibrary</tt> attribute. For example, if a
+RELAX NG implementation supported the datatypes of
+<a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>, you could use:</p><pre class="programlisting">&lt;element name="number"&gt;
+  &lt;data type="integer" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/&gt;
+&lt;/element&gt;</pre><p>It is inconvenient to specify the
+<tt>datatypeLibrary</tt> attribute on every
+<tt>data</tt> element, so RELAX NG allows the
+<tt>datatypeLibrary</tt> attribute to be inherited.  The
+<tt>datatypeLibrary</tt> attribute can be specified on any
+RELAX NG element.  If a <tt>data</tt> element does not have
+a <tt>datatypeLibrary</tt> attribute, it will use the
+value from the closest ancestor that has a
+<tt>datatypeLibrary</tt> attribute.  Typically, the
+<tt>datatypeLibrary</tt> attribute is specified on the
+root element of the RELAX NG pattern. For example,</p><pre class="programlisting">&lt;element name="point" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"&gt;
+  &lt;element name="x"&gt;
+    &lt;data type="double"/&gt;
+  &lt;/element&gt;
+  &lt;element name="y"&gt;
+    &lt;data type="double"/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>If the children of an element or an attribute match a
+<tt>data</tt> pattern, then complete content of the element or
+attribute must match that <tt>data</tt> pattern.  It is not
+permitted to have a pattern which allows part of the content to match
+a <tt>data</tt> pattern, and another part to match another
+pattern. For example, the following pattern is <i>not</i>
+allowed:</p><pre class="programlisting">&lt;element name="bad"&gt;
+  &lt;data type="int"/&gt;
+  &lt;element name="note"&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>However, this would be fine:</p><pre class="programlisting">&lt;element name="ok"&gt;
+  &lt;data type="int"/&gt;
+  &lt;attribute name="note"&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>Note that this restriction does not apply to the
+<tt>text</tt> pattern.</p><p>Datatypes may have parameters. For example, a string datatype may
+have a parameter controlling the length of the string.  The parameters
+applicable to any particular datatype are determined by the datatyping
+vocabulary.  Parameters are specified by adding one or more
+<tt>param</tt> elements as children of the <tt>data</tt>
+element.  For example, the following constrains the <tt>email</tt>
+element to contain a string at most 127 characters long:</p><pre class="programlisting">&lt;element name="email"&gt;
+  &lt;data type="string"&gt;
+    &lt;param name="maxLength"&gt;127&lt;/param&gt;
+  &lt;/data&gt;
+&lt;/element&gt;</pre></div><div class="section"><a name="IDAVXYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAVXYR"></a>6. Enumerations</h2></div></div><p>Many markup vocabularies have attributes whose value is constrained
+to be one of set of specified values.  The <tt>value</tt> pattern
+matches a string that has a specified value.  For example,</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;attribute name="name"/&gt;
+  &lt;attribute name="email"/&gt;
+  &lt;attribute name="preferredFormat"&gt;
+    &lt;choice&gt;
+      &lt;value&gt;html&lt;/value&gt;
+      &lt;value&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>allows the <tt>preferredFormat</tt> attribute to have the value
+<tt>html</tt> or <tt>text</tt>.  This corresponds to the
+DTD:</p><pre class="programlisting">&lt;!DOCTYPE card [
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED
+  preferredFormat (html|text) #REQUIRED&gt;
+]&gt;</pre><p>The <tt>value</tt> pattern is not restricted to attribute
+values. For example, the following is allowed:</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;element name="name"&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name="email"&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name="preferredFormat"&gt;
+    &lt;choice&gt;
+      &lt;value&gt;html&lt;/value&gt;
+      &lt;value&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>The prohibition against a <tt>data</tt> pattern's matching
+only part of the content of an element also applies to
+<tt>value</tt> patterns.</p><p>By default, the <tt>value</tt> pattern will consider the string
+in the pattern to match the string in the document if the two strings
+are the same after the whitespace in both strings is normalized.
+Whitespace normalization strips leading and trailing whitespace
+characters, and collapses sequences of one or more whitespace
+characters to a single space character.  This corresponds to the
+behaviour of an XML parser for an attribute that is declared as other
+than CDATA. Thus the above pattern will match any of:</p><pre class="programlisting">&lt;card name="John Smith" email="js at example.com" preferredFormat="html"/&gt;
+&lt;card name="John Smith" email="js at example.com" preferredFormat="  html  "/&gt;</pre><p>The way that the <tt>value</tt> pattern compares the
+pattern string with the document string can be controlled by
+specifying a <tt>type</tt> attribute and optionally a
+<tt>datatypeLibrary</tt> attribute, which identify a
+datatype in the same way as for the <tt>data</tt> pattern.
+The pattern string matches the document string if they both represent
+the same value of the specified datatype. Thus, whereas the
+<tt>data</tt> pattern matches an arbitrary value of a
+datatype, the <tt>value</tt> pattern matches a specific
+value of a datatype.</p><p>If there is no ancestor element with a
+<tt>datatypeLibrary</tt> element, the datatype library
+defaults to a built-in RELAX NG datatype library.  This provides two
+datatypes, <tt>string</tt> and <tt>token</tt>.
+The built-in datatype <tt>token</tt> corresponds to the
+default comparison behavior of the <tt>value</tt> pattern.
+The built-in datatype <tt>string</tt> compares strings
+without any whitespace normalization (other than the end-of-line and
+attribute value normalization automatically performed by XML).  For
+example,</p><pre class="programlisting">&lt;element name="card"&gt;
+  &lt;attribute name="name"/&gt;
+  &lt;attribute name="email"/&gt;
+  &lt;attribute name="preferredFormat"&gt;
+    &lt;choice&gt;
+      &lt;value type="string"&gt;html&lt;/value&gt;
+      &lt;value type="string"&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>will <i>not</i> match</p><pre class="programlisting">&lt;card name="John Smith" email="js at example.com" preferredFormat="  html  "/&gt;</pre></div><div class="section"><a name="IDAK0YR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAK0YR"></a>7. Lists</h2></div></div><p>The <tt>list</tt> pattern matches a whitespace-separated
+sequence of tokens; it contains a pattern that the sequence of
+individual tokens must match.  The <tt>list</tt> pattern
+splits a string into a list of strings, and then matches the resulting
+list of strings against the pattern inside the <tt>list</tt>
+pattern.</p><p>For example, suppose we want to have a <tt>vector</tt>
+element that contains two floating point numbers separated by
+whitespace.  We could use <tt>list</tt> as follows:</p><pre class="programlisting">&lt;element name="vector"&gt;
+  &lt;list&gt;
+    &lt;data type="float"/&gt;
+    &lt;data type="float"/&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre><p>Or suppose we want the <tt>vector</tt> element to
+contain a list of one or more floating point numbers separated by
+whitespace:</p><pre class="programlisting">&lt;element name="vector"&gt;
+  &lt;list&gt;
+    &lt;oneOrMore&gt;
+      &lt;data type="double"/&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre><p>Or suppose we want a <tt>path</tt> element containing
+an even number of floating point numbers:</p><pre class="programlisting">&lt;element name="path"&gt;
+  &lt;list&gt;
+    &lt;oneOrMore&gt;
+      &lt;data type="double"/&gt;
+      &lt;data type="double"/&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre></div><div class="section"><a name="IDAN1YR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAN1YR"></a>8. Interleaving</h2></div></div><p>The <tt>interleave</tt> pattern allows child elements to occur
+in any order. For example, the following would allow the
+<tt>card</tt> element to contain the <tt>name</tt> and
+<tt>email</tt> elements in any order:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;interleave&gt;
+	&lt;element name="name"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;element name="email"&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/interleave&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The pattern is called <tt>interleave</tt> because of how it
+works with patterns that match more than one element.  Suppose we want
+to write a pattern for the HTML <tt>head</tt> element which
+requires exactly one <tt>title</tt> element, at most one
+<tt>base</tt> element and zero or more <tt>style</tt>,
+<tt>script</tt>, <tt>link</tt> and <tt>meta</tt> elements
+and suppose we are writing a <tt>grammar</tt> pattern that has one
+definition for each element.  Then we could define the pattern for
+<tt>head</tt> as follows:</p><pre class="programlisting">&lt;define name="head"&gt;
+  &lt;element name="head"&gt;
+    &lt;interleave&gt;
+      &lt;ref name="title"/&gt;
+      &lt;optional&gt;
+        &lt;ref name="base"/&gt;
+      &lt;/optional&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="style"/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="script"/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="link"/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="meta"/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>Suppose we had a <tt>head</tt> element that contained a
+<tt>meta</tt> element, followed by a <tt>title</tt> element,
+followed by a <tt>meta</tt> element.  This would match the pattern
+because it is an interleaving of a sequence of two <tt>meta</tt>
+elements, which match the child pattern</p><pre class="programlisting">      &lt;zeroOrMore&gt;
+        &lt;ref name="meta"/&gt;
+      &lt;/zeroOrMore&gt;</pre><p>and a sequence of one <tt>title</tt> element, which matches
+the child pattern</p><pre class="programlisting">      &lt;ref name="title"/&gt;</pre><p>The semantics of the <tt>interleave</tt> pattern are that a
+sequence of elements matches an <tt>interleave</tt> pattern if it
+is an interleaving of sequences that match the child patterns of the
+<tt>interleave</tt> pattern.  Note that this is different from the
+<tt>&amp;</tt> connector in SGML: <tt>A* &amp; B</tt> matches
+the sequence of elements <tt>A A B</tt> or the sequence of
+elements <tt>B A A</tt> but not the sequence of elements <tt>A B
+A</tt>.</p><p>One special case of <tt>interleave</tt> is very common:
+interleaving <tt>&lt;text/&gt;</tt> with a pattern
+<i><tt>p</tt></i> represents a pattern that matches what <i><tt>p</tt></i>
+matches but also allows characters to occur as children.  The
+<tt>mixed</tt> element is a shorthand for this.</p><pre class="programlisting">&lt;mixed&gt; <i><tt>p</tt></i> &lt;/mixed&gt;</pre><p>is short for</p><pre class="programlisting">&lt;interleave&gt; &lt;text/&gt; <i><tt>p</tt></i> &lt;/interleave&gt;</pre></div><div class="section"><a name="IDAX4YR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAX4YR"></a>9. Modularity</h2></div></div><div class="section"><a name="IDA04YR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA04YR"></a>9.1. Referencing external patterns</h3></div></div><p>The <tt>externalRef</tt> pattern can be used to
+reference a pattern defined in a separate file.  The
+<tt>externalRef</tt> element has a required
+<tt>href</tt> attribute that specifies the URL of a file
+containing the pattern.  The <tt>externalRef</tt> matches if
+the pattern contained in the specified URL matches. Suppose for
+example, you have a RELAX NG pattern that matches HTML inline content
+stored in <tt>inline.rng</tt>:</p><pre class="programlisting">&lt;grammar&gt;
+  &lt;start&gt;
+    &lt;ref name="inline"/&gt;
+  &lt;/start&gt;
+
+  &lt;define name="inline"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+        &lt;text/&gt;
+        &lt;element name="code"&gt;
+          &lt;ref name="inline"/&gt;
+        &lt;/element&gt;
+        &lt;element name="em"&gt;
+          &lt;ref name="inline"/&gt;
+        &lt;/element&gt;
+        &lt;!-- etc --&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+&lt;/grammar&gt;</pre><p>Then we could allow the <tt>note</tt> element to contain
+inline HTML markup by using <tt>externalRef</tt> as follows:</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name="note"&gt;
+	  &lt;externalRef href="inline.rng"/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>For another example, suppose you have two RELAX NG patterns stored in
+files <tt>pattern1.rng</tt> and <tt>pattern2.rng</tt>. Then
+the following is a pattern that matches anything matched
+by either of those patterns:</p><pre class="programlisting">&lt;choice&gt;
+  &lt;externalRef href="pattern1.rng"/&gt;
+  &lt;externalRef href="pattern2.rng"/&gt;
+&lt;/choice&gt;</pre></div><div class="section"><a name="IDACAZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDACAZR"></a>9.2. Combining definitions</h3></div></div><p>If a grammar contains multiple definitions with the same name,
+then the definitions must specify how they are to be combined into a
+single definition by using the <tt>combine</tt> attribute.
+The <tt>combine</tt> attribute may have the value
+<tt>choice</tt> or <tt>interleave</tt>. For
+example,</p><pre class="programlisting">&lt;define name="inline.class" combine="choice"&gt;
+  &lt;element name="bold"&gt;
+    &lt;ref name="inline"/&gt;
+  &lt;/element&gt;
+&lt;/define&gt;
+
+&lt;define name="inline.class" combine="choice"&gt;
+  &lt;element name="italic"&gt;
+    &lt;ref name="inline"/&gt;
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;define name="inline.class"&gt;
+  &lt;choice&gt;
+    &lt;element name="bold"&gt;
+      &lt;ref name="inline"/&gt;
+    &lt;/element&gt;
+    &lt;element name="italic"&gt;
+      &lt;ref name="inline"/&gt;
+    &lt;/element&gt;
+  &lt;/choice&gt;
+&lt;/define&gt;</pre><p>When combining attributes, <tt>combine="interleave"</tt>
+is typically used.  For example,</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="card.attlist"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="card.attlist" combine="interleave"&gt;
+    &lt;attribute name="name"&gt;
+      &lt;text/&gt;
+    &lt;/attribute&gt;
+  &lt;/define&gt;
+
+  &lt;define name="card.attlist" combine="interleave"&gt;
+    &lt;attribute name="email"&gt;
+      &lt;text/&gt;
+    &lt;/attribute&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="card.attlist"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="card.attlist"&gt;
+    &lt;interleave&gt;
+      &lt;attribute name="name"&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name="email"&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>which is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="card.attlist"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="card.attlist"&gt;
+    &lt;group&gt;
+      &lt;attribute name="name"&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name="email"&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/group&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>since combining attributes with <tt>interleave</tt>
+has the same effect as combining them with
+<tt>group</tt>.</p><p>It is an error for two definitions of the same name to specify
+different values for <tt>combine</tt>. Note that the order
+of definitions within a grammar is not significant.</p><p>Multiple <tt>start</tt> elements can be combined in
+the same way as multiple definitions.</p></div><div class="section"><a name="IDAXBZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAXBZR"></a>9.3. Merging grammars</h3></div></div><p>The <tt>include</tt> element allows grammars to be
+merged together. A <tt>grammar</tt> pattern may have
+<tt>include</tt> elements as children.  An
+<tt>include</tt> element has a required
+<tt>href</tt> attribute that specifies the URL of a file
+containing a <tt>grammar</tt> pattern.  The definitions in
+the referenced <tt>grammar</tt> pattern will be included in
+<tt>grammar</tt> pattern containing the
+<tt>include</tt> element.</p><p>The <tt>combine</tt> attribute is particularly useful
+in conjunction with <tt>include</tt>.  For example, suppose
+a RELAX NG pattern <tt>inline.rng</tt> provides a pattern
+for inline content, which allows <tt>bold</tt> and
+<tt>italic</tt> elements arbitrarily nested:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name="inline"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name="inline.class"/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name="inline.class"&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name="bold"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="italic"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Another RELAX NG pattern could use <tt>inline.rng</tt>
+and add <tt>code</tt> and <tt>em</tt> to the set
+of inline elements as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href="inline.rng"/&gt;
+
+  &lt;start&gt;
+    &lt;element name="doc"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="p"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="inline.class" combine="choice"&gt;
+    &lt;choice&gt;
+      &lt;element name="code"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+      &lt;element name="em"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre><p>This would be equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name="inline"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name="inline.class"/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name="inline.class"&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name="bold"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="italic"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  &lt;start&gt;
+    &lt;element name="doc"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="p"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="inline.class" combine="choice"&gt;
+    &lt;choice&gt;
+      &lt;element name="code"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+      &lt;element name="em"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre><p>which is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name="inline"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name="inline.class"/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name="inline.class"&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name="bold"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="italic"&gt;
+	&lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+      &lt;element name="code"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+      &lt;element name="em"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  &lt;start&gt;
+    &lt;element name="doc"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="p"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+&lt;/grammar&gt;</pre><p>Note that it is allowed for one of the definitions of a name to
+omit the <tt>combine</tt> attribute.  However, it is an
+error if there is more than one definition that does so.</p><p>The <tt>notAllowed</tt> pattern is useful when merging
+grammars. The <tt>notAllowed</tt> pattern never matches
+anything.  Just as adding <tt>empty</tt> to a
+<tt>group</tt> makes no difference, so adding
+<tt>notAllowed</tt> to a <tt>choice</tt> makes no
+difference.  It is typically used to allow an including pattern to
+specify additional choices with <tt>combine="choice"</tt>.
+For example, if <tt>inline.rng</tt> were written like
+this:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name="inline"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+	&lt;text/&gt;
+	&lt;element name="bold"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+	&lt;element name="italic"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+	&lt;ref name="inline.extra"/&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name="inline.extra"&gt;
+    &lt;notAllowed/&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>then it could be customized to allow inline
+<tt>code</tt> and <tt>em</tt> elements as
+follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href="inline.rng"/&gt;
+
+  &lt;start&gt;
+    &lt;element name="doc"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="p"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="inline.extra" combine="choice"&gt;
+    &lt;choice&gt;
+      &lt;element name="code"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+      &lt;element name="em"&gt;
+	&lt;ref name="inline"&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre></div><div class="section"><a name="IDAVEZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAVEZR"></a>9.4. Replacing definitions</h3></div></div><p>RELAX NG allows <tt>define</tt> elements to be put
+inside the <tt>include</tt> element to indicate that they
+are to replace definitions in the included <tt>grammar</tt>
+pattern.</p><p>Suppose the file <tt>addressBook.rng</tt>
+contains:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="cardContent"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="cardContent"&gt;
+    &lt;element name="name"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name="email"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Suppose we wish to modify this pattern so that the
+<tt>card</tt> element contains an
+<tt>emailAddress</tt> element instead of an
+<tt>email</tt> element. Then we could replace the definition
+of <tt>cardContent</tt> as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href="addressBook.rng"&gt;
+
+    &lt;define name="cardContent"&gt;
+      &lt;element name="name"&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="emailAddress"&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/define&gt;
+
+  &lt;/include&gt;
+
+&lt;/grammar&gt;</pre><p>This would be equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="addressBook"&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name="card"&gt;
+	  &lt;ref name="cardContent"/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="cardContent"&gt;
+    &lt;element name="name"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name="emailAddress"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>An <tt>include</tt> element can also contain a
+<tt>start</tt> element, which replaces the
+<tt>start</tt> in the included grammar pattern.</p></div></div><div class="section"><a name="IDADGZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDADGZR"></a>10. Namespaces</h2></div></div><p>RELAX NG is namespace-aware. Thus, it considers an element or attribute
+to have both a local name and a namespace URI which together
+constitute the name of that element or attribute.</p><div class="section"><a name="IDAIGZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAIGZR"></a>10.1. Using the <tt>ns</tt> attribute</h3></div></div><p>The <tt>element</tt> pattern uses an <tt>ns</tt> attribute
+to specify the namespace URI of the elements that it matches.  For
+example,</p><pre class="programlisting">&lt;element name="foo" ns="http://www.example.com"&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre><p>would match any of:</p><pre class="programlisting">&lt;foo xmlns="http://www.example.com"/&gt;
+&lt;e:foo xmlns:e="http://www.example.com"/&gt;
+&lt;example:foo xmlns:example="http://www.example.com"/&gt;</pre><p>but not any of:</p><pre class="programlisting">&lt;foo/&gt;
+&lt;e:foo xmlns:e="http://WWW.EXAMPLE.COM"/&gt;
+&lt;example:foo xmlns:example="http://www.example.net"/&gt;</pre><p>A value of an empty string for the <tt>ns</tt> attribute
+indicates a null or absent namespace URI (just as with the
+<tt>xmlns</tt> attribute).  Thus, the pattern</p><pre class="programlisting">&lt;element name="foo" ns=""&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre><p>matches any of:</p><pre class="programlisting">&lt;foo xmlns=""/&gt;
+&lt;foo/&gt;</pre><p>but not any of:</p><pre class="programlisting">&lt;foo xmlns="http://www.example.com"/&gt;
+&lt;e:foo xmlns:e="http://www.example.com"/&gt;</pre><p>It is tedious and error-prone to specify the <tt>ns</tt>
+attribute on every <tt>element</tt>, so RELAX NG allows it to be
+defaulted.  If an <tt>element</tt> pattern does not specify an
+<tt>ns</tt> attribute, then it defaults to the value of the
+<tt>ns</tt> attribute of the nearest ancestor that has an
+<tt>ns</tt> attribute, or the empty string if there is no such
+ancestor. Thus,</p><pre class="programlisting">&lt;element name="addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name="addressBook" ns=""&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card" ns=""&gt;
+      &lt;element name="name" ns=""&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email" ns=""&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>and</p><pre class="programlisting">&lt;element name="addressBook" ns="http://www.example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name="addressBook" ns="http://www.example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card" ns="http://www.example.com"&gt;
+      &lt;element name="name" ns="http://www.example.com"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email" ns="http://www.example.com"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt>attribute</tt> pattern also takes an
+<tt>ns</tt> attribute.  However, there is a
+difference in how it defaults.  This is because of the fact that the
+XML Namespaces Recommendation does not apply the default namespace to
+attributes.  If an <tt>ns</tt> attribute is not
+specified on the <tt>attribute</tt> pattern, then it
+defaults to the empty string. Thus,</p><pre class="programlisting">&lt;element name="addressBook" ns="http://www.example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;attribute name="name"/&gt;
+      &lt;attribute name="email"/&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name="addressBook" ns="http://www.example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card" ns="http://www.example.com"&gt;
+      &lt;attribute name="name" ns=""/&gt;
+      &lt;attribute name="email" ns=""/&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>and so will match</p><pre class="programlisting">&lt;addressBook xmlns="http://www.example.com"&gt;
+  &lt;card name="John Smith" email="js at example.com"/&gt;
+&lt;/addressBook&gt;</pre><p>or</p><pre class="programlisting">&lt;example:addressBook xmlns:example="http://www.example.com"&gt;
+  &lt;example:card name="John Smith" email="js at example.com"/&gt;
+&lt;/example:addressBook&gt;</pre><p>but not</p><pre class="programlisting">&lt;example:addressBook xmlns:example="http://www.example.com"&gt;
+  &lt;example:card example:name="John Smith" example:email="js at example.com"/&gt;
+&lt;/example:addressBook&gt;</pre></div><div class="section"><a name="IDAYJZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDAYJZR"></a>10.2. Qualified names</h3></div></div><p>When a pattern matches elements and attributes from multiple
+namespaces, using the <tt>ns</tt> attribute would require
+repeating namespace URIs in different places in the pattern.  This is
+error-prone and hard to maintain, so RELAX NG also allows the
+<tt>element</tt> and <tt>attribute</tt> patterns to use a
+prefix in the value of the <tt>name</tt> attribute to specify the
+namespace URI. In this case, the prefix specifies the namespace URI to
+which that prefix is bound by the namespace declarations in scope on
+the <tt>element</tt> or <tt>attribute</tt> pattern. Thus,</p><pre class="programlisting">&lt;element name="ab:addressBook" xmlns:ab="http://www.example.com/addressBook"
+                               xmlns:a="http://www.example.com/address"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="ab:card"&gt;
+      &lt;element name="a:name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="a:email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name="addressBook" ns="http://www.example.com/addressBook"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card" ns="http://www.example.com/addressBook"&gt;
+      &lt;element name="name" ns="http://www.example.com/address"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email" ns="http://www.example.com/address"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>If a prefix is specified in the value of the <tt>name</tt>
+attribute of an <tt>element</tt> or <tt>attribute</tt>
+pattern, then that prefix determines the namespace URI of the elements
+or attributes that will be matched by that pattern, regardless of
+the value of any <tt>ns</tt> attribute.</p><p>Note that the XML default namespace (as specified by the
+<tt>xmlns</tt> attribute) is not used in determining the namespace
+URI of elements and attributes that <tt>element</tt> and
+<tt>attribute</tt> patterns match.</p></div></div><div class="section"><a name="IDAFLZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAFLZR"></a>11. Name classes</h2></div></div><p>Normally, the name of the element to be matched by an
+<tt>element</tt> element is specified by a <tt>name</tt>
+attribute.  An <tt>element</tt> element can instead start with an
+element specifying a <i>name-class</i>.  In this case, the
+<tt>element</tt> pattern will only match an element if the name of
+the element is a member of the name-class.  The simplest name-class is
+<tt>anyName</tt>, which any name at all is a member of, regardless
+of its local name and its namespace URI.  For example, the following
+pattern matches any well-formed XML document:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;ref name="anyElement"/&gt;
+  &lt;/start&gt;
+
+  &lt;define name="anyElement"&gt;
+    &lt;element&gt;
+      &lt;anyName/&gt;
+      &lt;zeroOrMore&gt;
+	&lt;choice&gt;
+	  &lt;attribute&gt;
+	    &lt;anyName/&gt;
+	  &lt;/attribute&gt;
+	  &lt;text/&gt;
+	  &lt;ref name="anyElement"/&gt;
+	&lt;/choice&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>The <tt>nsName</tt> name-class contains any
+name with the namespace URI specified by the
+<tt>ns</tt> attribute, which defaults in the same way
+as the <tt>ns</tt> attribute on the
+<tt>element</tt> pattern.</p><p>The <tt>choice</tt> name-class matches any name that is a
+member of any of its child name-classes.</p><p>The <tt>anyName</tt> and <tt>nsName</tt>
+name-classes can contain an <tt>except</tt> clause. For
+example,</p><pre class="programlisting">&lt;element name="card" ns="http://www.example.com"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName&gt;
+        &lt;except&gt;
+          &lt;nsName/&gt;
+          &lt;nsName ns=""/&gt;
+        &lt;/except&gt;
+      &lt;/anyName&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;text/&gt;
+&lt;/element&gt;</pre><p>would allow the <tt>card</tt> element to have any number of
+namespace-qualified attributes provided that they were qualified with
+namespace other than that of the <tt>card</tt> element.</p><p>Note that an <tt>attribute</tt> pattern matches a single
+attribute even if it has a name-class that contains multiple names.
+To match zero or more attributes, the <tt>zeroOrMore</tt> element
+must be used.</p><p>The <tt>name</tt> name-class contains a single name.
+The content of the <tt>name</tt> element specifies the name
+in the same way as the <tt>name</tt> attribute of the
+<tt>element</tt> pattern.  The <tt>ns</tt>
+attribute specifies the namespace URI in the same way as the
+<tt>element</tt> pattern.</p><p>Some schema languages have a concept of <i>lax</i> validation,
+where an element or attribute is validated against a definition only
+if there is one.  We can implement this concept in RELAX NG with name
+classes that uses <tt>except</tt> and <tt>name</tt>.
+Suppose, for example, we wanted to allow an element to have any
+attribute with a qualified name, but we still wanted to ensure that if
+there was an <tt>xml:space</tt> attribute, it had the value
+<tt>default</tt> or <tt>preserve</tt>.  It wouldn't work to
+use</p><pre class="programlisting">&lt;element name="example"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName/&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;optional&gt;
+    &lt;attribute name="xml:space"&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;
+  &lt;/optional&gt;
+&lt;/element&gt;</pre><p>because an <tt>xml:space</tt> attribute with a value
+other than <tt>default</tt> or <tt>preserve</tt>
+would match</p><pre class="programlisting">    &lt;attribute&gt;
+      &lt;anyName/&gt;
+    &lt;/attribute&gt;</pre><p>even though it did not match</p><pre class="programlisting">    &lt;attribute name="xml:space"&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;</pre><p>The solution is to use <tt>name</tt> together with
+<tt>except</tt>:</p><pre class="programlisting">&lt;element name="example"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName&gt;
+        &lt;except&gt;
+          &lt;name&gt;xml:space&lt;/name&gt;
+        &lt;/except&gt;
+      &lt;/anyName&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;optional&gt;
+    &lt;attribute name="xml:space"&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;
+  &lt;/optional&gt;
+&lt;/element&gt;</pre><p>Note that the <tt>define</tt> element cannot contain a
+name-class; it can only contain a pattern.</p></div><div class="section"><a name="IDA1OZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA1OZR"></a>12. Annotations</h2></div></div><p>If a RELAX NG element has an attribute or child element with a
+namespace URI other than the RELAX NG namespace, then that attribute or
+element is ignored.  Thus, you can add annotations to RELAX NG patterns
+simply by using an attribute or element in a separate namespace:</p><pre class="programlisting">&lt;element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://www.example.com/annotation"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name="card"&gt;
+      &lt;a:documentation&gt;Information about a single email address.&lt;/a:documentation&gt;
+      &lt;element name="name"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name="email"&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>RELAX NG also provides a <tt>div</tt> element which
+allows an annotation to be applied to a group of definitions in a
+grammar.  For example, you might want to divide up the definitions of
+the grammar into modules:</p><pre class="programlisting">&lt;grammar xmlns:m="http://www.example.com/module"&gt;
+
+  &lt;div m:name="inline"&gt;
+
+    &lt;define name="code"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name="em"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name="var"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+
+  &lt;/div&gt;
+
+  &lt;div m:name="block"&gt;
+
+    &lt;define name="p"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name="ul"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name="ol"&gt; <i><tt>pattern</tt></i> &lt;/define&gt;
+
+  &lt;/div&gt;
+
+&lt;/grammar&gt;</pre><p>This would allow you easily to generate variants of the grammar
+based on a selection of modules.</p><p>A companion specification, RELAX NG DTD Compatibility
+<a href="#compat" title="[Compatibility]">[Compatibility]</a>, defines annotations to implement
+some features of XML DTDs.</p></div><div class="section"><a name="IDA3PZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA3PZR"></a>13. Nested grammars</h2></div></div><p>There is no prohibition against nesting grammar patterns.  A
+<tt>ref</tt> pattern refers to a definition from nearest
+<tt>grammar</tt> ancestor. There is also a
+<tt>parentRef</tt> element that escapes out of the current
+grammar and references a definition from the parent of the current
+grammar.</p><p>Imagine the problem of writing a pattern for tables.  The pattern
+for tables only cares about the structure of tables; it doesn't care
+about what goes inside a table cell.  First, we create a RELAX NG pattern
+<tt>table.rng</tt> as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+&lt;define name="cell.content"&gt;
+  &lt;notAllowed/&gt;
+&lt;/define&gt;
+
+&lt;start&gt;
+  &lt;element name="table"&gt;
+    &lt;oneOrMore&gt;
+      &lt;element name="tr"&gt;
+        &lt;oneOrMore&gt;
+	  &lt;element name="td"&gt;
+	    &lt;ref name="cell.content"/&gt;
+	  &lt;/element&gt;
+        &lt;/oneOrMore&gt;
+      &lt;/element&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/element&gt;
+&lt;/start&gt;
+
+&lt;/grammar&gt;</pre><p>Patterns that include <tt>table.rng</tt> must redefine
+<tt>cell.content</tt>. By using a nested
+<tt>grammar</tt> pattern containing a
+<tt>parentRef</tt> pattern, the including pattern can
+redefine <tt>cell.content</tt> to be a pattern defined in
+the including pattern's grammar, thus effectively importing a pattern
+from the parent grammar into the child grammar:</p><pre class="programlisting">&lt;grammar&gt;
+
+&lt;start&gt;
+  &lt;element name="doc"&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+	&lt;element name="p"&gt;
+	  &lt;ref name="inline"/&gt;
+	&lt;/element&gt;
+	&lt;grammar&gt;
+	  &lt;include href="table.rng"&gt;
+	    &lt;define name="cell.content"&gt;
+	      &lt;parentRef name="inline"/&gt;
+	    &lt;/define&gt;
+          &lt;/include&gt;
+	&lt;/grammar&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/element&gt;
+&lt;/start&gt;
+
+&lt;define name="inline"&gt;
+  &lt;zeroOrMore&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name="em"&gt;
+        &lt;ref name="inline"/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Of course, in a trivial case like this, there is no advantage in
+nesting the grammars: we could simply have included
+<tt>table.rng</tt> within the outer <tt>grammar</tt> element.
+However, when the included grammar has many definitions, nesting it
+avoids the possibility of name conflicts between the including grammar
+and the included grammar.</p></div><div class="section"><a name="IDAIRZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAIRZR"></a>14. Non-restrictions</h2></div></div><p>RELAX NG does not require patterns to be "deterministic" or
+"unambiguous".</p><p>Suppose we wanted to write the email address book in HTML, but use
+class attributes to specify the structure:</p><pre class="programlisting">&lt;element name="html"&gt;
+  &lt;element name="head"&gt;
+    &lt;element name="title"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/element&gt;
+  &lt;element name="body"&gt;
+    &lt;element name="table"&gt;
+      &lt;attribute name="class"&gt;
+        &lt;value&gt;addressBook&lt;/value&gt;
+      &lt;/attribute&gt;
+      &lt;oneOrMore&gt;
+        &lt;element name="tr"&gt;
+	  &lt;attribute name="class"&gt;
+	    &lt;value&gt;card&lt;/value&gt;
+	  &lt;/attribute&gt;
+          &lt;element name="td"&gt;
+	    &lt;attribute name="class"&gt;
+	      &lt;value&gt;name&lt;/value&gt;
+	    &lt;/attribute&gt;
+            &lt;interleave&gt;
+              &lt;text/&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;givenName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+              &lt;optional&gt;
+                &lt;element name="span"&gt;
+                  &lt;attribute name="class"&gt;
+                    &lt;value&gt;familyName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+            &lt;/interleave&gt;
+          &lt;/element&gt;
+          &lt;element name="td"&gt;
+	    &lt;attribute name="class"&gt;
+	      &lt;value&gt;email&lt;/value&gt;
+	    &lt;/attribute&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/element&gt;
+      &lt;/oneOrMore&gt;
+    &lt;/element&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>This would match a XML document such as:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class="addressBook"&gt;
+      &lt;tr class="card"&gt;
+        &lt;td class="name"&gt;
+          &lt;span class="givenName"&gt;John&lt;/span&gt;
+          &lt;span class="familyName"&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class="email"&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre><p>but not:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class="addressBook"&gt;
+      &lt;tr class="card"&gt;
+        &lt;td class="name"&gt;
+          &lt;span class="givenName"&gt;John&lt;/span&gt;
+          &lt;!-- Note the incorrect class attribute --&gt;
+          &lt;span class="givenName"&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class="email"&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre></div><div class="section"><a name="IDA3RZR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDA3RZR"></a>15. Further information</h2></div></div><p>The definitive specification of RELAX NG is <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>.</p></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAGSZR"></a>A. Comparison with XML DTDs</h2><p>RELAX NG provides functionality that goes beyond XML DTDs. In
+particular, RELAX NG</p><div class="itemizedlist"><ul><li><a name="IDAMSZR"></a>uses XML syntax to represent schemas</li><li><a name="IDAPSZR"></a>supports datatyping</li><li><a name="IDASSZR"></a>integrates attributes into content
+models</li><li><a name="IDAVSZR"></a>supports XML namespaces</li><li><a name="IDAYSZR"></a>supports unordered content</li><li><a name="IDA1SZR"></a>supports context-sensitive content
+models</li></ul></div><p>ID/IDREF validation is not provided by RELAX NG; however, it is
+provided by a companion specification, RELAX NG DTD Compatibility
+<a href="#compat" title="[Compatibility]">[Compatibility]</a>.  Comprehensive support for
+cross-reference checking is planned for a future specification.</p><p>RELAX NG does not support features of XML DTDs that involve
+changing the infoset of an XML document.  In particular, RELAX
+NG</p><div class="itemizedlist"><ul><li><a name="IDAHTZR"></a>does not allow defaults for attributes to be
+specified; however, this is allowed by RELAX NG DTD Compatibility
+<a href="#compat" title="[Compatibility]">[Compatibility]</a></li><li><a name="IDAMTZR"></a>does not allow entities to be specified</li><li><a name="IDAPTZR"></a>does not allow notations to be specified</li><li><a name="IDASTZR"></a>does not specify whether whitespace is significant</li></ul></div><p>Also RELAX NG does not define a way for an XML document to associate
+itself with a RELAX NG pattern.</p></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAZTZR"></a>B. Comparison with RELAX Core</h2><p>Any description in RELAX Core can be directly captured in RELAX
+NG without loss of information.</p><div class="section"><a name="IDA4TZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA4TZR"></a>B.1. Mapping RELAX NG to RELAX Core</h3></div></div><div class="section"><a name="IDABUZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDABUZR"></a>B.1.1. <tt>elementRule</tt>-<tt>tag</tt> pairs</h4></div></div><p>An <tt>elementRule</tt> as well as the referenced
+<tt>tag</tt> element is typically captured by a
+<tt>define</tt> element containing an
+<tt>element</tt> element as the child.</p><p>An <tt>elementRule</tt>-<tt>tag</tt> pair 
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;elementRule role="foo" label="bar"&gt;
+  <i><tt>hedge model</tt></i>
+&lt;/elementRule&gt;
+</pre><pre class="programlisting">
+&lt;tag role="foo" name="baz"&gt;
+  <i><tt>attribute declarations</tt></i>
+&lt;/tag&gt;
+</pre><p>A rewrite in RELAX NG is shown below:</p><pre class="programlisting">
+&lt;define name="bar"&gt;
+  &lt;element name="baz"&gt;
+    <i><tt>hedge model</tt></i>
+    <i><tt>attribute declarations</tt></i>
+  &lt;/element&gt;
+&lt;/define&gt;
+</pre></div><div class="section"><a name="IDAJVZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDAJVZR"></a>B.1.2. <tt>hedgeRule</tt></h4></div></div><p>A <tt>hedgeRule</tt> element is captured by a
+<tt>define</tt> element containing attribute
+declarations.</p><p>A <tt>hedgeRule</tt> element
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;hedgeRule label="bar"&gt;
+  <i><tt>hedge model</tt></i>
+&lt;/hedgeRule&gt;
+</pre><p>A rewrite in RELAX NG is:</p><pre class="programlisting">
+&lt;define name="bar"&gt;
+  <i><tt>hedge model</tt></i>
+&lt;/define&gt;
+</pre></div><div class="section"><a name="IDACWZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDACWZR"></a>B.1.3. <tt>attPool</tt></h4></div></div><p>An <tt>attPool</tt> element
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;attPool role="foo"&gt;
+  <i><tt>attribute declarations</tt></i>
+&lt;/attPool&gt;
+</pre><p>A rewrite in RELAX NG is</p><pre class="programlisting">
+&lt;define name="foo"&gt;
+  <i><tt>attribute declarations</tt></i>
+&lt;/define&gt;
+</pre></div><div class="section"><a name="IDAVWZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDAVWZR"></a>B.1.4. Hedge models</h4></div></div><p>Mapping of hedge models in RELAX Core to RELAX NG is summarized below:
+</p><div class="orderedlist"><ol type="1"><li><a name="IDA1WZR"></a>
+<tt>occurs="*"</tt> in RELAX Core 
+is captured by
+<tt>&lt;zeroOrMore&gt;...&lt;/zeroOrMore&gt;</tt>.
+</li><li><a name="IDACXZR"></a>
+<tt>occurs="+"</tt> in RELAX Core 
+is captured by
+<tt>&lt;oneOrMore&gt;...&lt;/oneOrMore&gt;</tt>
+</li><li><a name="IDAJXZR"></a>
+<tt>occurs="?"</tt> in RELAX Core 
+is captured by
+<tt>&lt;optional&gt;...&lt;/optional&gt;</tt>
+</li><li><a name="IDAQXZR"></a>
+<tt>&lt;mixed&gt;...&lt;/mixed&gt;</tt> in
+RELAX Core is captured by
+<tt>&lt;mixed&gt;...&lt;/mixed&gt;</tt>
+</li><li><a name="IDAXXZR"></a>
+<tt>&lt;ref label="..."/&gt;</tt> in
+RELAX Core is captured by
+<tt>&lt;ref name="..."/&gt;</tt>.
+</li><li><a name="IDA4XZR"></a>
+<tt>&lt;hedgeRef label="..."/&gt;</tt> in
+RELAX Core is captured by
+<tt>&lt;ref name="..."/&gt;</tt>
+</li></ol></div></div><div class="section"><a name="IDAKYZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDAKYZR"></a>B.1.5. Attribute declarations</h4></div></div><p>Both languages use <tt>attribute</tt>.  However, in
+RELAX Core, an <tt>attribute</tt> without
+<tt>required="true"</tt> declares a defaultable attribute.  
+On the other hand, in RELAX NG, a defaultable attribute has to 
+be declared by an <tt>attribute</tt> element within 
+an <tt>optional</tt> element.</p><p>Declaration of a required attribute in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;attribute name="foo" type="integer" required="true"/&gt;
+</pre><p>In RELAX NG, this is captured by:</p><pre class="programlisting">
+&lt;attribute name="foo"&gt;
+  &lt;data type="integer"/&gt;
+&lt;/attribute&gt;
+</pre><p>Declaration of an optional attribute in RELAX Core is shown
+below:</p><pre class="programlisting">
+&lt;attribute name="foo" type="integer"/&gt;
+</pre><p>In RELAX NG, this is captured by:</p><pre class="programlisting">
+&lt;optional&gt;
+  &lt;attribute name="foo"&gt;
+    &lt;data type="integer"/&gt;
+  &lt;/attribute&gt;
+&lt;/optional&gt;
+</pre></div></div><div class="section"><a name="IDALZZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDALZZR"></a>B.2. Examples</h3></div></div><div class="section"><a name="IDAOZZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDAOZZR"></a>B.2.1. Ancestor-and-sibling-sensitive content models</h4></div></div><p>Here is a rewrite of an example in <a href="http://www.xml.gr.jp/relax/html4/howToRELAX_p1_c8_en.html" target="_top">STEP
+7</a> of "HOW TO RELAX".  The first paragraph cannot contain
+footnotes, but the other paragraphs can.</p><pre class="programlisting">
+&lt;grammar&gt;
+  &lt;start&gt;
+    &lt;element name="doc"&gt;
+      &lt;ref name="paraWithoutFNotes"/&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="paraWithFNotes"/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="paraWithoutFNotes"&gt;
+    &lt;element name="para"&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="paraWithFNotes"&gt;
+    &lt;element name="para"&gt;
+      &lt;mixed&gt;
+        &lt;zeroOrMore&gt;
+          &lt;element name="fnote"&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/zeroOrMore&gt;
+      &lt;/mixed&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre><p>The following document matches this pattern:</p><pre class="programlisting">
+&lt;doc&gt;&lt;para/&gt;&lt;para&gt;&lt;fnote/&gt;&lt;/para&gt;&lt;/doc&gt;
+</pre><p>On the other hand, the following document does not:</p><pre class="programlisting">
+&lt;doc&gt;&lt;para&gt;&lt;fnote/&gt;&lt;/para&gt;&lt;/doc&gt;
+</pre></div><div class="section"><a name="IDAC0ZR"></a><div class="titlepage"><div><h4 class="title"><a name="IDAC0ZR"></a>B.2.2. Attribute-sensitive content model</h4></div></div><p>Here is a rewrite of an example in <a href="http://www.xml.gr.jp/relax/html4/howToRELAX_p1_c9_en.html" target="_top">STEP
+8</a> of "HOW TO RELAX".  This pattern assigns different content
+models for the same tag name <tt>div</tt> depending on the
+value of the attribute <tt>class</tt>.</p><pre class="programlisting">
+&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name="html"&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="section"/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name="section"&gt;
+    &lt;element name="div"&gt;
+      &lt;attribute name="class"&gt;&lt;value&gt;section&lt;/value&gt;&lt;/attribute&gt;
+      &lt;zeroOrMore&gt;
+        &lt;element name="para"&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name="subsection"/&gt;
+      &lt;/zeroOrMore&gt;
+   &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name="subsection"&gt;
+    &lt;element name="div"&gt;
+      &lt;attribute name="class"&gt;&lt;value&gt;subsection&lt;/value&gt;&lt;/attribute&gt;
+      &lt;zeroOrMore&gt;
+        &lt;element name="para"&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre><p>The following document matches this pattern:</p><pre class="programlisting">
+&lt;html&gt;
+  &lt;div class="section"&gt;
+    &lt;para/&gt;
+    &lt;div class="subsection"&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+  &lt;div class="section"&gt;
+    &lt;div class="subsection"&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/html&gt;
+</pre><p>On the other hand, the following document does not:</p><pre class="programlisting">
+&lt;html&gt;
+  &lt;div class="subsection"&gt;
+    &lt;para/&gt;
+    &lt;div class="section"&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/html&gt;
+</pre></div></div><div class="section"><a name="IDA10ZR"></a><div class="titlepage"><div><h3 class="title"><a name="IDA10ZR"></a>B.3. Features of RELAX NG beyond RELAX Core</h3></div></div><p>RELAX NG has some features which are missing in RELAX
+Core.</p><div class="orderedlist"><ol type="1"><li><a name="IDAB1ZR"></a>Namespaces: since RELAX Core is intended to be used in
+conjunction with RELAX Namespace, RELAX Core does not support
+namespaces.  On the other hand, RELAX NG supports namespaces.  RELAX
+Namespace will be extended so that it can work with RELAX NG.
+</li><li><a name="IDAE1ZR"></a>Mixture of <tt>element</tt> and
+<tt>attribute</tt>: RELAX Core does not allow their 
+mixture but rather provide two types of basic constructs, 
+namely <tt>elementRule/hedgeRule</tt> and 
+<tt>tag/attPool</tt>.</li><li><a name="IDAP1ZR"></a>Name classes: RELAX Core does not have name
+classes but merely provide name literals.</li><li><a name="IDAS1ZR"></a><tt>interleave</tt>:  RELAX Core does not 
+provide any mechanism for interleaving.</li><li><a name="IDAX1ZR"></a>Datatype libraries: RELAX Core allows XML Schema Part
+2 but does not allow other datatype libaries.</li><li><a name="IDA01ZR"></a><tt>define</tt> in <tt>include</tt>: 
+RELAX Core does not allow such redefinitions.</li><li><a name="IDAB2ZR"></a><tt>list</tt>: RELAX Core does not provide
+such structured strings.</li><li><a name="IDAG2ZR"></a><tt>data</tt> in <tt>choice</tt>:
+in RELAX Core, the hedge model of <tt>elementRule</tt> is 
+either a datatype reference or an expression without datatype 
+references.</li></ol></div></div></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDAS2ZR"></a>C. Comparison with TREX</h2><p>RELAX NG has the following changes from TREX:</p><div class="orderedlist"><ol type="1"><li><a name="IDAY2ZR"></a>the <tt>concur</tt> pattern has been removed</li><li><a name="IDA32ZR"></a>the <tt>string</tt> pattern has been replaced by the
+<tt>value</tt> pattern</li><li><a name="IDAE3ZR"></a>the <tt>anyString</tt> pattern has been renamed to
+<tt>text</tt></li><li><a name="IDAK3ZR"></a>the namespace URI is different</li><li><a name="IDAN3ZR"></a>pattern elements must be namespace qualified</li><li><a name="IDAQ3ZR"></a>anonymous datatypes have been removed</li><li><a name="IDAT3ZR"></a>the <tt>data</tt> pattern can have parameters specified by
+<tt>param</tt> child elements</li><li><a name="IDA03ZR"></a>the <tt>list</tt> pattern has been added
+for matching whitespace-separated lists of tokens</li><li><a name="IDA53ZR"></a>the <tt>replace</tt> and
+<tt>group</tt> values for the <tt>combine</tt>
+attribute have been removed</li><li><a name="IDAI4ZR"></a>an <tt>include</tt> element in a grammar may contain
+<tt>define</tt> elements that replace included definitions</li><li><a name="IDAP4ZR"></a>the restriction that definitions combined with the
+<tt>combine</tt> attribute must be from different files has
+been removed</li><li><a name="IDAU4ZR"></a>a <tt>div</tt> element may be used to group
+together definitions within a
+<tt>grammar</tt></li><li><a name="IDA04ZR"></a>an <tt>include</tt> element occurring as a
+pattern has been renamed to <tt>externalRef</tt>; an
+<tt>include</tt> element is now allowed only as a child of
+the <tt>grammar</tt> element</li><li><a name="IDAF5ZR"></a>the <tt>parent</tt> attribute on the
+<tt>ref</tt> element has been replaced by a new
+<tt>parentRef</tt> element</li><li><a name="IDAO5ZR"></a>the <tt>type</tt> attribute of the
+<tt>data</tt> element is an unqualified name; the
+<tt>data</tt> element uses the
+<tt>datatypeLibrary</tt> attribute rather than the
+<tt>ns</tt> attribute to identify the namespace of the
+datatype</li><li><a name="IDA15ZR"></a>a <tt>start</tt> element is not allowed to
+have a <tt>name</tt> attribute</li><li><a name="IDAFA0R"></a>an <tt>attribute</tt> element is not allowed
+to have a <tt>global</tt> attribute</li><li><a name="IDAMA0R"></a>the <tt>not</tt> and <tt>difference</tt>
+name classes have been replaced by <tt>except</tt></li><li><a name="IDAUA0R"></a>the <tt>data</tt> element may have
+an <tt>except</tt> child</li></ol></div></div><div class="appendix"><h2 class="title" style="clear: both"><a name="IDA3A0R"></a>D. Changes from 12 June 2001 version</h2><div class="orderedlist"><ol type="1"><li><a name="IDABB0R"></a><tt>key</tt> and <tt>keyRef</tt>
+have been removed; support for ID and IDREF is now available
+in a companion specification, RELAX NG DTD Compatibility
+Annotations <a href="#compat" title="[Compatibility]">[Compatibility]</a></li><li><a name="IDAKB0R"></a><tt>difference</tt> and <tt>not</tt>
+have been replaced by <tt>except</tt></li><li><a name="IDASB0R"></a>a <tt>start</tt> element is no longer
+allowed to have a <tt>name</tt> attribute</li><li><a name="IDAZB0R"></a>an <tt>attribute</tt> element is no longer
+allowed to have a <tt>global</tt>
+attribute</li></ol></div></div><div id="IDACC0R" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="IDACC0R"></a>References</h2></div></div><dl><dt>Compatibility</dt><dd id="compat" class="bibliomixed"><a name="compat"></a>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/compatibility.html" target="_top">RELAX NG
+DTD Compatibility</a></i></span>.  OASIS, 2001.</dd><dt>RELAX</dt><dd id="relax" class="bibliomixed"><a name="relax"></a>MURATA Makoto.
+<span class="citetitle"><i><a href="http://www.xml.gr.jp/relax/" target="_top">RELAX (Regular
+Language description for XML)</a></i></span>.  INSTAC
+(Information Technology Research and Standardization Center), 2001.</dd><dt>RELAX NG</dt><dd id="spec" class="bibliomixed"><a name="spec"></a>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</dd><dt>TREX</dt><dd id="trex" class="bibliomixed"><a name="trex"></a>James Clark.
+<span class="citetitle"><i><a href="http://www.thaiopensource.com/trex/" target="_top">TREX - Tree Regular Expressions for XML</a></i></span>.
+Thai Open Source Software Center, 2001.</dd><dt>W3C XML Schema Datatypes</dt><dd id="xmlschema-2" class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd></dl></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20011203.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,1754 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>RELAX NG Tutorial</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.60.1"><meta name="description" content="RELAX NG is a simple schema language for XML, based on  and . A RELAX NG schema
+specifies a pattern for the structure and content of an XML
+document. A RELAX NG schema thus identifies a class of XML documents
+consisting of those documents that match the pattern. Two syntaxes have been defined for RELAX NG.  The original
+syntax uses XML; with this syntax an RELAX NG schema is itself an XML
+document.  Subsequently, a compact non-XML syntax has been
+defined. This document is a tutorial for RELAX NG version 1.0 using the
+XML
+syntax."><meta http-equiv="content-style-type" content="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="id2811955"></a>RELAX NG Tutorial</h1></div><div><h2>Working Draft 26 March 2003</h2></div><div><dl><dt>This version:</dt><dd>Working Draft: 26 March 2003</dd></dl><dl><dt>Previous versions:</dt><dd>Committee Specification: 3 December 2001<br>Committee Specification: 10 August 2001</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt class="email">&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, MURATA Makoto <tt class="email">&lt;<a href="mailto:EB2M-MRT at asahi-net.or.jp">EB2M-MRT at asahi-net.or.jp</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001, 2003. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an &quot;<span class="quote">AS IS</span>&quot; basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="id2811725"></a>Abstract</h2><p>RELAX NG is a simple schema language for XML, based on [<a href="#relax"><span class="abbrev">RELAX</span></a>] and [<a href="#trex"><span class="abbrev">TREX</span></a>]. A RELAX NG schema
+specifies a pattern for the structure and content of an XML
+document. A RELAX NG schema thus identifies a class of XML documents
+consisting of those documents that match the pattern.</p><p>Two syntaxes have been defined for RELAX NG.  The original
+syntax uses XML; with this syntax an RELAX NG schema is itself an XML
+document.  Subsequently, a compact non-XML syntax has been
+defined.</p><p>This document is a tutorial for RELAX NG version 1.0 using the
+XML
+syntax.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This is a working draft constructed by the editors. It is not an
+official committee work product and may not reflect the consensus
+opinion of the committee.  Comments on this document may be sent to
+<a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1. <a href="#id2814004">Getting started</a></dt><dt>2. <a href="#id2814145">Choice</a></dt><dt>3. <a href="#id2814190">Attributes</a></dt><dt>4. <a href="#id2814574">Named patterns</a></dt><dt>5. <a href="#id2814728">Datatyping</a></dt><dt>6. <a href="#id2814985">Enumerations</a></dt><dt>7. <a href="#id2815195">Lists</a></dt><dt>8. <a href="#id2815274">Interleaving</a></dt><dt>9. <a href="#id2815519">Modularity</a></dt><dd><dl><dt>9.1. <a href="#id2815526">Referencing external patterns</a></dt><dt>9.2. <a href="#id2815624">Combining definitions</a></dt><dt>9.3. <a href="#id2813894">Merging grammars</a></dt><dt>9.4. <a href="#id2816167">Replacing definitions</a></dt></dl></dd><dt>10. <a href="#id2816290">Namespaces</a></dt><dd><dl><dt>10.1. <a href="#id2816305">Using the ns attribute</a></dt><dt>10.2. <a href="#id2816564">Qualified names</a></dt></dl></dd><dt>11. <a href="#id2816679">Name classes</a></dt><dt>12. <a href="#id2816970">Annotations</a></dt><dt>13. <a href="#id2817066">Nested grammars</a></dt><dt>14. <a href="#id2817179">Non-restrictions</a></dt><dt>15. <a href="#id2817227">Further information</a></dt></dl><h3>Appendixes</h3><dl><dt>A. <a href="#id2817313">Comparison with XML DTDs</a></dt><dt>B. <a href="#id2817433">Comparison with RELAX Core</a></dt><dd><dl><dt>1. <a href="#id2817447">Mapping RELAX NG to RELAX Core</a></dt><dd><dl><dt>1.1. <a href="#id2817454">elementRule-tag pairs</a></dt><dt>1.2. <a href="#id2817543">hedgeRule</a></dt><dt>1.3. <a href="#id2817597">attPool</a></dt><dt>1.4. <a href="#id2817638">Hedge models</a></dt><dt>1.5. <a href="#id2817748">Attribute declarations</a></dt></dl></dd><dt>2. <a href="#id2817827">Examples</a></dt><dd><dl><dt>2.1. <a href="#id2817835">Ancestor-and-sibling-sensitive content models</a></dt><dt>2.2. <a href="#id2817896">Attribute-sensitive content model</a></dt></dl></dd><dt>3. <a href="#id2817974">Features of RELAX NG beyond RELAX Core</a></dt></dl></dd><dt>C. <a href="#id2818092">Comparison with TREX</a></dt><dt>D. <a href="#id2818380">Changes from 12 June 2001 version</a></dt><dt><a href="#id2818456">References</a></dt></dl></div><hr><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814004"></a>1. Getting started</h2></div></div><p>Consider a simple XML representation of an email address book:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;name&gt;John Smith&lt;/name&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>The DTD (as an internal subset) would be as follows:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card (name, email)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+]&gt;</pre><p>A RELAX NG pattern for this could be written as follows:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>If the <tt class="literal">addressBook</tt> is required to be non-empty, then
+we can use <tt class="literal">oneOrMore</tt> instead of
+<tt class="literal">zeroOrMore</tt>:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
+  &lt;oneOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/oneOrMore&gt;
+&lt;/element&gt;</pre><p>Now let's change it to allow each <tt class="literal">card</tt> to have an
+optional <tt class="literal">note</tt> element:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name=&quot;note&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>Note that the <tt class="literal">text</tt> pattern matches arbitrary text,
+including empty text. Note also that whitespace separating tags is
+ignored when matching against a pattern.</p><p>All the elements specifying the pattern must be namespace qualified
+by the namespace URI:</p><pre class="programlisting">http://relaxng.org/ns/structure/1.0</pre><p>The examples above use a default namespace declaration
+<tt class="literal">xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;</tt> for this. A
+namespace prefix is equally acceptable:</p><pre class="programlisting">&lt;rng:element name=&quot;addressBook&quot; xmlns:rng=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
+  &lt;rng:zeroOrMore&gt;
+    &lt;rng:element name=&quot;card&quot;&gt;
+      &lt;rng:element name=&quot;name&quot;&gt;
+        &lt;rng:text/&gt;
+      &lt;/rng:element&gt;
+      &lt;rng:element name=&quot;email&quot;&gt;
+        &lt;rng:text/&gt;
+      &lt;/rng:element&gt;
+    &lt;/rng:element&gt;
+  &lt;/rng:zeroOrMore&gt;
+&lt;/rng:element&gt;</pre><p>For the remainder of this document, the default namespace
+declaration will be left out of examples.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814145"></a>2. Choice</h2></div></div><p>Now suppose we want to allow the <tt class="literal">name</tt> to be broken
+down into a <tt class="literal">givenName</tt> and a <tt class="literal">familyName</tt>,
+allowing an <tt class="literal">addressBook</tt> like this:</p><pre class="programlisting">&lt;addressBook&gt;
+  &lt;card&gt;
+    &lt;givenName&gt;John&lt;/givenName&gt;
+    &lt;familyName&gt;Smith&lt;/familyName&gt;
+    &lt;email&gt;js at example.com&lt;/email&gt;
+  &lt;/card&gt;
+  &lt;card&gt;
+    &lt;name&gt;Fred Bloggs&lt;/name&gt;
+    &lt;email&gt;fb at example.net&lt;/email&gt;
+  &lt;/card&gt;
+&lt;/addressBook&gt;</pre><p>We can use the following pattern:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;choice&gt;
+        &lt;element name=&quot;name&quot;&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+        &lt;group&gt;
+          &lt;element name=&quot;givenName&quot;&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+          &lt;element name=&quot;familyName&quot;&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/group&gt;
+      &lt;/choice&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name=&quot;note&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>This corresponds to the following DTD:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card ((name | (givenName, familyName)), email, note?)&gt;
+&lt;!ELEMENT name (#PCDATA)&gt;
+&lt;!ELEMENT email (#PCDATA)&gt;
+&lt;!ELEMENT givenName (#PCDATA)&gt;
+&lt;!ELEMENT familyName (#PCDATA)&gt;
+&lt;!ELEMENT note (#PCDATA)&gt;
+]&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814190"></a>3. Attributes</h2></div></div><p>Suppose we want the <tt class="literal">card</tt> element to have attributes
+rather than child elements. The DTD might look like this:</p><pre class="programlisting">&lt;!DOCTYPE addressBook [
+&lt;!ELEMENT addressBook (card*)&gt;
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED&gt;
+]&gt;</pre><p>Just change each <tt class="literal">element</tt> pattern to an
+<tt class="literal">attribute</tt> pattern:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;attribute name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>In XML, the order of attributes is traditionally not significant.
+RELAX NG follows this tradition.  The above pattern would match both</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;</pre><p>and</p><pre class="programlisting">&lt;card email=&quot;js at example.com&quot; name=&quot;John Smith&quot;/&gt;</pre><p>In contrast, the order of elements is significant. The pattern</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;element name=&quot;name&quot;&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name=&quot;email&quot;&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>would <span class="strong">not</span> match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>Note that an <tt class="literal">attribute</tt> pattern by itself indicates a
+required attribute, just as an <tt class="literal">element</tt> pattern by itself
+indicates a required element. To specify an optional attribute, use
+<tt class="literal">optional</tt> just as with <tt class="literal">element</tt>:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;attribute name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;optional&gt;
+        &lt;attribute name=&quot;note&quot;&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt class="literal">group</tt> and <tt class="literal">choice</tt> patterns can be
+applied to <tt class="literal">attribute</tt> patterns in the same way they are
+applied to <tt class="literal">element</tt> patterns.  For example, if we wanted
+to allow either a <tt class="literal">name</tt> attribute or both a
+<tt class="literal">givenName</tt> and a <tt class="literal">familyName</tt> attribute, we can
+specify this in the same way that we would if we were using
+elements:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;choice&gt;
+        &lt;attribute name=&quot;name&quot;&gt;
+          &lt;text/&gt;
+        &lt;/attribute&gt;
+        &lt;group&gt;
+          &lt;attribute name=&quot;givenName&quot;&gt;
+            &lt;text/&gt;
+          &lt;/attribute&gt;
+          &lt;attribute name=&quot;familyName&quot;&gt;
+            &lt;text/&gt;
+          &lt;/attribute&gt;
+        &lt;/group&gt;
+      &lt;/choice&gt;
+      &lt;attribute name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt class="literal">group</tt> and <tt class="literal">choice</tt>
+patterns can combine <tt class="literal">element</tt> and
+<tt class="literal">attribute</tt> patterns without restriction. For
+example, the following pattern would allow a choice of elements and
+attributes independently for both the <tt class="literal">name</tt> and the
+<tt class="literal">email</tt> part of a <tt class="literal">card</tt>:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;choice&gt;
+	&lt;element name=&quot;name&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;attribute name=&quot;name&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/attribute&gt;
+      &lt;/choice&gt;
+      &lt;choice&gt;
+	&lt;element name=&quot;email&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;attribute name=&quot;email&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/attribute&gt;
+      &lt;/choice&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>As usual, the relative order of elements is significant, but the
+relative order of attributes is not. Thus the above would match any
+of:</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;card email=&quot;js at example.com&quot; name=&quot;John Smith&quot;/&gt;
+&lt;card email=&quot;js at example.com&quot;&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;
+&lt;card name=&quot;John Smith&quot;&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;
+&lt;card&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;/card&gt;</pre><p>However, it would not match</p><pre class="programlisting">&lt;card&gt;&lt;email&gt;js at example.com&lt;/email&gt;&lt;name&gt;John Smith&lt;/name&gt;&lt;/card&gt;</pre><p>because the pattern for <tt class="literal">card</tt> requires any
+<tt class="literal">email</tt> child element to follow any <tt class="literal">name</tt> child
+element.</p><p>There is one difference between <tt class="literal">attribute</tt> and
+<tt class="literal">element</tt> patterns: <tt class="literal">&lt;text/&gt;</tt>
+is the default for the content of an <tt class="literal">attribute</tt> pattern,
+whereas an <tt class="literal">element</tt> pattern is not allowed to be
+empty. For example,</p><pre class="programlisting">&lt;attribute name=&quot;email&quot;/&gt;</pre><p>is short for</p><pre class="programlisting">&lt;attribute name=&quot;email&quot;&gt;
+  &lt;text/&gt;
+&lt;/attribute&gt;</pre><p>It might seem natural that</p><pre class="programlisting">&lt;element name=&quot;x&quot;/&gt;</pre><p>matched an <tt class="literal">x</tt> element with no attributes and no
+content.  However, this would make the meaning of empty content
+inconsistent between the <tt class="literal">element</tt> pattern and the
+<tt class="literal">attribute</tt> pattern, so RELAX NG does not allow the
+<tt class="literal">element</tt> pattern to be empty. A pattern that matches an
+element with no attributes and no children must use
+<tt class="literal">&lt;empty/&gt;</tt> explicitly:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+        &lt;element name=&quot;prefersHTML&quot;&gt;
+          &lt;empty/&gt;
+        &lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>Even if the pattern in an <tt class="literal">element</tt> pattern
+matches attributes only, there is no need to use
+<tt class="literal">empty</tt>. For example,</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;attribute name=&quot;email&quot;&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;attribute name=&quot;email&quot;&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814574"></a>4. Named patterns</h2></div></div><p>For a non-trivial RELAX NG pattern, it is often convenient to be able
+to give names to parts of the pattern.  Instead of</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>we can write</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;cardContent&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;cardContent&quot;&gt;
+    &lt;element name=&quot;name&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;email&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>A <tt class="literal">grammar</tt> element has a single <tt class="literal">start</tt>
+child element, and zero or more <tt class="literal">define</tt> child elements.
+The <tt class="literal">start</tt> and <tt class="literal">define</tt> elements contain
+patterns. These patterns can contain <tt class="literal">ref</tt> elements that
+refer to patterns defined by any of the <tt class="literal">define</tt> elements
+in that <tt class="literal">grammar</tt> element. A <tt class="literal">grammar</tt> pattern
+is matched by matching the pattern contained in the <tt class="literal">start</tt>
+element.</p><p>We can use the <tt class="literal">grammar</tt> pattern to write RELAX NG in a
+style similar to DTDs:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;ref name=&quot;AddressBook&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;AddressBook&quot;&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;Card&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;Card&quot;&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;ref name=&quot;Name&quot;/&gt;
+      &lt;ref name=&quot;Email&quot;/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;Name&quot;&gt;
+    &lt;element name=&quot;name&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;Email&quot;&gt;
+    &lt;element name=&quot;email&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Recursive references are allowed.  For example,</p><pre class="programlisting">&lt;define name=&quot;inline&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name=&quot;bold&quot;&gt;
+        &lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;italic&quot;&gt;
+        &lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;span&quot;&gt;
+        &lt;optional&gt;
+          &lt;attribute name=&quot;style&quot;/&gt;
+        &lt;/optional&gt;
+        &lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/define&gt;</pre><p>However, recursive references must be within an
+<tt class="literal">element</tt> pattern.  Thus, the following is <span class="strong">not</span>
+allowed:</p><pre class="programlisting">&lt;define name=&quot;inline&quot;&gt;
+  &lt;choice&gt;
+    &lt;text/&gt;
+    &lt;element name=&quot;bold&quot;&gt;
+      &lt;ref name=&quot;inline&quot;/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;italic&quot;&gt;
+      &lt;ref name=&quot;inline&quot;/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;span&quot;&gt;
+      &lt;optional&gt;
+	&lt;attribute name=&quot;style&quot;/&gt;
+      &lt;/optional&gt;
+      &lt;ref name=&quot;inline&quot;/&gt;
+    &lt;/element&gt;
+  &lt;/choice&gt;
+  &lt;optional&gt;
+    &lt;ref name=&quot;inline&quot;/&gt;
+  &lt;/optional&gt;
+&lt;/define&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814728"></a>5. Datatyping</h2></div></div><p>RELAX NG allows patterns to reference externally-defined
+datatypes.  RELAX NG implementations may differ in what datatypes they
+support.  You can only use datatypes that are supported by the
+implementation you plan to use. The most commonly used datatypes are
+those defined by [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>].</p><p>The <tt class="literal">data</tt> pattern matches a string that
+represents a value of a named datatype. The
+<tt class="literal">datatypeLibrary</tt> attribute contains a URI
+identifying the library of datatypes being used. The datatype
+library defined by [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] is identified by the
+URI <tt class="literal">http://www.w3.org/2001/XMLSchema-datatypes</tt>.
+The <tt class="literal">type</tt> attribute specifies the name of the
+datatype in the library identified by the
+<tt class="literal">datatypeLibrary</tt> attribute. For example, assuming the
+RELAX NG implementation supported the datatypes of
+[<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>], you could use:</p><pre class="programlisting">&lt;element name=&quot;number&quot;&gt;
+  &lt;data type=&quot;integer&quot; datatypeLibrary=&quot;http://www.w3.org/2001/XMLSchema-datatypes&quot;/&gt;
+&lt;/element&gt;</pre><p>It is inconvenient to specify the
+<tt class="literal">datatypeLibrary</tt> attribute on every
+<tt class="literal">data</tt> element, so RELAX NG allows the
+<tt class="literal">datatypeLibrary</tt> attribute to be inherited.  The
+<tt class="literal">datatypeLibrary</tt> attribute can be specified on any
+RELAX NG element.  If a <tt class="literal">data</tt> element does not have
+a <tt class="literal">datatypeLibrary</tt> attribute, it will use the
+value from the closest ancestor that has a
+<tt class="literal">datatypeLibrary</tt> attribute.  Typically, the
+<tt class="literal">datatypeLibrary</tt> attribute is specified on the
+root element of the RELAX NG pattern. For example,</p><pre class="programlisting">&lt;element name=&quot;point&quot; datatypeLibrary=&quot;http://www.w3.org/2001/XMLSchema-datatypes&quot;&gt;
+  &lt;element name=&quot;x&quot;&gt;
+    &lt;data type=&quot;double&quot;/&gt;
+  &lt;/element&gt;
+  &lt;element name=&quot;y&quot;&gt;
+    &lt;data type=&quot;double&quot;/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>If the children of an element or an attribute match a
+<tt class="literal">data</tt> pattern, then the complete content of the element or
+attribute must match that <tt class="literal">data</tt> pattern.  It is not
+permitted to have a pattern which allows part of the content to match
+a <tt class="literal">data</tt> pattern, and another part to match another
+pattern. For example, the following pattern is <span class="strong">not</span>
+allowed:</p><pre class="programlisting">&lt;element name=&quot;bad&quot;&gt;
+  &lt;data type=&quot;int&quot;/&gt;
+  &lt;element name=&quot;note&quot;&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>However, this would be fine:</p><pre class="programlisting">&lt;element name=&quot;ok&quot;&gt;
+  &lt;data type=&quot;int&quot;/&gt;
+  &lt;attribute name=&quot;note&quot;&gt;
+    &lt;text/&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>Note that this restriction does not apply to the
+<tt class="literal">text</tt> pattern.</p><p>Datatypes may have parameters. For example, a string datatype may
+have a parameter controlling the length of the string.  The parameters
+applicable to any particular datatype are determined by the datatyping
+vocabulary. In the case of [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>], the
+applicable parameters correspond to the facets defined in
+[<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] with the exception of the
+<tt class="literal">enumeration</tt> and <tt class="literal">whiteSpace</tt>
+facets. Parameters are specified by adding one or more
+<tt class="literal">param</tt> elements as children of the <tt class="literal">data</tt>
+element. For example, the following
+constrains the <tt class="literal">email</tt> element to contain a string at
+least 6 characters long and at most 127 characters long:</p><pre class="programlisting">&lt;element name=&quot;email&quot;&gt;
+  &lt;data type=&quot;string&quot;&gt;
+    &lt;param name=&quot;minLength&quot;&gt;6&lt;/param&gt;
+    &lt;param name=&quot;maxLength&quot;&gt;127&lt;/param&gt;
+  &lt;/data&gt;
+&lt;/element&gt;</pre><p>A companion document, [<a href="#guidelines"><span class="abbrev">Guidelines</span></a>], describes
+exactly how the datatypes defined in [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] can
+be used as a RELAX NG datatype library.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2814985"></a>6. Enumerations</h2></div></div><p>Many markup vocabularies have attributes whose value is constrained
+to be one of a set of specified values.  The <tt class="literal">value</tt> pattern
+matches a string that has a specified value. For example,</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;attribute name=&quot;name&quot;/&gt;
+  &lt;attribute name=&quot;email&quot;/&gt;
+  &lt;attribute name=&quot;preferredFormat&quot;&gt;
+    &lt;choice&gt;
+      &lt;value&gt;html&lt;/value&gt;
+      &lt;value&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>allows the <tt class="literal">preferredFormat</tt> attribute to have the value
+<tt class="literal">html</tt> or <tt class="literal">text</tt>.  This corresponds to the
+DTD:</p><pre class="programlisting">&lt;!DOCTYPE card [
+&lt;!ELEMENT card EMPTY&gt;
+&lt;!ATTLIST card
+  name CDATA #REQUIRED
+  email CDATA #REQUIRED
+  preferredFormat (html|text) #REQUIRED&gt;
+]&gt;</pre><p>The <tt class="literal">value</tt> pattern is not restricted to attribute
+values. For example, the following is allowed:</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;element name=&quot;name&quot;&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name=&quot;email&quot;&gt;
+    &lt;text/&gt;
+  &lt;/element&gt;
+  &lt;element name=&quot;preferredFormat&quot;&gt;
+    &lt;choice&gt;
+      &lt;value&gt;html&lt;/value&gt;
+      &lt;value&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>The prohibition against a <tt class="literal">data</tt> pattern's matching
+only part of the content of an element also applies to
+<tt class="literal">value</tt> patterns.</p><p>By default, the <tt class="literal">value</tt> pattern will consider the string
+in the pattern to match the string in the document if the two strings
+are the same after the whitespace in both strings is normalized.
+Whitespace normalization strips leading and trailing whitespace
+characters, and collapses sequences of one or more whitespace
+characters to a single space character.  This corresponds to the
+behaviour of an XML parser for an attribute that is declared as other
+than CDATA. Thus the above pattern will match any of:</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;html&quot;/&gt;
+&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;  html  &quot;/&gt;</pre><p>The way that the <tt class="literal">value</tt> pattern compares the
+pattern string with the document string can be controlled by
+specifying a <tt class="literal">type</tt> attribute and optionally a
+<tt class="literal">datatypeLibrary</tt> attribute, which identify a
+datatype in the same way as for the <tt class="literal">data</tt> pattern.
+The pattern string matches the document string if they both represent
+the same value of the specified datatype. Thus, whereas the
+<tt class="literal">data</tt> pattern matches an arbitrary value of a
+datatype, the <tt class="literal">value</tt> pattern matches a specific
+value of a datatype.</p><p>If there is no ancestor element with a
+<tt class="literal">datatypeLibrary</tt> element, the datatype library
+defaults to a built-in RELAX NG datatype library.  This provides two
+datatypes, <tt class="literal">string</tt> and <tt class="literal">token</tt>:
+<tt class="literal">token</tt> corresponds to the
+default comparison behavior of the <tt class="literal">value</tt> pattern;
+<tt class="literal">string</tt> compares strings
+without any whitespace normalization (other than the end-of-line and
+attribute value normalization automatically performed by an XML processor).  For
+example,</p><pre class="programlisting">&lt;element name=&quot;card&quot;&gt;
+  &lt;attribute name=&quot;name&quot;/&gt;
+  &lt;attribute name=&quot;email&quot;/&gt;
+  &lt;attribute name=&quot;preferredFormat&quot;&gt;
+    &lt;choice&gt;
+      &lt;value type=&quot;string&quot;&gt;html&lt;/value&gt;
+      &lt;value type=&quot;string&quot;&gt;text&lt;/value&gt;
+    &lt;/choice&gt;
+  &lt;/attribute&gt;
+&lt;/element&gt;</pre><p>will <span class="strong">not</span> match</p><pre class="programlisting">&lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot; preferredFormat=&quot;  html  &quot;/&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815195"></a>7. Lists</h2></div></div><p>The <tt class="literal">list</tt> pattern matches a whitespace-separated
+sequence of tokens; it contains a pattern that the sequence of
+individual tokens must match.  The <tt class="literal">list</tt> pattern
+splits a string into a list of strings, and then matches the resulting
+list of strings against the pattern inside the <tt class="literal">list</tt>
+pattern.</p><p>For example, suppose we want to have a <tt class="literal">vector</tt>
+element that contains two floating point numbers separated by
+whitespace.  We could use <tt class="literal">list</tt> as follows:</p><pre class="programlisting">&lt;element name=&quot;vector&quot;&gt;
+  &lt;list&gt;
+    &lt;data type=&quot;float&quot;/&gt;
+    &lt;data type=&quot;float&quot;/&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre><p>Or suppose we want the <tt class="literal">vector</tt> element to
+contain a list of one or more floating point numbers separated by
+whitespace:</p><pre class="programlisting">&lt;element name=&quot;vector&quot;&gt;
+  &lt;list&gt;
+    &lt;oneOrMore&gt;
+      &lt;data type=&quot;double&quot;/&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre><p>Or suppose we want a <tt class="literal">path</tt> element containing
+an even number of floating point numbers:</p><pre class="programlisting">&lt;element name=&quot;path&quot;&gt;
+  &lt;list&gt;
+    &lt;oneOrMore&gt;
+      &lt;data type=&quot;double&quot;/&gt;
+      &lt;data type=&quot;double&quot;/&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/list&gt;
+&lt;/element&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815274"></a>8. Interleaving</h2></div></div><p>The <tt class="literal">interleave</tt> pattern allows child elements to occur
+in any order. For example, the following would allow the
+<tt class="literal">card</tt> element to contain the <tt class="literal">name</tt> and
+<tt class="literal">email</tt> elements in any order:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;interleave&gt;
+	&lt;element name=&quot;name&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+	&lt;element name=&quot;email&quot;&gt;
+	  &lt;text/&gt;
+	&lt;/element&gt;
+      &lt;/interleave&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The pattern is called <tt class="literal">interleave</tt> because of how it
+works with patterns that match more than one element.  Suppose we want
+to write a pattern for the HTML <tt class="literal">head</tt> element which
+requires exactly one <tt class="literal">title</tt> element, at most one
+<tt class="literal">base</tt> element and zero or more <tt class="literal">style</tt>,
+<tt class="literal">script</tt>, <tt class="literal">link</tt> and <tt class="literal">meta</tt> elements
+and suppose we are writing a <tt class="literal">grammar</tt> pattern that has one
+definition for each element.  Then we could define the pattern for
+<tt class="literal">head</tt> as follows:</p><pre class="programlisting">&lt;define name=&quot;head&quot;&gt;
+  &lt;element name=&quot;head&quot;&gt;
+    &lt;interleave&gt;
+      &lt;ref name=&quot;title&quot;/&gt;
+      &lt;optional&gt;
+        &lt;ref name=&quot;base&quot;/&gt;
+      &lt;/optional&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;style&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;script&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;link&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;meta&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/interleave&gt;
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>Suppose we had a <tt class="literal">head</tt> element that contained a
+<tt class="literal">meta</tt> element, followed by a <tt class="literal">title</tt> element,
+followed by a <tt class="literal">meta</tt> element.  This would match the pattern
+because it is an interleaving of a sequence of two <tt class="literal">meta</tt>
+elements, which match the child pattern</p><pre class="programlisting">      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;meta&quot;/&gt;
+      &lt;/zeroOrMore&gt;</pre><p>and a sequence of one <tt class="literal">title</tt> element, which matches
+the child pattern</p><pre class="programlisting">      &lt;ref name=&quot;title&quot;/&gt;</pre><p>The semantics of the <tt class="literal">interleave</tt> pattern are that a
+sequence of elements matches an <tt class="literal">interleave</tt> pattern if it
+is an interleaving of sequences that match the child patterns of the
+<tt class="literal">interleave</tt> pattern.  Note that this is different from the
+<tt class="literal">&amp;</tt> connector in SGML: <tt class="literal">A* &amp; B</tt> matches
+the sequence of elements <tt class="literal">A A B</tt> or the sequence of
+elements <tt class="literal">B A A</tt> but not the sequence of elements <tt class="literal">A B
+A</tt>.</p><p>One special case of interleaving is very common:
+interleaving <tt class="literal">&lt;text/&gt;</tt> with a pattern
+<i class="replaceable"><tt>p</tt></i> represents a pattern that matches what <i class="replaceable"><tt>p</tt></i>
+matches but also allows characters to occur as children.  The
+<tt class="literal">mixed</tt> pattern is a shorthand for this.</p><pre class="programlisting">&lt;mixed&gt; <i class="replaceable"><tt>p</tt></i> &lt;/mixed&gt;</pre><p>is short for</p><pre class="programlisting">&lt;interleave&gt; &lt;text/&gt; <i class="replaceable"><tt>p</tt></i> &lt;/interleave&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2815519"></a>9. Modularity</h2></div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815526"></a>9.1. Referencing external patterns</h3></div></div><p>The <tt class="literal">externalRef</tt> pattern can be used to
+reference a pattern defined in a separate file.  The
+<tt class="literal">externalRef</tt> element has a required
+<tt class="literal">href</tt> attribute that specifies the URL of a file
+containing the pattern.  The <tt class="literal">externalRef</tt> pattern matches if
+the pattern contained in the specified URL matches. Suppose for
+example, you have a RELAX NG pattern that matches HTML inline content
+stored in <tt class="literal">inline.rng</tt>:</p><pre class="programlisting">&lt;grammar&gt;
+  &lt;start&gt;
+    &lt;ref name=&quot;inline&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;inline&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+        &lt;text/&gt;
+        &lt;element name=&quot;code&quot;&gt;
+          &lt;ref name=&quot;inline&quot;/&gt;
+        &lt;/element&gt;
+        &lt;element name=&quot;em&quot;&gt;
+          &lt;ref name=&quot;inline&quot;/&gt;
+        &lt;/element&gt;
+        &lt;!-- etc --&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+&lt;/grammar&gt;</pre><p>Then we could allow the <tt class="literal">note</tt> element to contain
+inline HTML markup by using <tt class="literal">externalRef</tt> as follows:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;optional&gt;
+	&lt;element name=&quot;note&quot;&gt;
+	  &lt;externalRef href=&quot;inline.rng&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/optional&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>For another example, suppose you have two RELAX NG patterns stored in
+files <tt class="literal">pattern1.rng</tt> and <tt class="literal">pattern2.rng</tt>. Then
+the following is a pattern that matches anything matched
+by either of those patterns:</p><pre class="programlisting">&lt;choice&gt;
+  &lt;externalRef href=&quot;pattern1.rng&quot;/&gt;
+  &lt;externalRef href=&quot;pattern2.rng&quot;/&gt;
+&lt;/choice&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2815624"></a>9.2. Combining definitions</h3></div></div><p>If a grammar contains multiple definitions with the same name,
+then the definitions must specify how they are to be combined into a
+single definition by using the <tt class="literal">combine</tt> attribute.
+The <tt class="literal">combine</tt> attribute may have the value
+<tt class="literal">choice</tt> or <tt class="literal">interleave</tt>. For
+example,</p><pre class="programlisting">&lt;define name=&quot;inline.class&quot; combine=&quot;choice&quot;&gt;
+  &lt;element name=&quot;bold&quot;&gt;
+    &lt;ref name=&quot;inline&quot;/&gt;
+  &lt;/element&gt;
+&lt;/define&gt;
+
+&lt;define name=&quot;inline.class&quot; combine=&quot;choice&quot;&gt;
+  &lt;element name=&quot;italic&quot;&gt;
+    &lt;ref name=&quot;inline&quot;/&gt;
+  &lt;/element&gt;
+&lt;/define&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;define name=&quot;inline.class&quot;&gt;
+  &lt;choice&gt;
+    &lt;element name=&quot;bold&quot;&gt;
+      &lt;ref name=&quot;inline&quot;/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;italic&quot;&gt;
+      &lt;ref name=&quot;inline&quot;/&gt;
+    &lt;/element&gt;
+  &lt;/choice&gt;
+&lt;/define&gt;</pre><p>When combining attributes, <tt class="literal">combine=&quot;interleave&quot;</tt>
+is typically used.  For example,</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;card.attlist&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;card.attlist&quot; combine=&quot;interleave&quot;&gt;
+    &lt;attribute name=&quot;name&quot;&gt;
+      &lt;text/&gt;
+    &lt;/attribute&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;card.attlist&quot; combine=&quot;interleave&quot;&gt;
+    &lt;attribute name=&quot;email&quot;&gt;
+      &lt;text/&gt;
+    &lt;/attribute&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;card.attlist&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;card.attlist&quot;&gt;
+    &lt;interleave&gt;
+      &lt;attribute name=&quot;name&quot;&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name=&quot;email&quot;&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/interleave&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>which is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;card.attlist&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;card.attlist&quot;&gt;
+    &lt;group&gt;
+      &lt;attribute name=&quot;name&quot;&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+      &lt;attribute name=&quot;email&quot;&gt;
+	&lt;text/&gt;
+      &lt;/attribute&gt;
+    &lt;/group&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>since combining attributes with <tt class="literal">interleave</tt>
+has the same effect as combining them with
+<tt class="literal">group</tt>.</p><p>It is an error for two definitions of the same name to specify
+different values for <tt class="literal">combine</tt>. Note that the order
+of definitions within a grammar is not significant.</p><p>Multiple <tt class="literal">start</tt> elements can be combined in
+the same way as multiple definitions.</p></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2813894"></a>9.3. Merging grammars</h3></div></div><p>The <tt class="literal">include</tt> element allows grammars to be
+merged together. A <tt class="literal">grammar</tt> pattern may have
+<tt class="literal">include</tt> elements as children.  An
+<tt class="literal">include</tt> element has a required
+<tt class="literal">href</tt> attribute that specifies the URL of a file
+containing a <tt class="literal">grammar</tt> pattern.  The definitions in
+the referenced <tt class="literal">grammar</tt> pattern will be included in
+<tt class="literal">grammar</tt> pattern containing the
+<tt class="literal">include</tt> element.</p><p>The <tt class="literal">combine</tt> attribute is particularly useful
+in conjunction with <tt class="literal">include</tt>.  For example, suppose
+a RELAX NG pattern <tt class="literal">inline.rng</tt> provides a pattern
+for inline content, which allows <tt class="literal">bold</tt> and
+<tt class="literal">italic</tt> elements arbitrarily nested:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name=&quot;inline&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name=&quot;inline.class&quot;/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;inline.class&quot;&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name=&quot;bold&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;italic&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Another RELAX NG pattern could use <tt class="literal">inline.rng</tt>
+and add <tt class="literal">code</tt> and <tt class="literal">em</tt> to the set
+of inline elements as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href=&quot;inline.rng&quot;/&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;doc&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;p&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;inline.class&quot; combine=&quot;choice&quot;&gt;
+    &lt;choice&gt;
+      &lt;element name=&quot;code&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;em&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre><p>This would be equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name=&quot;inline&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name=&quot;inline.class&quot;/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;inline.class&quot;&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name=&quot;bold&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;italic&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;doc&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;p&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;inline.class&quot; combine=&quot;choice&quot;&gt;
+    &lt;choice&gt;
+      &lt;element name=&quot;code&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;em&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre><p>which is equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name=&quot;inline&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;ref name=&quot;inline.class&quot;/&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;inline.class&quot;&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name=&quot;bold&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;italic&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;code&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;em&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;doc&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;p&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+&lt;/grammar&gt;</pre><p>Note that it is allowed for one of the definitions of a name to
+omit the <tt class="literal">combine</tt> attribute.  However, it is an
+error if there is more than one definition that does so.</p><p>The <tt class="literal">notAllowed</tt> pattern is useful when merging
+grammars. The <tt class="literal">notAllowed</tt> pattern never matches
+anything.  Just as adding <tt class="literal">empty</tt> to a
+<tt class="literal">group</tt> makes no difference, so adding
+<tt class="literal">notAllowed</tt> to a <tt class="literal">choice</tt> makes no
+difference.  It is typically used to allow an including pattern to
+specify additional choices with <tt class="literal">combine=&quot;choice&quot;</tt>.
+For example, if <tt class="literal">inline.rng</tt> were written like
+this:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;define name=&quot;inline&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+	&lt;text/&gt;
+	&lt;element name=&quot;bold&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+	&lt;element name=&quot;italic&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+	&lt;ref name=&quot;inline.extra&quot;/&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;inline.extra&quot;&gt;
+    &lt;notAllowed/&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>then it could be customized to allow inline
+<tt class="literal">code</tt> and <tt class="literal">em</tt> elements as
+follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href=&quot;inline.rng&quot;/&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;doc&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;p&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;inline.extra&quot; combine=&quot;choice&quot;&gt;
+    &lt;choice&gt;
+      &lt;element name=&quot;code&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;em&quot;&gt;
+	&lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/define&gt;
+  
+&lt;/grammar&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816167"></a>9.4. Replacing definitions</h3></div></div><p>RELAX NG allows <tt class="literal">define</tt> elements to be put
+inside the <tt class="literal">include</tt> element to indicate that they
+are to replace definitions in the included <tt class="literal">grammar</tt>
+pattern.</p><p>Suppose the file <tt class="literal">addressBook.rng</tt>
+contains:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;cardContent&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;cardContent&quot;&gt;
+    &lt;element name=&quot;name&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;email&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Suppose we wish to modify this pattern so that the
+<tt class="literal">card</tt> element contains an
+<tt class="literal">emailAddress</tt> element instead of an
+<tt class="literal">email</tt> element. Then we could replace the definition
+of <tt class="literal">cardContent</tt> as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;include href=&quot;addressBook.rng&quot;&gt;
+
+    &lt;define name=&quot;cardContent&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;emailAddress&quot;&gt;
+	&lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/define&gt;
+
+  &lt;/include&gt;
+
+&lt;/grammar&gt;</pre><p>This would be equivalent to</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;addressBook&quot;&gt;
+      &lt;zeroOrMore&gt;
+	&lt;element name=&quot;card&quot;&gt;
+	  &lt;ref name=&quot;cardContent&quot;/&gt;
+	&lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;cardContent&quot;&gt;
+    &lt;element name=&quot;name&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+    &lt;element name=&quot;emailAddress&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>An <tt class="literal">include</tt> element can also contain a
+<tt class="literal">start</tt> element, which replaces the
+<tt class="literal">start</tt> in the included grammar pattern.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816290"></a>10. Namespaces</h2></div></div><p>RELAX NG is namespace-aware. Thus, it considers an element or attribute
+to have both a local name and a namespace URI which together
+constitute the name of that element or attribute.</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816305"></a>10.1. Using the <tt class="literal">ns</tt> attribute</h3></div></div><p>The <tt class="literal">element</tt> pattern uses an <tt class="literal">ns</tt> attribute
+to specify the namespace URI of the elements that it matches.  For
+example,</p><pre class="programlisting">&lt;element name=&quot;foo&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre><p>would match any of:</p><pre class="programlisting">&lt;foo xmlns=&quot;http://www.example.com&quot;/&gt;
+&lt;e:foo xmlns:e=&quot;http://www.example.com&quot;/&gt;
+&lt;example:foo xmlns:example=&quot;http://www.example.com&quot;/&gt;</pre><p>but not any of:</p><pre class="programlisting">&lt;foo/&gt;
+&lt;e:foo xmlns:e=&quot;http://WWW.EXAMPLE.COM&quot;/&gt;
+&lt;example:foo xmlns:example=&quot;http://www.example.net&quot;/&gt;</pre><p>A value of an empty string for the <tt class="literal">ns</tt> attribute
+indicates a null or absent namespace URI (just as with the
+<tt class="literal">xmlns</tt> attribute).  Thus, the pattern</p><pre class="programlisting">&lt;element name=&quot;foo&quot; ns=&quot;&quot;&gt;
+  &lt;empty/&gt;
+&lt;/element&gt;</pre><p>matches any of:</p><pre class="programlisting">&lt;foo xmlns=&quot;&quot;/&gt;
+&lt;foo/&gt;</pre><p>but not any of:</p><pre class="programlisting">&lt;foo xmlns=&quot;http://www.example.com&quot;/&gt;
+&lt;e:foo xmlns:e=&quot;http://www.example.com&quot;/&gt;</pre><p>It is tedious and error-prone to specify the <tt class="literal">ns</tt>
+attribute on every <tt class="literal">element</tt>, so RELAX NG allows it to be
+defaulted.  If an <tt class="literal">element</tt> pattern does not specify an
+<tt class="literal">ns</tt> attribute, then it defaults to the value of the
+<tt class="literal">ns</tt> attribute of the nearest ancestor that has an
+<tt class="literal">ns</tt> attribute, or the empty string if there is no such
+ancestor. Thus,</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot; ns=&quot;&quot;&gt;
+      &lt;element name=&quot;name&quot; ns=&quot;&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot; ns=&quot;&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>and</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot; ns=&quot;http://www.example.com&quot;&gt;
+      &lt;element name=&quot;name&quot; ns=&quot;http://www.example.com&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot; ns=&quot;http://www.example.com&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>The <tt class="literal">attribute</tt> pattern also takes an
+<tt class="literal">ns</tt> attribute.  However, there is a
+difference in how it defaults.  This is because of the fact that the
+XML Namespaces Recommendation does not apply the default namespace to
+attributes.  If an <tt class="literal">ns</tt> attribute is not
+specified on the <tt class="literal">attribute</tt> pattern, then it
+defaults to the empty string. Thus,</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;attribute name=&quot;name&quot;/&gt;
+      &lt;attribute name=&quot;email&quot;/&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot; ns=&quot;http://www.example.com&quot;&gt;
+      &lt;attribute name=&quot;name&quot; ns=&quot;&quot;/&gt;
+      &lt;attribute name=&quot;email&quot; ns=&quot;&quot;/&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>and so will match</p><pre class="programlisting">&lt;addressBook xmlns=&quot;http://www.example.com&quot;&gt;
+  &lt;card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;/addressBook&gt;</pre><p>or</p><pre class="programlisting">&lt;example:addressBook xmlns:example=&quot;http://www.example.com&quot;&gt;
+  &lt;example:card name=&quot;John Smith&quot; email=&quot;js at example.com&quot;/&gt;
+&lt;/example:addressBook&gt;</pre><p>but not</p><pre class="programlisting">&lt;example:addressBook xmlns:example=&quot;http://www.example.com&quot;&gt;
+  &lt;example:card example:name=&quot;John Smith&quot; example:email=&quot;js at example.com&quot;/&gt;
+&lt;/example:addressBook&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2816564"></a>10.2. Qualified names</h3></div></div><p>When a pattern matches elements and attributes from multiple
+namespaces, using the <tt class="literal">ns</tt> attribute would require
+repeating namespace URIs in different places in the pattern.  This is
+error-prone and hard to maintain, so RELAX NG also allows the
+<tt class="literal">element</tt> and <tt class="literal">attribute</tt> patterns to use a
+prefix in the value of the <tt class="literal">name</tt> attribute to specify the
+namespace URI. In this case, the prefix specifies the namespace URI to
+which that prefix is bound by the namespace declarations in scope on
+the <tt class="literal">element</tt> or <tt class="literal">attribute</tt> pattern. Thus,</p><pre class="programlisting">&lt;element name=&quot;ab:addressBook&quot; xmlns:ab=&quot;http://www.example.com/addressBook&quot;
+                               xmlns:a=&quot;http://www.example.com/address&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;ab:card&quot;&gt;
+      &lt;element name=&quot;a:name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;a:email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>is equivalent to</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; ns=&quot;http://www.example.com/addressBook&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot; ns=&quot;http://www.example.com/addressBook&quot;&gt;
+      &lt;element name=&quot;name&quot; ns=&quot;http://www.example.com/address&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot; ns=&quot;http://www.example.com/address&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>If a prefix is specified in the value of the <tt class="literal">name</tt>
+attribute of an <tt class="literal">element</tt> or <tt class="literal">attribute</tt>
+pattern, then that prefix determines the namespace URI of the elements
+or attributes that will be matched by that pattern, regardless of
+the value of any <tt class="literal">ns</tt> attribute.</p><p>Note that the XML default namespace (as specified by the
+<tt class="literal">xmlns</tt> attribute) is not used in determining the namespace
+URI of elements and attributes that <tt class="literal">element</tt> and
+<tt class="literal">attribute</tt> patterns match.</p></div></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816679"></a>11. Name classes</h2></div></div><p>Normally, the name of the element to be matched by an
+<tt class="literal">element</tt> element is specified by a <tt class="literal">name</tt>
+attribute.  An <tt class="literal">element</tt> element can instead start with an
+element specifying a <span class="emphasis"><em>name-class</em></span>.  In this case, the
+<tt class="literal">element</tt> pattern will only match an element if the name of
+the element is a member of the name-class.  The simplest name-class is
+<tt class="literal">anyName</tt>, which any name at all is a member of, regardless
+of its local name and its namespace URI.  For example, the following
+pattern matches any well-formed XML document:</p><pre class="programlisting">&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;ref name=&quot;anyElement&quot;/&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;anyElement&quot;&gt;
+    &lt;element&gt;
+      &lt;anyName/&gt;
+      &lt;zeroOrMore&gt;
+	&lt;choice&gt;
+	  &lt;attribute&gt;
+	    &lt;anyName/&gt;
+	  &lt;/attribute&gt;
+	  &lt;text/&gt;
+	  &lt;ref name=&quot;anyElement&quot;/&gt;
+	&lt;/choice&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>The <tt class="literal">nsName</tt> name-class contains any
+name with the namespace URI specified by the
+<tt class="literal">ns</tt> attribute, which defaults in the same way
+as the <tt class="literal">ns</tt> attribute on the
+<tt class="literal">element</tt> pattern.</p><p>The <tt class="literal">choice</tt> name-class matches any name that is a
+member of any of its child name-classes.</p><p>The <tt class="literal">anyName</tt> and <tt class="literal">nsName</tt>
+name-classes can contain an <tt class="literal">except</tt> clause. For
+example,</p><pre class="programlisting">&lt;element name=&quot;card&quot; ns=&quot;http://www.example.com&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName&gt;
+        &lt;except&gt;
+          &lt;nsName/&gt;
+          &lt;nsName ns=&quot;&quot;/&gt;
+        &lt;/except&gt;
+      &lt;/anyName&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;text/&gt;
+&lt;/element&gt;</pre><p>would allow the <tt class="literal">card</tt> element to have any number of
+namespace-qualified attributes provided that they were qualified with
+namespace other than that of the <tt class="literal">card</tt> element.</p><p>Note that an <tt class="literal">attribute</tt> pattern matches a single
+attribute even if it has a name-class that contains multiple names.
+To match zero or more attributes, the <tt class="literal">zeroOrMore</tt> element
+must be used.</p><p>The <tt class="literal">name</tt> name-class contains a single name.
+The content of the <tt class="literal">name</tt> element specifies the name
+in the same way as the <tt class="literal">name</tt> attribute of the
+<tt class="literal">element</tt> pattern.  The <tt class="literal">ns</tt>
+attribute specifies the namespace URI in the same way as the
+<tt class="literal">element</tt> pattern.</p><p>Some schema languages have a concept of <span class="emphasis"><em>lax</em></span> validation,
+where an element or attribute is validated against a definition only
+if there is one.  We can implement this concept in RELAX NG with name
+classes that use <tt class="literal">except</tt> and <tt class="literal">name</tt>.
+Suppose, for example, we wanted to allow an element to have any
+attribute with a qualified name, but we still wanted to ensure that if
+there was an <tt class="literal">xml:space</tt> attribute, it had the value
+<tt class="literal">default</tt> or <tt class="literal">preserve</tt>.  It wouldn't work to
+use</p><pre class="programlisting">&lt;element name=&quot;example&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName/&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;optional&gt;
+    &lt;attribute name=&quot;xml:space&quot;&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;
+  &lt;/optional&gt;
+&lt;/element&gt;</pre><p>because an <tt class="literal">xml:space</tt> attribute with a value
+other than <tt class="literal">default</tt> or <tt class="literal">preserve</tt>
+would match</p><pre class="programlisting">    &lt;attribute&gt;
+      &lt;anyName/&gt;
+    &lt;/attribute&gt;</pre><p>even though it did not match</p><pre class="programlisting">    &lt;attribute name=&quot;xml:space&quot;&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;</pre><p>The solution is to use <tt class="literal">name</tt> together with
+<tt class="literal">except</tt>:</p><pre class="programlisting">&lt;element name=&quot;example&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;attribute&gt;
+      &lt;anyName&gt;
+        &lt;except&gt;
+          &lt;name&gt;xml:space&lt;/name&gt;
+        &lt;/except&gt;
+      &lt;/anyName&gt;
+    &lt;/attribute&gt;
+  &lt;/zeroOrMore&gt;
+  &lt;optional&gt;
+    &lt;attribute name=&quot;xml:space&quot;&gt;
+      &lt;choice&gt;
+        &lt;value&gt;default&lt;/value&gt;
+        &lt;value&gt;preserve&lt;/value&gt;
+      &lt;/choice&gt;
+    &lt;/attribute&gt;
+  &lt;/optional&gt;
+&lt;/element&gt;</pre><p>Note that the <tt class="literal">define</tt> element cannot contain a
+name-class; it can only contain a pattern.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2816970"></a>12. Annotations</h2></div></div><p>If a RELAX NG element has an attribute or child element with a
+namespace URI other than the RELAX NG namespace, then that attribute or
+element is ignored.  Thus, you can add annotations to RELAX NG patterns
+simply by using an attribute or element in a separate namespace:</p><pre class="programlisting">&lt;element name=&quot;addressBook&quot; xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot; xmlns:a=&quot;http://www.example.com/annotation&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;element name=&quot;card&quot;&gt;
+      &lt;a:documentation&gt;Information about a single email address.&lt;/a:documentation&gt;
+      &lt;element name=&quot;name&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+      &lt;element name=&quot;email&quot;&gt;
+        &lt;text/&gt;
+      &lt;/element&gt;
+    &lt;/element&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/element&gt;</pre><p>RELAX NG also provides a <tt class="literal">div</tt> element which
+allows an annotation to be applied to a group of definitions in a
+grammar.  For example, you might want to divide up the definitions of
+the grammar into modules:</p><pre class="programlisting">&lt;grammar xmlns:m=&quot;http://www.example.com/module&quot;&gt;
+
+  &lt;div m:name=&quot;inline&quot;&gt;
+
+    &lt;define name=&quot;code&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name=&quot;em&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name=&quot;var&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+
+  &lt;/div&gt;
+
+  &lt;div m:name=&quot;block&quot;&gt;
+
+    &lt;define name=&quot;p&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name=&quot;ul&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+    &lt;define name=&quot;ol&quot;&gt; <i class="replaceable"><tt>pattern</tt></i> &lt;/define&gt;
+
+  &lt;/div&gt;
+
+&lt;/grammar&gt;</pre><p>This would allow you easily to generate variants of the grammar
+based on a selection of modules.</p><p>A companion specification, RELAX NG DTD Compatibility
+[<a href="#compat"><span class="abbrev">Compatibility</span></a>], defines annotations to implement
+some features of XML DTDs.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817066"></a>13. Nested grammars</h2></div></div><p>There is no prohibition against nesting grammar patterns.  A
+<tt class="literal">ref</tt> pattern refers to the definition from the nearest
+<tt class="literal">grammar</tt> ancestor. There is also a
+<tt class="literal">parentRef</tt> pattern that escapes out of the current
+grammar and references a definition from the parent of the current
+grammar.</p><p>Imagine the problem of writing a pattern for tables.  The pattern
+for tables only cares about the structure of tables; it doesn't care
+about what goes inside a table cell.  First, we create a RELAX NG pattern
+<tt class="literal">table.rng</tt> as follows:</p><pre class="programlisting">&lt;grammar&gt;
+
+&lt;define name=&quot;cell.content&quot;&gt;
+  &lt;notAllowed/&gt;
+&lt;/define&gt;
+
+&lt;start&gt;
+  &lt;element name=&quot;table&quot;&gt;
+    &lt;oneOrMore&gt;
+      &lt;element name=&quot;tr&quot;&gt;
+        &lt;oneOrMore&gt;
+	  &lt;element name=&quot;td&quot;&gt;
+	    &lt;ref name=&quot;cell.content&quot;/&gt;
+	  &lt;/element&gt;
+        &lt;/oneOrMore&gt;
+      &lt;/element&gt;
+    &lt;/oneOrMore&gt;
+  &lt;/element&gt;
+&lt;/start&gt;
+
+&lt;/grammar&gt;</pre><p>Patterns that include <tt class="literal">table.rng</tt> must redefine
+<tt class="literal">cell.content</tt>. By using a nested
+<tt class="literal">grammar</tt> pattern containing a
+<tt class="literal">parentRef</tt> pattern, the including pattern can
+redefine <tt class="literal">cell.content</tt> to be a pattern defined in
+the including pattern's grammar, thus effectively importing a pattern
+from the parent grammar into the child grammar:</p><pre class="programlisting">&lt;grammar&gt;
+
+&lt;start&gt;
+  &lt;element name=&quot;doc&quot;&gt;
+    &lt;zeroOrMore&gt;
+      &lt;choice&gt;
+	&lt;element name=&quot;p&quot;&gt;
+	  &lt;ref name=&quot;inline&quot;/&gt;
+	&lt;/element&gt;
+	&lt;grammar&gt;
+	  &lt;include href=&quot;table.rng&quot;&gt;
+	    &lt;define name=&quot;cell.content&quot;&gt;
+	      &lt;parentRef name=&quot;inline&quot;/&gt;
+	    &lt;/define&gt;
+          &lt;/include&gt;
+	&lt;/grammar&gt;
+      &lt;/choice&gt;
+    &lt;/zeroOrMore&gt;
+  &lt;/element&gt;
+&lt;/start&gt;
+
+&lt;define name=&quot;inline&quot;&gt;
+  &lt;zeroOrMore&gt;
+    &lt;choice&gt;
+      &lt;text/&gt;
+      &lt;element name=&quot;em&quot;&gt;
+        &lt;ref name=&quot;inline&quot;/&gt;
+      &lt;/element&gt;
+    &lt;/choice&gt;
+  &lt;/zeroOrMore&gt;
+&lt;/define&gt;
+
+&lt;/grammar&gt;</pre><p>Of course, in a trivial case like this, there is no advantage in
+nesting the grammars: we could simply have included
+<tt class="literal">table.rng</tt> within the outer <tt class="literal">grammar</tt> pattern.
+However, when the included grammar has many definitions, nesting it
+avoids the possibility of name conflicts between the including grammar
+and the included grammar.</p></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817179"></a>14. Non-restrictions</h2></div></div><p>RELAX NG does not require patterns to be &quot;deterministic&quot; or
+&quot;unambiguous&quot;.</p><p>Suppose we wanted to write the email address book in HTML, but use
+class attributes to specify the structure:</p><pre class="programlisting">&lt;element name=&quot;html&quot;&gt;
+  &lt;element name=&quot;head&quot;&gt;
+    &lt;element name=&quot;title&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/element&gt;
+  &lt;element name=&quot;body&quot;&gt;
+    &lt;element name=&quot;table&quot;&gt;
+      &lt;attribute name=&quot;class&quot;&gt;
+        &lt;value&gt;addressBook&lt;/value&gt;
+      &lt;/attribute&gt;
+      &lt;oneOrMore&gt;
+        &lt;element name=&quot;tr&quot;&gt;
+	  &lt;attribute name=&quot;class&quot;&gt;
+	    &lt;value&gt;card&lt;/value&gt;
+	  &lt;/attribute&gt;
+          &lt;element name=&quot;td&quot;&gt;
+	    &lt;attribute name=&quot;class&quot;&gt;
+	      &lt;value&gt;name&lt;/value&gt;
+	    &lt;/attribute&gt;
+            &lt;mixed&gt;
+              &lt;optional&gt;
+                &lt;element name=&quot;span&quot;&gt;
+                  &lt;attribute name=&quot;class&quot;&gt;
+                    &lt;value&gt;givenName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+              &lt;optional&gt;
+                &lt;element name=&quot;span&quot;&gt;
+                  &lt;attribute name=&quot;class&quot;&gt;
+                    &lt;value&gt;familyName&lt;/value&gt;
+                  &lt;/attribute&gt;
+                  &lt;text/&gt;
+                &lt;/element&gt;
+              &lt;/optional&gt;
+            &lt;/mixed&gt;
+          &lt;/element&gt;
+          &lt;element name=&quot;td&quot;&gt;
+	    &lt;attribute name=&quot;class&quot;&gt;
+	      &lt;value&gt;email&lt;/value&gt;
+	    &lt;/attribute&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/element&gt;
+      &lt;/oneOrMore&gt;
+    &lt;/element&gt;
+  &lt;/element&gt;
+&lt;/element&gt;</pre><p>This would match a document such as:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class=&quot;addressBook&quot;&gt;
+      &lt;tr class=&quot;card&quot;&gt;
+        &lt;td class=&quot;name&quot;&gt;
+          &lt;span class=&quot;givenName&quot;&gt;John&lt;/span&gt;
+          &lt;span class=&quot;familyName&quot;&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class=&quot;email&quot;&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre><p>but not:</p><pre class="programlisting">&lt;html&gt;
+  &lt;head&gt;
+    &lt;title&gt;Example Address Book&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;table class=&quot;addressBook&quot;&gt;
+      &lt;tr class=&quot;card&quot;&gt;
+        &lt;td class=&quot;name&quot;&gt;
+          &lt;span class=&quot;givenName&quot;&gt;John&lt;/span&gt;
+          &lt;!-- Note the incorrect class attribute --&gt;
+          &lt;span class=&quot;givenName&quot;&gt;Smith&lt;/span&gt;
+        &lt;/td&gt;
+        &lt;td class=&quot;email&quot;&gt;js at example.com&lt;/td&gt;
+      &lt;/tr&gt;
+    &lt;/table&gt;
+  &lt;/body&gt;
+&lt;/html&gt;</pre></div><div class="section" lang="en"><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="id2817227"></a>15. Further information</h2></div></div><p>The definitive specification of RELAX NG is [<a href="#spec"><span class="abbrev">Specification</span></a>], which uses the XML syntax.  [<a href="#compact"><span class="abbrev">Compact</span></a>] is the definitive specification for the compact
+syntax, which defines the compact syntax by mapping it to the XML
+syntax.</p><p>A tutorial for the compact syntax is available
+separately [<a href="#compact-tutorial"><span class="abbrev">Compact Tutorial</span></a>].</p><p>[<a href="#guidelines"><span class="abbrev">Guidelines</span></a>] defines how to use the datatypes
+defined in [<a href="#xmlschema-2"><span class="abbrev">W3C XML Schema Datatypes</span></a>] as a RELAX NG datatype
+library.</p></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="id2817313"></a>A. Comparison with XML DTDs</h2><p>RELAX NG provides functionality that goes beyond XML DTDs. In
+particular, RELAX NG</p><div class="itemizedlist"><ul type="disc"><li><a name="id2817329"></a>provides a choice of an XML syntax or a compact
+non-XML syntax to represent schemas</li><li><a name="id2817336"></a>supports datatyping</li><li><a name="id2817341"></a>integrates attributes into content
+models</li><li><a name="id2817347"></a>supports XML namespaces</li><li><a name="id2817353"></a>supports unordered content</li><li><a name="id2817359"></a>supports context-sensitive content
+models</li></ul></div><p>ID/IDREF validation is not provided by RELAX NG; however, it is
+provided by a companion specification, RELAX NG DTD Compatibility
+[<a href="#compat"><span class="abbrev">Compatibility</span></a>].  Comprehensive support for
+cross-reference checking is planned for a future specification.</p><p>RELAX NG does not support features of XML DTDs that involve
+changing the infoset of an XML document.  In particular, RELAX
+NG</p><div class="itemizedlist"><ul type="disc"><li><a name="id2817390"></a>does not allow defaults for attributes to be
+specified; however, this is allowed by RELAX NG DTD Compatibility
+[<a href="#compat"><span class="abbrev">Compatibility</span></a>]</li><li><a name="id2817402"></a>does not allow entities to be specified</li><li><a name="id2817407"></a>does not allow notations to be specified</li><li><a name="id2817413"></a>does not specify whether whitespace is significant</li></ul></div><p>Also, whereas an XML document can associate itself with a DTD
+using a <tt class="literal">DOCTYPE</tt> declaration,
+RELAX NG does not define a way for an XML document to associate
+itself with a RELAX NG pattern.</p></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="id2817433"></a>B. Comparison with RELAX Core</h2><p>Any description in RELAX Core can be directly captured in RELAX
+NG without loss of information.</p><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817447"></a>1. Mapping RELAX NG to RELAX Core</h3></div></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817454"></a>1.1. <tt class="literal">elementRule</tt>-<tt class="literal">tag</tt> pairs</h4></div></div><p>An <tt class="literal">elementRule</tt> as well as the referenced
+<tt class="literal">tag</tt> element is typically captured by a
+<tt class="literal">define</tt> element containing an
+<tt class="literal">element</tt> element as the child.</p><p>An <tt class="literal">elementRule</tt>-<tt class="literal">tag</tt> pair 
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;elementRule role=&quot;foo&quot; label=&quot;bar&quot;&gt;
+  <i class="replaceable"><tt>hedge model</tt></i>
+&lt;/elementRule&gt;
+</pre><pre class="programlisting">
+&lt;tag role=&quot;foo&quot; name=&quot;baz&quot;&gt;
+  <i class="replaceable"><tt>attribute declarations</tt></i>
+&lt;/tag&gt;
+</pre><p>A rewrite in RELAX NG is shown below:</p><pre class="programlisting">
+&lt;define name=&quot;bar&quot;&gt;
+  &lt;element name=&quot;baz&quot;&gt;
+    <i class="replaceable"><tt>hedge model</tt></i>
+    <i class="replaceable"><tt>attribute declarations</tt></i>
+  &lt;/element&gt;
+&lt;/define&gt;
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817543"></a>1.2. <tt class="literal">hedgeRule</tt></h4></div></div><p>A <tt class="literal">hedgeRule</tt> element is captured by a
+<tt class="literal">define</tt> element containing attribute
+declarations.</p><p>A <tt class="literal">hedgeRule</tt> element
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;hedgeRule label=&quot;bar&quot;&gt;
+  <i class="replaceable"><tt>hedge model</tt></i>
+&lt;/hedgeRule&gt;
+</pre><p>A rewrite in RELAX NG is:</p><pre class="programlisting">
+&lt;define name=&quot;bar&quot;&gt;
+  <i class="replaceable"><tt>hedge model</tt></i>
+&lt;/define&gt;
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817597"></a>1.3. <tt class="literal">attPool</tt></h4></div></div><p>An <tt class="literal">attPool</tt> element
+in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;attPool role=&quot;foo&quot;&gt;
+  <i class="replaceable"><tt>attribute declarations</tt></i>
+&lt;/attPool&gt;
+</pre><p>A rewrite in RELAX NG is</p><pre class="programlisting">
+&lt;define name=&quot;foo&quot;&gt;
+  <i class="replaceable"><tt>attribute declarations</tt></i>
+&lt;/define&gt;
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817638"></a>1.4. Hedge models</h4></div></div><p>Mapping of hedge models in RELAX Core to RELAX NG is summarized below:
+</p><div class="orderedlist"><ol type="1"><li><a name="id2817654"></a>
+<tt class="literal">occurs=&quot;*&quot;</tt> in RELAX Core 
+is captured by
+<tt class="literal">&lt;zeroOrMore&gt;...&lt;/zeroOrMore&gt;</tt>.
+</li><li><a name="id2817669"></a>
+<tt class="literal">occurs=&quot;+&quot;</tt> in RELAX Core 
+is captured by
+<tt class="literal">&lt;oneOrMore&gt;...&lt;/oneOrMore&gt;</tt>
+</li><li><a name="id2817685"></a>
+<tt class="literal">occurs=&quot;?&quot;</tt> in RELAX Core 
+is captured by
+<tt class="literal">&lt;optional&gt;...&lt;/optional&gt;</tt>
+</li><li><a name="id2817700"></a>
+<tt class="literal">&lt;mixed&gt;...&lt;/mixed&gt;</tt> in
+RELAX Core is captured by
+<tt class="literal">&lt;mixed&gt;...&lt;/mixed&gt;</tt>
+</li><li><a name="id2817716"></a>
+<tt class="literal">&lt;ref label=&quot;...&quot;/&gt;</tt> in
+RELAX Core is captured by
+<tt class="literal">&lt;ref name=&quot;...&quot;/&gt;</tt>.
+</li><li><a name="id2817731"></a>
+<tt class="literal">&lt;hedgeRef label=&quot;...&quot;/&gt;</tt> in
+RELAX Core is captured by
+<tt class="literal">&lt;ref name=&quot;...&quot;/&gt;</tt>
+</li></ol></div></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817748"></a>1.5. Attribute declarations</h4></div></div><p>Both languages use <tt class="literal">attribute</tt>.  However, in
+RELAX Core, an <tt class="literal">attribute</tt> without
+<tt class="literal">required=&quot;true&quot;</tt> declares a defaultable attribute.  
+On the other hand, in RELAX NG, a defaultable attribute has to 
+be declared by an <tt class="literal">attribute</tt> pattern within 
+an <tt class="literal">optional</tt> element.</p><p>Declaration of a required attribute in RELAX Core is shown below:</p><pre class="programlisting">
+&lt;attribute name=&quot;foo&quot; type=&quot;integer&quot; required=&quot;true&quot;/&gt;
+</pre><p>In RELAX NG, this is captured by:</p><pre class="programlisting">
+&lt;attribute name=&quot;foo&quot;&gt;
+  &lt;data type=&quot;integer&quot;/&gt;
+&lt;/attribute&gt;
+</pre><p>Declaration of an optional attribute in RELAX Core is shown
+below:</p><pre class="programlisting">
+&lt;attribute name=&quot;foo&quot; type=&quot;integer&quot;/&gt;
+</pre><p>In RELAX NG, this is captured by:</p><pre class="programlisting">
+&lt;optional&gt;
+  &lt;attribute name=&quot;foo&quot;&gt;
+    &lt;data type=&quot;integer&quot;/&gt;
+  &lt;/attribute&gt;
+&lt;/optional&gt;
+</pre></div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817827"></a>2. Examples</h3></div></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817835"></a>2.1. Ancestor-and-sibling-sensitive content models</h4></div></div><p>Here is a rewrite of an example in <a href="http://www.xml.gr.jp/relax/html4/howToRELAX_p1_c8_en.html" target="_top">STEP
+7</a> of &quot;HOW TO RELAX&quot;.  The first paragraph cannot contain
+footnotes, but the other paragraphs can.</p><pre class="programlisting">
+&lt;grammar&gt;
+  &lt;start&gt;
+    &lt;element name=&quot;doc&quot;&gt;
+      &lt;ref name=&quot;paraWithoutFNotes&quot;/&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;paraWithFNotes&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;paraWithoutFNotes&quot;&gt;
+    &lt;element name=&quot;para&quot;&gt;
+      &lt;text/&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;paraWithFNotes&quot;&gt;
+    &lt;element name=&quot;para&quot;&gt;
+      &lt;mixed&gt;
+        &lt;zeroOrMore&gt;
+          &lt;element name=&quot;fnote&quot;&gt;
+            &lt;text/&gt;
+          &lt;/element&gt;
+        &lt;/zeroOrMore&gt;
+      &lt;/mixed&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre><p>The following document matches this pattern:</p><pre class="programlisting">
+&lt;doc&gt;&lt;para/&gt;&lt;para&gt;&lt;fnote/&gt;&lt;/para&gt;&lt;/doc&gt;
+</pre><p>On the other hand, the following document does not:</p><pre class="programlisting">
+&lt;doc&gt;&lt;para&gt;&lt;fnote/&gt;&lt;/para&gt;&lt;/doc&gt;
+</pre></div><div class="section" lang="en"><div class="titlepage"><div><h4 class="title"><a name="id2817896"></a>2.2. Attribute-sensitive content model</h4></div></div><p>Here is a rewrite of an example in <a href="http://www.xml.gr.jp/relax/html4/howToRELAX_p1_c9_en.html" target="_top">STEP
+8</a> of &quot;HOW TO RELAX&quot;.  This pattern assigns different content
+models for the same tag name <tt class="literal">div</tt> depending on the
+value of the attribute <tt class="literal">class</tt>.</p><pre class="programlisting">
+&lt;grammar&gt;
+
+  &lt;start&gt;
+    &lt;element name=&quot;html&quot;&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;section&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/start&gt;
+
+  &lt;define name=&quot;section&quot;&gt;
+    &lt;element name=&quot;div&quot;&gt;
+      &lt;attribute name=&quot;class&quot;&gt;&lt;value&gt;section&lt;/value&gt;&lt;/attribute&gt;
+      &lt;zeroOrMore&gt;
+        &lt;element name=&quot;para&quot;&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+      &lt;zeroOrMore&gt;
+        &lt;ref name=&quot;subsection&quot;/&gt;
+      &lt;/zeroOrMore&gt;
+   &lt;/element&gt;
+  &lt;/define&gt;
+
+  &lt;define name=&quot;subsection&quot;&gt;
+    &lt;element name=&quot;div&quot;&gt;
+      &lt;attribute name=&quot;class&quot;&gt;&lt;value&gt;subsection&lt;/value&gt;&lt;/attribute&gt;
+      &lt;zeroOrMore&gt;
+        &lt;element name=&quot;para&quot;&gt;
+          &lt;text/&gt;
+        &lt;/element&gt;
+      &lt;/zeroOrMore&gt;
+    &lt;/element&gt;
+  &lt;/define&gt;
+
+&lt;/grammar&gt;
+</pre><p>The following document matches this pattern:</p><pre class="programlisting">
+&lt;html&gt;
+  &lt;div class=&quot;section&quot;&gt;
+    &lt;para/&gt;
+    &lt;div class=&quot;subsection&quot;&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+  &lt;div class=&quot;section&quot;&gt;
+    &lt;div class=&quot;subsection&quot;&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/html&gt;
+</pre><p>On the other hand, the following document does not:</p><pre class="programlisting">
+&lt;html&gt;
+  &lt;div class=&quot;subsection&quot;&gt;
+    &lt;para/&gt;
+    &lt;div class=&quot;section&quot;&gt;
+      &lt;para/&gt;
+    &lt;/div&gt;
+  &lt;/div&gt;
+&lt;/html&gt;
+</pre></div></div><div class="section" lang="en"><div class="titlepage"><div><h3 class="title"><a name="id2817974"></a>3. Features of RELAX NG beyond RELAX Core</h3></div></div><p>RELAX NG has some features which are missing in RELAX
+Core.</p><div class="orderedlist"><ol type="1"><li><a name="id2817989"></a>Namespaces: since RELAX Core is intended to be used in
+conjunction with RELAX Namespace, RELAX Core does not support
+namespaces.  On the other hand, RELAX NG supports namespaces.  RELAX
+Namespace will be extended so that it can work with RELAX NG.
+</li><li><a name="id2817999"></a>Mixture of <tt class="literal">element</tt> and
+<tt class="literal">attribute</tt>: RELAX Core does not allow their 
+mixture but rather provide two types of basic constructs, 
+namely <tt class="literal">elementRule/hedgeRule</tt> and 
+<tt class="literal">tag/attPool</tt>.</li><li><a name="id2818023"></a>Name classes: RELAX Core does not have name
+classes but merely provide name literals.</li><li><a name="id2818030"></a><tt class="literal">interleave</tt>:  RELAX Core does not 
+provide any mechanism for interleaving.</li><li><a name="id2818040"></a>Datatype libraries: RELAX Core allows XML Schema Part
+2 but does not allow other datatype libaries.</li><li><a name="id2818047"></a><tt class="literal">define</tt> in <tt class="literal">include</tt>: 
+RELAX Core does not allow such redefinitions.</li><li><a name="id2818060"></a><tt class="literal">list</tt>: RELAX Core does not provide
+such structured strings.</li><li><a name="id2818070"></a><tt class="literal">data</tt> in <tt class="literal">choice</tt>:
+in RELAX Core, the hedge model of <tt class="literal">elementRule</tt> is 
+either a datatype reference or an expression without datatype 
+references.</li></ol></div></div></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="id2818092"></a>C. Comparison with TREX</h2><p>RELAX NG has the following changes from TREX:</p><div class="orderedlist"><ol type="1"><li><a name="id2818107"></a>the <tt class="literal">concur</tt> pattern has been removed</li><li><a name="id2818117"></a>the <tt class="literal">string</tt> pattern has been replaced by the
+<tt class="literal">value</tt> pattern</li><li><a name="id2818131"></a>the <tt class="literal">anyString</tt> pattern has been renamed to
+<tt class="literal">text</tt></li><li><a name="id2818144"></a>the namespace URI is different</li><li><a name="id2818150"></a>pattern elements must be namespace qualified</li><li><a name="id2818156"></a>anonymous datatypes have been removed</li><li><a name="id2818162"></a>the <tt class="literal">data</tt> pattern can have parameters specified by
+<tt class="literal">param</tt> child elements</li><li><a name="id2818177"></a>the <tt class="literal">list</tt> pattern has been added
+for matching whitespace-separated lists of tokens</li><li><a name="id2818188"></a>the <tt class="literal">replace</tt> and
+<tt class="literal">group</tt> values for the <tt class="literal">combine</tt>
+attribute have been removed</li><li><a name="id2818206"></a>an <tt class="literal">include</tt> element in a grammar may contain
+<tt class="literal">define</tt> elements that replace included definitions</li><li><a name="id2818221"></a>the restriction that definitions combined with the
+<tt class="literal">combine</tt> attribute must be from different files has
+been removed</li><li><a name="id2818233"></a>a <tt class="literal">div</tt> element may be used to group
+together definitions within a
+<tt class="literal">grammar</tt></li><li><a name="id2818246"></a>an <tt class="literal">include</tt> element occurring as a
+pattern has been renamed to <tt class="literal">externalRef</tt>; an
+<tt class="literal">include</tt> element is now allowed only as a child of
+the <tt class="literal">grammar</tt> element</li><li><a name="id2818270"></a>the <tt class="literal">parent</tt> attribute on the
+<tt class="literal">ref</tt> element has been replaced by a new
+<tt class="literal">parentRef</tt> element</li><li><a name="id2818289"></a>the <tt class="literal">type</tt> attribute of the
+<tt class="literal">data</tt> element is an unqualified name; the
+<tt class="literal">data</tt> element uses the
+<tt class="literal">datatypeLibrary</tt> attribute rather than the
+<tt class="literal">ns</tt> attribute to identify the namespace of the
+datatype</li><li><a name="id2818318"></a>a <tt class="literal">start</tt> element is not allowed to
+have a <tt class="literal">name</tt> attribute</li><li><a name="id2818332"></a>an <tt class="literal">attribute</tt> element is not allowed
+to have a <tt class="literal">global</tt> attribute</li><li><a name="id2818346"></a>the <tt class="literal">not</tt> and <tt class="literal">difference</tt>
+name classes have been replaced by <tt class="literal">except</tt></li><li><a name="id2818363"></a>the <tt class="literal">data</tt> element may have
+an <tt class="literal">except</tt> child</li></ol></div></div><div class="appendix" lang="en"><h2 class="title" style="clear: both"><a name="id2818380"></a>D. Changes from 12 June 2001 version</h2><div class="orderedlist"><ol type="1"><li><a name="id2818390"></a><tt class="literal">key</tt> and <tt class="literal">keyRef</tt>
+have been removed; support for ID and IDREF is now available
+in a companion specification, RELAX NG DTD Compatibility
+Annotations [<a href="#compat"><span class="abbrev">Compatibility</span></a>]</li><li><a name="id2818411"></a><tt class="literal">difference</tt> and <tt class="literal">not</tt>
+have been replaced by <tt class="literal">except</tt></li><li><a name="id2818426"></a>a <tt class="literal">start</tt> element is no longer
+allowed to have a <tt class="literal">name</tt> attribute</li><li><a name="id2818439"></a>an <tt class="literal">attribute</tt> element is no longer
+allowed to have a <tt class="literal">global</tt>
+attribute</li></ol></div></div><div id="id2818456" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="id2818456"></a>References</h2></div></div><dl><dt><span class="abbrev">Compact</span></dt><dd class="bibliomixed"><a name="compact"></a>James Clark, editor. <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/compact.html" target="_top">RELAX NG
+Compact Syntax</a></i></span>.  OASIS, 2002.</dd><dt><span class="abbrev">Compact Tutorial</span></dt><dd class="bibliomixed"><a name="compact-tutorial"></a>James Clark, John Cowan, MURATA Makoto, editors.
+<span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/compact-tutorial.html" target="_top">RELAX
+NG Compact Syntax Tutorial</a></i></span>.  OASIS,
+2003.</dd><dt><span class="abbrev">Compatibility</span></dt><dd class="bibliomixed"><a name="compat"></a>James Clark, MURATA
+Makoto, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/compatibility.html" target="_top">RELAX NG
+DTD Compatibility</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">Guidelines</span></dt><dd class="bibliomixed"><a name="guidelines"></a>James Clark, Kohsuke
+KAWAGUCHI, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/xsd.html" target="_top">Guidelines for using W3C XML Schema Datatypes with RELAX NG</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">RELAX</span></dt><dd class="bibliomixed"><a name="relax"></a>MURATA Makoto.
+<span class="citetitle"><i class="citetitle"><a href="http://www.xml.gr.jp/relax/" target="_top">RELAX (Regular
+Language description for XML)</a></i></span>.  INSTAC
+(Information Technology Research and Standardization Center), 2001.</dd><dt><span class="abbrev">Specification</span></dt><dd class="bibliomixed"><a name="spec"></a>James Clark, MURATA
+Makoto, editors.  <span class="citetitle"><i class="citetitle"><a href="http://relaxng.org/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</dd><dt><span class="abbrev">TREX</span></dt><dd class="bibliomixed"><a name="trex"></a>James Clark.
+<span class="citetitle"><i class="citetitle"><a href="http://www.thaiopensource.com/trex/" target="_top">TREX - Tree Regular Expressions for XML</a></i></span>.
+Thai Open Source Software Center, 2001.</dd><dt><span class="abbrev">W3C XML Schema Datatypes</span></dt><dd class="bibliomixed"><a name="xmlschema-2"></a>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i class="citetitle"><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</dd></dl></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/tutorial-20030326.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html (added)
+++ packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html Wed Nov 11 20:36:49 2009
@@ -1,0 +1,93 @@
+<html><head>
+<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>Guidelines for using W3C XML Schema Datatypes with RELAX NG</title><link rel="stylesheet" href="tr.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.40"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article"><div class="titlepage"><p class="logo"><a href="http://www.oasis-open.org/"><img src="oasis.png" alt="OASIS" border="0"></a></p><div><h1 class="title"><a name="IDAHAYR"></a>Guidelines for using W3C XML Schema Datatypes with RELAX NG</h1></div><div><h2>Committee Specification 7 September 2001</h2></div><div><dl><dt>This version:</dt><dd>Committee Specification: 7 September 2001</dd></dl></div><div><dl><dt>Editors:</dt><dd>James Clark <tt>&lt;<a href="mailto:jjc at jclark.com">jjc at jclark.com</a>&gt;</tt>, KAWAGUCHI Kohsuke <tt>&lt;<a href="mailto:kohsuke.kawaguchi at sun.com">kohsuke.kawaguchi at sun.com</a>&gt;</tt></dd></dl></div><div></div><div><div class="legalnotice"><p>Copyright © The Organization for the Advancement of
+Structured Information Standards [OASIS] 2001. All Rights
+Reserved.</p><p>This document and translations of it may be copied and furnished
+to others, and derivative works that comment on or otherwise explain
+it or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any kind,
+provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to OASIS, except as needed for the
+purpose of developing OASIS specifications, in which case the
+procedures for copyrights defined in the OASIS Intellectual Property
+Rights document must be followed, or as required to translate it into
+languages other than English.</p><p>The limited permissions granted above are perpetual and will not
+be revoked by OASIS or its successors or assigns.</p><p>This document and the information contained herein is provided
+on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE
+USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
+IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE.</p></div></div><div><hr><div class="abstract"><h2><a name="IDAGCYR"></a>Abstract</h2><p>This document specifies guidelines for using the datatypes
+defined by <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> with <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>.</p></div></div><div><div class="legalnotice"><h2>Status of this Document</h2><p>This committee specification was approved for publication by the
+OASIS RELAX NG technical committee.  Comments on this document may be
+sent to <a href="mailto:relax-ng-comment at lists.oasis-open.org" target="_top">relax-ng-comment at lists.oasis-open.org</a>.</p></div></div></div><div class="toc"><h2>Table of Contents</h2><dl><dt>1 <a href="#IDAZCYR">Introduction</a></dt><dt>2 <a href="#IDAMDYR">Parameters</a></dt><dt>3 <a href="#IDAVEYR"><tt>NOTATION</tt> datatype</a></dt><dt>4 <a href="#IDAOGYR"><tt>ID</tt>, <tt>IDREF</tt> and
+<tt>IDREFS</tt> datatypes</a></dt></dl><h3>Appendixes</h3><dl><dt><a href="#IDADQYR">References</a></dt></dl></div><hr><div class="section"><a name="IDAZCYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAZCYR"></a>1. Introduction</h2></div></div><p>This document specifies guidelines for using the datatypes
+defined by <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> as a datatype library for
+<a href="#spec" title="[RELAX NG]">[RELAX NG]</a>.  The URI</p><pre class="programlisting">http://www.w3.org/2001/XMLSchema-datatypes</pre><p>should be used to identify the datatype library.  The library
+identified by this URI contains all the builtin datatypes of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>, both primitive and derived.</p></div><div class="section"><a name="IDAMDYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAMDYR"></a>2. Parameters</h2></div></div><p>Any facet can be specified as a parameter with the following
+exceptions</p><div class="itemizedlist"><ul><li><a name="IDASDYR"></a><tt>whiteSpace</tt> (the builtin derived
+datatype that specifies the desired value for the
+<tt>whiteSpace</tt> facet should be used
+instead)</li><li><a name="IDAZDYR"></a><tt>enumeration</tt> (the
+<tt>value</tt> element should be used
+instead)</li></ul></div><p>If the <tt>pattern</tt> parameter is specified more
+than once for a single <tt>data</tt> element, then a string
+matches the <tt>data</tt> element only if it matches all of
+the patterns.  It is an error to specify a parameter other than
+<tt>pattern</tt> more than once for a single
+<tt>data</tt> element.</p><p>The value of any parameter other than <tt>pattern</tt>
+should be normalized by applying the normalizeWhiteSpace function
+defined in <a href="#spec" title="[RELAX NG]">[RELAX NG]</a>.</p></div><div class="section"><a name="IDAVEYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAVEYR"></a>3. <tt>NOTATION</tt> datatype</h2></div></div><p>The relationship between the <tt>NOTATION</tt>
+datatype of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> and the
+<tt>NOTATION</tt> datatype of <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a> is
+different from the relationship between the <tt>ENTITY</tt>
+datatype of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> and the
+<tt>ENTITY</tt> datatype of <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a>.
+Whereas values of the <tt>ENTITY</tt> datatype of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> refer to entities declared in the DTD of
+document being validated, values of the <tt>NOTATION</tt>
+datatype of <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> refer to notations declared
+in the XML Schema.  This makes it problematic to use the
+<tt>NOTATION</tt> datatype outside the context of XML Schema
+Part 1. However, since <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> does not allow a
+schema to use the <tt>NOTATION</tt> datatype directly, but
+requires that a value be specified for the
+<tt>enumeration</tt> facet, and since the values of the
+<tt>NOTATION</tt> datatype are QNames, the
+<tt>NOTATION</tt> datatype is, considering just validation,
+effectively equivalent to the <tt>QName</tt> datatype. It is
+therefore recommended that RELAX NG validators implement the same
+validation semantics for the <tt>NOTATION</tt> datatype as
+for the <tt>QName</tt> datatype.</p></div><div class="section"><a name="IDAOGYR"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="IDAOGYR"></a>4. <tt>ID</tt>, <tt>IDREF</tt> and
+<tt>IDREFS</tt> datatypes</h2></div></div><p>The semantics defined by <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> for the
+<tt>ID</tt>, <tt>IDREF</tt> and
+<tt>IDREFS</tt> datatypes are purely lexical and do not
+include the cross-reference semantics of the corresponding <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a> datatypes.  The cross-reference semantics of these
+datatypes in XML Schema comes from XML Schema Part 1.  Furthermore,
+the <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a> cross-reference semantics of these
+datatypes do not fit into the RELAX NG model of what a datatype is.
+Therefore, RELAX NG validation will only validate the lexical aspects
+of these datatypes as defined in <a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a>.</p><p>However, <a href="#compatibility" title="[DTD
+Compatibility]">[DTD
+Compatibility]</a> defines the concept of
+an ID-type, which is an additional semantic for datatypes that allows
+datatypes to have <a href="#xml-rec" title="[XML 1.0]">[XML 1.0]</a> cross-reference
+semantics. An implementation of <a href="#compatibility" title="[DTD
+Compatibility]">[DTD
+Compatibility]</a> that
+supports these guidelines should associate the <tt>ID</tt>,
+<tt>IDREF</tt> and <tt>IDREFS</tt> datatypes of
+<a href="#xmlschema-2" title="[W3C XML Schema Datatypes]">[W3C XML Schema Datatypes]</a> with the ID-types ID, IDREF, and IDREFS
+respectively.</p></div><div id="IDADQYR" class="bibliography"><div class="titlepage"><div><h2 class="title"><a name="IDADQYR"></a>References</h2></div></div><div id="xml-rec" class="bibliomixed"><a name="xml-rec"></a><p>Tim Bray,
+Jean Paoli, and
+C. M. Sperberg-McQueen, Eve Maler, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/REC-xml" target="_top">Extensible Markup
+Language (XML) 1.0 Second Edition</a></i></span>.
+W3C (World Wide Web Consortium), 2000.</p></div><div id="spec" class="bibliomixed"><a name="spec"></a><p>James Clark, Makoto
+MURATA, editors.  <span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/spec.html" target="_top">RELAX NG
+Specification</a></i></span>.  OASIS, 2001.</p></div><div id="compatibility" class="bibliomixed"><a name="compatibility"></a><p>James Clark, Makoto MURATA, editors.
+<span class="citetitle"><i><a href="http://www.oasis-open.org/committees/relax-ng/compatibility.html" target="_top">RELAX
+NG DTD Compatibility</a></i></span>.  OASIS, 2001.</p></div><div id="xmlschema-2" class="bibliomixed"><a name="xmlschema-2"></a><p>Paul V. Biron, Ashok Malhotra, editors.
+<span class="citetitle"><i><a href="http://www.w3.org/TR/xmlschema-2/" target="_top">XML Schema Part 2: Datatypes</a></i></span>.
+W3C (World Wide Web Consortium), 2001.</p></div></div></div></body></html>

Propchange: packages/relax-ng/trunk/relaxng-1.0/html/xsd-20010907.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: packages/relax-ng/trunk/relaxng-1.0/relaxng.dtd
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/relaxng.dtd?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/relaxng.dtd (added)
+++ packages/relax-ng/trunk/relaxng-1.0/relaxng.dtd Wed Nov 11 20:36:49 2009
@@ -1,0 +1,163 @@
+<!-- relaxng.dtd
+
+     Based on grammar in section 3 of RELAX NG 1.0 (3 December 2001), which
+     made this very easy to put together. While entity declarations such as
+     those for param, start, and define may look redundant, I wanted this to
+     reflect the BNF grammar as closely as possible.
+     
+     12/05/01 Bob DuCharme. Use at your own risk, no warrantee expressed or
+     implied, etc.
+
+     Last updated 12/31/01. 
+     See http://www.snee.com/xml/relaxng/dtdChangeList.html for changes.
+
+     Tested with:
+
+     - RELAX NG schema for RELAX NG, App A of spec:
+       http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#IDA5MCS
+
+     - RELAX NG schema for RELAX NG at
+       http://thaiopensource.com/relaxng/relaxng.rng
+
+     - XSLT schema at http://thaiopensource.com/relaxng/xslt.rng
+
+     - testSuite.rng from http://thaiopensource.com/relaxng/testSuite.zip
+
+ -->
+
+<!ENTITY % extensionAtts "">
+
+<!ENTITY % extensionPattern "">  <!-- Add | before each one, e.g. "| x | y" -->
+
+
+<!ENTITY % extensionGrammarContent "">           <!-- Add | before each one -->
+
+<!ENTITY % commonAtts "datatypeLibrary CDATA #IMPLIED
+                       ns CDATA #IMPLIED
+                       xmlns CDATA #FIXED 'http://relaxng.org/ns/structure/1.0'
+                       %extensionAtts;">
+
+<!-- Declare all nonterminals in grammar as parameter entities. -->
+
+<!ENTITY % pattern  "element | attribute | group | interleave | choice |
+                     optional | zeroOrMore | oneOrMore | list | mixed |
+                     ref | parentRef | empty | text | value | data |
+                     notAllowed | externalRef | grammar %extensionPattern;">
+
+<!ENTITY % param "param">
+
+<!ENTITY % exceptPattern  "except">
+
+<!ENTITY % start  "start">
+
+<!ENTITY % define "define">
+
+<!ENTITY % grammarContent "%start; | %define; |
+                           div | include %extensionGrammarContent;">
+
+<!ENTITY % includeContent  "%start; | %define; | div %extensionGrammarContent;">
+
+<!ENTITY % method  "choice | interleave">
+
+<!-- "| choice" not in the following; See change notes. -->
+<!ENTITY % nameClass "name | anyName | nsName"> 
+
+<!ENTITY % exceptNameClass  "except">
+
+
+<!ELEMENT element     ((%nameClass;)?, (%pattern;)+)>
+<!ATTLIST element     name NMTOKEN #IMPLIED 
+                      %commonAtts;>
+
+<!ELEMENT attribute   ((%nameClass;)?, (%pattern;)?)>
+<!ATTLIST attribute   name NMTOKEN #IMPLIED 
+                      %commonAtts;>
+
+<!ELEMENT group       (%pattern;)+>
+<!ATTLIST group       %commonAtts;>
+
+<!ELEMENT interleave  (%pattern;)+>
+<!ATTLIST interleave  %commonAtts;>
+
+<!ELEMENT choice      (%nameClass; | %pattern;)+>
+<!ATTLIST choice      %commonAtts;>
+
+<!ELEMENT optional    (%pattern;)+>
+<!ATTLIST optional    %commonAtts;>
+
+<!ELEMENT zeroOrMore  (%pattern;)+>
+<!ATTLIST zeroOrMore  %commonAtts;>
+
+<!ELEMENT oneOrMore   (%pattern;)+>
+<!ATTLIST oneOrMore   %commonAtts;>
+
+<!ELEMENT list        (%pattern;)+>
+<!ATTLIST list        %commonAtts;>
+
+<!ELEMENT mixed       (%pattern;)+>
+<!ATTLIST mixed       %commonAtts;>
+
+<!ELEMENT ref         EMPTY>
+<!ATTLIST ref         name NMTOKEN #REQUIRED
+                      %commonAtts;>
+
+<!ELEMENT parentRef   EMPTY>
+<!ATTLIST parentRef   name NMTOKEN #REQUIRED
+                      %commonAtts;>
+
+<!ELEMENT empty       EMPTY>
+<!ATTLIST empty       %commonAtts;>
+
+<!ELEMENT text        EMPTY>
+<!ATTLIST text        %commonAtts;>
+
+<!ELEMENT value       (#PCDATA)>
+<!ATTLIST value       type NMTOKEN #IMPLIED
+                      %commonAtts;>
+
+<!ELEMENT data        ((%param;)*,(%exceptPattern;)?)>
+<!ATTLIST data        type NMTOKEN #REQUIRED
+                      %commonAtts;>
+
+<!ELEMENT notAllowed  EMPTY>
+<!ATTLIST notAllowed  %commonAtts;>
+
+<!ELEMENT externalRef EMPTY>
+<!ATTLIST externalRef href CDATA #REQUIRED
+                      %commonAtts;>
+
+<!ELEMENT grammar     (%grammarContent;)*>
+<!ATTLIST grammar     %commonAtts;>
+
+<!ELEMENT param       (#PCDATA)>
+<!ATTLIST param       name NMTOKEN #REQUIRED>
+
+<!ELEMENT except      (%nameClass; | %pattern;)+>
+<!ATTLIST except      %commonAtts;>
+
+<!ELEMENT div         (%grammarContent;)*>
+<!ATTLIST div         %commonAtts;>
+
+<!ELEMENT include     (%includeContent;)*>
+<!ATTLIST include     href CDATA #REQUIRED
+                      %commonAtts;>
+
+<!ELEMENT start       (%pattern;) >
+<!ATTLIST start       combine (%method;) #IMPLIED
+                      %commonAtts;>
+
+<!ELEMENT define      (%pattern;)+ >
+<!ATTLIST define      name    NMTOKEN    #REQUIRED
+                      combine (%method;) #IMPLIED
+                      %commonAtts;>
+     
+<!ELEMENT name        (#PCDATA)>
+<!ATTLIST name        %commonAtts;>
+
+<!ELEMENT anyName     (%exceptNameClass;)?>
+<!ATTLIST anyName     %commonAtts;>
+
+<!ELEMENT nsName      (%exceptNameClass;)?>
+<!ATTLIST nsName      %commonAtts;>
+
+<!-- eof for relaxng.dtd -->

Added: packages/relax-ng/trunk/relaxng-1.0/relaxng.rng
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/relaxng.rng?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/relaxng.rng (added)
+++ packages/relax-ng/trunk/relaxng-1.0/relaxng.rng Wed Nov 11 20:36:49 2009
@@ -1,0 +1,335 @@
+<?xml version="1.0"?>
+<!-- RELAX NG for RELAX NG -->
+<!-- $Id: relaxng.rng,v 1.31 2002/05/30 06:07:43 jjc Exp $ -->
+<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
+         ns="http://relaxng.org/ns/structure/1.0"
+         xmlns="http://relaxng.org/ns/structure/1.0">
+  <start>
+    <ref name="pattern"/>
+  </start>
+
+  <define name="pattern">
+    <choice>
+      <element name="element">
+        <choice>
+          <attribute name="name">
+            <data type="QName"/>
+          </attribute>
+          <ref name="open-name-class"/>
+        </choice>
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="attribute">
+        <ref name="common-atts"/>
+        <choice>
+	  <attribute name="name">
+	    <data type="QName"/>
+	  </attribute>
+          <ref name="open-name-class"/>
+        </choice>
+        <interleave>
+          <ref name="other"/>
+          <optional>
+            <ref name="pattern"/>
+          </optional>
+        </interleave>
+      </element>
+      <element name="group">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="interleave">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="choice">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="optional">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="zeroOrMore">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="oneOrMore">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="list">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="mixed">
+        <ref name="common-atts"/>
+        <ref name="open-patterns"/>
+      </element>
+      <element name="ref">
+        <attribute name="name">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="parentRef">
+        <attribute name="name">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="empty">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="text">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="value">
+        <optional>
+          <attribute name="type">
+            <data type="NCName"/>
+          </attribute>
+        </optional>
+        <ref name="common-atts"/>
+        <text/>
+      </element>
+      <element name="data">
+        <attribute name="type">
+          <data type="NCName"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <interleave>
+          <ref name="other"/>
+          <group>
+	    <zeroOrMore>
+	      <element name="param">
+		<attribute name="name">
+		  <data type="NCName"/>
+		</attribute>
+                <ref name="common-atts"/>
+		<text/>
+	      </element>
+	    </zeroOrMore>
+            <optional>
+              <element name="except">
+		<ref name="common-atts"/>
+		<ref name="open-patterns"/>
+              </element>
+            </optional>
+          </group>
+        </interleave>
+      </element>
+      <element name="notAllowed">
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="externalRef">
+        <attribute name="href">
+          <data type="anyURI"/>
+        </attribute>
+        <ref name="common-atts"/>
+        <ref name="other"/>
+      </element>
+      <element name="grammar">
+        <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">
+            <ref name="common-atts"/>
+            <ref name="grammar-content"/>
+          </element>
+          <element name="include">
+            <attribute name="href">
+              <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">
+            <ref name="common-atts"/>
+            <ref name="include-content"/>
+          </element>
+        </choice>
+      </zeroOrMore>
+    </interleave>
+  </define>
+
+  <define name="start-element">
+    <element name="start">
+      <ref name="combine-att"/>
+      <ref name="common-atts"/>
+      <ref name="open-pattern"/>
+    </element>
+  </define>
+
+  <define name="define-element">
+    <element name="define">
+      <attribute name="name">
+        <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">
+        <choice>
+          <value>choice</value>
+          <value>interleave</value>
+        </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">
+        <ref name="common-atts"/>
+        <data type="QName"/>
+      </element>
+      <element name="anyName">
+        <ref name="common-atts"/>
+        <ref name="except-name-class"/>
+      </element>
+      <element name="nsName">
+        <ref name="common-atts"/>
+        <ref name="except-name-class"/>
+      </element>
+      <element name="choice">
+        <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">
+          <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"/>
+    </optional>
+    <optional>
+      <attribute name="datatypeLibrary">
+        <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>

Added: packages/relax-ng/trunk/relaxng-1.0/relaxng.xsd
URL: http://svn.debian.org/wsvn/debian-xml-sgml/packages/relax-ng/trunk/relaxng-1.0/relaxng.xsd?rev=1628&op=file
==============================================================================
--- packages/relax-ng/trunk/relaxng-1.0/relaxng.xsd (added)
+++ packages/relax-ng/trunk/relaxng-1.0/relaxng.xsd Wed Nov 11 20:36:49 2009
@@ -1,0 +1,344 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  A schema for RELAX NG syntax staying within the
+  expressive power of W3C XML Schema.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://relaxng.org/ns/structure/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0">
+  <xs:element name="patternNotChoice" abstract="true"/>
+  <xs:element name="element" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:group ref="rng:nameClassOrPattern"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:sequence minOccurs="0" maxOccurs="unbounded">
+          <xs:group ref="rng:patternAfterNameClass"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        </xs:sequence>
+      </xs:sequence>
+      <xs:attribute name="name" type="xs:QName"/>
+      <xs:attributeGroup ref="rng:commonAttributes"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="attribute" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:sequence minOccurs="0">
+          <xs:group ref="rng:nameClassOrPattern"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+          <xs:sequence minOccurs="0">
+            <xs:group ref="rng:patternAfterNameClass"/>
+            <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+          </xs:sequence>
+        </xs:sequence>
+      </xs:sequence>
+      <xs:attribute name="name" type="xs:QName"/>
+      <xs:attributeGroup ref="rng:commonAttributes"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="group" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="interleave" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="optional" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="zeroOrMore" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="oneOrMore" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="list" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="mixed" substitutionGroup="rng:patternNotChoice" type="rng:oneOrMorePatternsType"/>
+  <xs:element name="ref" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:common">
+          <xs:attributeGroup ref="rng:nameNCName"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="parentRef" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:common">
+          <xs:attributeGroup ref="rng:nameNCName"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="empty" substitutionGroup="rng:patternNotChoice" type="rng:common"/>
+  <xs:element name="notAllowed" substitutionGroup="rng:patternNotChoice" type="rng:common"/>
+  <xs:element name="text" substitutionGroup="rng:patternNotChoice" type="rng:common"/>
+  <xs:element name="data" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:sequence minOccurs="0" maxOccurs="unbounded">
+          <xs:element ref="rng:param"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        </xs:sequence>
+        <xs:sequence minOccurs="0">
+          <xs:group ref="rng:exceptPattern"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        </xs:sequence>
+      </xs:sequence>
+      <xs:attributeGroup ref="rng:type"/>
+      <xs:attributeGroup ref="rng:commonAttributes"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="value" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:string">
+          <xs:attributeGroup ref="rng:commonAttributes"/>
+          <xs:attribute name="type" type="xs:NCName"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="externalRef" substitutionGroup="rng:patternNotChoice">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:common">
+          <xs:attributeGroup ref="rng:href"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="grammar" substitutionGroup="rng:patternNotChoice" type="rng:grammarType"/>
+  <xs:complexType name="oneOrMorePatternsType">
+    <xs:sequence>
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      <xs:sequence maxOccurs="unbounded">
+        <xs:group ref="rng:pattern"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      </xs:sequence>
+    </xs:sequence>
+    <xs:attributeGroup ref="rng:commonAttributes"/>
+  </xs:complexType>
+  <xs:complexType name="grammarType">
+    <xs:sequence>
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      <xs:sequence minOccurs="0" maxOccurs="unbounded">
+        <xs:group ref="rng:grammarContent"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      </xs:sequence>
+    </xs:sequence>
+    <xs:attributeGroup ref="rng:commonAttributes"/>
+  </xs:complexType>
+  <xs:group name="pattern">
+    <xs:choice>
+      <xs:element ref="rng:patternNotChoice"/>
+      <xs:element name="choice" type="rng:oneOrMorePatternsType"/>
+    </xs:choice>
+  </xs:group>
+  <xs:group name="patternAfterNameClass">
+    <xs:choice>
+      <xs:element ref="rng:patternNotChoice"/>
+      <xs:group ref="rng:choice"/>
+    </xs:choice>
+  </xs:group>
+  <xs:group name="nameClassOrPattern">
+    <xs:choice>
+      <xs:element ref="rng:nameClassNotChoice"/>
+      <xs:element ref="rng:patternNotChoice"/>
+      <xs:group ref="rng:choice"/>
+    </xs:choice>
+  </xs:group>
+  <xs:group name="choice">
+    <xs:sequence>
+      <xs:element name="choice">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+            <xs:sequence maxOccurs="unbounded">
+              <xs:group ref="rng:nameClassOrPattern"/>
+              <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+            </xs:sequence>
+          </xs:sequence>
+          <xs:attributeGroup ref="rng:commonAttributes"/>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:group>
+  <xs:element name="param">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:string">
+          <xs:attributeGroup ref="rng:commonAttributes"/>
+          <xs:attributeGroup ref="rng:nameNCName"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:group name="exceptPattern">
+    <xs:sequence>
+      <xs:element name="except" type="rng:oneOrMorePatternsType"/>
+    </xs:sequence>
+  </xs:group>
+  <xs:group name="grammarContent">
+    <xs:choice>
+      <xs:element ref="rng:definition"/>
+      <xs:element name="div" type="rng:grammarType"/>
+      <xs:element ref="rng:include"/>
+    </xs:choice>
+  </xs:group>
+  <xs:element name="include">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:includeType">
+          <xs:attributeGroup ref="rng:href"/>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:group name="includeContent">
+    <xs:choice>
+      <xs:element ref="rng:definition"/>
+      <xs:element name="div" type="rng:includeType"/>
+    </xs:choice>
+  </xs:group>
+  <xs:complexType name="includeType">
+    <xs:sequence>
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      <xs:sequence minOccurs="0" maxOccurs="unbounded">
+        <xs:group ref="rng:includeContent"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      </xs:sequence>
+    </xs:sequence>
+    <xs:attributeGroup ref="rng:commonAttributes"/>
+  </xs:complexType>
+  <xs:element name="definition" abstract="true"/>
+  <xs:element name="start" substitutionGroup="rng:definition">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:oneOrMorePatternsType">
+          <xs:attribute name="combine">
+            <xs:simpleType>
+              <xs:restriction base="xs:token">
+                <xs:enumeration value="choice"/>
+                <xs:enumeration value="interleave"/>
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="define" substitutionGroup="rng:definition">
+    <xs:complexType>
+      <xs:complexContent>
+        <xs:extension base="rng:oneOrMorePatternsType">
+          <xs:attributeGroup ref="rng:nameNCName"/>
+          <xs:attribute name="combine">
+            <xs:simpleType>
+              <xs:restriction base="xs:token">
+                <xs:enumeration value="choice"/>
+                <xs:enumeration value="interleave"/>
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+        </xs:extension>
+      </xs:complexContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:attributeGroup name="combine">
+    <xs:attribute name="combine" use="required">
+      <xs:simpleType>
+        <xs:restriction base="xs:token">
+          <xs:enumeration value="choice"/>
+          <xs:enumeration value="interleave"/>
+        </xs:restriction>
+      </xs:simpleType>
+    </xs:attribute>
+  </xs:attributeGroup>
+  <xs:element name="nameClassNotChoice" abstract="true"/>
+  <xs:element name="name" substitutionGroup="rng:nameClassNotChoice">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:QName">
+          <xs:attributeGroup ref="rng:commonAttributes"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="anyName" substitutionGroup="rng:nameClassNotChoice">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:sequence minOccurs="0">
+          <xs:group ref="rng:exceptNameClass"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        </xs:sequence>
+      </xs:sequence>
+      <xs:attributeGroup ref="rng:commonAttributes"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="nsName" substitutionGroup="rng:nameClassNotChoice">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        <xs:sequence minOccurs="0">
+          <xs:group ref="rng:exceptNameClass"/>
+          <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+        </xs:sequence>
+      </xs:sequence>
+      <xs:attributeGroup ref="rng:commonAttributes"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:group name="nameClass">
+    <xs:choice>
+      <xs:element ref="rng:nameClassNotChoice"/>
+      <xs:element name="choice" type="rng:oneOrMoreNameClassType"/>
+    </xs:choice>
+  </xs:group>
+  <xs:group name="exceptNameClass">
+    <xs:sequence>
+      <xs:element name="except" type="rng:oneOrMoreNameClassType"/>
+    </xs:sequence>
+  </xs:group>
+  <xs:complexType name="oneOrMoreNameClassType">
+    <xs:sequence>
+      <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      <xs:sequence maxOccurs="unbounded">
+        <xs:group ref="rng:nameClass"/>
+        <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+      </xs:sequence>
+    </xs:sequence>
+    <xs:attributeGroup ref="rng:commonAttributes"/>
+  </xs:complexType>
+  <xs:attributeGroup name="nameQName">
+    <xs:attribute name="name" use="required" type="xs:QName"/>
+  </xs:attributeGroup>
+  <xs:attributeGroup name="nameNCName">
+    <xs:attribute name="name" use="required" type="xs:NCName"/>
+  </xs:attributeGroup>
+  <xs:attributeGroup name="href">
+    <xs:attribute name="href" use="required" type="xs:anyURI"/>
+  </xs:attributeGroup>
+  <xs:attributeGroup name="type">
+    <xs:attribute name="type" use="required" type="xs:NCName"/>
+  </xs:attributeGroup>
+  <xs:complexType name="common">
+    <xs:group minOccurs="0" maxOccurs="unbounded" ref="rng:foreignElement"/>
+    <xs:attributeGroup ref="rng:commonAttributes"/>
+  </xs:complexType>
+  <xs:attributeGroup name="commonAttributes">
+    <xs:attribute name="ns" type="xs:string"/>
+    <xs:attribute name="datatypeLibrary" type="xs:anyURI"/>
+    <xs:attributeGroup ref="rng:foreignAttributes"/>
+  </xs:attributeGroup>
+  <xs:group name="foreignElement">
+    <xs:choice>
+      <xs:any namespace="##other" processContents="skip"/>
+      <xs:any namespace="##local" processContents="skip"/>
+    </xs:choice>
+  </xs:group>
+  <xs:attributeGroup name="foreignAttributes">
+    <xs:anyAttribute namespace="##other" processContents="skip"/>
+  </xs:attributeGroup>
+  <xs:group name="anyElement">
+    <xs:sequence>
+      <xs:any processContents="skip"/>
+    </xs:sequence>
+  </xs:group>
+  <xs:attributeGroup name="anyAttributes">
+    <xs:anyAttribute processContents="skip"/>
+  </xs:attributeGroup>
+</xs:schema>




More information about the debian-xml-sgml-commit mailing list