<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.2//EN"
       "http://www.w3.org/2002/xmlspec/dtd/2.2/xmlspec.dtd"  [

<!--for doing work locally without a network connection -->
<!-- <!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.2//EN"
       "xmlspec.dtd"  [ -->

  <!ENTITY exins "http://www.w3.org/2009/exi">
  <!ENTITY times "&#215;">
  <!ENTITY ne "&#8800;">
  <!ENTITY le "&#8804;">
  <!ENTITY oplus "&#8853;">
  <!ENTITY hellip "&#8230;">
  <!ENTITY vellip "&#8942;">
  <!ENTITY lceil "&#8968;">
  <!ENTITY rceil "&#8969;">
  <!ENTITY sqcup "&#x2294;">
  <!-- cup looked so close to alphabet "U", use sqcup instead -->
  <!-- !ENTITY cup "&#8746;" -->
  <!ENTITY nbsp "&#160;">
  <!ENTITY nbhyphen "&#8209;">
  <!ENTITY mdash "&#8212;">
  <!ENTITY mdash "&#8212;">
  <!ENTITY minus "&#8722;">

  <!ENTITY xsiType-matching-AT-star SYSTEM "xsiType-matching-AT-star.xml">
  <!ENTITY xsiType-matching-AT-xsiType SYSTEM "xsiType-matching-AT-xsiType.xml">
  <!ENTITY xsiNil-matching-AT-star SYSTEM "xsiNil-matching-AT-star.xml">

  <!ENTITY pubDate "20">
]>
<!--

/*
 * Copyright (c) 2007-2008 World Wide Web Consortium,
 *
 * (Massachusetts Institute of Technology, European Research Consortium for
 * Informatics and Mathematics, Keio University). All Rights Reserved. This
 * work is distributed under the W3C(r) Document License [1] in the hope that
 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
 */

    -->
<?xml-stylesheet type="text/xsl" href="exi.xsl"?>
<spec w3c-doctype="pr">
<header>
<title>Efficient XML Interchange (EXI) Format</title>
<version>1.0</version>
<w3c-designation>PR-exi-201101&pubDate;</w3c-designation>
<!-- <w3c-doctype>W3C Editors' Draft</w3c-doctype>-->
<w3c-doctype>W3C Proposed Recommendation</w3c-doctype>
<pubdate>
<day>&pubDate;</day>
<month>January</month>
<year>2011</year></pubdate>
<publoc>
<loc href="http://www.w3.org/TR/2011/PR-exi-201101&pubDate;/">http://www.w3.org/TR/2011/PR-exi-201101&pubDate;/</loc>
</publoc>
<altlocs>
<loc role="xml" href="exi.xml">XML</loc></altlocs>
<prevlocs>
<!-- loc href="http://www.w3.org/TR/2007/WD-exi-20070716/">http://www.w3.org/TR/2007/WD-exi-20070716/</loc -->
<!-- loc href="http://www.w3.org/TR/2007/WD-exi-20071219/">http://www.w3.org/TR/2007/WD-exi-20071219/</loc -->
<!-- loc href="http://www.w3.org/TR/2008/WD-exi-20080326/">http://www.w3.org/TR/2008/WD-exi-20080326/</loc -->
<!-- loc href="http://www.w3.org/TR/2008/WD-exi-20080728/">http://www.w3.org/TR/2008/WD-exi-20080728/</loc -->
<!--<loc href="http://www.w3.org/TR/2008/WD-exi-20080919/">http://www.w3.org/TR/2008/WD-exi-20080919/</loc>-->
<loc href="http://www.w3.org/TR/2009/CR-exi-20091208/">http://www.w3.org/TR/2009/CR-exi-20091208/</loc>
</prevlocs>
<latestloc>
<loc href="http://www.w3.org/TR/exi/">http://www.w3.org/TR/exi/</loc></latestloc>
<authlist>
<author>
<name>John Schneider</name>
<affiliation>AgileDelta, Inc.</affiliation>
</author>
<author>
<name>Takuki Kamiya</name>
<affiliation>Fujitsu Laboratories of America, Inc.</affiliation>
</author></authlist>
<abstract>
<p>This document is the specification of the Efficient XML Interchange (EXI)
format. EXI is a very compact representation for the Extensible Markup
Language (XML) Information Set that is intended to simultaneously optimize
performance and the utilization of computational resources. The EXI
format uses a hybrid approach drawn from the information and formal language
theories, plus practical techniques verified by measurements,
for entropy encoding XML information. Using a relatively simple algorithm,
which is amenable to fast and compact implementation, and a small set of
datatype representations, 
it reliably produces efficient encodings of XML event streams.
The grammar production system and format definition of EXI are presented.</p>
</abstract>
<status id="Status">
<!-- p>This document is an Editors' Draft of a possible future W3C
Recommendation for internal review by W3C members and has no official
standing. It has been developed by the <loc
href="http://www.w3.org/XML/EXI/">Efficient XML Interchange (EXI)
Working Group</loc>, which is part of the <loc
href="http://www.w3.org/XML/Activity">Extensible Markup Language (XML)
Activity</loc>.</p -->

<p>
<emph>This section describes the status of this document at the time
of its publication. Other documents may supersede this document. A
list of current W3C publications and the latest revision of this
technical report can be found in the <loc href="http://www.w3.org/TR/">W3C technical reports index</loc> at
http://www.w3.org/TR/.</emph></p>

<p>This is the Proposed Recommendation of the Efficient XML Interchange Format 1.0. It has been produced by the <loc href="http://www.w3.org/XML/EXI/">EXI Working Group</loc>, which is part of the <loc href="http://www.w3.org/XML/Activity">Extensible Markup Language (XML) Activity</loc>.
</p>

<p>Changes since the previous publication based on feedback received during the review period and from implementers are listed in the <xspecref href='#changes'>Change Log</xspecref>. A <loc href="http://www.w3.org/2007/10/htmldiff?doc1=http://www.w3.org/TR/2009/CR-exi-20091208/&amp;amp;doc2=http://www.w3.org/TR/2011/PR-exi-201101&pubDate;/">diff-marked version</loc> against the previous version of this document is also available.  </p>

<p> The EXI Working Group has produced a test suite and an <loc href="http://www.w3.org/XML/EXI/implementation-report/">implementation report</loc>. </p>

<p>A W3C Proposed Recommendation is a mature technical report that, after wide review for technical soundness and implementability, W3C has sent to the W3C Advisory Committee for final endorsement. W3C Advisory Committee Representatives should consult their <loc href="http://www.w3.org/2002/09/wbs/myQuestionnaires">WBS questionnaires</loc>. Reviews are expected until 17 February 2011.</p>

<p>Individuals are invited to send feedback on this document by email to <loc href="mailto:public-exi-comments@w3.org">public-exi-comments@w3.org</loc>, a mailing list with a <loc href="http://lists.w3.org/Archives/Public/public-exi-comments/">public archive</loc>. This mailing list is reserved for comments, it is inappropriate to send discussion email to this address. Discussion should take place on the <loc href="mailto:public-exi@w3.org">public-exi@w3.org</loc> mailing list (<loc href="http://lists.w3.org/Archives/Public/public-exi/">public archive</loc>).</p>

<p>Publication as a Proposed Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p>

<p>This document was produced by a group operating under the <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</loc>. W3C maintains a <loc href="http://www.w3.org/2004/01/pp-impl/38502/status#specs" role="disclosure">public list of any patent disclosures</loc> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</loc> must disclose the information in accordance with <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</loc>.</p>
</status>


<langusage>
<language id="en-US">English</language></langusage>
<revisiondesc>
<p>Last Modified: $Date: 2011/01/19 18:00:42 $</p></revisiondesc></header>
<body>
<div1 id="introduction">
<head>Introduction</head>
<p>The Efficient XML Interchange (EXI) format is a very compact, high
performance XML representation that was designed to work well for a
broad range of applications.  It simultaneously improves performance
and significantly reduces bandwidth requirements without compromising
efficient use of other resources such as battery life, code size,
processing power, and memory.
</p>
<p>EXI uses a grammar-driven approach that achieves very efficient
encodings using a straightforward encoding algorithm and a small set
of 
datatype representations. 
Consequently, <termref def="key-exiprocessor">EXI processors</termref> are relatively simple and
can be implemented on devices with limited capacity. </p> <p>EXI is schema
&quot;informed&quot;, meaning that it can utilize available schema
information to improve compactness and performance, but does not
depend on accurate, complete or current schemas to work. It supports
arbitrary schema extensions and deviations and also works very
effectively with partial schemas or in the absence of any schema.  The
format itself also does not depend on any particular schema language,
or format, for schema information. </p>
<p><termdef id="key-exiprocessor" term="EXI processor">A program module
called an <term>EXI processor</term>, whether it is software or
hardware, is used by application programs to encode their structured data
into <termref def="key-existream">EXI streams</termref> and/or to decode
<termref def="key-existream">EXI streams</termref> to make the structured
data accessible.</termdef>

The former and latter aforementioned roles of EXI processors are called <termdef id="key-exiencoder"><term>EXI stream encoder</term></termdef> and <termdef id="key-exidecoder"><term>EXI stream decoder</term></termdef> respectfully.

This document not only specifies the
EXI format, but also defines errors that EXI processors are required to
detect and behave upon.</p>

<p>The primary goal of this document is to define the EXI format completely without leaving ambiguity so as to make it feasible for implementations to interoperate. As such, the document lends itself to describing the design and features of the format in a systematic manner, often declaratively with relatively few prosaic annotations and examples. Those readers who prefer a step-by-step introduction to the EXI format design and features are suggested to start with the non-normative <bibref ref="exiprimer"/>.
</p>
<div2 id="history">
<head>History and Design</head>
<p>EXI is the result of extensive work carried out by the W3C's XML
Binary Characterization (XBC) and Efficient XML Interchange (EXI)
Working Groups. XBC was chartered to investigate the costs and
benefits of an alternative form of XML, and formulate a way to objectively
evaluate the potential of a substitute format for XML.  Based on XBC's
recommendations, EXI was chartered, first to measure, evaluate, and
compare the performance of various XML technologies (using metrics
developed by XBC <bibref ref="xbcmeas"/>), and then, if it appeared
suitable, to formulate a recommendation for a W3C format
specification. The measurements results and analyses, are presented
elsewhere <bibref ref="eximeas"/>. The format described in this
document is the specification so recommended. 
</p>
<p>The functional requirements of the EXI format are those that were
prepared by the XBC WG in their analysis of the desirable properties
of a high performance representation for XML <bibref ref="xbcproperties"/>.
Those properties were derived from a very broad set of use cases also
identified by the XBC working group <bibref ref="xbcusecases"/>.
</p>
<p>The design of the format presented here, is largely based on the
results of the measurements carried out by the group to evaluate the
performance characteristics (mainly of processing efficiency and
compactness) of various existing formats. The EXI format is based on
Efficient XML <bibref ref="efx"/>, including for example the basis heuristic grammar approach,
compression algorithm, and resulting entropy encoding. 
</p>
<p>EXI is compatible with XML at the XML Information Set <bibref
ref="XMLInfoset"/> level, rather than at the XML syntax level. This
permits it to encapsulate an efficient alternative syntax and grammar
for XML, while facilitating at least the potential for minimizing the
impact on XML application interoperability.
</p>    
</div2>
<div2 id="conventions">
<head>Notational Conventions and Terminology</head>
<p>The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD,
SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL, when they appear
EMPHASIZED in this document, are to be interpreted as described in RFC
2119 <bibref ref="RFC2119"/>. Other terminology used to describe the EXI
format is defined in the body of this specification.
</p>
<p>The term <term>event</term> and <term>stream</term> is used throughout this document to denote <term><termref def="key-exievent">EXI event</termref></term> and <term><termref def="key-existream">EXI stream</termref></term> respectively unless the words are qualified differently to mean otherwise.</p>
<p>This document specifies an abstract grammar for EXI. In grammar notation, all terminal
symbols are represented in plain text and all non-terminal symbols are
represented in <emph>italics</emph>. Grammar productions are
represented as follows: </p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>LeftHandSide</emph> :&nbsp;&nbsp;
Terminal&nbsp;&nbsp;<emph>NonTerminal</emph></td></tr></tbody></table>
<p>A set of one or more grammar productions that share the same
left-hand side non-terminal symbol are often presented together annotated
with <termref def="key-eventcode">event codes</termref> that specify how events matching the terminal symbols of the associated productions are represented in the EXI stream as follows: 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>LeftHandSide</emph> :</td></tr>

<tr>
<td></td>
<td width="5%"></td>
<td width="75%">
Terminal<sub>&nbsp;1</sub>&nbsp;&nbsp;<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>EventCode<sub>&nbsp;1</sub></td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>&nbsp;&nbsp;<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>EventCode<sub>&nbsp;2</sub></td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;3</sub>&nbsp;&nbsp;<emph>NonTerminal</emph><sub>&nbsp;3</sub></td>
<td>EventCode<sub>&nbsp;3</sub></td></tr>
<tr>
<td></td>
<td></td>
<td>...</td>
<td></td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;n</sub>&nbsp;&nbsp;<emph>NonTerminal</emph><sub>&nbsp;n</sub></td>
<td>EventCode<sub>&nbsp;n</sub></td></tr>
</tbody></table>
<p>Section <specref ref="grammarNotation"/> introduces additional notations for describing productions and <termref def="key-eventcode">event codes</termref> in grammars. Those additional notations facilitate concise representation of the EXI grammar system.
</p>
<p>
<termdef id="key-qname">
In this document, the term <term>qname</term> is used to denote a 
<xspecref spec="XS2" ref="QName">QName</xspecref>.
</termdef>
QName values are composed of an uri, a local-name and an optional prefix. Two qnames are considered equal if they have the same uri and local-name, regardless of their prefix values. In cases where prefixes are not relevant, such as in the grammar notation, they are not specified by this document.
</p>
<p>Terminal symbols that are qualified with a qname permit the use of a wildcard symbol (*) in place of or as part of a qname. The forms of terminal symbols involving qname wildcards used in grammars and their definitions are described in the table below.
</p>
<table width="80%" border="1">
<colgroup align="left" width="25%"></colgroup>
<colgroup/>
<thead>
<tr>
<th align="center">Wildcard</th>
<th>Definition</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;SE&nbsp;(*)</td>
<td>The terminal symbol that matches a start element (SE) event with any qname.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;SE (<emph>uri</emph>&nbsp;:&nbsp;*)</td>
<td>The terminal symbol that matches a start element (SE) event with any local-name in namespace <emph>uri</emph>.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;AT&nbsp;(*)</td>
<td>The terminal symbol that matches an attribute (AT) event with any qname.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;AT&nbsp;(<emph>uri</emph>&nbsp;: *)</td>
<td>The terminal symbol that matches an attribute (AT) event with any local-name in namespace <emph>uri</emph>.</td>
</tr>
</tbody>
</table>
<p>Several prefixes are used throughout this document to designate certain namespaces. The bindings shown below are assumed, however, any prefixes can be used in practice if they are properly bound to the namespaces.</p>
<table width="80%" border="1">
<colgroup align="left" width="25%"></colgroup>
<colgroup/>
<thead>
<tr>
<th align="center">Prefix</th>
<th>Namespace Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;exi</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&exins;
</td>
</tr>
<!-- tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;xml</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
http://www.w3.org/XML/1998/namespace</td>
</tr -->
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;xsd</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
http://www.w3.org/2001/XMLSchema</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;xsi</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
http://www.w3.org/2001/XMLSchema-instance</td>
</tr>
</tbody>
</table>
<p>In describing the layout of an EXI format construct, a pair of square brackets [ ] are used to surround the name of a field to denote that the occurrence of the field is optional in the structure of the part or component that contains the field.
</p>
<p>In arithmetic expressions, the notation &lceil;<emph>x</emph>&rceil; where <emph>x</emph> represents a real number denotes the ceiling of <emph>x</emph>, that is, the smallest integer greater than or equal to <emph>x</emph>.
</p>
<p>
When it is stated that strings are sorted in lexicographical order, 
it is done so character by character, and the order among characters is determined by comparing their Unicode code points.
</p>
<p>Unless stated otherwise, when this specification indicates one type is derived from another type, it means the type is derived by extension or restriction, not by union or list. Similarly, when this specification uses the term type hierarchy, it is referring to the hierarchy of types derived from one another by extension or restriction
</p>
</div2></div1>
<div1 id="principles">
<head>Design Principles</head>
<p>The following design principles were used to guide the development of EXI and encourage consistent design decisions. They are listed here to provide insight into the EXI design rationale and to anchor discussions on desirable EXI traits.</p>
<glist>
<gitem>
<label>General:</label>
<def>
<p>One of primary objectives of EXI is to maximize the number of systems, devices and applications that can communicate using XML data. Specialized approaches optimized for specific use cases should be avoided.</p></def></gitem>
<gitem>
<label>Minimal:</label>
<def>
<p>To reach the broadest set of small, mobile and embedded applications, simple, elegant approaches are preferred to large, analytical or complex ones. </p></def></gitem>
<gitem>
<label>Efficient:</label>
<def>
<p>EXI must be competitive with hand-optimized binary formats so it can be used by applications that require this level of efficiency. </p></def></gitem>
<gitem>
<label>Flexible:</label>
<def>
<p>EXI must deal flexibly and efficiently with documents that contain arbitrary schema extensions or deviate from their schema. Documents that contain schema deviations should not cause encoding to fail. </p></def></gitem>
<gitem>
<label>Interoperable:</label>
<def>
<p>EXI must integrate well with existing XML technologies, minimizing the changes required to those technologies. It must be compatible with the XML Information Set <bibref ref="XMLInfoset"/>, without significant subsetting or supersetting, in order to maintain interoperability with existing and prospective XML specifications.</p></def></gitem></glist></div1>
<div1 id="concepts">
<head>Basic Concepts</head>
<p>EXI achieves broad generality, flexibility, and performance, by unifying concepts from formal language theory and information theory into a single, relatively simple algorithm. The algorithm uses a grammar to determine what is likely to occur at any given point in an XML document and encodes the most likely alternatives in fewer bits. The fully generalized algorithm works for any language that can be described by a grammar (e.g., XML, Java, HTTP, etc.); however, EXI is optimized specifically for XML languages. </p>
<p>The built-in EXI grammars accept any XML document or fragment and may be augmented with productions derived from schemas or other sources of information about what is likely to occur in a set of XML documents. 
When schemas are used, EXI also supports a user-customizable set of Datatype Representations for efficiently representing typed values.
Though use of any schema languages including XML Schemas <bibref ref="schema1"/> 
&nbsp; <bibref ref="schema2"/>, RELAX NG schemas <bibref ref="relaxng"/>, DTDs 
<bibref ref="XML10"/> &nbsp; <bibref ref="XML11"/> is permitted, EXI grammars and 
datatype representations need to be given bindings for each schema language used.
This specification only defines how EXI grammars and datatype representations 
relate to XML schema.
</p>
<p>
The <termref def="key-exiencoder">EXI stream encoder</termref> uses the grammar to map a stream of XML information items onto a smaller, lower entropy, stream of <termref def="key-exievent">events</termref>. </p>
<p>The <termref def="key-exiencoder">EXI stream encoder</termref> then represents the stream of events using a set of simple variable length codes called <termref def="key-eventcode">event codes</termref>. <termref def="key-eventcode">Event codes</termref> are similar to Huffman codes <bibref ref="huffman"/>, but are much simpler to compute and maintain. They are encoded directly as a sequence of values, or if additional compression is desired, they are passed to the <termref def="compression">EXI compression</termref> algorithm, which replaces frequently occurring event patterns to further reduce size. </p>

<!-- p>When schemas are used, EXI also supports a user-customizable set of Datatype Representations for efficiently representing typed values. </p -->
</div1>

<div1 id="streams">
<head>EXI Streams</head>
<p><termdef id="key-existream" term="EXI Stream">An <term>EXI stream</term> is an 
<termref def="key-exiheader">EXI header</termref>
followed by an EXI body.</termdef> <termdef id="key-exibody" term="EXI Body">The <term>EXI body</term> carries the content of the document, while the EXI header communicates the options used for encoding the EXI body.</termdef> Section
<specref ref="header"/> describes the <termref def="key-exiheader">EXI header</termref>. 
</p>
<!-- This is still permitted, but is not normative and should go in best practices -->
<!--
<p>Applications that use EXI streams embedded in a container data format that discerns it is an EXI stream, dictates the EXI format version and the EXI Options used for its encoding, may omit the EXI header. Although an EXI Body is not a valid EXI stream, EXI processors MAY provide a capability to process an EXI body independent of an EXI stream.
</p>
-->
<p><termdef id="key-exievent" term="EXI Event">The building block of an EXI body is an <term>EXI event</term>.</termdef> An EXI body consists of a sequence of EXI events representing an <termref def="key-exidocument">EXI document</termref> or an <termref def="key-exifragment">EXI fragment</termref>.
</p>
<p>The EXI events permitted at any given position in an EXI stream are determined by the EXI grammar. 
As is the case with XML, 
the events occur with nesting pairs of matching start element and end element events where any pair does not intersect with another except when it is fully contained in the other.

The EXI grammar incorporates knowledge of the XML grammar and may be augmented and refined using schema information and fidelity options. The EXI grammar is formally specified in section <specref ref="grammars"/>.</p>
<p>
An EXI body can represent an EXI document with a single root element or an EXI fragment with zero or more root elements. 
<termdef id="key-exidocument" term="EXI Document">
<term>EXI documents</term> are EXI bodies with a single root element that conform to the Built-in Document Grammar (See <specref ref="builtinDocGrammars"/>) or Schema-informed Document Grammar (See <specref ref="informedDocGrammars"/>).
</termdef>
<termdef id="key-exifragment" term="EXI Fragment">
<term>EXI fragments</term> are EXI bodies with zero or more root elements that conform to the Built-in Fragment Grammar (See <specref ref="builtinFragGrammars"/>) or Schema-informed Fragment Grammar (See <specref ref="informedFragGrammars"/>).
</termdef>
</p>
<p>
<termdef id="key-schemainformed-existream" term="Schema-informed EXI Stream">When schema information is available to describe the contents of an EXI body, such an EXI stream is a <term>schema-informed EXI stream</term> and the EXI body is interpreted according to the Schema-informed Document Grammar (See <specref ref="informedDocGrammars"/>) or Schema-informed Fragment Grammar (See <specref ref="informedFragGrammars"/>).</termdef> 
<termdef id="key-schemaless-existream" term="Schema-less EXI Stream">Otherwise, an EXI stream is a <term>schema-less EXI stream</term>, and the EXI body is interpreted according to the Built-in Document Grammar (See <specref ref="builtinDocGrammars"/>) or Built-in Fragment Grammar (See <specref ref="builtinFragGrammars"/>).</termdef>
</p>
<p>The following table summarizes the EXI event types and associated event content that occur in an EXI stream.  
<termdef id="key-content-item" term="Content Item">
The content of an event consists of <term>content items</term>, 
</termdef>
and the content items appear in an EXI stream in the order they are shown in the table 
following their respective <termref def="key-eventcode">event codes</termref> that 
each marks the start of an <termref def="key-exievent">event</termref>. 
In addition, the table includes the grammar notation used to represent each <termref def="key-exievent">event</termref> in this specification. Each <termref def="key-exievent">event</termref> in an EXI stream participates in a mapping system that relates <termref def="key-exievent">events</termref> to XML Information Items so that an EXI document 
or an EXI fragment 
as a whole serves to represent an XML Information Set. The table shows XML Information Items relevant to each EXI event. Appendix <specref ref="InfosetMapping"/> describes the mapping system in detail.</p>
<table id="eventTypes" border="1">
<caption>EXI events</caption>
<thead>
<tr>
<th>EXI Event Type</th>
<th>Event Content 
(Content Items) 
</th>
<th>Grammar Notation 
(Terminal Symbols) 
</th>
<th>Information Item</th>
</tr>
</thead>
<tbody>
<tr>
<td>Start Document</td>
<td>&nbsp;</td>
<td>SD</td>
<td rowspan="2"><specref ref="DocumentInformationItem"/></td></tr>
<tr>
<td>End Document</td>
<td>&nbsp;</td>
<td>ED</td></tr>
<tr>
<td rowspan="3">Start Element</td>
<td rowspan="3"><emph>qname</emph>
</td>
<td>SE (&nbsp;<emph>qname</emph>&nbsp;)</td>
<td rowspan="4"><specref ref="ElementInformationItem"/></td></tr>
<tr>
<td>SE&nbsp;(&nbsp;*&nbsp;)</td></tr>
<tr>
<td>
SE&nbsp;(&nbsp;<emph>uri&nbsp;:&nbsp;</emph>*&nbsp;)
</td></tr>
<tr>
<td>End Element</td>
<td>&nbsp;</td>
<td>EE</td></tr>
<tr>
<td rowspan="3">Attribute</td>
<td rowspan="3"><emph>qname, value</emph></td>
<td>AT&nbsp;(&nbsp;<emph>qname</emph>&nbsp;)</td>
<td rowspan="3"><specref ref="AttributeInformationItem"/></td></tr>
<tr>
<td>AT&nbsp;(&nbsp;*&nbsp;)</td></tr>
<tr>
<td>
AT&nbsp;(&nbsp;<emph>uri&nbsp;:&nbsp;</emph>*&nbsp;)
</td></tr>
<tr>
<td>Characters</td>
<td><emph>value</emph></td>
<td>CH</td>
<td><specref ref="CharacterInformationItem"/></td></tr>
<tr>
<td>Namespace Declaration</td>
<td>
<emph>
uri
</emph>, <emph>
prefix
</emph>, 
<emph>local-element-ns</emph>
</td>
<td>NS</td>
<td><specref ref="NamespaceInformationItem"/></td></tr>
<tr>
<td>Comment</td>
<td>
<emph>text</emph></td>
<td>CM</td>
<td><specref ref="CommentInformationItem"/></td></tr>
<tr>
<td>Processing Instruction</td>
<td>
<emph>name, text</emph></td>
<td>PI</td>
<td><specref ref="ProcessingInstructionInformationItem"/></td></tr>
<tr>
<td>DOCTYPE</td>
<td>
<emph>name, public, system, text</emph></td>
<td>DT</td>
<td><specref ref="DocumentTypeDeclaractionInformationItem"/></td></tr>
<tr>
<td>Entity Reference</td>
<td>
<emph>name</emph></td>
<td>ER</td>
<td><specref ref="UnexpandedEntityInformationItem"/></td></tr>
<tr>
<td>Self Contained</td>
<td>&nbsp;</td>
<td>SC</td>
<td>&nbsp;</td></tr>
</tbody></table>
<p>Section 
<specref ref="encodingEvents"/> describes the algorithm used to encode <termref def="key-exievent">events</termref> in the EXI stream. 
As indicated in the table above, there are some event types that carry content with their <termref def="key-exievent">event</termref> instances while other event types function as markers without content. 
</p>
<p>SE events may be followed by a series of NS events. Each NS event either associates a prefix with an URI, assigns a default namespace, or in the case of a namespace declaration with an empty URI, rescinds one of such associations in effect at the point of its occurrence. The effect of the association or disassociation caused by a NS event stays in effect until the corresponding EE event occurs.
</p>
<p>Like XML, the namespace of a particular element may be specified by a namespace declaration 
preceding 
the element or a local namespace declaration following the element name. When the namespace is specified by a local namespace declaration, the <emph>local-element-ns</emph> flag of the associated NS event is set to true and the prefix of the element is set to the prefix of that NS event. When the namespace is specified by a previous namespace declaration, the <emph>local-element-ns</emph> flag of all local NS events is false and the prefix of the element is set according to the prefix component of the element <emph>qname</emph>. The series of NS events associated with a particular element may include at most one NS event with its 
<emph>local-element-ns</emph> flag
 set to true. The <emph>uri</emph> of a NS event with its 
<emph>local-element-ns</emph> flag
 set to true MUST match the <emph>uri</emph> of the associated SE event.
</p>
<p>An SE event may be followed by a SC event, indicating the element is self-contained and can be read independently from the rest of the EXI body. Applications may use self-contained elements to index portions of the EXI body for random access.
</p>
<p>
The representation of <termref def="key-eventcode">event codes</termref> which identify the event type and start each event is described in <specref ref="encodingEventCodes"/>. 
Each item in the event content has a 
datatype representation
associated with it as shown in the following table. The content of each <termref def="key-exievent">event</termref>, if any, is encoded as a sequence of items each of which being encoded according to its 
datatype representation 
in order starting with the first item followed by subsequent items.</p>
<table border="1" width="95%" id='table2'>
<caption>Datatype representations of event content items</caption>
<colgroup width="20%"/>
<colgroup width="30%"/>
<colgroup width="50%"/>
<thead>
<tr>
<th>Content item</th>
<th>Used in</th>
<th>
Datatype representation
</th></tr>
</thead>
<tbody>
<tr>
<td id="key-nameContentItem">
<emph>name</emph></td>
<td>PI, DT, ER</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-prefixContentItem">
<emph>prefix</emph></td>
<td>NS</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-indicatorContentItem">
<emph>local-element-ns</emph>
</td>
<td>NS</td>
<td>
<specref ref="encodingBoolean"/></td></tr>
<tr>
<td id="key-publicContentItem">
<emph>public</emph></td>
<td>DT</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-qnameContentItem">
<emph>qname</emph></td>
<td>SE, AT</td>
<td>
<specref ref="encodingQName"/></td></tr>
<tr>
<td id="key-systemContentItem">
<emph>system</emph></td>
<td>DT</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-textContentItem">
<emph>text</emph></td>
<td>CM, PI, DT</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-uriContentItem">
<emph>uri</emph></td>
<td>NS</td>
<td>
<specref ref="encodingString"/></td></tr>
<tr>
<td id="key-valueContentItem">
<emph>value</emph></td>
<td>CH, AT</td>
<td>According to the schema datatype (see 
<specref ref="encodingValues"/>) if any is in effect, otherwise <specref ref="encodingString"/></td></tr></tbody></table>

<p>The datatype representation 
used for each <termref def="key-valueContentItem"><emph>value</emph></termref> content item depends on the schema 
<xspecref spec="XS2" ref="datatype">datatype</xspecref> 
if any that is in effect for that <termref def="key-valueContentItem"><emph>value</emph></termref>. 
The String datatype representation (see <specref ref="encodingString"/>) 
is used for <termref def="key-valueContentItem"><emph>values</emph></termref> that do not have an associated schema datatype, 
cannot be or are opted not to be represented by their associated datatype representations, 
or occur in mixed content. Section 
<specref ref="encodingValues"/> describes how each of the types listed above are encoded in an EXI stream. </p>
<note>
The syntax and semantics of the NS event are designed to minimize the overhead required for representing namespace prefixes in EXI streams without introducing significant complexity. In the common case where each namespace is bound to a single prefix, this design reduces the overhead for representing all element and attribute namespace prefixes to zero bits.
</note>
</div1>
<div1 id="header">
<head>EXI Header</head>
<p>
Each <termref def="key-existream">EXI stream</termref> begins with an EXI header.
<termdef id="key-exiheader" term="EXI header">
The <term>EXI header</term> 
can identify EXI streams, 

distinguish EXI 
streams 

from text XML documents, 
identify the version of the EXI format being used, and specify the options used to process the body of the EXI stream.
</termdef>
The EXI header has the following structure:
</p>

<table border="1" rules="cols">
<tbody>
<tr>
<td align="center" rowspan="2">
<termref def="key-exiCookie">
&nbsp;[&nbsp;EXI&nbsp;Cookie&nbsp;]&nbsp;
</termref>

</td>
<td align="center" rowspan="2">
<termref def="key-distinguishingbits">
&nbsp;Distinguishing&nbsp;Bits&nbsp;
</termref></td>
<td align="center">
&nbsp;Presence&nbsp;Bit&nbsp;
</td>
<td align="center">
<termref def="key-version">
&nbsp;EXI&nbsp;Format&nbsp;
</termref>
</td>
<td align="center" rowspan="2">
&nbsp;[<termref def="key-options">EXI&nbsp;Options</termref>]&nbsp;
</td>
<td align="center" rowspan="2">
&nbsp;[Padding&nbsp;Bits]&nbsp;
</td>
</tr>
<tr>
<td align="center">
&nbsp;for&nbsp;EXI&nbsp;Options&nbsp;
</td>
<td align="center">
<termref def="key-version">
&nbsp;Version&nbsp;
</termref>
</td>
</tr>
</tbody>
</table>
<p>The EXI Options field within an EXI header is optional.  Its presence is indicated by
the value of the presence bit that follows <termref def="key-distinguishingbits">Distinguishing Bits</termref>. The presence and absence is indicated by the value 1 and 0, respectively.  
</p>

<p>When the <termref def="key-compressionOption">compression</termref> option is true, or the <termref def="key-alignmentOption">alignment</termref> option is <termref def="key-bytealignment">byte-alignment</termref> or <termref def="key-precompression">pre-compression</termref>, 
padding bits of minimum length required to make the whole length of 
the header byte-aligned are added at the end of the header. 
On the other hand, there are no padding bits when the alignment in use is <termref def="key-unaligned">bit-packed</termref>.
The padding bits field 
if it is present 
can contain any values of bits as its contents.
</p>

<p>
The details of the 
<termref def="key-exiCookie">EXI Cookie</termref>, 

<termref def="key-distinguishingbits">Distinguishing Bits</termref>, <termref def="key-version">EXI Format Version</termref> and <termref def="key-options">EXI Options</termref> are described in the following sections.
</p>

<div2 id="EXICookie">
<head>EXI Cookie</head>
<p>
<termdef id="key-exiCookie" term="EXI Cookie">
An <termref def="key-exiheader">EXI header</termref> MAY start with an <term>EXI Cookie</term>,
which is a four byte field that serves to indicate that the stream of which it is a part is an EXI stream.</termdef> The four byte field consists of four characters 
"&nbsp;$&nbsp;" , "&nbsp;E&nbsp;", "&nbsp;X&nbsp;" and "&nbsp;I&nbsp;" 

in that order, each represented as an ASCII octet, as follows.
</p>

<table border="1">
<tbody>
<tr class="bitcell">
<td align="center" class="bitcell">'<sup>&nbsp;</sup>$<sub>&nbsp;</sub>'</td>
<td align="center" class="bitcell">'<sup>&nbsp;</sup>E<sub>&nbsp;</sub>'</td>
<td align="center" class="bitcell">'<sup>&nbsp;</sup>X<sub>&nbsp;</sub>'</td>
<td align="center" class="bitcell">'<sup>&nbsp;</sup>I<sub>&nbsp;</sub>'</td>
</tr>
</tbody>
</table>

<p>
This four byte sequence is particular to EXI and specific enough to distinguish EXI streams from a broad range of data types currently used on the Web. While the EXI cookie is optional, its use is RECOMMENDED in the EXI header when the EXI stream is exchanged in a context where a longer, more specific content-based datatype identifier is desired than that provided by the <termref def="key-distinguishingbits">Distinguishing Bits</termref>,  whose role is more narrowly focused on distinguishing EXI streams from XML documents.
</p>

</div2>

<div2 id="DistinguishingBits">
<head>Distinguishing Bits</head>

<p>
<termdef id="key-distinguishingbits" term="Distinguishing Bits">
The second part in the EXI header is the <term>Distinguishing Bits</term>,
which is a two bit field of which the first bit contains the value 1 and the second bit contains the value 0, as follows.</termdef>
</p>

<table border="1">
<tbody>
<tr class="bitcell">
<td align="center" class="bitcell">1</td>
<td align="center" class="bitcell">0</td></tr>
</tbody>
</table>

<p>
Unlike the optional EXI cookie that MAY occur to precede this field, the presence of Distinguishing Bits is REQUIRED in the EXI header. It is used to distinguish EXI  streams from text XML documents in the absence of an <termref def="key-exiCookie">EXI cookie</termref>.

This two bit sequence is the minimum that suffices to distinguish EXI
streams from XML documents since it is the minimum length bit
pattern that cannot occur as the first two bits of a well-formed XML
document represented in any one of the conventional character
encodings, such as UTF-8, UTF-16, UTF-32, UCS-2, UCS-4, EBCDIC, ISO 8859,
Shift-JIS and EUC, according to 
XML <bibref ref="XML10"/> &nbsp; <bibref ref="XML11"/>. 
Therefore, XML Processors that do not support EXI are expected to reject an EXI stream as early as they read
and process the first byte from the stream.</p>

<p>
Systems that use EXI streams as well as XML documents can reliably look at
the Distinguishing Bits to determine whether to interpret a particular
stream as XML or EXI.
</p>
</div2>

<div2 id="version">
<head>EXI Format Version</head>
<p><termdef id="key-version" term="EXI Format Version">
The fourth part in the EXI header is the <term>EXI Format Version</term>, which identifies the version of the EXI format being used.</termdef>
EXI format version numbers are integers. Each version of the EXI Format Specification specifies the corresponding EXI format version number to be used by conforming implementations. The EXI format version number that corresponds with this version of the EXI format specification is 1 (one).</p>

<p>
The first bit of the version field indicates whether the version is a preview or final version of the EXI format.
A value of 0 indicates this is a final version and a value of 1 indicates this is a preview
version. Final versions correspond to final, approved versions of the EXI format specification.
An <termref def="key-exiprocessor">EXI processor</termref> that implements a final version of the EXI format specification is REQUIRED to process EXI streams that have a version field with its first bit set to 0 followed by a version number that corresponds to the version of the EXI specification the processor implements. The behavior of an EXI processor on an EXI stream with its first bit set to 0 followed by a version not corresponding to a version implemented by the processor is not constrained by this specification. For example, the EXI processor MAY reject such a stream outright or it MAY attempt to process the EXI body.

Preview versions of the EXI format are useful for
gaining implementation and deployment experience prior to finalizing a
particular version of the EXI format. While preview versions may match drafts of this specification, they are not governed by this specification and the behaviour of EXI processors encountering preview versions of the EXI format is implementation dependent. Implementers are free to coordinate to achieve interoperability between different preview versions of the EXI format.
</p>

<p>Following the first bit of the version is a sequence of one or more
4-bit unsigned integers representing the version number. The version
number is determined by summing this sequence of 4-bit unsigned
values and adding 1 (one). The sequence is terminated by any 4-bit unsigned integer with
a value in the range 0-14. As such, the first 15 version numbers are
represented by 4 bits, the next 15 are represented by 8 bits, etc.</p>

<p>Given an EXI stream with its stream cursor positioned just past the first bit of the EXI format version field, the EXI format version number can be computed by going through the following steps with version number initially set to 1.</p>
<olist>
<item>Read next 4 bits as an unsigned integer value.</item>
<item>Add the value that was just read to the version number.</item>
<item>If the value is 15, go to step 1, otherwise (i.e. the value being in the range of 0-14), use the current value of the version number as the EXI version number.</item>
</olist>

<p>The following are example EXI format version numbers.</p>

<example>
<head>EXI Format Version Examples</head>
<table border="1">
<!-- caption>EXI Version Examples</caption -->
<thead>
<tr>
<th width="200">EXI Format Version Field</th>
<th width="200">Description</th></tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;1 0000</td>
<td>&nbsp;&nbsp;Preview version 1</td>
</tr>
<tr>
<td>&nbsp;&nbsp;0 0000</td>
<td>&nbsp;&nbsp;Final version 1</td>
</tr>
<tr>
<td>&nbsp;&nbsp;0 1110</td>
<td>&nbsp;&nbsp;Final version 15</td>
</tr>
<tr>
<td>&nbsp;&nbsp;0 1111 0000</td>
<td>&nbsp;&nbsp;Final version 16</td>
</tr>
<tr>
<td>&nbsp;&nbsp;0 1111 0001</td>
<td>&nbsp;&nbsp;Final version 17</td>
</tr>
</tbody>
</table>
</example>

<p><termref def="key-exiprocessor">EXI processors</termref> conforming with the final version of this
specification MUST use the 5-bit value 0 0000 as the version
number.</p>

</div2>
<div2 id="options">
<head>EXI Options</head>
<p><termdef id="key-options" term="EXI Options">The 
fifth 

part of the EXI
header is the <term>EXI Options</term>, which provides a way to specify the
options used to encode the body of the EXI stream</termdef>.
<termdef id="key-optionsDoc" term="EXI Options document">

The EXI Options are represented as an <term>EXI Options document</term>, which is an XML document encoded using the EXI format described in this specification.

</termdef>
This results in a very compact header
format that can be read and written with very little additional software.
</p>
<p>The presence of EXI Options in its entirety is optional in EXI header,
and it is predicated on the value of the presence bit that follows the
<termref def="key-distinguishingbits">Distinguishing Bits</termref>.
When EXI Options are present in the header, an EXI Processor MUST observe the
specified options to process the EXI stream that follows. Otherwise,
an EXI Processor may obtain the EXI options using another mechanism. 
There are no fallback option values provided by this specification for use
in the absence of the whole EXI Options part.

</p>
<p>
<termref def="key-exiprocessor">EXI processors</termref> MAY provide external means for applications or users to
specify EXI Options when the EXI Options document is absent.
Such <termref def="key-exiprocessor">EXI processors</termref> are typically used in controlled systems
where the knowledge about the effective EXI Options is shared prior to
the exchange of EXI 
streams . The mechanisms to communicate out-of-band EXI Options and their representation are implementation dependent.</p>

<p>The following table describes the EXI options that may be specified in the
EXI Options document.</p>

<table border="1" id="exiOptionsInOptionsField">
<caption>EXI Options in Options Document</caption>
<thead>
<tr>
<th>EXI Option</th>
<th>Description</th>

<th>Default Value</th>

</tr>
</thead>
<tbody>
<tr>
<td>
<termref def="key-alignmentOption">alignment</termref>
</td>
<td>
Alignment of <termref def="key-eventcode">event codes</termref> and <termref def="key-content-item">content items</termref>
</td>
<td>
<termref def="key-unaligned">bit-packed</termref>
</td>
</tr>
<tr>
<td><termref def="key-compressionOption">compression</termref></td>
<td>EXI compression is used to achieve better compactness</td>
<td>false</td>
</tr>
<tr>
<td><termref def="key-strictOption">strict</termref></td>
<td>Strict interpretation of schemas is used to achieve better compactness</td>
<td>false</td>
</tr>
<tr>
<td><termref def="key-fragmentOption">fragment</termref></td>
<td>Body is encoded as an <termref def="key-exifragment">EXI fragment</termref> instead of an <termref def="key-exidocument">EXI document</termref>
</td>
<td>false</td>
</tr>
<tr>
<td><termref def="key-preserveOption">preserve</termref></td>
<td>
Specifies whether the support for the preservation of comments, pis, etc. is each enabled
<!--
Specifies whether comments, pis, etc. are preserved
-->
</td>
<td>all false</td>
</tr>
<tr>
<td><termref def="key-selfContained">selfContained</termref></td>
<td>Enables self-contained elements</td>
<td>false</td>
</tr>
<tr>
<td><termref def="key-schemaIdOption">schemaId</termref></td>
<td>Identify the schema information, if any, used to encode the body</td>
<td>
<emph>no default value</emph>
</td>
</tr>
<tr>
<td><termref def="key-datatypeRepresentationOption">
datatypeRepresentationMap
</termref></td>
<td>
Specify alternate datatype representations for typed <termref def="key-valueContentItem"><emph>values</emph></termref> in the <termref def="key-exibody">EXI body</termref>

</td>
<td>
<emph>no default value</emph>
</td>
</tr>
<tr>
<td><termref def="key-blockSizeOption">blockSize</termref></td>
<td>Specifies the block size used for EXI compression</td>
<td>1,000,000</td>
</tr>
<tr>
<td>
<termref def="key-valueMaxLengthOption">valueMaxLength</termref>

</td>
<td>
Specifies the maximum string length of 
<termref def="key-valueContentItem"><emph>value</emph></termref> 
content items to be considered for addition to the string table.
</td>
<td>
unbounded

</td>
</tr>
<tr>
<td>
<termref def="key-valuePartitionCapacityOption">valuePartitionCapacity</termref>
</td>
<td>
Specifies the total capacity of value partitions in a string table

</td>
<td>
unbounded

</td>
</tr>
<tr>
<td><termref def="key-userMetaData">[user defined meta-data]</termref></td>
<td>User defined meta-data may be added</td>
<td><emph>no default value</emph></td>
</tr>
</tbody>
</table>

<p>Appendix <specref ref="optionsSchema"/> provides an XML Schema
describing 
<termref def="key-optionsDoc">the EXI Options document</termref>.
This schema is designed to produce smaller headers
for option combinations used when compactness is critical.</p>

<p>
The <termref def="key-optionsDoc">EXI Options document</termref> is
represented as an <termref def="key-exibody">EXI body</termref> 
 informed by the above mentioned schema using the default options 
specified by the following XML document.
An EXI Options document consists only of an EXI body, and MUST NOT 
start with an EXI header.
</p>

<reprdef>
<head>Header options used for encoding the <termref def="key-optionsDoc">EXI Options document</termref></head>
<repr xml:space="preserve">
  &lt;header xmlns="&exins;"&gt;
    &lt;strict/&gt;
  &lt;/header&gt;
</repr>
</reprdef>

<p>Note that this specification does not require <termref def="key-exiprocessor">EXI processors</termref> to read and process the schema prescribed for EXI options document (<specref ref="optionsSchema"/>), in order to process EXI options documents. EXI processors MUST use the schema-informed grammars that stem from the schema in processing EXI options documents, beyond which there is no requirement as to the use of the schema, and implementations are free to use any methods to retrieve the instructions that observe the grammars for processing EXI options documents. Section <specref ref="informedGrammars"/> describes the system to derive schema-informed grammars from XML Schemas.
</p>

<p>Below is a brief description of each EXI option.</p>

<p><termdef id="key-alignmentOption">The <term>alignment option</term> is used to control the alignment of <termref def="key-eventcode">event codes</termref> and <termref def="key-content-item">content items</termref>.</termdef> The value is one of <termref def="key-unaligned">bit-packed</termref>, <termref def="key-bytealignment">byte-alignment</termref> or <termref def="key-precompression">pre-compression</termref>, of which <termref def="key-unaligned">bit-packed</termref> is the default value assumed when the "alignment" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref>. 
The option values <termref def="key-bytealignment">byte-alignment</termref> and <termref def="key-precompression">pre-compression</termref> are effected when "byte" and "pre-compress" elements are present in the EXI Options document, respectively. 
When the value of <termref def="key-compressionOption">compression option</termref> is set to true, alignment of the EXI Body is governed by the rules specified in <specref ref="compression"/> instead of the alignment option value. The "alignment" element MUST NOT appear in an EXI options document when the "compression" element is present.
</p>

<p><termdef id="key-unaligned">The alignment option value <term>bit-packed</term> indicates that the <termref def="key-eventcode">event codes</termref> and associated content are packed in bits without any padding in-between.</termdef>
</p>

<p><termdef id="key-bytealignment">The alignment option value <term>byte-alignment</term> indicates that the <termref def="key-eventcode">event codes</termref> and associated content are aligned on byte boundaries.</termdef> While byte-alignment generally results in EXI streams of larger sizes compared with their bit-packed equivalents, byte-alignment may provide a help in some use cases that involve frequent copying of large arrays of scalar data directly out of the stream. It can also make it possible to work with data in-place and can make it easier to debug encoded data by allowing items on aligned boundaries to be easily located in the stream.</p>

<p>
<termdef id="key-precompression">The alignment option value <term>pre-compression</term> indicates that all steps involved in compression (see section <specref ref="compression"/>) are to be done with the exception of the final step of applying the DEFLATE algorithm.</termdef> The primary use case of pre-compression is to avoid a duplicate compression step when compression capability is built into the transport protocol. In this case, pre-compression just prepares the stream for later compression.
</p>

<p>
<termdef id="key-compressionOption">The <term>compression option</term> is a Boolean used to increase compactness using additional computational resources.</termdef> The default value "false" is assumed when the "compression" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref> whereas its presence denotes the value "true". 
When set to true, the <termref def="key-eventcode">event codes</termref> and associated content are compressed according to <specref ref="compression"/> regardless of the <termref def="key-alignmentOption">alignment</termref> option value. As mentioned above, the "compression" element MUST NOT appear in an EXI options document when the "alignment" element is present.
</p>

<p>
<termdef id="key-strictOption">The <term>strict option</term> is a Boolean used to increase compactness by using a strict interpretation of the schemas and omitting preservation of certain items, such as comments, processing instructions and namespace prefixes.</termdef> The default value "false" is assumed when the "strict" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref> 
whereas its presence denotes the value "true". 
When set to true, 
those productions that have NS, CM, PI, ER, and SC terminal symbols are omitted from the
EXI grammars, and schema-informed element and type grammars are restricted to only permit items declared in the schemas. 
A note in section <specref ref="addingProductionsStrict"/> describes some additional restrictions consequential of the use of this option.
<!--
Consequently, when the strict option is set to true 
for a schema-informed EXI stream, 
xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes are 
permitted to appear in a schema-informed element only when they match specific schema declarations (i.e., wildcards or ur-types).
-->
<!--
The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes are not permitted to appear in an element when the strict option is set to true unless its type is defined with an attribute wildcard that results in its grammar having a production of which the right-hand side starts with either AT&nbsp;(*) or AT&nbsp;(&nbsp;xsi&nbsp;:&nbsp;*&nbsp;) events.-->
The "strict" element MUST NOT appear in an <termref def="key-optionsDoc">EXI options document</termref> when 
one of "dtd", "prefixes", "comments", "pis" or "selfContained" 
element is present in the same options document.
</p>

<p>
<termdef id="key-fragmentOption">The <term>fragment option</term> is a Boolean that indicates whether the <termref def="key-exibody">EXI body</termref> is an <termref def="key-exidocument">EXI document</termref> or an <termref def="key-exifragment">EXI fragment</termref>.</termdef>  When set to true, the <termref def="key-exibody">EXI body</termref> is an <termref def="key-exifragment">EXI fragment</termref>. Otherwise, the <termref def="key-exibody">EXI body</termref> is an <termref def="key-exidocument">EXI document</termref>. The default value "false" is assumed when the "fragment" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref> 
whereas its presence denotes the value "true". 
</p>

<p><termdef id="key-preserveOption">The <term>preserve option</term> is a set of Booleans that can be set independently 
to each enable or disable a share of the format's capacity determining whether or how certain information items can be preserved in the EXI stream.
</termdef> 
Section <specref ref="fidelityOptions"/> describes the set of information items 
affected by the preserve option.
The presence of "dtd", "prefixes", "lexicalValues", "comments" and "pis" in the EXI Options document each turns on fidelity options Preserve.comments, Preserve.pis, Preserve.dtd, Preserve.prefixes and Preserve.lexicalValues whereas the absence denotes turning each off. 
The elements "dtd", "prefixes", "comments" and "pis" 
MUST NOT appear in an <termref def="key-optionsDoc">EXI options document</termref> when the "strict" element is present in the same options document. 
The element "lexicalValues", on the other hand, is permitted to occur in the presence of "strict" element.
</p>

<p><termdef id="key-selfContained">The <term>selfContained option</term> is a Boolean used to enable the use of self-contained elements in the EXI stream.</termdef> Self-contained elements may be read independently from the rest of the EXI body, allowing them to be indexed for random access. The "selfContained" element MUST NOT appear in an <termref def="key-optionsDoc">EXI options document</termref> when 
one of "compression", "pre-compression" or "strict" elements are present 
in the same options document. The default value "false" is assumed when the "selfContained" element is absent from the <termref def="key-optionsDoc">EXI Options document</termref> 
whereas its presence denotes the value "true". 
</p>

<p><termdef id="key-schemaIdOption">The <term>schemaId option</term> may be used to identify the schema information used 
for processing 
the EXI body.</termdef> When the 
"schemaId" element in the <termref def="key-optionsDoc">EXI options document</termref> contains the xsi:nil attribute 
with its value set to true, 
no schema information 
is used for processing
the EXI body (i.e. a <termref def="key-schemaless-existream">schema-less EXI stream</termref>). 
When the value of the "schemaId" element is empty, no user defined schema information is used for processing the EXI body;
however, the built-in XML schema types are available for use in the EXI body.
When the schemaId option is absent (i.e., undefined), no statement is made about the schema information used to encode the EXI body and this information
MUST be communicated out of band.
This specification does not dictate the syntax or semantics of other values specified in this field. An example schemaId scheme is the use of URI that is apt for globally identifying schema resources on the Web.
The parties involved in the exchange are free to agree on the scheme of schemaId field that is appropriate for their use to uniquely identify the schema information. 
</p>

<p><termdef id="key-datatypeRepresentationOption">The <term>
datatypeRepresentationMap option</term> 
specifies an alternate set of datatype representations for typed
<termref def="key-valueContentItem"><emph>values</emph></termref> in 
the <termref def="key-exibody">EXI body</termref> 
as described in <specref ref="datatypeRepresentationMap"/>.</termdef>
When there are no "datatypeRepresentationMap" elements in the <termref def="key-optionsDoc">EXI Options document</termref>, no Datatype Representation Map is used for processing the EXI body.
This option does not take effect when the value of the Preserve.lexicalValues fidelity option is true (see <specref ref="fidelityOptions"/>), 
or when  the <termref def="key-existream">EXI stream</termref> is a <termref def="key-schemaless-existream">schema-less EXI stream.</termref>

</p>

<p><termdef id="key-blockSizeOption">The <term>blockSize option</term> specifies the block size used for EXI compression.</termdef> When the "blockSize" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref>, the default blocksize of 1,000,000 is used. The default blockSize is intentionally large but can be reduced for processing large documents on devices with limited memory.</p> 


<p>

<termdef id="key-valueMaxLengthOption">
The <term>valueMaxLength option</term> specifies the maximum length of <termref def="key-valueContentItem"><emph>value</emph></termref> content items to be considered for addition to the string table.
</termdef> 
The default value "unbounded" is assumed when the "valueMaxLength" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref>.
</p> 

<p>
<termdef id="key-valuePartitionCapacityOption">
The <term>valuePartitionCapacity option</term> specifies the maximum number of <termref def="key-valueContentItem"><emph>value</emph></termref> content items in the string table at any given time.
</termdef>
The default value "unbounded" is assumed when the "valuePartitionCapacity" element is absent in the <termref def="key-optionsDoc">EXI Options document</termref>. 
Section <specref ref="encodingOptimizedForMisses"/> specifies the behavior of the string table when this capacity is reached.



<!--
only when doing so would not cause the number of unique values in value partitions to exceed the capacity.
The use of valuePartitionCapacity option value and the way the number of unique values are counted for value partitions are described in <specref ref="stringTablePartitions"/>.
-->
</p> 
<p>
<termdef id="key-userMetaData">
The <term>user defined meta-data</term> conveys auxiliary information that applications may use to facilitate interpretation of the EXI stream. 
</termdef> 
The user defined meta-data MUST NOT be interpreted in a way that alters or extends the EXI data format defined in this specification. 
User defined meta-data may be added to an EXI Options document just prior to the <termref def="key-alignmentOption">alignment</termref> option. 
</p>

</div2>
</div1>

<div1 id="encodingEvents">
<head>Encoding EXI Streams</head>
<p>The rules for encoding a series of <termref def="key-exievent">events</termref> as an <termref def="key-existream">EXI stream</termref> are very
simple and are driven by a declarative set of grammars that describes
the structure of an <termref def="key-existream">EXI stream</termref>. Every <termref def="key-exievent">event</termref> in the stream is
encoded using the same set of encoding rules, which are summarized as
follows: </p>
<olist>
<item>Get the next event 
data 
to be encoded</item>
<item>If fidelity options (see <specref ref="fidelityOptions"/>) indicate this event type is not processed,
go to step 1
</item>
<item>Use the grammars to determine the <termref def="key-eventcode">event code</termref> of the <termref def="key-exievent">event</termref></item>
<item>Encode the <termref def="key-eventcode">event code</termref> followed by the event content (see <specref ref="eventTypes"/>)</item>
<item>Evaluate the grammar production matched by the <termref def="key-exievent">event</termref></item>
<item>Repeat until the End Document (ED) event is encoded</item></olist>

<p>Self-contained (SC), namespace (NS) and attribute (AT) events associated with a given element occur directly after the start element (SE) event in the following order:</p>

<table border="1" rules="cols">
<tbody>
<tr>
<td align="center" width="50" height="30">SC</td>
<td align="center" width="50">NS</td>
<td align="center" width="50">NS</td>
<td align="center" width="50">...</td>
<td align="center" width="50">NS</td>
<td align="center" width="100">
AT (xsi:type)
</td>
<td align="center" width="100">
AT (xsi:nil)
</td>
<td align="center" width="50">AT</td>
<td align="center" width="50">AT</td>
<td align="center" width="50">...</td>
<td align="center" width="50">AT</td>
</tr>
</tbody>
</table>

<p>Namespace (NS) events occur in document order. 
The xsi:type and xsi:nil attributes 
occur before all other AT events. 
When the grammar currently in effect for the element is either a <termref def="key-builtin-elem-grammar"/> (see <specref ref="builtinElemGrammars"/>) or a <termref def="key-informed-elem-fragment-grammar">schema-informed element fragment grammar</termref> (see <specref ref="informedElementFragGrammar"/>), the remaining attribute (AT) events can occur in any order. Otherwise, when the grammar in effect is a <termref def="key-informedElementGrammar">schema-informed element grammar</termref> or a <termref def="key-informedTypeGrammar">schema-informed type grammar</termref> (see <specref ref="informedElemGrammars"/>), the remaining attributes can occur in any order that is permitted by the grammar, though in practice they SHOULD occur in lexicographical order sorted first by <emph>qname</emph> local-name then by <emph>qname</emph> uri for achieving better compactness, where a <emph>qname</emph> is a <termref def="key-qname">qname</termref> of an attribute.
</p>

<note>
Under certain cirmcumstances, it is not strictly required that the xsi:type or xsi:nil attributes occur before other AT events of the same element. See the notes in section <specref ref="builtinElemGrammars"/> for details.
</note>

<p>EXI uses the same simple procedure described above, to encode well-formed documents, document fragments, schema-valid information items, schema-invalid information items, information items partially described by schemas and information items with no schema at all. Only the grammars that describe these items differ. For example, an element with no schema information is encoded according to the XML grammar defined by the XML specification, while an element with schema information is encoded according to the more specific grammar defined by that schema. </p>

<p><termdef id="key-eventcode" term="Event Code">An <term>event code</term> is a sequence of 1 to 3 non-negative integers called parts used to identify each event in an EXI stream. The EXI grammars describe which events may occur at each point in an EXI stream and associate an even code with each one.</termdef> 
(See <specref ref="grammarEventCodes"/> for more description of event codes.) 

</p>

<p>Section <specref ref="eventCodes"/> describes in detail how the grammar is used to determine the event code of an <termref def="key-exievent">event</termref>. Section <specref ref="encodingEventCodes"/> describes in detail how event codes are represented as bits. Section 
<specref ref="fidelityOptions"/> describes available fidelity options and how they 
affect 
the EXI stream. Section <specref ref="encodingValues"/> describes how the typed event contents are represented as bits. </p>

<div2 id="eventCodes">
<head>Determining Event Codes</head>
<p>The structure of an EXI stream is described by the EXI grammars, which are formally specified in section 
<specref ref="grammars"/>. Each grammar defines which events are permitted to occur at any given point in the EXI stream and provides a pre-assigned <termref def="key-eventcode">event code</termref> for each one.
</p>

<p>For example, the grammar productions below describe the events that can occur in a schema-informed EXI stream after the Start-Document (SD) event provided there are four global elements defined in the schema and assign an <termref def="key-eventcode">event code</termref> for each one. 
See <specref ref="informedDocGrammars"/> for the process used for generating the grammar productions below from the schema.
</p>
<example>
<head>Example productions with event codes</head>

<table width="95%">
<thead>
<tr>
<th colspan="4">&nbsp;</th>
</tr>
<tr>
<th align="left" colspan="3">&nbsp;&nbsp;Syntax</th>
<th align="left">Event Code</th></tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3"><emph>DocContent</emph></td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SE ("A") 
<emph>DocEnd</emph></td>
<td>0</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SE ("B") 
<emph>DocEnd</emph></td>
<td>1</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SE ("C") 
<emph>DocEnd</emph></td>
<td>2</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SE ("D") 
<emph>DocEnd</emph></td>
<td>3</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SE&nbsp;(*) 
<emph>DocEnd</emph></td>
<td>4</td></tr>
<tr>
<td></td>
<td></td>
<td>DT 
<emph>DocContent</emph></td>
<td>5.0</td></tr>
<!-- tr>
<td></td>
<td></td>
<td>CH 
<emph>DocContent</emph></td>
<td>5.1</td></tr -->
<tr>
<td></td>
<td></td>
<td>CM 
<emph>DocContent</emph></td>
<td>5.1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>DocContent</emph></td>
<td>5.1.1</td></tr></tbody></table></example>
<p>At the point in an EXI stream where the above grammar productions are in effect, the <termref def="key-eventcode">event code</termref> of Start Element "A" (i.e. SE("A")) is 0. The event code of a DOCTYPE (DT) event at this point in the stream is 5.0, and so on. 
</p>
</div2>

<div2 id="encodingEventCodes">
<head>Representing Event Codes</head>

<p>Each <termref def="key-eventcode">event code</termref> is represented by a sequence of 1 to 3 parts that uniquely identify an event. 

<termref def="key-eventcode">Event code</termref> parts are encoded in order starting with the first part followed by subsequent parts.</p>

<p>
<!--
When the value of <termref def="key-compressionOption">compression option</termref> is false, and
<termref def="key-unaligned">bit-packed</termref> alignment option is used for the current processing of the stream,
the <emph>i</emph>-th part of an <termref def="key-eventcode">event code</termref> is encoded using the minimum number of bits required to distinguish it from the <emph>i</emph>-th part of the other sibling event codes in the current grammar. Specifically,
-->
The 
<emph>i</emph>-th part of an <termref def="key-eventcode">event code</termref> is encoded as an <emph>n</emph>-bit unsigned integer (<specref ref="encodingBoundedUnsigned" />), where 
<emph>n</emph> is &lceil;&nbsp;log<sub>&nbsp;2</sub>&nbsp;<emph>m</emph>&nbsp;&rceil; and <emph>m</emph> is the number of distinct values used as the 
<emph>i</emph>-th part of its own and all its sibling event codes in the current grammar.
<!-- In cases, where there is only one distinct value for a given part, the part is omitted (i.e., encoded in log 
<sub>2</sub> 1 = 0 bits). -->
Two <termref def="key-eventcode">event codes</termref> are siblings at the <emph>i</emph>-th part if and only if they share the same values in all preceding parts. All <termref def="key-eventcode">event codes</termref> are siblings at the first part.
</p>

<!-- this is covered in section 7.1.9 and doesn't need to be replicated here 
<p>
On the other hand, when the value of <termref def="key-compressionOption">compression option</termref> is true, or either <termref def="key-bytealignment">byte-alignment</termref> or <termref def="key-precompression">pre-compression</termref> alignment option is used, 
the <emph>i</emph>-th part of an <termref def="key-eventcode">event code</termref> is encoded using the minimum number of bytes instead of 
bits required to distinguish it from the <emph>i</emph>-th part of the other sibling event codes in 
the current grammar.  Each part is encoded as an <emph>n</emph>-bit unsigned integer 
(<specref ref="encodingBoundedUnsigned" />), of which 
<emph>n</emph> is &lceil;&nbsp;log<sub>&nbsp;2</sub>&nbsp;<emph>m</emph>&nbsp;&rceil; where <emph>m</emph> is the 
number of distinct values used as the 
<emph>i</emph>-th part of its own and all its sibling <termref def="key-eventcode">event codes</termref> in the current grammar.
The number of bytes used for the <emph>n</emph>-bit unsigned integer representation in this case 
is equal to &lceil;&nbsp;<emph>n</emph>&nbsp;/&nbsp;8&nbsp;&rceil;.</p>

<p>Regardless of the values of <termref def="key-compressionOption">compression option</termref> and <termref def="key-alignmentOption">alignment option</termref>, 
-->

<p>
If there is only one distinct value for a given part, the part is omitted (i.e., encoded in log<sub>&nbsp;2</sub>&nbsp;1 =&nbsp;0&nbsp;bits =&nbsp;0&nbsp;bytes).
</p>
<p>For example, the eight  <termref def="key-eventcode">event codes</termref> shown in the 
<emph>DocContent</emph> grammar above have values ranging from 0 to 5 for the first part. Six distinct values are needed to identify the first part of these <termref def="key-eventcode">event codes</termref>. 
Therefore, the first part can be encoded as an <emph>n</emph>-bit unsigned integer where <emph>n</emph> = &lceil;&nbsp;log<sub>&nbsp;2</sub>&nbsp;6&nbsp;&rceil; =&nbsp;3. In the same fashion, the second and third part (if present) are represented as <emph>n</emph>-bit unsigned integers where <emph>n</emph> is &lceil;&nbsp;log<sub>&nbsp;2</sub>&nbsp;2&nbsp;&rceil; =&nbsp;1&nbsp; and &lceil;&nbsp;log<sub>&nbsp;2</sub>&nbsp;2&nbsp;&rceil; =&nbsp;1&nbsp; respectively.
</p>

<p>
When the value of the <termref def="key-compressionOption">compression option</termref> is false and <termref def="key-unaligned">bit-packed</termref> alignment is used, <emph>n</emph>-bit unsigned integers are represented using <emph>n</emph> bits. The first table below illustrates how the <termref def="key-eventcode">event codes</termref> of each 
event matched by the <emph>DocContent</emph> grammar above are represented in this case.</p>

<p>
When the value of <termref def="key-compressionOption">compression option</termref> is true, or either <termref def="key-bytealignment">byte-alignment</termref> or <termref def="key-precompression">pre-compression</termref> alignment option is used, <emph>n</emph>-bit unsigned integers are represented using the minimum number of bytes required to store <emph>n</emph> bits. The second table below illustrates how the <termref def="key-eventcode">event codes</termref> of each 
event matched by the <emph>DocContent</emph> grammar above are represented in this case. </p>
<example>
<head>Example event code encoding</head>
<p></p>
<table border="1" width="95%">
<caption>Example event code encoding 
when EXI compression is not in effect and <termref def="key-unaligned">bit-packed</termref> alignment option is used
</caption>
<colgroup></colgroup>
<colgroup span="3" align="center"></colgroup>
<colgroup></colgroup>
<colgroup align="center"></colgroup>
<thead>
<tr>
<th width="30%">Event</th>
<th colspan="3">Part values</th>
<th width="40%">Event Code Encoding</th>
<th width="10%"># bits</th></tr>
</thead>
<tbody>
<tr>
<td>SE ("A")</td>
<td>0</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>000</td><td>3</td></tr>
<tr>
<td>SE ("B")</td>
<td>1</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>001</td><td>3</td></tr>
<tr>
<td>SE ("C")</td>
<td>2</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>010</td><td>3</td></tr>
<tr>
<td>SE ("D")</td>
<td>3</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>011</td><td>3</td></tr>
<tr>
<td>SE&nbsp;(*)</td>
<td>4</td>
<td>&nbsp;
</td>
<td>&nbsp;</td>
<td>100
</td><td>3</td></tr>
<tr>
<td>DT</td>
<td>5</td>
<td>0</td>
<td>&nbsp;</td>
<td>101&nbsp;&nbsp;0</td><td>4</td></tr>
<!-- tr>
<td>CH</td>
<td>4</td>
<td>2</td>
<td>&nbsp;</td>
<td>100&nbsp;&nbsp;10</td><td>5</td></tr -->
<tr>
<td>CM</td>
<td>5</td>
<td>1</td>
<td>0</td>
<td>101&nbsp;&nbsp;1&nbsp;&nbsp;0</td><td>5</td></tr>
<tr>
<td>PI</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>101&nbsp;&nbsp;1&nbsp;&nbsp;1</td><td>5</td></tr></tbody></table>
<table border="1" width="95%">
<colgroup></colgroup>
<colgroup span="3" align="center"></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<tbody>
<tr>
<td width="30%"># distinct values (<emph>m</emph>)</td>
<td>6</td>
<td>2</td>
<td>2</td>
<td width="40%">&nbsp;</td><td width="10%">&nbsp;</td></tr>
<tr>
<td><table border="0">
<tr><td># bits per part</td></tr>
<tr><td>&nbsp;&nbsp;&lceil; log <sub>2</sub>&nbsp;<emph>m</emph> &rceil;</td></tr>
</table></td>
<td>3</td>
<td>1</td>
<td>1</td>
<td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table>
<p></p>




<table border="1" width="95%">
<caption>Example event code encoding 
when EXI compression is in effect, or either
<termref def="key-bytealignment">byte-alignment</termref> or <termref def="key-precompression">pre-compression</termref> alignment option is used
</caption>
<colgroup></colgroup>
<colgroup span="3" align="center"></colgroup>
<colgroup></colgroup>
<colgroup align="center"></colgroup>
<thead>
<tr>
<th width="30%">Event</th>
<th colspan="3">Part values</th>
<th width="40%">Event Code Encoding</th>
<th width="10%"># bytes</th></tr>
</thead>
<tbody>
<tr>
<td>SE ("A")</td>
<td>0</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>00000000</td><td>1</td></tr>
<tr>
<td>SE ("B")</td>
<td>1</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>00000001</td><td>1</td></tr>
<tr>
<td>SE ("C")</td>
<td>2</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>00000010</td><td>1</td></tr>
<tr>
<td>SE ("D")</td>
<td>3</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>00000011</td><td>1</td></tr>
<tr>
<td>SE&nbsp;(*)</td>
<td>4</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>00000100
</td><td>1</td></tr>
<tr>
<td>DT</td>
<td>5</td>
<td>0</td>
<td>&nbsp;</td>
<td>00000101&nbsp;&nbsp;00000000</td><td>2</td></tr>
<!-- tr>
<td>CH</td>
<td>4</td>
<td>2</td>
<td>&nbsp;</td>
<td>00000100&nbsp;&nbsp;00000010</td><td>2</td></tr -->
<tr>
<td>CM</td>
<td>5</td>
<td>1</td>
<td>0</td>
<td>00000101&nbsp;&nbsp;00000001&nbsp;&nbsp;00000000</td><td>3</td></tr>
<tr>
<td>PI</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>00000101&nbsp;&nbsp;00000001&nbsp;&nbsp;00000001</td><td>3</td></tr></tbody></table>
<table border="1" width="95%">
<colgroup></colgroup>
<colgroup span="3" align="center"></colgroup>
<colgroup></colgroup>
<colgroup></colgroup>
<tbody>
<tr>
<td width="30%"># distinct values (<emph>m</emph>)</td>
<td>6</td>
<td>2</td>
<td>2</td>
<td width="40%">&nbsp;</td><td width="10%">&nbsp;</td></tr>
<tr>
<td><table border="0">
<tr><td># bytes per part</td></tr>
<tr><td>&nbsp;&nbsp;&lceil; (log <sub>2</sub>&nbsp;<emph>m</emph>) / 8 &rceil;</td></tr>
</table></td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>&nbsp;</td><td>&nbsp;</td></tr>
</tbody></table>
</example>

</div2>
<div2 id="fidelityOptions">
<head>Fidelity Options</head>
<p>Some XML applications do not require the entire XML feature set and would prefer to eliminate the overhead associated with unused features. For example, the SOAP 1.2 specification 
<bibref ref="soap12" /> prohibits the use of XML 
processing instructions. 
In addition, there are many data-exchange use cases that do not require XML comments or DTDs. </p>
<p>
The <termref def="key-preserveOption">preserve option</termref> in EXI Options comprises a set of fidelity options, each of which independently 
enables or disables the format's capacity for 
the preservation (or preservation level) of a certain type of information item. 
Applications can use the <termref def="key-preserveOption">preserve option</termref> to specify the set of fidelity options they require.
As specified in section 
<specref ref="pruningProductions"/>, EXI processors MUST use these fidelity options to prune 
productions that match the associated events from the grammars, improving compactness and processing efficiency. </p>
<p>The table below lists the fidelity options supported by this version of the EXI specification and describes the effect setting these options has on the <termref def="key-existream">EXI stream</termref>. </p>
<table border="1">
<caption>Fidelity options</caption>
<thead>
<tr>
<th>Fidelity option</th>
<th>Effect</th></tr>
</thead>
<tbody>
<tr>
<td id="key-preserveCommentsOption">Preserve.comments</td>
<td>CM events can be preserved</td></tr>
<tr>
<td id="key-preservePIsOption">Preserve.pis</td>
<td>PI events can be preserved</td></tr>
<tr>
<td id="key-preserveDTDOption">Preserve.dtd</td>
<td>DT and ER events can be preserved</td></tr>
<tr>
<td id="key-preservePrefixesOption">Preserve.prefixes</td>
<td>NS events and namespace prefixes can be preserved</td></tr>
<tr>
<td id="key-preserveLexicalValuesOption">Preserve.lexicalValues</td>
<td>Lexical form of element and attribute values can be preserved in <termref def="key-valueContentItem"><emph>value</emph></termref> content items
</td></tr></tbody></table>
<p>
When <xspecref spec="NS" ref="dt-qualname">qualified names</xspecref> are used in the <termref def="key-valueContentItem"><emph>value</emph>s</termref> of AT or CH events in an EXI Stream, the Preserve.prefixes fidelity option SHOULD be turned on to enable the preservation of the NS prefix declarations used by these values. 
Note, in particular among other cases, that this practice applies to the use of xsi:type attributes in EXI streams when Preserve.lexicalValues fidelity option is set to <emph>true</emph>.
</p>
<p>See section <specref ref="streams"/> for the definition of EXI event types and their associated <termref def="key-content-item">content items</termref>.
</p>
</div2></div1>

<div1 id="encodingValues">
<head>Representing Event Content</head>
<p>
The <termref def="key-eventcode">event code</termref> of each event in an EXI body is represented as a sequence of 
<emph>n</emph>-bit unsigned integers (<specref ref="encodingBoundedUnsigned" />).
See section <specref ref="encodingEventCodes" /> for the description of the event code representation. 
The <termref def="key-content-item">content items</termref> of an event are represented according to their datatype representations (see <specref ref='table2'/>). In the absence of an associated datatype representation, attribute and character <termref def="key-valueContentItem"><emph>values</emph></termref> are 
represented as String (<specref ref="encodingString" />).
</p>

<p><termdef id="key-exidatatype" term="EXI Datatype">EXI defines a minimal set of datatype representations called 
<term>Built-in EXI datatype representations</term> that define how 
<termref def="key-content-item">content items</termref>
as well as the parts of an <termref def="key-eventcode">event code</termref> 
are represented in EXI streams.</termdef> 
When the <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option is false, 
<termref def="key-valueContentItem">values</termref> are represented using built-in EXI datatype representations 
(see <specref ref="encodingDatatypes"/>) or user-defined datatype representations 
(see <specref ref="datatypeRepresentationMap"/>) associated with the schema 
<xspecref spec="XS2" ref="datatype">datatypes</xspecref>. 
 
Otherwise, 
<termref def="key-valueContentItem">values</termref>
are represented as Strings with restricted character sets (see <specref ref='builtInRestrictedStrings'/> below). The following table lists the 
built-in EXI datatype representations, associated 
EXI datatype identifiers 
and the XML Schema <xspecref spec="XS2" ref="built-in-datatypes">built-in datatypes</xspecref> 
each 
EXI datatype representation
is used to represent by default.</p>
<table border="1" id="builtInEXITypes">
<caption>
Built-in EXI Datatype Representations
</caption>
<thead>
<tr>
<th>
Built-in EXI Datatype Representation

</th>
<th>EXI Datatype ID</th>
<th colspan="2">
XML Schema Datatypes 
</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">
<xspecref href="#encodingBinary">Binary</xspecref>
</td>
<td>
exi:base64Binary
</td>
<td colspan="2"><emph>base64Binary</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:hexBinary
</td>
<td colspan="2"><emph>hexBinary</emph></td>
</tr>
<tr>
<td>
<xspecref href="#encodingBoolean">Boolean</xspecref>
</td>
<td>
exi:boolean
</td>
<td colspan="2"><emph>boolean</emph></td>
</tr>
<tr>
<td rowspan="8">
<xspecref href="#encodingDateTime">Date-Time</xspecref>
</td>
<td>
exi:dateTime
</td>
<td colspan="2"><emph>dateTime</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:time
</td>
<td colspan="2"><emph>time</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:date
</td>
<td colspan="2"><emph>date</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:gYearMonth
</td>
<td colspan="2"><emph>gYearMonth</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:gYear
</td>
<td colspan="2"><emph>gYear</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:gMonthDay
</td>
<td colspan="2"><emph>gMonthDay</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:gDay
</td>
<td colspan="2"><emph>gDay</emph></td>
</tr>
<tr>
<!-- td/ -->
<td>
exi:gMonth
</td>
<td colspan="2"><emph>gMonth</emph></td>
</tr>
<tr>
<td>
<xspecref href="#encodingDecimal">Decimal</xspecref>
</td>
<td>
exi:decimal
</td>
<td colspan="2"><emph>decimal</emph></td>
</tr>
<tr>
<td>
<xspecref href="#encodingFloat">Float</xspecref>
</td>
<td>
exi:double
</td>
<td colspan="2"><emph>float</emph>, <emph>double</emph></td>
</tr>
<tr>
<td>
<xspecref href="#encodingInteger">Integer</xspecref>
</td>
<td>
exi:integer
</td>
<td colspan="2">
<emph>integer</emph>
</td>
</tr>
<tr>
<td>
<xspecref href="#encodingString">String</xspecref>
</td>
<td>
exi:string
</td>
<td colspan="2">
<emph>string</emph>, <emph>anySimpleType</emph> and all types derived by <emph>union</emph>
</td>
</tr>
<tr>
<td>
<xspecref href="#encodingBoundedUnsigned">n-bit Unsigned Integer</xspecref>
</td>
<td>&nbsp;</td>
<td colspan="2">
Not associated with any datatype directly, but used by <xspecref href="#encodingInteger">Integer</xspecref>
 datatype representation for some bounded <emph>integers</emph> (see <specref ref="encodingInteger"/>)
</td>
</tr>
<tr>
<td>
<xspecref href="#encodingUnsignedInteger">Unsigned Integer</xspecref>
</td>
<td>&nbsp;</td>
<td colspan="2">
Not associated with any datatype directly, but used by <xspecref href="#encodingInteger">Integer</xspecref>
 datatype representation for unsigned <emph>integers</emph> (see <specref ref="encodingInteger"/>)
</td>
</tr>
<tr>
<td>
<xspecref href="#encodingList">List</xspecref>
</td>
<td>&nbsp;</td>
<td colspan="2">All types derived by <emph>list</emph>, including 
<emph>NMTOKENS</emph>, <emph>IDREFS</emph> and <emph>ENTITIES</emph></td></tr>
<tr>
<td>
<xspecref href="#encodingQName">QName</xspecref>
</td>
<td>&nbsp;</td>
<td colspan="2">
xsi:type attribute values when <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option value is <emph>false</emph>
<!--
Otherwise, values of <xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#QName'>QName</xspecref> datatype are represented by built-in String representation by default.
-->
<!-- xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#QName'>QName</xspecref> but only for 
the value of xsi:type attributes -->
<!-- All element and attribute <emph>qnames</emph>,--> <!-- NOTE: these are not schema types. -->
<!-- <xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#QName'>QName</xspecref>, <xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#Notation'>Notation</xspecref>--> 
<!-- note : the qname type is not used for element/attribute values - only for element/attribute names -->
&nbsp;</td></tr>
</tbody></table>
<p>By default, datatypes derived from the XML Schema datatypes above are also represented according to the associated <termref def="key-exidatatype">built-in EXI datatype representation</termref>. When there are more than one XML Schema datatypes above from which a datatype is derived directly or indirectly, the closest ancestor is used to determine the <termref def="key-exidatatype">built-in EXI datatype representation</termref>. For example, a value of XML Schema datatype xsd:int is represented according to the same <termref def="key-exidatatype">built-in EXI datatype representation</termref> as a value of XML Schema datatype xsd:integer. Although xsd:int is derived indirectly from xsd:integer and also further from xsd:decimal, a value of xsd:int is processed as an instance of xsd:integer because xsd:integer is closer to xsd:int than xsd:decimal is in the datatype inheritance hierarchy.</p>

<p>Each EXI datatype identifier above is a <termref def="key-qname">qname</termref> that uniquely identifies one of the 
<termref def="key-exidatatype">built-in EXI datatype representations.</termref> 
EXI datatype identifiers are used in <termref def="key-datatypeRepresentationMaps">Datatype Representation Maps</termref> to 
change
the datatype representations used for specific schema <xspecref spec="XS2" ref="datatype">datatypes</xspecref> and their sub-types.
Only <termref def="key-exidatatype">built-in EXI datatype representations</termref>
 that have been assigned identifiers are usable in <termref def="key-datatypeRepresentationMaps">Datatype Representation Maps</termref>.
</p>
<p>When the <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option is true, all 
<termref def="key-valueContentItem"><emph>values</emph></termref> 
are represented as Strings. 

The table below defines restricted character sets for several of the built-in EXI datatypes. Each <termref def="key-valueContentItem"><emph>value</emph></termref> that would have otherwise been represented by one of these datatypes is instead represented as a String with the associated restricted character set,
regardless of the actual pattern facets, if any, specified in the definitions of the schema datatypes. 
</p>

<table border="1" width="95%" id='builtInRestrictedStrings'>
<caption>Restricted Character Sets for Built-in EXI 
Datatype Representations

</caption>
<colgroup width="20%"/>
<colgroup width="80%"/>
<thead>
<tr>
<th>EXI Datatype ID</th>
<th>Restricted Character Set</th>
</tr>
</thead>
<tbody>
<tr>
<td>
exi:base64Binary
</td>
<td>{ #x9, #xA, #xD, #x20, +, /, [0-9], =, [A-Z], [a-z] } </td>
</tr>
<tr>
<td>
exi:hexBinary
</td>
<td>{ #x9, #xA, #xD, #x20, [0-9], [A-F], [a-f] } </td>
</tr>
<tr>
<td>
exi:boolean
</td>
<td>{ #x9, #xA, #xD, #x20, 0, 1, a, e, f, l, r, s, t, u } </td>
</tr>
<tr>
<td>
exi:dateTime
</td>
<td rowspan="8">{ #x9, #xA, #xD, #x20, +, -, ., [0-9], :, T, Z } </td>
</tr>
<tr>
<td>
exi:time
</td>
</tr>
<tr>
<td>
exi:date
</td>
</tr>
<tr>
<td>
exi:gYearMonth
</td>
</tr>
<tr>
<td>
exi:gYear
</td>
</tr>
<tr>
<td>
exi:gMonthDay
</td>
</tr>
<tr>
<td>
exi:gDay
</td>
</tr>
<tr>
<td>
exi:gMonth
</td>
</tr>
<tr>
<td>
exi:decimal
</td>
<td>{ #x9, #xA, #xD, #x20, +, -, ., [0-9] } </td>
</tr>
<tr>
<td>
exi:double
</td>
<td>{ #x9, #xA, #xD, #x20, +, -, ., [0-9], E, F, I, N, a, e } </td>
</tr>
<tr>
<td>
exi:integer
</td>
<td>{ #x9, #xA, #xD, #x20, +, -, [0-9] } </td>
</tr>
</tbody></table>

<p>The restricted character set for the EXI List datatype representation is the restricted character set of the EXI datatype representation of the List item type.
</p>

<p>The rules used to represent values of String depend on the <termref def="key-content-item">content items</termref> to which the values belong. There are certain <termref def="key-content-item">content items</termref> whose value representation involve the use of string tables while other <termref def="key-content-item">content items</termref> are represented using the encoding rule described in <specref ref="encodingString"/> without involvement of string tables. The <termref def="key-content-item">content items</termref> that use string tables and how each of such <termref def="key-content-item">content items</termref> uses string tables to represent their values are described in <specref ref="stringTable"/>.</p>
<p>Schemas can provide one or more enumerated values for 
datatypes. 
When the <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option is false, 
EXI exploits those pre-defined values when they are available to represent values of such 
datatypes 
in a more efficient manner than 
would have done otherwise without using pre-defined values. 
The encoding rule for representing 
enumerated values 
is described in <specref ref="encodingEnumerations"/>. 
Datatypes 
that are derived from 
another 
by union and their subtypes are always represented as String regardless of the availability of enumerated values. Representation of values of which the 
datatype 
is one of QName, Notation or a 
datatype 
derived therefrom by restriction are also not affected by enumerated values if any.
</p>
<!-- p>The encoding rule to represent schema types that are derived by list and their subtypes, including <xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#IDREFS'>IDREFS</xspecref> and <xspecref href='http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#ENTITIES'>ENTITIES</xspecref> is described in <specref ref="encodingList"/>.
</p -->

<div2 id="encodingDatatypes">
<head>Built-in EXI Datatype Representations</head>
<p>The following sections describe the <termref def="key-exidatatype">built-in EXI datatype representations</termref> used for representing 
<termref def="key-eventcode">event codes</termref> and <termref def="key-content-item">content items</termref> in EXI streams. Unless otherwise stated, individual items in an EXI stream are packed into bytes most significant bit first.

</p>
<div3 id="encodingBinary">
<head>Binary</head>
<p>The Binary datatype representation is a length-prefixed sequence of octets representing the binary content. The length is represented as an Unsigned Integer (see 
<specref ref="encodingUnsignedInteger"/>). </p></div3>

<div3 id="encodingBoolean">
<head>Boolean</head>

<p>In the absence of pattern facets in the schema datatype, the Boolean datatype representation is a  <emph>n</emph>-bit unsigned integer (<specref ref="encodingBoundedUnsigned" />), where <emph>n</emph> is one (1). The value zero (0) represents false and the value one (1) represents true.
</p>
<p>Otherwise, when pattern facets are available in the schema datatype, the Boolean datatype representation is a <emph>n</emph>-bit unsigned integer (<specref ref="encodingBoundedUnsigned" />), where <emph>n</emph> is two (2) and the values zero (0), one (1), two (2) and three (3) represent the values "false", "0", "true" and "1" respectively.
</p>
</div3>

<div3 id="encodingDecimal">
<head>Decimal</head>
<p>The Decimal datatype representation is a Boolean sign (see <specref ref="encodingBoolean"/>) followed by two Unsigned Integers (see <specref
ref="encodingUnsignedInteger"/>). A sign value of zero (0) is used to represent positive Decimal values and a sign value of one (1) is used to represent negative Decimal values. The first Unsigned Integer represents the integral portion of the Decimal value. The second Unsigned Integer represents the fractional portion of the Decimal value with the digits in reverse order to preserve leading zeros.</p>
</div3>

<div3 id="encodingFloat">
<head>Float</head>
<p>The Float datatype representation is two consecutive Integers (see 
<specref ref="encodingInteger"/>). The first Integer represents the mantissa of the floating point number and the second Integer represents the base-10 exponent of the floating point number. The range of the mantissa is - (2<sup>63</sup>) to 2<sup>63</sup>-1 and the range of the exponent is - (2<sup>14</sup>-1) to 2<sup>14</sup>-1. 
Mantissa or exponent values outside of the respective accepted range MUST NOT be used in the Float datatype representation. Values typed as Float with a mantissa or exponent outside the accepted range are represented as untyped values, processed by an alternative production if available that can be used to represent untyped values. 
<!-- Listed as examples because vanilla AT(*) can sometimes be used to represent untyped values. -->
Examples of such productions are those whose terminal symbol on the right-hand side is AT(<emph>qname</emph>) [untyped&nbsp;value], AT(*) [untyped&nbsp;value] or CH [untyped&nbsp;value] (See <specref ref="addingProductions"/>).
</p>

<p>The exponent value -(2<sup>14</sup>) is used to indicate one of the special values: infinity, negative infinity and not-a-number (NaN). An exponent value -(2<sup>14</sup>) with mantissa values 1 and -1 represents 
positive infinity (INF) and negative infinity (-INF) respectively. An exponent value -(2<sup>14</sup>) with any other mantissa value represents NaN.
</p>

<p>The Float datatype representation can be decoded by going through the following steps.</p>
<olist>
<item>Retrieve the mantissa value using the procedure described in <specref ref="encodingInteger"/>.</item>
<item>Retrieve the exponent value using the procedure described in <specref ref="encodingInteger"/>.</item>
<item>If the exponent value is -(2<sup>14</sup>), the mantissa value 1 represents INF, the mantissa value -1 represents -INF and any other mantissa value represents NaN. If the exponent value is not -(2<sup>14</sup>), the float value is <emph>m</emph> &times; 10<sup><emph>e</emph></sup> where <emph>m</emph> is the mantissa and <emph>e</emph> is the exponent obtained in the preceding steps.
</item>
</olist>
</div3>

<div3 id="encodingInteger">
<head>Integer</head>
<p>The Integer datatype representation supports signed integer numbers of arbitrary magnitude. The specific representation used depends on the <xspecref spec="XS2" ref="dt-facet">facet</xspecref> values of the associated schema <xspecref spec="XS2" ref="datatype">datatype</xspecref> as follows. 
</p>
<p>
If the associated schema datatype is derived from xsd:integer and the bounded range determined by its
<xspecref spec="XS2" ref="rf-minInclusive">minInclusive</xspecref>, 
<xspecref spec="XS2" ref="rf-minExclusive">minExclusive</xspecref>, 
<xspecref spec="XS2" ref="rf-maxInclusive">maxInclusive</xspecref> and 
<xspecref spec="XS2" ref="rf-maxExclusive">maxExclusive</xspecref> facets has 4096 or fewer values,
the value is represented as an <xspecref href="#encodingBoundedUnsigned">n-bit Unsigned Integer</xspecref> where <emph>n</emph> is &lceil;&nbsp;log<sub>2</sub> <emph>m</emph>&nbsp;&rceil; and <emph>m</emph> is the bounded range of the schema datatype.</p>
<p>Otherwise, if the associated schema datatype is derived from xsd:integer and the <xspecref spec="XS2" ref="rf-minInclusive">minInclusive</xspecref> or 
<xspecref spec="XS2" ref="rf-minExclusive">minExclusive</xspecref> facets specify a lower bound greater than or equal to zero (0), the value is represented as an <xspecref href="#encodingUnsignedInteger">Unsigned Integer</xspecref>.</p>
<!-- 
<p>
When the associated schema <xspecref spec="XS2" ref="datatype">datatype</xspecref> is derived from xsd:integer, given the bounded range of the schema datatype that is determined by the values of 
<xspecref spec="XS2" ref="rf-minInclusive">minInclusive</xspecref>, 
<xspecref spec="XS2" ref="rf-minExclusive">minExclusive</xspecref>, 
<xspecref spec="XS2" ref="rf-maxInclusive">maxInclusive</xspecref> and 
<xspecref spec="XS2" ref="rf-maxExclusive">maxExclusive</xspecref> facets and, 
the value is represented as an <xspecref href="#encodingBoundedUnsigned">n-bit Unsigned Integer</xspecref> where <emph>n</emph> is &lceil;&nbsp;log<sub>2</sub> <emph>m</emph>&nbsp;&rceil; and <emph>m</emph> is the bounded range of the schema datatype 
if the bounded range is 4096 or smaller; otherwise, the value is represented as an <xspecref href="#encodingUnsignedInteger">Unsigned Integer</xspecref> if the <xspecref spec="XS2" ref="rf-minInclusive">minInclusive</xspecref> or 
<xspecref spec="XS2" ref="rf-minExclusive">minExclusive</xspecref> facets specify a lower bound greater than or equal to zero (0).
</p>
-->
<p>
Otherwise, the value is represented as a Boolean sign (see <specref ref="encodingBoolean" />) followed by an Unsigned Integer (see <specref ref="encodingUnsignedInteger" />). A sign value of zero (0) is used to represent positive integers and a sign value of one (1) is used to represent negative integers. For non-negative values, the Unsigned Integer holds the magnitude of the value. For negative values, the Unsigned Integer holds the magnitude of the value minus 1. 
</p>
</div3>

<div3 id="encodingUnsignedInteger">
<head>Unsigned Integer</head>
<p>The Unsigned Integer datatype representation supports unsigned integer numbers of arbitrary magnitude. It is represented as a sequence of octets terminated by an octet with its most significant bit set to 0. The value of the unsigned integer is stored in the least significant 7 bits of the octets as a sequence of 7-bit bytes, with the least significant byte first. </p>
<p>EXI processors SHOULD support arbitrarily large Unsigned Integer values. EXI processors MUST support Unsigned Integer values less than 2147483648.</p>
<!-- Unsigned Integer values SHOULD be stored in the minimum number of required octets. -->
<p>The Unsigned Integer datatype representation can be decoded by going through the following steps.</p> <example>
<head>
Example algorithm for decoding an Unsigned Integer
</head>
<olist>
<item>Start with the initial value set to 0 and the initial multiplier set to 1.</item>
<item>Read the next octet.</item>
<item>Multiply the value of the unsigned number represented by the 7 least significant bits of the octet by the current multiplier and add the result to the current value.</item>
<item>Multiply the multiplier by 128.</item>
<item>If the most significant bit of the octet was 1, go back to step 2.</item>
</olist>
</example>

<p/>
</div3>

<div3 id="encodingQName">
<head>QName</head>
<p>The QName datatype representation is a sequence of values representing the URI, local-name and prefix components of the QName in that order, where the prefix component is present only when the <termref def="key-preservePrefixesOption">Preserve.prefixes</termref> option is set to true.
</p>
<p>When the QName value is specified by a schema-informed grammar using the SE&nbsp;(<emph>qname</emph>) or AT&nbsp;(<emph>qname</emph>) terminal symbols, URI and local-name are implicit and are omitted.
Similarly, when the URI of the QName value is derived from a schema-informed grammar using 
SE&nbsp;(<emph>uri</emph>:&nbsp;*) 
or AT&nbsp;(<emph>uri</emph>:&nbsp;*) 
terminal symbols, URI is implicit thus omitted in the representation, and only the local-name component is encoded as a String (see <specref ref="encodingString"/>).
Otherwise, URI and local-name components are encoded as Strings. 
If the QName is in no namespace, the URI is represented by a zero length String. 
</p>
<p>When present, prefixes are represented as <emph>n</emph>-bit unsigned integers (<specref ref="encodingBoundedUnsigned" />), where <emph>n</emph> is 
&lceil;&nbsp;log<sub>2</sub>(<emph>N</emph>)&nbsp;&rceil; 
and <emph>N</emph> is the number of <emph>prefix</emph>es in the prefix string table partition associated with the URI of the QName or one (1) if there are no prefixes in this partition.  

<!-- If there are no <emph>prefix</emph>es specified for the URI of the QName by preceding NS events in the EXI stream, the prefix is undefined. An undefined prefix is represented using zero bits (i.e., omitted).
-->

If the given <emph>prefix</emph> exists in the associated prefix string table partition, it is represented using the compact identifier assigned by the partition. If the given <emph>prefix</emph> does not exist in the associated partition, the QName MUST be part of an SE event and the prefix MUST be resolved by one of the NS events immediately following the SE event (see resolution rules below). In this case, the unresolved prefix representation is not used and can be zero (0) or the compact identifier of any prefix in the associated partition.
 
</p>
<note>
When <emph>N</emph> is one, the prefix is represented using zero bits (i.e. omitted). 
</note>
<p>Given a <emph>n</emph>-bit unsigned integer <emph>m</emph> that represents either the prefix value or an unresolved prefix value, the effective prefix value is determined by following the rules described below in order. A QName is in error if its prefix cannot be resolved by the rules below.
</p>
<ol>
<li>If the prefix string table partition associated with the URI of the QName assigns the compact identifier <emph>m</emph> to a <emph>prefix</emph> value, select this <emph>prefix</emph> value as the candidate <emph>prefix</emph> value. Otherwise, there is no candidate <emph>prefix</emph> value.
</li>
<li>If the QName value is part of an SE event followed by an associated NS event with 
its <termref def="key-indicatorContentItem"><emph>local-element-ns</emph></termref> flag value 
set to true, the <emph>prefix</emph> value is the <emph>prefix</emph> of this NS event. Otherwise, the <emph>prefix</emph> value is the candidate value, if any, selected in step 1 above.
</li>
</ol>
</div3>

<div3 id="encodingDateTime">
<head>Date-Time</head>
<p>The Date-Time datatype representation is a sequence
of values representing the individual components of the Date-Time. The
following table specifies each of the possible date-time components
along with how they are encoded.</p>
<table border="1">
<caption>Date-Time components</caption>
<thead>
<tr>
<th>Component</th>
<th>Value</th>
<th>Type</th></tr>
</thead>
<tbody>
<!-- tr>
<td>Type</td>
<td>The type of date (see below)</td>
<td>3-bit Unsigned Integer (<specref ref="encodingBoundedUnsigned"/>)</td></tr -->
<tr>
<td>Year</td>
<td>Offset from 2000</td>
<td>Integer ( 
<specref ref="encodingInteger"/>)</td></tr>
<tr>
<td>MonthDay</td>
<td>
Month * 32 + Day
</td>
<td>
9-bit Unsigned Integer (<specref
ref="encodingBoundedUnsigned"/>) where day is a value in the range 1-31 and month is a value in the range 1-12.
</td></tr>
<tr>
<td>Time</td>
<td>
((Hour * 64) + Minutes) * 64 + seconds
</td>
<td>17-bit Unsigned Integer (<specref ref="encodingBoundedUnsigned"/>)</td></tr>
<!-- tr>
<td>FractionalSecs?</td>
<td>Boolean presence indicator</td>
<td>Boolean (<specref ref="encodingBoolean"/>)</td></tr -->
<tr>
<td>FractionalSecs</td>
<td>Fractional seconds</td>
<td>Unsigned Integer ( 
<specref ref="encodingUnsignedInteger"/>) representing the fractional part of the seconds with digits in reverse order to preserve leading zeros</td></tr>
<!-- tr>
<td>TimeZone?</td>
<td>Boolean presence indicator</td>
<td>Boolean (<specref ref="encodingBoolean"/>)</td></tr-->
<tr>
<td>TimeZone</td>
<td>
TZHours * 64 + TZMinutes
</td>
<td>11-bit Unsigned Integer (<specref ref="encodingBoundedUnsigned"/>) representing a signed integer offset by 896 ( = 14 * 64 )</td></tr>
<tr>
<td>presence</td>
<td>Boolean presence indicator</td>
<td>Boolean (<specref ref="encodingBoolean"/>)</td></tr>
</tbody></table>
<p>
The variety of components that constitute a value and their appearance order depend on the XML Schema type associated with the value. The following table shows which components are included in a value of each XML Schema type that is relevant to Date-Time datatype. Items listed in square brackets are included if and only if the value of its preceding presence indicator (specified above) is set to true.</p>
<table border="1">
<caption>Assortment of Date-Time components</caption>
<thead>
<tr>
<th>XML Schema Datatype</th>
<th>Included Components</th></tr>
</thead>
<tbody>
<tr>
<td><xspecref spec="XS2" ref='gYear'>gYear</xspecref></td>
<td>Year, presence, [TimeZone]</td></tr>
<tr>
<td><xspecref spec="XS2" ref='gYearMonth'>gYearMonth</xspecref></td>
<td rowspan="2">Year, MonthDay, presence, [TimeZone]</td></tr>
<tr>
<td><xspecref spec="XS2" ref='date'>date</xspecref></td>
<!-- td>Year, MonthDay, [TimeZone]</td --></tr>
<tr>
<td><xspecref spec="XS2" ref='dateTime'>dateTime</xspecref></td>
<td>Year, MonthDay, Time, presence, [FractionalSecs], presence, [TimeZone]</td></tr>
<tr>
<td><xspecref spec="XS2" ref='gMonth'>gMonth</xspecref></td>
<td rowspan="3">MonthDay, presence, [TimeZone]</td></tr>
<tr>
<td><xspecref spec="XS2" ref='gMonthDay'>gMonthDay</xspecref></td>
<!-- td>MonthDay, [TimeZone]</td --></tr>
<tr>
<td><xspecref spec="XS2" ref='gDay'>gDay</xspecref></td>
<!-- td>MonthDay, [TimeZone]</td --></tr>
<tr>
<td><xspecref spec="XS2" ref='time'>time</xspecref></td>
<td>Time, presence, [FractionalSecs], presence, [TimeZone]</td></tr></tbody></table></div3>

<div3 id="encodingBoundedUnsigned">
<head><emph>n</emph>-bit Unsigned Integer</head>
<p>
When the value of the <termref def="key-compressionOption">compression option</termref> is false and
the <termref def="key-unaligned">bit-packed</termref> alignment is used, 
the <emph>n</emph>-bit Unsigned Integer datatype representation is an unsigned binary integer using <emph>n</emph> bits. 
Otherwise, it is an unsigned integer using the minimum number of bytes required to store 
<emph>n</emph> bits. Bytes are ordered with the least significant byte first.</p>

<!-- p>The n-bit unsigned integer encoding is also used to encode <emph>bounded integers</emph>. 
These are integer values that have been constrained explicitly through the use of schema facets 
(for example, XML schema minInclusive and maxInclusive facets) or implicitly through the use 
of a restricted data type (for example, the XML schema <emph>unsignedByte</emph> type).</p -->

<p>
The <emph>n</emph>-bit unsigned integer is used for representing <termref def="key-eventcode">event codes</termref>, the prefix component of QNames (see <specref ref="encodingQName" />) and certain <termref def="key-valueContentItem"><emph>value</emph></termref> content items, as described in respective relevant parts of this document. As described in section <specref ref="encodingInteger" />, integers with a bounded range size <emph>m</emph> equal to 
4096 
or smaller are represented as <emph>n</emph>-bit unsigned integers with <emph>n</emph> being &lceil; log <sub>2</sub> <emph>m</emph> &rceil;, as an offset from the minimum value in the range.
</p>

</div3>

<div3 id="encodingString">
<head>String</head>
<p>The String datatype representation is a length prefixed sequence of
characters. The length indicates the number of characters in the
string and is represented as an Unsigned Integer (see <specref
ref="encodingUnsignedInteger"/>). If a restricted character set is defined for the string (see <specref ref="restrictedCharSet"/>), each character is represented as an <emph>n</emph>-bit Unsigned Integer (see <specref ref="encodingBoundedUnsigned"/>). Otherwise, each character is represented by its Unicode 
<bibref ref="Unicode"/>
code point encoded as an Unsigned Integer (see <specref ref="encodingUnsignedInteger"/>).
</p>
<p>EXI uses a string table to represent certain
<termref def="key-content-item">content items</termref> more efficiently. Section <specref ref="stringTable"/>
describes the string table and how it is applied to different content
items.</p>
<div4 id="restrictedCharSet">
<head>Restricted Character Sets</head>
<p>If a string value is associated with a schema <xspecref spec="XS2" ref="datatype">datatype</xspecref> 
derived from xsd:string and one or more of the datatypes in its datatype hierarchy has one or more pattern facets, there may be a restricted character set defined for the string value. The following steps are used to determine the restricted character set, if any, defined for a given string value associated with such a schema datatype.
</p>
<p>
Given the schema datatype, let the target datatype definition be the definition of the most-derived datatype that has one or more pattern facets immediately specified in its definition in the schema among those in the datatype inheritance hierarchy that traces backwards toward <xspecref spec="XS2" ref="dt-primitive">primitive datatypes</xspecref> starting from the datatype.
If the target datatype definition is a definition for a <xspecref spec="XS2" ref="dt-derived">built-in datatype</xspecref>, there is no restricted character set for the string value.  Otherwise, 
determine the set of characters for each immediate pattern facet of the target datatype definition according to section <specref ref="regexToCharset"/>.
Then, compute the restricted set of characters for the string value as the union of all the sets of characters computed in the previous step. If the resulting set of characters contains less than 
256 
characters and contains only BMP characters, the string value has a restricted character set and each character is represented using an <emph>n</emph>-bit Unsigned Integer (see <specref ref="encodingBoundedUnsigned"/>), where <emph>n</emph> is &lceil; log<sub>2</sub>(<emph>N</emph> + 1) &rceil; and <emph>N</emph> is the number of characters in the restricted character set.</p>

<p>The characters in the restricted character set are sorted by Unicode <bibref ref="Unicode"/> code point and represented by integer values in the range (0 ... <emph>N</emph>&minus;1) according to their ordinal position in the set. Characters that are not in this set are represented by the <emph>n</emph>-bit Unsigned Integer <emph>N</emph> followed by the Unicode code point of the character represented as an Unsigned Integer.</p>

<p>The figure below illustrates an overview of the process for determining and using restricted character sets described in this section. </p>
<graphic source="restrictedCharset.png" alt="String Processing Model"/>
</div4>
</div3>
<div3 id="encodingList">
<head>List</head>
<p>Values of type List are encoded as a length
prefixed sequence of values. The length is encoded as an Unsigned Integer (see
<specref ref="encodingUnsignedInteger"/>) and each value is encoded according
to its type (see <specref ref="encodingValues"/>).</p>
</div3>

</div2>
<div2 id="encodingEnumerations">
<head>Enumerations</head>
<p>
When the <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option is false, 
enumerated values 
are encoded as
<emph>n</emph>-bit Unsigned Integers (<specref ref="encodingBoundedUnsigned"/>) where <emph>n</emph> = &lceil; log <sub>2</sub> <emph>m</emph> &rceil; and <emph>m</emph> is the number of items
in the enumerated type. The unsigned integer value assigned to each item corresponds to
its ordinal position in the enumeration in schema-order starting with
position zero (0).
When there are more than one item that represent the same value in the enumeration, 
such value can be represented using the ordinal position of any items that represent the value.
</p>
<p>Exceptions are for schema types derived from others by union and their subtypes, QName or Notation and types derived therefrom by restriction. The values of such types are processed by their respective built-in EXI datatype representations instead of being represented as enumerations.</p>
</div2>

<div2 id="stringTable">
<head>String Table</head>
<p>EXI uses a string table to assign "compact identifiers" to some
string values. Occurrences of string values found in the string table
are represented using the associated compact identifier rather than
encoding the entire "string literal". The string table is initially pre-populated with
string values that are likely to occur in certain contexts and is
dynamically expanded to include additional string values encountered
in the document. The following <termref def="key-content-item">content items</termref> are encoded using a
string table: </p>

<ulist>
<item>
<termref def="key-uriContentItem"><emph>uris</emph></termref></item>
<item>
<termref def="key-prefixContentItem"><emph>prefixes</emph></termref></item>
<item>
<emph>uri</emph> and 
<emph>local-name</emph>
in <termref def="key-qnameContentItem"><emph>qnames</emph></termref>
</item>
<item>
<termref def="key-valueContentItem"><emph>values</emph></termref></item></ulist>

<p>When a string value is found in the string table, the value is encoded
using the compact identifier and no changes are made to the string table as a result. 
When a string value is not found in the string table, its string literal is encoded
as a String without using a compact identifier, only after which
the string table is augmented by including the string value with an assigned
compact identifier
unless the string value represents a <termref def="key-valueContentItem"><emph>value</emph></termref> content item 
and fails to satisfy the criteria in effect by virtue of <termref def="key-valuePartitionCapacityOption">valuePartitionCapacity</termref> and <termref def="key-valueMaxLengthOption">valueMaxLength</termref> options

.</p>

<p>The string table is divided into partitions and each partition is
optimized for more frequent use of either compact identifiers or string literals
depending on the purpose of the partition. Section <specref
ref="stringTablePartitions"/> describes how EXI string table is
partitioned. Section <specref ref="encodingOptimizedForHits"/>
describes how string values are encoded when the associated partition
is optimized for more frequent use of compact identifiers. Section <specref
ref="encodingOptimizedForMisses"/> describes how string values are
encoded when the associated partition is optimized for more frequent use
of string literals.</p>
<p>The life cycle of a string table spans the processing of 
a single EXI stream. String tables are not represented in an EXI stream or exchanged
between EXI processors. A string table cannot be reused across multiple EXI streams;
therefore, EXI processors MUST use a string table that is equivalent to
the one that would have been newly created and pre-populated with initial
values for processing each EXI stream.
</p>


<div3 id="stringTablePartitions">
<head>String Table Partitions</head>
<p>The string table is organized into partitions
so that the indices assigned to compact identifiers can stay relatively small.
Smaller number of indices results in improved average compactness and the efficiency
of table operations. Each partition has a separate set of compact identifiers and
<termref def="key-content-item">content items</termref> are assigned to specific partitions as described below. 
</p>
<p><termref def="key-uriContentItem"><emph>Uri</emph></termref> content items and the URI portion of 
<termref def="key-qnameContentItem"><emph>qname</emph></termref> content items are assigned to the uri
partition. The uri partition is optimized for frequent use of compact identifiers and is
pre-populated with initial entries as described in <specref ref="initialUriValues"/>.
When a schema is provided, the uri partition is also pre-populated with
the name of each
target
namespace URI declared in the schema,
plus some of the namespace URIs used in wildcard terms 
and attribute wildcards 
(see section <specref ref="wildcardTerms"/> 
and <specref ref="complexTypeGrammars"/>, respectively 
for the condition),
appended in lexicographical order.</p>

<p><termref def="key-prefixContentItem"><emph>Prefix</emph></termref> content items are assigned to partitions based
on their associated namespace URI. Partitions containing
<emph>prefix</emph> content items are optimized for frequent use of compact identifiers and the
string table is pre-populated with entries as described in
<specref ref="initialPrefixValues"/>.</p>

<p>
The local-name portion of <termref def="key-qnameContentItem"><emph>qname</emph></termref>
content items are assigned to partitions based on the namespace URI of 
the <emph>qname</emph> content item of which the local-name is a part. 
Partitions containing local-names are optimized for frequent use of string 
literals and the string table is pre-populated with entries as described in 
<specref ref="initialLocalNames"/>.
</p>

<p>
Each <termref def="key-valueContentItem"><emph>value</emph></termref>
content item is assigned to both the global value partition
and a "local" value partition based on the
<termref def="key-qname">qname</termref> 
of the attribute or element in context at the time
the value is added to the value partitions.
Partitions containing <termref def="key-valueContentItem"><emph>value</emph>
</termref> content items are optimized for frequent use of string literals and are initially empty.
<termdef id="key-globalID">
The variable <term><emph>globalID</emph></term> is a non-negative integer representing the compact identifier of the next item added to the global value partition.
</termdef>
<!-- termdef id="key-valueAmount">
All value partitions in a string table share a single variable <term><emph>valueAmount</emph></term> the value of which is a non-negative integer that reflects the current total number of characters in value partitions.
</termdef -->
Its value is initially set to 0 (zero) and changes while processing an EXI stream per the rule described in <specref ref="encodingOptimizedForMisses"/>.

</p>
</div3>

<div3 id="encodingOptimizedForHits">
<head>Partitions Optimized for Frequent use of Compact Identifiers</head>
<p>String table partitions that are expected to contain a relatively
small number of entries used repeatedly throughout the document are
optimized for the frequent use of compact identifiers. This includes the <termref def="key-uriContentItem"><emph>uri</emph></termref> partition and
all partitions containing <termref def="key-prefixContentItem"><emph>prefix</emph></termref> content items. </p>

<p>When a string value is found in a partition optimized for frequent use of compact identifiers,
the string value is represented as the value (<emph>i</emph>+1)
encoded as an <emph>n</emph>-bit Unsigned Integer (<specref ref="encodingBoundedUnsigned"/>), where
<emph>i</emph> is the value of the compact identifier, <emph>n</emph> is
&lceil; log<sub>2</sub> (<emph>m</emph>+1) &rceil; and <emph>m</emph> is the number of
entries in the string table partition at the time of the operation.
</p>

<p>When a string value is not found in a partition optimized for frequent use of compact identifiers,
the String value is represented as zero (0) encoded as an
<emph>n</emph>-bit Unsigned Integer, followed by the string literal
encoded as a String (<specref ref="encodingString"/>). After
encoding the String value, it is added to the string table partition
and assigned the next available compact identifier <emph>m</emph>.</p>
</div3>

<div3 id="encodingOptimizedForMisses">
<head>Partitions Optimized for Frequent use of String Literals</head>
<p>The remaining string table partitions are optimized for
the frequent use of string literals. This includes all string table partitions containing
local-names
and all string table partitions containing <termref def="key-valueContentItem"><emph>value</emph></termref> content
items.</p>

<p>When a string value is found in the partitions containing
local-names, the
string value is represented as zero (0) encoded as an Unsigned Integer (see
<specref ref="encodingUnsignedInteger"/>) followed by 
the compact identifier of the string value. The compact identifier of the string
value is encoded as an <emph>n</emph>-bit unsigned integer (<specref ref="encodingBoundedUnsigned"/>), where
<emph>n</emph> is &lceil; log<sub>2</sub> <emph>m</emph> &rceil; and <emph>m</emph> is
the number of entries in the string table partition at the time of the operation.</p>

<p>When a string value is not found in the partitions containing
local-names, its
string literal is encoded as a String (see <specref
ref="encodingString"/>) with the length of the string incremented
by one. After encoding the string value, it is added to the string
table partition and assigned the next available compact
identifier <emph>m</emph>.</p>

<p>As described above, each <termref def="key-valueContentItem"><emph>value</emph></termref> content item is assigned
to two partitions, a "local" value partition and the global
value partition. 
When a string value is found in the global or "local" partition, it is represented using a compact identifier. When a string value is found in the "local" value partition,
the string value may be represented as zero (0) encoded as an Unsigned Integer (see
<specref ref="encodingUnsignedInteger"/>) followed by the compact identifier
of the string value in the "local" value partition. 
When a string value is found in the global value partition, the String value may be represented as one (1) encoded as an
Unsigned Integer (see <specref ref="encodingUnsignedInteger"/>) followed by the compact
identifier of the String value in the global value
partition. The compact identifier is encoded as an <emph>n</emph>-bit
unsigned integer (<specref ref="encodingBoundedUnsigned"/>), where <emph>n</emph> is &lceil; log<sub>2</sub><emph>m</emph> &rceil; and <emph>m</emph> is the number of entries in the
associated partition at the time of the operation.</p>

<p>When a string value <emph>S</emph> is not found in the global or "local" 
<emph>value</emph> partition, its string literal is encoded as a
String (see <specref ref="encodingString"/>) with the length
<emph>L</emph> + 2 (incremented by two) where <emph>L</emph> is the number of characters in the string value. 
If <termref def="key-valuePartitionCapacityOption">valuePartitionCapacity</termref> is not zero, and 
<emph>L</emph> is greater than zero and no more than <termref def="key-valueMaxLengthOption">valueMaxLength</termref>, the string <emph>S</emph> is added to the associated "local" value partition using the next available compact identifier <emph>m</emph> and added to the global value partition using the compact identifier <termref def="key-globalID"><emph>globalID</emph></termref>. When <emph>S</emph> is added to the global value partition and there was already a string <emph>V</emph> in the global value partition associated with the compact identifier <termref def="key-globalID"><emph>globalID</emph></termref>, the string <emph>S</emph> replaces the string <emph>V</emph> in the global table, and the string <emph>V</emph> is removed from its associated local value partition by rendering its compact identifier permanently unassigned. When the string value is added to the global value partition, the value of <termref def="key-globalID"><emph>globalID</emph></termref> is incremented by one (1). If the resulting value of <termref def="key-globalID"><emph>globalID</emph></termref> is equal to <termref def="key-valuePartitionCapacityOption">valuePartitionCapacity</termref>, its value is reset to zero (0)
</p>
</div3>
</div2>

<div2 id="datatypeRepresentationMap">
<head>Datatype Representation Map</head>
<p>By default, each typed value in an EXI stream is represented using its
default built-in EXI datatype representation (see <specref ref="builtInEXITypes"/>). 
However, <termdef id="key-datatypeRepresentationMaps" 
term="Datatype Representation Map"><termref def="key-exiprocessor">EXI processors</termref> MAY provide the capability to specify alternate built-in EXI datatype representations or 
user-defined datatype representations for specific schema 
<xspecref spec="XS2" ref="datatype">datatypes</xspecref>. 
This capability is called a <term>Datatype Representation Map</term></termdef>.
</p>

<note>
This feature is relevant only to simple types in the schema. 
EXI does not provide a way for applications to infuse custom representations of structured data bound to complex types into the format. 
</note>

<p>
EXI processors that support Datatype Representation Maps MAY provide implementation specific means to define and install user-defined datatype representations. EXI processors MAY also provide implementation specific means for applications or users to specify alternate built-in EXI datatype representations or user-defined datatype representations for representing specific schema datatypes. As with the default EXI datatype representations, alternate datatype representations are used for the associated XML Schema types specified in the Datatype Representation Map and XML Schema datatypes derived from those datatypes. When there are built-in or user-defined datatype representations associated with more than one XML Schema datatype in the type hierarchy of a particular datatype, the closest ancestor with an associated datatype representation is used to determine the EXI datatype representation.
</p>
<p>When an EXI processor encodes an EXI stream using 
a Datatype Representation Map and the <termref def="key-options">EXI Options</termref> part of the header is present, the EXI options part MUST specify all alternate datatype representations used in the EXI stream.
An EXI processor that attempts to decode an
EXI stream that specifies a user-defined datatype representation in the EXI header that
it does not recognize MAY report a warning, but this is not an
error. However, when an EXI processor encounters a typed value that
was encoded by a user-defined datatype representation that it does not support, it MUST
report an error.</p>
<p>The EXI options header, when it appears in an EXI stream, MUST include a 
"datatypeRepresentationMap" element for each
schema datatype 
of which the descendant datatypes derived by restriction as well as itself are 
not represented using the default 
built-in EXI datatype representation. 

The "datatypeRepresentationMap" element includes two child elements. 
The <termref def="key-qname">qname</termref> of
the first child element identifies the schema datatype that is not
represented using the default 
built-in EXI datatype representation 

and the <termref def="key-qname">qname</termref> of the
second child element identifies the alternate 
built-in EXI datatype representation or user-defined datatype representation 
used to represent that type. 
Built-in EXI datatype representations are identified by the type identifiers in 
<specref ref="builtInEXITypes"/>. </p>

<p>For example, the following "datatypeRepresentationMap" element indicates all values of
type xsd:decimal are represented using the built-in exi:string datatype representation. In addition, all datatypes derived from xsd:decimal by restriction that do not have a closer ancestor in the type hierarchy with an associated datatype representation are represented using exi:string.
</p>

<example>
<head>datatypeRepresentationMap indicating all Decimal values are represented using
built-in String datatype representation</head>
<eg xml:space="preserve">
    &lt;exi:datatypeRepresentationMap xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
        &lt;xsd:decimal/&gt;
        &lt;exi:string/&gt;
    &lt;/exi:datatypeRepresentationMap&gt;
</eg>
</example>

<p>It is the responsibility of an EXI processor to interface with a particular implementation of 
built-in EXI datatype representations 

or user-defined 
datatype representations 

properly. In the example above, an EXI processor may need to provide a string value of the data being processed that is typed as xsd:decimal in order to interface with 
an implementation of built-in String datatype representation.

In such a case, some EXI processors may have started with a decimal value and such processors may well translate the value into a string before passing the data to 
the implementation of built-in String datatype representation 

while other EXI processors may already have a string value of the data so that it can pass the value directly to 
the implementation of built-in String datatype representation 

without any translation.
</p>

<p>As another example, the following 
"datatypeRepresentationMap" element indicates all
values of the used-defined 
simple type 
geo:geometricSurface 
and the datatypes derived from it by restriction 
are represented
using the user-defined datatype representation geo:geometricInterpolator: </p>

<example>
<head>datatypeRepresentationMap illustrating a user-defined type represented by a user-defined datatype representation</head>
<eg xml:space="preserve">
    &lt;exi:datatypeRepresentationMap xmlns:geo="http://example.com/Geometry"&gt;
        &lt;geo:geometricSurface/&gt;
	&lt;geo:geometricInterpolator/&gt;
    &lt;/exi:datatypeRepresentationMap&gt;
</eg>
</example>

<note>
EXI only defines a way to indicate the use of user-defined datatype representations for representing values of specific datatypes. 
Datatype representations are referred to by their respective <termref def="key-qname">qnames</termref> in "datatypeRepresentationMap" elements. A datatype representation is omnipresent only if its <termref def="key-qname">qname</termref> is one of those that represent built-in EXI datatype representations. 
For datatype representations of other <termref def="key-qname">qnames</termref>, EXI does not provide nor suggest a method by which they are identified and shared between EXI Processors. 
This suggests that the use of user-defined (i.e. custom) datatype representations 
needs to be restrained by weighing alternatives and considering the consequences of each in pros and cons, in order to avoid unruly proliferation of documents that use such datatype representations. 
Those applications that ever find Datatype Representation Map useful should make sure that they exchange such documents only among the parties that are pre-known or discovered to be able to process the user-defined datatype representations that are in use. Otherwise, if it is not for certain if a receiver understands the particular user-defined datatype representations, the sender should never attempt to send documents that use user-defined datatype representations to that recipient.
</note>

</div2>

</div1>

<div1 id="grammars">
<head>EXI Grammars</head>
<p>EXI is a knowledge based encoding that uses a set of grammars to
determine which events are most likely to occur at any given point in
an EXI stream and encodes the most likely alternatives in fewer
bits. It does this by mapping the stream of events to a lower entropy
set of representative values and encoding those values using a set of
simple variable length codes or an EXI compression algorithm. </p>
<p>The result is a very simple, small algorithm that uniformly handles
schema-less encoding, schema-informed encoding, schema deviations,
and any combination thereof in EXI streams. These variations do
not require different algorithms or different parsers, they are simply
informed by different combinations of grammars. </p>
<p>The following sections describe the grammars used to inform the EXI encoding. </p>
<!-- note>The grammars in this specification are intentionally permissive. They accept all valid documents, but also accept several invalid documents. </note -->
<note>The grammar semantics in this specification are written for clarity and generality. They do not prescribe a particular implementation approach. </note>
<div2 id="grammarNotation">
<head>Grammar Notation</head>

<div3 id="fixedEventCodes">
<head>Fixed Event Codes</head>
<p>Each grammar production has an <termref def="key-eventcode">event code</termref>, which is represented by a sequence of one to three parts separated by periods (&quot;.&quot;). Each part is an unsigned integer. The following are examples of grammar productions with <termref def="key-eventcode">event codes</termref> as they appear in this specification. </p>
<example>
<head>Example productions with fixed event codes</head>

<table width="95%">
<thead>
<tr>
<th colspan="4">&nbsp;</th></tr>
<tr>
<td width="5%"></td>
<th colspan="2" align="left">Productions</th>
<th align="left">Event Codes</th></tr>
</thead>
<tbody>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>LeftHandSide</emph><sub>&nbsp;1</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;3</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;3</sub></td>
<td>2.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;4</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;4</sub></td>
<td>2.1</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;5</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;5</sub></td>
<td>2.2.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;6</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;6</sub></td>
<td>2.2.1</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>LeftHandSide</emph><sub>&nbsp;2</sub> :</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;3</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;3</sub></td>
<td>1.1</td></tr></tbody></table>
</example>
<p>The number of parts in a given <termref def="key-eventcode">event code</termref> is called the event code's length. No two productions with the same non-terminal symbol on the left-hand side are permitted to have the same <termref def="key-eventcode">event code</termref>. </p></div3>
<div3 id="variableEventCodes">
<head>Variable Event Codes</head>
<p>Some non-terminal symbols are used on the right-hand side in a production without 
a terminal symbol prefixed to them, but with a parenthesized event code affixed instead. 
Such non-terminal symbols are macros and they are used to capture some recurring set of productions 
as 
symbols so that a symbol can be used in the grammar representation instead of including all the productions the macro represents in place every time it is used.
</p>

<example>
<head>Example productions that use macro non-terminal symbols</head>
<table width="95%">
<thead>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ABigProduction</emph><sub>&nbsp;1</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph>LEFTHANDSIDE <sub>1</sub></emph> (2.0)</td>
<td>2.0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>ABigProduction</emph><sub>&nbsp;2</sub> :</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph>LEFTHANDSIDE <sub>1</sub></emph> (1.1)</td>
<td>1.1</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1.2</td></tr>
</tbody></table>

</example>

<p>
Because non-terminal macros are injected into the right-hand side of more than one production,
the <termref def="key-eventcode">event codes</termref> of productions with these macro non-terminals on the left-hand side are not fixed, but will have different event code values depending on the context in which the macro non-terminal appears. This specification calls these variable event codes and uses variables in place of individual event code parts to indicate the event code parts are determined by the context. Below are some examples of variable event codes: </p>
<example>
<head>Example non-terminal macros and its productions with variable event codes</head>

<table width="95%">
<thead>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>LEFTHANDSIDE</emph><sub>&nbsp;1</sub><emph>&nbsp;(n.m)</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">
TERMINAL<sub>&nbsp;1</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;1</sub></td>
<td>
<emph>n</emph>.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;2</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;2</sub></td>
<td>
<emph>n</emph>.1</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;3</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;3</sub></td>
<td>
<emph>n</emph>. 
<emph>m</emph>+2</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;4</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;4</sub></td>
<td>
<emph>n</emph>. 
<emph>m</emph>+3</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;5</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;5</sub></td>
<td>
<emph>n</emph>. 
<emph>m</emph>+4.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;6</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;6</sub></td>
<td>
<emph>n</emph>. 
<emph>m</emph>+4.1</td></tr></tbody></table>
</example>
<p>Unless otherwise specified, the variable 
<emph>n</emph> evaluates to the first part of the 
<termref def="key-eventcode">event code</termref> of the production in which the macro non-terminal 
<emph>LEFTHANDSIDE</emph><sub>&nbsp;1&nbsp;</sub> appears on the right-hand side. Similarly, the expression 
<emph>n</emph>. 
<emph>m</emph> represents the first two parts of the <termref def="key-eventcode">event code</termref> of the production in which the macro non-terminal 
<emph>LEFTHANDSIDE</emph><sub>&nbsp;1&nbsp;</sub> appears on the right-hand side. </p>

<p>Non-terminal macros are used in this specification for notational convenience only.
They are not non-terminals, even though they are used in place of non-terminals.
Productions that use non-terminal macros on the right-hand side need to be expanded by macro substitution before such productions are interpreted.
Therefore, <emph>ABigProduction</emph><sub>&nbsp;1</sub> and <emph>ABigProduction</emph><sub>&nbsp;2&nbsp;</sub> shown in the preceding example are equivalent to the following set of productions obtained by expanding the non-terminal macro symbol <emph>LEFTHANDSIDE</emph><sub>&nbsp;1&nbsp;</sub> and evaluating the variable event codes.
</p>
<example>
<head>Expanded productions equivalent to the productions used above</head>

<table width="95%">
<thead>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ABigProduction</emph><sub>&nbsp;1</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;1</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;1</sub></td>
<td>2.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;2</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;2</sub></td>
<td>2.1</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;3</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;3</sub></td>
<td>2.2</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;4</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;4</sub></td>
<td>2.3</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;5</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;5</sub></td>
<td>2.4.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;6</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;6</sub></td>
<td>2.4.1</td></tr>
<tr>
<td colspan="5">&nbsp;</td></tr>


<tr>
<td width="5%"></td>
<td colspan="4">
<emph>ABigProduction</emph><sub>&nbsp;2</sub> :</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;1</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;1</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td width="75%">
TERMINAL<sub>&nbsp;1</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;1</sub></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;2</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;2</sub></td>
<td>1.1</td></tr>
<tr>
<td></td>
<td></td>
<td>
Terminal<sub>&nbsp;2</sub>
&nbsp;&nbsp;
<emph>NonTerminal</emph><sub>&nbsp;2</sub></td>
<td>1.2</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;3</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;3</sub></td>
<td>1.3</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;4</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;4</sub></td>
<td>1.4</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;5</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;5</sub></td>
<td>1.5.0</td></tr>
<tr>
<td></td>
<td></td>
<td>
TERMINAL<sub>&nbsp;6</sub>
&nbsp;&nbsp;<emph>NONTERMINAL</emph><sub>&nbsp;6</sub></td>
<td>1.5.1</td></tr>
</tbody></table>

</example></div3>
</div2>

<div2 id="grammarEventCodes">
<head>Grammar Event Codes</head>
<p>Each production rule in the EXI grammar includes an <termref def="key-eventcode">event code</termref> value that approximates the likelihood the associated production rule will be matched over the other productions with the same left-hand-side non-terminal symbol. Ultimately, the <termref def="key-eventcode">event codes</termref> determine the value(s) by which each non-terminal symbol will be represented in the EXI stream. </p>
<p>To understand how a given <termref def="key-eventcode">event code</termref> approximates the likelihood a given production will match, it is useful to visualize the <termref def="key-eventcode">event codes</termref> for a set of production rules that have the same non-terminal symbol on the left-hand side as a tree. For example, the following set of productions: </p>
<example>
<head>Example productions with event codes</head>

<table width="95%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="4">
<emph>ElementContent</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">EE</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*)&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>CH&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.1</td></tr>
<tr>
<td></td>
<td></td>
<td>ER&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.2</td></tr>
<tr>
<td></td>
<td></td>
<td>CM&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.3.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.3.1</td></tr></tbody></table></example>
<p>represents a set of information items that might occur as element content after the start tag. Using the production <termref def="key-eventcode">event codes</termref>, we can visualize this set of productions as follows: </p>
<graphic source="eventCodeTree.png" alt="Event code tree for ElementContent grammar"/>
<p>
where the 
terminal symbols 
are represented by the leaf nodes of the tree, and the <termref def="key-eventcode">event code</termref> of each production rule 
defines a path from the root of the tree to the node 
that represents the terminal symbol that is on the right-hand side of the production. 
We call this the event code tree for a given set of productions. </p>
<p>An event code tree is similar to a Huffman tree <bibref ref="huffman"/> in that shorter paths are generally used for symbols that are considered more likely. However, event code trees are far simpler and less costly to compute and maintain. Event code trees are shallow and contain at most three levels. In addition, the length of each <termref def="key-eventcode">event code</termref> in the event code tree is assigned statically without analyzing the data. This classification provides some of the benefits of a Huffman tree without the cost. </p></div2>
<div2 id="pruningProductions">
<head>Pruning Unneeded Productions</head>
<p>As discussed in section 
<specref ref="fidelityOptions"/>, applications MAY provide a set of fidelity options to specify the XML features they require. EXI processors MUST use these fidelity options to prune 
the productions of which the terminal symbols represent the events that are not required from the grammars, 
improving compactness and processing efficiency.</p>
<p>For example, the following set of productions represent the set of information items that might occur as element content after the start tag.</p>
<example>
<head>Example productions with full fidelity</head>

<table width="95%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ElementContent</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">EE</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*)&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>CH&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.1</td></tr>
<tr>
<td></td>
<td></td>
<td>ER&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.2</td></tr>
<tr>
<td></td>
<td></td>
<td>CM&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.3.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.3.1</td></tr></tbody></table>
</example>
<p>If an application sets the fidelity options Preserve.comments, Preserve.pis and Preserve.dtd to false, the productions matching comment (CM), processing instruction (PI) and entity reference (ER) events are pruned from the grammar, producing the following set of productions: </p>
<example>
<head>Example productions after pruning</head>

<table width="95%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="4">
<emph>ElementContent</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">EE</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*)&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>CH&nbsp;&nbsp;<emph>ElementContent</emph></td>
<td>1.1</td></tr></tbody></table>
</example>
<p>Removing these productions from the grammar tells EXI processors that comments and processing instructions will never occur in the EXI stream, which reduces the entropy of the stream allowing it to be encoded in fewer bits. </p>
<p>Each time a production is removed from a grammar, the <termref def="key-eventcode">event codes</termref> of the other productions with the same non-terminal symbol on the left-hand side MUST be adjusted to keep them contiguous if its removal has left the remaining productions with non-contiguous event codes.</p></div2>


<div2 id="builtinGrammars">
<head>Built-in XML Grammars</head>
<p>This section describes the built-in XML grammars used by EXI when no schema information is available or when available schema information describes only portions of the EXI stream. </p>

<p>The built-in XML grammars are dynamic and continuously evolve to reflect knowledge learned while processing an EXI stream. New <termref def="key-builtin-elem-grammar">built-in element grammars</termref> are created to describe the content of newly encountered elements and new grammar productions are added to refine existing built-in grammars. Newly learned grammars and productions are used to more efficiently represent subsequent events in the EXI stream. All newly created <termref def="key-builtin-elem-grammar">built-in element grammars</termref> are <termref def="key-global-element-grammar">global element grammars</termref>. 
</p>

<p><termdef id="key-global-element-grammar" term="global element grammar">A <term>global element grammar</term> is a grammar describing the content of an element that has global scope (i.e. a global element).</termdef> At the onset of processing an EXI stream, the set of global element grammars is the set of all schema-informed element grammars derived from element declarations that have a {scope} property of <emph>global</emph>. Each <termref def="key-builtin-elem-grammar"/> created while processing an EXI stream is added to the set of global element grammars. Each global element 
grammar 
has a unique <termref def="key-qname">qname</termref>.</p>

<div3 id="builtinDocGrammars">
<head>Built-in Document Grammar</head>
<p>In the absence of schema information describing the content of the EXI stream, the following grammar describes the events that will occur in an <termref def="key-exidocument">EXI document</termref>. </p>
<table width="100%">
<tbody>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Document</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="60%">SD 
<emph>DocContent</emph></td>
<td width="30%">0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>DocContent</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*) 
<emph>DocEnd</emph></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>DT 
<emph>DocContent</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>DocContent</emph></td>
<td>1.1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>DocContent</emph></td>
<td>1.1.1</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>DocEnd</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>ED</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>DocEnd</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>DocEnd</emph></td>
<td>1.1</td></tr></tbody></table>
<p></p>
<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td><p>All productions in the built-in document grammars of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) <emph>RightHandSide</emph>
are evaluated as follows: </p>
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item> 
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>
</td></tr>
</tbody></table>
</div3>
<div3 id="builtinFragGrammars">
<head>Built-in Fragment Grammar</head>
<p>In the absence of schema information describing the contents of an EXI stream, the following grammar describes the events that may occur in an <termref def="key-exifragment">EXI fragment</termref>. The grammar below represents the initial set of productions in the built-in fragment grammar at the start of EXI stream processing. The associated semantics explain how the built-in fragment grammar evolves to more efficiently represent subsequent events in the EXI stream.</p>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr>
</thead>
<tbody>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Fragment</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="60%">SD 
<emph>FragmentContent</emph></td>
<td width="30%">0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>FragmentContent</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*) 
<emph>FragmentContent</emph></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>ED</td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>FragmentContent</emph></td>
<td>2.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>FragmentContent</emph></td>
<td>2.1</td></tr>
</tbody></table>
<p></p>
<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>All productions in the built-in fragment grammars of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) <emph>RightHandSide</emph>
are evaluated as follows: </p>
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>Create a production of the form <emph>LeftHandSide</emph> : SE (<emph>qname</emph>) <emph>RightHandSide</emph> with an <termref def="key-eventcode">event code</termref> 0</item>
<item>Increment the first part of the <termref def="key-eventcode">event code</termref> of each production in the current grammar with the non-terminal <emph>LeftHandSide</emph> on the left-hand side</item>
<item>Add the production created in step 
3 
to the grammar</item>
<item>Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>
<p>All productions of the form <emph>LeftHandSide</emph> : SE (<emph>qname</emph>) <emph>RightHandSide</emph> that were previously added to the grammar upon the first occurrence of the element that has the <termref def="key-qname">qname</termref>&nbsp;<emph>qname</emph> are evaluated as follows when they are matched: </p>
<olist>
<item>Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph></item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>
</td></tr>
</tbody></table>
</div3>

<div3 id="builtinElemGrammars">
<head>Built-in Element Grammar</head>
<p><termdef id="key-builtin-elem-grammar" term="built-in element grammar">When no grammar exists for an element occurring in an EXI stream, a <term>built-in element grammar</term> is created for that element.</termdef> 
Built-in element grammars are initially generic and are progressively refined as the specific content for the associated element is learned. All built-in element grammars are <termref def="key-global-element-grammar"/>s and can be uniquely identified by the qname of the global element they describe. At the outset of processing an EXI stream, the set of built-in element grammars is empty.</p> 

<p>Below is the initial set of productions used for all newly created <termref def="key-builtin-elem-grammar">built-in element grammars</termref>. The semantics describe how productions are added to each <termref def="key-builtin-elem-grammar"/> as the content of the associated element is learned.</p>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr>
</thead>
<tbody>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>StartTagContent</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="60%">EE</td>
<td width="30%">0.0</td></tr>
<tr>
<td></td>
<td></td>
<td>AT&nbsp;(*) 
<emph>StartTagContent</emph></td>
<td>0.1</td></tr>
<tr>
<td></td>
<td></td>
<td>NS 
<emph>StartTagContent</emph></td>
<td>0.2</td></tr>
<tr>
<td></td>
<td></td>
<td>SC 
<emph>Fragment</emph></td>
<td>0.3</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph><kw>ChildContentItems</kw></emph>&nbsp;<kw>(0.4)</kw></td>
<td></td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>


<tr>
<td></td>
<td colspan="3">
<emph>ElementContent</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>EE</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph>ChildContentItems</emph> (1.0)</td>
<td></td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>ChildContentItems (n.m)</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*) <emph>ElementContent</emph></td>
<td>
<emph>n</emph>. 
<emph>m</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>CH <emph>ElementContent</emph></td>
<td>
<emph>n</emph>.(<emph>m</emph>+1)</td></tr>
<tr>
<td></td>
<td></td>
<td>ER <emph>ElementContent</emph></td>
<td>
<emph>n</emph>.(<emph>m</emph>+2)</td></tr>
<tr>
<td></td>
<td></td>
<td>CM <emph>ElementContent</emph></td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI <emph>ElementContent</emph></td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).1</td></tr>
</tbody></table>
<p></p>
<table width="100%">
<thead>
<tr>
<th align="left">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<ulist>
<item>
When the value of the <termref def="key-selfContained">selfContained option</termref> is false, 
the production with the terminal symbol SC on the right-hand side is absent from the above grammar, and 
the use of the non-terminal macro <emph>ChildContentItems</emph> that has <emph>StartTagContent</emph> non-terminal on the left-hand side (shown in bold above) gets expanded with variable values (0.3) instead of (0.4) used above.
</item>
</ulist>
</td>
</tr>
<tr id="builtInGrammarOrderNotes">
<td>
<ulist>
<item>
When a xsi:type attribute appears in an element where the <termref def="key-builtin-elem-grammar"/> is in effect, it MUST occur before any other AT events of the same element 
unless it is known that xsi:type attribute will not impact grammar selection. 
</item>
</ulist>
</td>
</tr>
<tr>
<td>
<ulist>
<item>
When a xsi:nil attribute appears in an element where the <termref def="key-builtin-elem-grammar"/> is in effect, it does not impact grammar selection and is not strictly required to occur before other AT events of the same element. 
</item>
</ulist>
</td>
</tr>
</tbody></table>
<p/>

<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>All productions in the <termref def="key-builtin-elem-grammar"/> of the form 
<emph>LeftHandSide</emph>: AT&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the attribute matched by AT&nbsp;(*) </item>
<item>Create a production of the form 
<emph>LeftHandSide</emph> : AT&nbsp;(<emph>qname</emph>) <emph>RightHandSide</emph>
with an <termref def="key-eventcode">event code</termref> 0 and increment the first part of the event code of each production in the current grammar with the non-terminal <emph>LeftHandSide</emph> on the left-hand side. Add this production to the grammar.</item>
<item>
&xsiType-matching-AT-star;
</item>
</olist>

<p>The production of the form <emph>LeftHandSide</emph> : AT (<emph>xsi:type</emph>) <emph>RightHandSide</emph> that was previously added to the grammar upon the first occurrence of the xsi:type attribute is evaluated as follows when it is matched: </p>
<olist>
&xsiType-matching-AT-xsiType;
</olist>

<p>All productions of the form <emph>LeftHandSide</emph> : SC <emph>Fragment</emph> are evaluated as follows: </p>
<olist>
<item>
Save the string table, grammars and any implementation-specific state learned while processing this EXI Body.
</item>
<item>Initialize the string table, grammars and any implementation-specific state learned while processing this EXI Body to the state they held just prior to processing this EXI Body.
</item>
<item>Skip to the next byte-aligned boundary in the stream 
if it is not already at such a boundary.
</item>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the SE event immediately preceding this SC event.</item>
<item>Let <emph>content</emph> be the sequence of events following this SC event that match the grammar for element <emph>qname</emph>, up to and including the terminating EE event.</item>
<item>Evaluate the sequence of events (SD, SE(<emph>qname</emph>), <emph>content</emph>, ED) according to the <emph>Fragment</emph> grammar (see <specref ref="builtinFragGrammars"/>).
</item>
<item>Skip to the next byte-aligned boundary in the stream 
if it is not already at such a boundary.
</item>
<item>Restore the string table, grammars and implementation-specific state learned while processing this EXI Body to that saved in step 1 above.
</item>
</olist>

<p>All productions in the <termref def="key-builtin-elem-grammar"/> of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) <emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>Create a production of the form <emph>LeftHandSide</emph> : SE (<emph>qname</emph>) <emph>RightHandSide</emph> with an <termref def="key-eventcode">event code</termref> 0</item>
<item>Increment the first part of the <termref def="key-eventcode">event code</termref> of each production in the current grammar with the non-terminal <emph>LeftHandSide</emph> on the left-hand side</item>
<item>Add the production created in step 
3 
to the grammar</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>

<p>All productions of the form <emph>LeftHandSide</emph> : SE (<emph>qname</emph>) <emph>RightHandSide</emph> that were previously added to the grammar upon the first occurrence of the element that has the <termref def="key-qname">qname</termref>&nbsp;<emph>qname</emph> are evaluated as follows when they are matched: </p>
<olist>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph></item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>

<p>All productions in the <termref def="key-builtin-elem-grammar"/> of the form 
<emph>LeftHandSide</emph> : CH 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>If a production of the form, 
<emph>LeftHandSide</emph> : CH 
<emph>RightHandSide</emph> with an <termref def="key-eventcode">event code</termref> of length 1 does not exist in the current element grammar, create one with event code 0 and increment the first part of the event code of each production in the current grammar with the non-terminal 
<emph>LeftHandSide</emph> on the left-hand side. </item>
<item>Add the production created in step 1 to the grammar
</item>
<item>Evaluate the remainder of event sequence using <emph>RightHandSide</emph>.</item>
</olist>

<p>All productions in the <termref def="key-builtin-elem-grammar"/> of the form 
<emph>LeftHandSide</emph> : EE 
are evaluated as follows: </p>
<olist>
<item>If a production of the form, 
<emph>LeftHandSide</emph> : EE 
with an <termref def="key-eventcode">event code</termref> of length 1 does not exist in the current element grammar, create one with event code 0 and increment the first part of the event code of each production in the current grammar with the non-terminal 
<emph>LeftHandSide</emph> on the left-hand side. </item>
<item>Add the production created in step 1 to the grammar
</item>
</olist>
</td></tr>
</tbody></table>
</div3></div2>
<div2 id="informedGrammars">
<head>Schema-informed Grammars</head>
<p>This section describes the schema-informed grammars used by EXI when schema information is available to describe the contents of the <termref def="key-existream">EXI stream</termref>. 
Schema information used for processing an EXI stream is either indicated by the header option <termref def="key-schemaIdOption">schemaId</termref>, or communicated out-of-band in the absence of <termref def="key-schemaIdOption">schemaId</termref>. 
</p>

<p>Schema-informed grammars accept all XML documents and fragments regardless of whether and how closely they match the schema. The <termref def="key-exiencoder">EXI stream encoder</termref> encodes individual events using schema-informed grammars where they are available and falls back to the built-in XML grammars where they are not. In general, events for which a schema-informed grammar exists will be encoded more efficiently. </p>
<p>Unlike built-in XML grammars, schema-informed grammars are static and do not evolve, which permits the reuse of schema-informed grammars across the processing of multiple EXI streams. This is a single outstanding difference between the two grammar systems.</p>
<!-- NOTE: merge into the paragraph above -->
<p>It is important to note that schema-informed and built-in grammars are often used together within the context of a single <termref def="key-existream">EXI stream</termref>. While processing a schema-informed grammar, built-in grammars may be created to represent schema deviations or elements that match wildcards declared in the schema. Even though these built-in grammars occur in the context of a schema-informed stream, they are still dynamic and evolve to represent content learned while processing the EXI stream as is described in <specref ref="builtinGrammars"/>. 
</p>
<div3 id="informedDocGrammars">
<head>Schema-informed Document Grammar</head>
<p>When schema information is available to describe the contents of an <termref def="key-existream">EXI stream</termref>, the following grammar describes the events that will occur in an <termref def="key-exidocument">EXI document</termref>. </p>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr></thead>
<tbody><tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Document</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SD 
<emph>DocContent</emph></td>
<td>0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>DocContent</emph> :</td></tr>

<tr>
<td></td>
<td></td>
<td>SE (G <sub>0</sub>) <emph>DocEnd</emph></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>SE (G <sub>1</sub>) <emph>DocEnd</emph></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&vellip;</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>SE (G <sub><emph>n</emph>&minus;1</sub>) <emph>DocEnd</emph></td>
<td><emph>n</emph>&minus;1</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*) 
<emph>DocEnd</emph></td>
<td>
<emph>n</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>DT 
<emph>DocContent</emph></td>
<td>
(<emph>n</emph>+1).0</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>DocContent</emph></td>
<td>
(<emph>n</emph>+1).1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>DocContent</emph></td>
<td>
(<emph>n</emph>+1).1.1</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<table>
<tr><th colspan="2" align="left">Note:</th></tr>
</table></td></tr>
<tr>
<td></td>
<td colspan="3"><ulist><item>The variable 
<emph>n</emph> in the grammar above is the number of global elements declared in the schema. 
G&nbsp;<sub>0</sub>, G&nbsp;<sub>1</sub>, ... G&nbsp;<sub><emph>n</emph>&minus;1</sub> represent all the <termref def="key-qname">qnames</termref> of global elements sorted lexicographically, first by local-name, then by uri.</item></ulist>
</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>DocEnd</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>ED</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>DocEnd</emph></td>
<td>1.0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>DocEnd</emph></td>
<td>1.1</td></tr></tbody></table>
<p></p>
<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>
In a schema-informed grammar, all productions of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of event sequence using <emph>RightHandSide</emph>
</item>
</olist>
</td></tr>

</tbody></table>
</div3>

<div3 id="informedFragGrammars">
<head>Schema-informed Fragment Grammar</head>
<p>When schema information is available to describe the contents of an <termref def="key-existream">EXI stream</termref>, the following grammar describes the events that will occur in an <termref def="key-exifragment">EXI fragment</termref>. </p>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr></thead>
<tbody><tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Fragment</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">SD 
<emph>FragmentContent</emph></td>
<td>0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<emph>FragmentContent</emph> :</td></tr>
<tr>
<td></td>
<td></td>
<td>SE (F <sub>0</sub>) <emph>FragmentContent</emph></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>SE (F <sub>1</sub>) <emph>FragmentContent</emph></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&vellip;</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>SE (F <sub><emph>n</emph>&minus;1</sub>) <emph>FragmentContent</emph></td>
<td><emph>n</emph>&minus;1</td></tr>
<tr>
<td></td>
<td></td>
<td>SE&nbsp;(*) 
<emph>FragmentContent</emph></td>
<td><emph>n</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>ED</td>
<td>
<emph>n</emph>+1</td></tr>
<tr>
<td></td>
<td></td>
<td>CM 
<emph>FragmentContent</emph></td>
<td>(<emph>n</emph>+2).0</td></tr>
<tr>
<td></td>
<td></td>
<td>PI 
<emph>FragmentContent</emph></td>
<td>(<emph>n</emph>+2).1</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td></td>
<td colspan="3">
<table>
<tr><th colspan="2" align="left">Note:</th></tr>
</table></td></tr>
<tr>
<td></td>
<td colspan="3">
<ulist><item>The variable <emph>n</emph> in the grammar above represents the number of unique element <termref def="key-qname">qnames</termref> declared in the schema. The variables F&nbsp;<sub>0&nbsp;</sub>, F&nbsp;<sub>1&nbsp;</sub>, ... F&nbsp;<sub>n&minus;1</sub> represent these <termref def="key-qname">qnames</termref> sorted lexicographically, first by local-name, then by uri. If there is more than one element declared with the same <termref def="key-qname">qname</termref>, the <termref def="key-qname">qname</termref> is included only once. 
If all such elements have the same schema type name and {nillable} property value, their content is evaluated according to the specific grammar for that element declaration. 
Otherwise, their content is evaluated according to the relaxed Element Fragment grammar described in <specref ref="informedElementFragGrammar"/>.</item>
</ulist>
</td>
</tr></tbody></table>
<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>
In a schema-informed grammar, all productions of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of event sequence using <emph>RightHandSide</emph>
</item>
</olist>
</td></tr>
</tbody></table>
</div3>

<div3 id="informedElementFragGrammar">
<head>Schema-informed Element Fragment Grammar</head>
<p><termdef id="key-informed-elem-fragment-grammar" term="schema-informed element fragment grammar">
When schema information is available to describe the contents of an <termref def="key-existream">EXI stream</termref> and more than one element is declared with the same <termref def="key-qname">qname</termref>, 
but not all such elements have the same type name and {nillable} property value, 
the <term>Schema-informed Element Fragment Grammar</term> are used for processing the events that may occur in such elements when they occur inside an EXI fragment or EXI Element Fragment. 
</termdef>
The schema-informed element fragment grammar consists of <emph>ElementFragment</emph> and <emph>ElementFragmentTypeEmpty</emph> which are defined below. <emph>ElementFragment</emph> is a grammar that accounts both element declarations and attribute declarations in the schemas, whereas <emph>ElementFragmentTypeEmpty</emph> is a grammar that regards only attribute declarations.
</p>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax</th>
<th align="left">Event Code</th></tr></thead>
<tbody>
<tr>
<td colspan="4">&nbsp;</td></tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ElementFragment</emph><sub>&nbsp;0</sub> :
</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td width="75%">AT&nbsp;(<sub>&nbsp;</sub>A<sub>&nbsp;0&nbsp;</sub>) [schema-typed value] <emph>ElementFragment</emph><sub>&nbsp;0</sub></td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>AT&nbsp;(<sub>&nbsp;</sub>A<sub>&nbsp;1&nbsp;</sub>) [schema-typed value] <emph>ElementFragment</emph><sub>&nbsp;0</sub></td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&vellip;</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>AT&nbsp;(<sub>&nbsp;</sub>A<sub>&nbsp;<emph>n</emph>&minus;1&nbsp;</sub>) [schema-typed value] <emph>ElementFragment</emph><sub>&nbsp;0</sub></td>
<td><emph>n</emph>&minus;1</td></tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<sub>&nbsp;</sub>*<sub>&nbsp;</sub>) <emph>ElementFragment</emph><sub>&nbsp;0</sub>
</td>
<td><emph>n</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub>0&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>n</emph>+1</td></tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub>1&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>n</emph>+2</td></tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&vellip;</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub><emph>m</emph>-1&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>n</emph>+<emph>m</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>
SE&nbsp;(<sub>&nbsp;</sub>*<sub>&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>n</emph>+<emph>m</emph>+1</td></tr>
<tr>
<td></td>
<td></td>
<td>EE</td>
<td>
<emph>n</emph>+<emph>m</emph>+2</td></tr>
<tr>
<td></td>
<td></td>
<td>CH [untyped&nbsp;value] 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>n</emph>+<emph>m</emph>+3</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>

<tr>
<td></td>
<td colspan="3">
<emph>ElementFragment</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub>0&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>0</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub>1&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&vellip;</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>SE (<sub>&nbsp;</sub>F<sub><emph>m</emph>-1&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td><emph>m</emph>-1</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE&nbsp;(<sub>&nbsp;</sub>*<sub>&nbsp;</sub>) 
<emph>ElementFragment</emph><sub>&nbsp;2
</sub>
</td>
<td><emph>m</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>EE</td>
<td>
<emph>m</emph>+1</td></tr>
<tr>
<td></td>
<td></td>
<td>CH [untyped&nbsp;value] 
<emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>m</emph>+2</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>

<tr>
<td></td>
<td colspan="3">
<emph>ElementFragment</emph><sub>&nbsp;2</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE (<sub>&nbsp;</sub>F<sub>0&nbsp;</sub>) <emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>0</emph>
</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE (<sub>&nbsp;</sub>F<sub>1&nbsp;</sub>) <emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&vellip;
</td>
<td>
&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE (<sub>&nbsp;</sub>F<sub><emph>m</emph>-1&nbsp;</sub>) <emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>m</emph>-1
</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE&nbsp;(<sub>&nbsp;</sub>*<sub>&nbsp;</sub>) <emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>m</emph>
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
<td>
<emph>m</emph>+1
</td></tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>ElementFragment</emph><sub>&nbsp;2</sub>
</td>
<td>
<emph>m</emph>+2
</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>

<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;0</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<sub>&nbsp;</sub>A <sub>0&nbsp;</sub>) [schema-typed value] <emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;0</sub>
</td>
<td>0</td></tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<sub>&nbsp;</sub>A <sub>1&nbsp;</sub>) [schema-typed value] <emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;0</sub>
</td>
<td>1</td></tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&vellip;
</td>
<td>&vellip;</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<sub>&nbsp;</sub>A <sub><emph>n</emph>&minus;1&nbsp;</sub>) [schema-typed value] <emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;0</sub>
</td>
<td><emph>n</emph>&minus;1</td></tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<sub>&nbsp;</sub>*<sub>&nbsp;</sub>) <emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;0</sub>
</td>
<td><emph>n</emph></td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
<td>
<emph>n</emph>+1</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>

<tr>
<td width="5%"></td>
<td colspan="3">
<emph>ElementFragmentTypeEmpty</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
<td>0</td></tr>
<tr>
<td colspan="4">&nbsp;</td></tr>

<tr>
<td></td>
<td colspan="3">
<table>
<tr><th colspan="2" align="left">Note:</th></tr>
</table></td></tr>
<tr>
<td></td>
<td colspan="3">
<ulist><item>The variable <emph>n</emph> in the grammar above represents 
the number of unique <termref def="key-qname">qnames</termref> given to explicitly declared attributes in the schema. 
The variables A<sub>&nbsp;0</sub>&nbsp;, A<sub>&nbsp;1&nbsp;</sub>, ... A<sub>&nbsp;<emph>n</emph>&minus;1&nbsp;</sub> represent these qnames sorted lexicographically, first by local-name, then by uri. If there is more than one attribute declared with the same <termref def="key-qname">qname</termref>, the qname is included only once. 
If all such attributes have the same schema type name, their <termref def="key-valueContentItem"><emph>value</emph></termref> is represented using that type. 
Otherwise, their <termref def="key-valueContentItem"><emph>value</emph></termref> is represented as a String.</item>
</ulist>
<ulist><item>The variable <emph>m</emph> in the grammar above represents the number of unique element <termref def="key-qname">qnames</termref> declared in the schema. The variables F<sub>0&nbsp;</sub>, F<sub>1&nbsp;</sub>, ... F<sub><emph>m</emph>-1&nbsp;</sub> represent these qnames sorted lexicographically, first by local-name, then by uri. If there is more than one element declared with the same <termref def="key-qname">qname</termref>, the qname is included only once. 
If all such elements have the same type name and {nillable} property value, their content is evaluated according to specific grammar for that element declaration. 
Otherwise, their content is evaluated according to the relaxed Element Fragment grammar described above.
</item>
</ulist>

</td>
</tr></tbody></table>

<table>
<tbody>
<tr>
<th colspan="2" align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>
In a schema-informed grammar, all productions of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of event sequence using <emph>RightHandSide</emph>
</item>
</olist>
<p>All productions in the schema-informed element fragment grammar of the form 
<emph>LeftHandSide</emph>: AT&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the attribute matched by AT&nbsp;(*) </item>
<item>
</item>
<item>If a global attribute definition exists for <emph>qname</emph>, let <emph>global-type</emph> be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with <emph>global-type</emph>, it SHOULD be represented  using the datatype representation associated with <emph>global-type</emph> (see <specref ref="encodingValues"/>). If the attribute value is not represented using the datatype representation associated with <emph>global-type</emph>, represent the 
attribute event 
using the AT&nbsp;(*) [untyped&nbsp;value] terminal (see <specref ref="undeclaredProductions"/>).
</item>
</olist>
<note>
When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal.
</note>
</td></tr>
</tbody></table>

<p>As with all schema informed element grammars, the schema-informed element fragment grammar is augmented with additional productions that describe events that may occur in an EXI stream, but are not explicitly declared in the schema. The process for augmenting the grammar is described in <specref ref="undeclaredProductions"/>. 
For the purposes of this process, the schema-informed element fragment grammar is treated as though it is created from an element declaration with a {nillable} property value of true and a type declaration that has named sub-types, and <emph>ElementFragmentTypeEmpty</emph> is used to serve as the <termref def="key-type-empty"><emph>TypeEmpty</emph></termref> of the type in the process.
</p>

<p>The <termref def="key-contentIndex"><emph>content</emph></termref> index of grammars 
<emph>ElementFragment</emph> 
and <emph>ElementFragmentTypeEmpty</emph> 
are both 1 (one). 

</p>
</div3>

<div3 id="informedElemGrammars">
<head>Schema-informed Element and Type Grammars</head>
<p><termdef id="key-informedElementGrammar" term="Schema-informed Element Grammar">When one or more XML Schema is available to describe the contents of an EXI stream, a <term>schema-informed element grammar</term> <emph>Element</emph><sub>&nbsp;i&nbsp;</sub> is derived for each element declaration <emph>E</emph><sub>&nbsp;i&nbsp;</sub> described by the schemas, where 0 &le; <emph>i</emph> &lt; <emph>n</emph> and <emph>n</emph> is the number of element declarations in the schema.</termdef>
</p>
<p><termdef id="key-informedTypeGrammar" term="Schema-informed Type Grammar">When one or more XML Schema is available to describe the contents of an EXI stream, a <term>schema-informed type grammar</term> <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> is derived 
for each named type declaration <emph>T</emph><sub>&nbsp;i&nbsp;</sub> described by the schemas as well as for each of the <xspecref spec="XS2" ref="built-in-primitive-datatypes">built-in primitive types</xspecref> and <xspecref spec="XS2" ref="built-in-derived">built-in derived types</xspecref>, the <xspecref spec="XS1" ref="key-urType">complex ur-type</xspecref> and the <xspecref spec="XS2" ref="dt-anySimpleType">simple ur-type</xspecref> defined by XML Schema specification <bibref ref="schema1"/><bibref ref="schema2"/>, where 0 &le; <emph>i</emph> &lt; <emph>n</emph> and <emph>n</emph> is the total number of such available types.
</termdef>
</p>
<p>Each schema-informed element grammar and type grammar is constructed according to the following four steps:</p>
<ol>
<li>Create a proto-grammar that describes the content model according to available schema information (see section <specref ref="protoGrammars"/>). 
</li>
<li>Normalize the proto-grammar into an EXI grammar (see section <specref ref="normalizedGrammars"/>).</li>
<li>Assign <termref def="key-eventcode">event codes</termref> to each production in the normalized EXI grammar (see section <specref ref="eventCodeAssignment"/>). 
</li>
<li>Add additional productions to the normalized EXI grammar to represent events that may occur in the EXI stream, but are not described by the schema, such as comments, processing-instructions, schema-deviations, etc. (see section <specref ref="undeclaredProductions"/>). 
</li></ol>
<p>Each element grammar <emph>Element</emph><sub>&nbsp;i&nbsp;</sub> includes a sequence of <emph>n</emph> non-terminals <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub>, where 0 &le; <emph>j</emph> &lt; <emph>n</emph>. The content of the entire element is described by the first non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub>. The remaining non-terminals describe portions of the element content. Likewise, each type grammar <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> includes a sequence of <emph>n</emph> non-terminals <emph>Type</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub> and the content of the entire type is described by the first non-terminal <emph>Type</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub>.</p>
<p>The algorithms expressed in this section provide a concise and formal description of the EXI grammars for a given set of XML Schema definitions. More efficient algorithms likely exist for generating these EXI grammars and EXI implementations are free to use any algorithm that produces grammars and <termref def="key-eventcode">event codes</termref> that generate EXI encodings that match those produced by the grammars described here. </p>
<p>
An example is provided in the appendix (see <specref ref="grammarExamples"/>) that demonstrates the process described in this section to generate a complete schema-informed element grammar from an element declaration
in a schema.
</p>
<div4 id="protoGrammars">
<head>EXI Proto-Grammars</head>
<p>This section describes the process for creating the EXI proto-grammars from XML Schema declarations and definitions. EXI proto-grammars differ from normalized EXI grammars in that they may contain productions of the form:</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>LeftHandSide</emph> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td><emph>RightHandSide</emph></td>
</tr>
</tbody></table>
<p>where <emph>LeftHandSide</emph> and <emph>RightHandSide</emph> are both non-terminals. Whereas, all productions in a normalized EXI grammar contain exactly one terminal symbol and at most one non-terminal symbol on the right-hand side. This is a restricted form of Greibach normal form <bibref ref="greibach"/>. </p>
<p>EXI proto-grammars are derived from XML Schema in a straight-forward manner and can easily be normalized with simple algorithm (see <specref ref="normalizedGrammars"/>).
</p>
<div5 id="grammarConcatOperator">
<head>Grammar Concatenation Operator</head>
<p>Proto-grammars are specified in a modular, constructive fashion. XML Schema components such as terms, particles, attribute uses are transformed each into a distinct proto-grammar, leveraging proto-grammars of their sub-components. At various stages of proto-grammar construction, two or more of proto-grammars are concatenated one after another to form more composite grammars.
</p>
<p>The grammar concatenation operator &oplus; is a binary, associative operator that creates a new grammar from its left and right grammar operands. The new grammar accepts any set of symbols accepted by its left operand followed by any set of symbols accepted by its right operand.
</p>
<p>Given a left operand <emph>Grammar<sup>&nbsp;L</sup></emph> and a right operand <emph>Grammar<sup>&nbsp;R</sup></emph>, the following operation
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>Grammar<sup>&nbsp;L</sup></emph> &oplus; <emph>Grammar<sup>&nbsp;R</sup></emph>
</td>
</tr>
</tbody></table>
<p>creates a combined grammar by replacing each production of the form
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Grammar<sup>&nbsp;L</sup></emph><sub>k</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>
<p>where 0 &le; <emph>k</emph> &lt; <emph>n</emph> and <emph>n</emph> is the number of non-terminals that occur on the left-hand side of productions in <emph>Grammar<sup>&nbsp;L</sup></emph>, with a production of the form
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Grammar<sup>&nbsp;L</sup></emph><sub>k</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>Grammar<sup>&nbsp;R</sup></emph><sub>0</sub>
</td>
</tr>
</tbody></table>
<p>connecting each accept state of <emph>Grammar<sup>&nbsp;L</sup></emph> with the start state of <emph>Grammar<sup>&nbsp;R</sup></emph>.
</p>
</div5>
<div5 id="elementGrammars">
<head>Element Grammars</head>
<p>This section describes the process for creating an EXI element grammar from an XML Schema <xspecref spec="XS1" ref="cElement_Declarations">element declaration</xspecref>. </p>
<p>Given an element declaration <emph>E</emph><sub>&nbsp;i&nbsp;</sub>, with properties {name}, {target&nbsp;namespace}, {type&nbsp;definition}, {scope} and {nillable}, create a corresponding EXI grammar <emph>Element</emph><sub>&nbsp;i&nbsp;</sub> for evaluating the contents of elements in the specified {scope} with <emph>qname</emph>&nbsp;local-name = {name} and <emph>qname</emph>&nbsp;uri  = {target&nbsp;namespace} 
where <emph>qname</emph> is the <termref def="key-qname">qname</termref> of the elements. 
</p>

<p>Let <emph>T</emph><sub>&nbsp;j</sub> be the {type&nbsp;definition} of <emph>E</emph><sub>&nbsp;i&nbsp;</sub> and <emph>Type</emph><sub>&nbsp;j&nbsp;</sub> be the type grammar created from <emph>T</emph><sub>&nbsp;j&nbsp;</sub>. The grammar <emph>Element</emph><sub>&nbsp;i&nbsp;</sub> describing the content model of <emph>E</emph><sub>&nbsp;i&nbsp;</sub> is created as follows.
</p>
<table width="100%">
<thead>
<tr>
<th>Syntax:</th>
<th colspan="2">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Element</emph><sub>&nbsp;i&nbsp;,&nbsp;0</sub> :
</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>Type</emph><sub>&nbsp;j&nbsp;,&nbsp;0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody></table>

</div5>
<div5 id="typeGrammars">
<head>Type Grammars</head>
<p>Given an XML Schema type definition <emph>T</emph><sub>&nbsp;i&nbsp;</sub> 
with properties {name} and {target&nbsp;namespace}, 
two type grammars are created, which are denoted by <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> and <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub>. <termdef id="key-type"><term><emph>Type</emph></term><sub>&nbsp;i</sub> is a grammar that fully reflects the type definition of <emph>T</emph><sub>&nbsp;i&nbsp;</sub></termdef>, whereas <termdef id="key-type-empty"><term><emph>TypeEmpty</emph></term><sub>&nbsp;i</sub> is a grammar that 
regards 
only the attribute uses and attribute wildcards of <emph>T</emph><sub>&nbsp;i&nbsp;</sub>, if any</termdef>.
</p>
<p>The grammar <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> is used for evaluating the content of elements that are defined to be of type <emph>T</emph><sub>&nbsp;i&nbsp;</sub> in the schema. 
<termdef id="key-globalTypeGrammars" term="Global Type Grammars"><emph>Type</emph><sub>&nbsp;i&nbsp;</sub> is a <term>global type grammar</term> when <emph>T</emph><sub>&nbsp;i&nbsp;</sub> is a named type.
</termdef> 
<emph>Type</emph><sub>&nbsp;i&nbsp;</sub>, when it is a global type grammar, can additionally be used as the effective grammar designated by a xsi:type attribute with the attribute value that is a <termref def="key-qname">qname</termref> with local-name = {name} and uri = {target&nbsp;namespace}.
<emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> is used in place of <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> when the element instance that is being evaluated has a xsi:nil attribute with the value <emph>true</emph>.
</p>
<p>
<termdef id="key-contentIndex" term="content">For each type grammar <emph>Type</emph><sub>&nbsp;i&nbsp;</sub>, an unique index number <term><emph>content</emph></term> is determined such that all non-terminal symbols of indices smaller than <emph>content</emph> have at least one 
AT terminal symbol 
and the rest of the non-terminal symbols in <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> do not have 
AT terminal symbols 
on their right-hand side, where indices are assigned to non-terminal symbols in ascending order with the entry non-terminal symbol of <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> being assigned index 0 (zero).</termdef>
There is also a <emph>content</emph> index associated with each <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> where its value is determined in the same manner as for <emph>Type</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<p>
Sections <specref ref="simpleTypeGrammars"/> and <specref ref="complexTypeGrammars"/> describe the processes for creating <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> and <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> from XML Schema <xspecref spec="XS1" ref="Simple_Type_Definitions">simple type definitions</xspecref> and <xspecref spec="XS1" ref="Complex_Type_Definitions">complex type definitions</xspecref> defined in schemas as well as <xspecref spec="XS2" ref="built-in-primitive-datatypes">built-in primitive types</xspecref>, <xspecref spec="XS2" ref="built-in-derived">built-in derived types</xspecref> and <xspecref spec="XS2" ref="dt-anySimpleType">simple ur-type</xspecref> defined by XML Schema specification <bibref ref="schema2"/>.

Section <specref ref="anyTypeGrammar"/> defines the grammar used for processing instances of element contents of type <xspecref spec="XS1" ref="d0e9252">xsd:anyType</xspecref>.
</p>

<div6 id="simpleTypeGrammars">
<head>Simple Type Grammars</head>
<p>This section describes the process for creating an EXI type grammar from an XML Schema <xspecref spec="XS1" ref="Simple_Type_Definitions">simple type definition</xspecref>.</p>

<p>Given a simple type definition <emph>T</emph><sub>&nbsp;i&nbsp;</sub>, 
 create two new EXI grammars <termref def="key-type"><emph>Type</emph></termref><sub>&nbsp;i</sub> and <termref def="key-type-empty"><emph>TypeEmpty</emph></termref><sub>&nbsp;i</sub> 
following the procedure described below. 
</p>
<p>Add the following grammar productions to <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> and  <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> : </p>

<table width="100%">
<thead>
<tr>
<th>Syntax:</th>
<th colspan="2">&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Type</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>CH [schema-typed value] <emph>Type</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub></td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Type</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td></td>
<td>EE</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>TypeEmpty</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody></table>
<table>
<tbody>
<tr>
<th align="left">Note:</th>
</tr>
<tr>
<td></td>
<td>
Productions of the form <emph>LeftHandSide</emph> : CH [schema-typed value] <emph>RightHandSide</emph> represent 
typed character data that can be represented using the EXI datatype representation associated with the simple type definition (see <specref ref="encodingValues"/>).

Character data that can be represented using the EXI datatype representation associated with the simple type definition SHOULD be represented this way. Character data that is not represented using the EXI datatype representation associated with the simple type definition is represented by productions of the form <emph>LeftHandSide</emph> : CH [untyped&nbsp;value] <emph>RightHandSide</emph> described in section <specref ref="undeclaredProductions"/>.
</td></tr>
</tbody></table>
<p>
The <termref def="key-contentIndex"><emph>content</emph></termref> index of grammar <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> 
and <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> 
created from an XML Schema simple type definition is always 0 (zero).
</p>

</div6>
<div6 id="complexTypeGrammars">
<head>Complex Type Grammars</head>
<p>This section describes the process for creating an EXI type grammar from an XML Schema <xspecref spec="XS1" ref="Complex_Type_Definitions">complex type definition</xspecref>.</p>
<p>Given a complex type definition <emph>T</emph><sub>&nbsp;i&nbsp;</sub>, with properties {name}, {target&nbsp;namespace}, 
{attribute uses}, {attribute wildcard} and {content type}, 
 create two EXI grammars <termref def="key-type"><emph>Type</emph></termref><sub>&nbsp;i&nbsp;</sub> and <termref def="key-type-empty"><emph>TypeEmpty</emph></termref><sub>&nbsp;i&nbsp;</sub> 
following the procedure described below. 
</p>
<p>Generate a grammar <emph>Attribute</emph><sub>&nbsp;i&nbsp;</sub>, for each attribute use <emph>A</emph><sub>&nbsp;i</sub> in {attribute uses} according to section <specref ref="attributeUses"/>.
</p>
<p>Sort the attribute use grammars first by qname local-name, then by qname uri to form a sequence of grammars <emph>G</emph><sub>&nbsp;0&nbsp;</sub>, <emph>G</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>G</emph><sub>&nbsp;n&minus;1&nbsp;</sub>, where <emph>n</emph> is the number of attribute uses in {attribute uses}. 
</p>
<p>
If an {attribute wildcard} is specified, increment <emph>n</emph> and generate an additional attribute use grammar <emph>G</emph><sub>&nbsp;n&minus;1&nbsp;</sub> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;n&minus;1,&nbsp;0&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>EE</td>
</tr>
</tbody></table>
<p>
When the {attribute wildcard}'s {namespace&nbsp;constraint} is <emph>any</emph>, or 
a pair of <emph>not</emph> and either a namespace name or the special value 
<emph>absent</emph> indicating no namespace, 
add the following production to each grammar 
<emph>G</emph><sub>&nbsp;i&nbsp;</sub> 
generated above, 
where 0&nbsp;&le;&nbsp;<emph>i</emph>&nbsp;&lt;&nbsp;<emph>n</emph> :
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>AT&nbsp;(*) <emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub></td>
</tr>
</tbody></table>

<p>
Otherwise, that is, when {namespace&nbsp;constraint} is a set of values whose members are namespace names or the special value <emph>absent</emph> indicating no namespace, 
add the following production to each grammar 
<emph>G</emph><sub>&nbsp;i&nbsp;</sub> 
generated above
where 0&nbsp;&le;&nbsp;<emph>i</emph>&nbsp;&lt;&nbsp;<emph>n</emph> :
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>AT(<emph>uri<sub>x</sub></emph> : *) <emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub></td>
</tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr>
<td colspan="3">
<p>
where <emph>uri</emph><sub><emph>x</emph></sub> is a member value of {namespace&nbsp;constraint}, 
provided that it is the empty string (i.e. "") that is used as <emph>uri</emph><sub><emph>x</emph></sub> when the member value is the special value <emph>absent</emph>. 
Each <emph>uri<sub>&nbsp;x&nbsp;</sub></emph> is used to augment the uri partition of the String table.
Section <specref ref="stringTablePartitions"/> describes how these <emph>uri</emph> strings are put into String table for pre-population.
</p>
</td></tr>

<tr>
<td colspan="3">&nbsp;</td></tr>

<tr><td colspan="3">

<table>
<tbody>
<tr>
<th align="left">Note:</th></tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td>
<p>
When xsi:type and/or xsi:nil attributes appear in an element where schema-informed grammars are in effect, they MUST occur before any other AT events of the same element, with xsi:type placed before xsi:nil when they both occur.
</p>
</td>
</tr>
</tbody></table>

</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td></tr>
<tr><td colspan="3">


<table>
<tbody>
<tr>
<th align="left">Semantics:</th></tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td>
<p>
In complex type grammars, 
all productions of the form 
<emph>LeftHandSide</emph>: AT&nbsp;(*) 
<emph>RightHandSide</emph> and <emph>LeftHandSide</emph>: AT(<emph>uri</emph><sub><emph>x</emph></sub> : *) 
<emph>RightHandSide</emph> 
that stem from attribute wildcards 
are evaluated as follows: </p>
</td>
</tr>
</tbody></table>

<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the attribute matched by AT&nbsp;(*) or AT(<emph>uri</emph><sub><emph>x</emph></sub>&nbsp;:&nbsp;*)</item>
<item>If a global attribute definition exists for <emph>qname</emph>, let <emph>global-type</emph> be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with <emph>global-type</emph>, it SHOULD be represented  using the datatype representation associated with <emph>global-type</emph> (see <specref ref="encodingValues"/>). If the attribute value is not represented using the datatype representation associated with <emph>global-type</emph>, represent the 
attribute event 
using the AT&nbsp;(*) [untyped&nbsp;value] terminal (see <specref ref="undeclaredProductions"/>).
</item>

</olist>
<note>
When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal.
</note>
</td></tr>

</tbody></table>

<p>
The grammar <emph>TypeEmpty</emph><sub>&nbsp;i</sub> is created by combining the sequence of attribute use grammars 
terminated by an empty {content type} grammar 
as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>TypeEmpty</emph><sub>&nbsp;i</sub> = <emph>G</emph><sub>&nbsp;0</sub> &oplus; <emph>G</emph><sub>&nbsp;1</sub> &oplus; &hellip; &oplus; <emph>G</emph><sub>&nbsp;n&minus;1</sub> 
&oplus; <emph>Content</emph><sub>&nbsp;i</sub>
</td>
</tr>
</tbody></table>
<p>
where the grammar <emph>Content</emph><sub>&nbsp;i</sub> is created as follows: 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Content</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>

<p>
The <termref def="key-contentIndex"><emph>content</emph></termref> index of grammar <emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub> is the index of its last non-terminal symbol.
</p>

<p>
The grammar <emph>Type</emph><sub>&nbsp;i</sub> is generated as follows.
</p>

<p>If {content type} is a simple type definition
<emph>T</emph><sub>&nbsp;j</sub>
, generate a grammar <emph>Content</emph><sub>&nbsp;i</sub>
as <emph>Type</emph><sub>&nbsp;j</sub>
according to section <specref ref="simpleTypeGrammars"/>. 
If {content type} has a content model particle, generate a grammar <emph>Content</emph><sub>&nbsp;i</sub> according to section <specref ref="particles"/>.
Otherwise, if {content type} is <emph>empty</emph>, 
create a grammar <emph>Content</emph><sub>&nbsp;i</sub> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Content</emph><sub>&nbsp;i</sub> :
</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>

<p>
If {content type} is a content model particle with mixed content, add a production for each non-terminal <emph>Content</emph><sub>&nbsp;i&nbsp;,&nbsp;j&nbsp;</sub> in <emph>Content</emph><sub>&nbsp;i&nbsp;</sub> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Content</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>CH 
[untyped&nbsp;value] 
<emph>Content</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub></td>
</tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
The value of each Characters event that has an [untyped&nbsp;value] is represented as a String (see <specref ref="encodingString"/>).
</td>
</tr>
</tbody>
</table>

<p>Then, create a copy <emph>H</emph><sub>&nbsp;i&nbsp;</sub> of each attribute use grammar <emph>G</emph><sub>&nbsp;i&nbsp;</sub> and create the grammar <emph>Type</emph><sub>&nbsp;i</sub> by combining this sequence of attribute use grammars and the <emph>Content</emph><sub>&nbsp;i</sub> grammar using the grammar concatenation operator defined in section <specref ref="grammarConcatOperator"/> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>Type</emph><sub>&nbsp;i</sub> = <emph>H</emph><sub>&nbsp;0</sub> &oplus; <emph>H</emph><sub>&nbsp;1</sub> &oplus; &hellip; &oplus; <emph>H</emph><sub>&nbsp;n&minus;1</sub> &oplus; <emph>Content</emph><sub>&nbsp;i</sub>
</td>
</tr>
</tbody></table>
<p>
The <termref def="key-contentIndex"><emph>content</emph></termref> index of grammar <emph>Type</emph><sub>&nbsp;i&nbsp;</sub> created from an XML Schema complex type definition is the index of the first non-terminal symbol of <emph>Content</emph><sub>&nbsp;i</sub> within the context of <emph>Type</emph><sub>&nbsp;i&nbsp;</sub>.
</p>

</div6>
<div6 id="anyTypeGrammar">
<head>Complex Ur-Type Grammar</head>
<p>
XML Schema <bibref ref="schema1"/> defines a 
<xspecref spec="XS1" ref="key-urType">complex ur-type</xspecref>
called <xspecref spec="XS1" ref="d0e9252">xsd:anyType</xspecref>, which is the default type for declared elements when no type is specified in the declaration. The type xsd:anyType can  be used as the type of declared elements in schemas, or as the explicit type given to elements by means of xsi:type attribute in <termref def="key-schemainformed-existream">schema-informed EXI streams</termref>.
</p>
<p>When schemas are available to describe the body of an EXI stream, create 
grammars 
<termref def="key-type"><emph>Type</emph></termref><sub>&nbsp;ur-type</sub> and <termref def="key-type-empty"><emph>TypeEmpty</emph></termref><sub>&nbsp;ur-type</sub> that are used to process the element contents of type <xspecref spec="XS1" ref="d0e9252">xsd:anyType</xspecref> as shown below. 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;0</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT&nbsp;(*) &nbsp;<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) &nbsp;<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH &nbsp;<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(*) &nbsp;<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH &nbsp;<emph>Type</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>TypeEmpty</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) &nbsp;<emph>TypeEmpty</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>TypeEmpty</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody></table>

<table width="100%">
<thead>
<tr><th colspan="2" align="left">Semantics:</th></tr>
</thead>
<tbody>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
<p>In a schema-informed grammar, all productions of the form 
<emph>LeftHandSide</emph>: AT&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let 
<emph>qname</emph> be the <termref def="key-qname">qname</termref> of the attribute matched by AT&nbsp;(*) </item>
<item>If a global attribute definition exists for <emph>qname</emph>, let <emph>global-type</emph> be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with <emph>global-type</emph>, it SHOULD be represented  using the datatype representation associated with <emph>global-type</emph> (see <specref ref="encodingValues"/>). If the attribute value is not represented using the datatype representation associated with <emph>global-type</emph>, represent the 
attribute event 
using the AT&nbsp;(*) [untyped&nbsp;value] terminal (see <specref ref="undeclaredProductions"/>).
</item>

</olist>
<note>
When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal.
</note>

<p>
In a schema-informed grammar, all productions of the form 
<emph>LeftHandSide</emph> : SE&nbsp;(*) 
<emph>RightHandSide</emph> are evaluated as follows: </p>
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*) </item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of event sequence using <emph>RightHandSide</emph>
</item>
</olist>
</td></tr>
</tbody></table>
<p>
The <termref def="key-contentIndex"><emph>content</emph></termref> index of 
grammars 
<emph>Type</emph><sub>&nbsp;ur-type</sub> 
and <emph>TypeEmpty</emph><sub>&nbsp;ur-type</sub> 
are both 1 (one). 
</p>
</div6>
</div5>
<div5 id="attributeUses">
<head>Attribute Uses</head>
<p>
Given an attribute use <emph>A</emph><sub>&nbsp;i</sub> with properties {required} and {attribute&nbsp;declaration}, where {attribute&nbsp;declaration} has properties {name}, {target&nbsp;namespace}, {type&nbsp;definition} and {scope}, generate a new EXI grammar <emph>Attribute</emph><sub>&nbsp;i&nbsp;</sub> for evaluating attributes in the specified {scope} with <emph>qname</emph> local-name = {name} and <emph>qname</emph> uri = {target&nbsp;namespace}
where <emph>qname</emph> is the <termref def="key-qname">qname</termref> of the attributes. 
Add the following grammar productions to <emph>Attribute</emph><sub>&nbsp;i&nbsp;</sub>:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Attribute</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>AT(<emph>qname</emph>) [schema-typed value] <emph>Attribute</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Attribute</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub> :</td></tr>
<tr>
<td></td>
<td></td>
<td>EE</td>
</tr>
</tbody></table>



<p>If the {required} property of <emph>A</emph><sub>&nbsp;i</sub> is false, add the following grammar production to indicate this attribute occurrence may be omitted from the content model.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Attribute</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>EE</td>
</tr>
</tbody></table>

<table>
<tbody>
<tr>
<th align="left">Note:</th>
</tr>
<tr>
<td></td>
<td>
Productions of the form <emph>LeftHandSide</emph> : AT(<emph>qname</emph>) [schema-typed value] <emph>RightHandSide</emph> represent typed attributes that occur in schema-valid contexts with values that can be represented using the EXI datatype representation associated with the attribute's {type&nbsp;definition} (see <specref ref="encodingValues"/>).
Attributes that occur in schema-valid contexts that can be represented using the EXI datatype representation associated with the attribute's {type&nbsp;definition}, SHOULD be represented this way. Attributes that are not represented this way, are represented using the alternate forms of AT events described in section <specref ref="undeclaredProductions"/>.
</td></tr>
</tbody></table>

</div5>
<div5 id="particles">
<head>Particles</head>
<p>Given 
an XML Schema <xspecref spec="XS1" ref="cParticles">particle</xspecref> 
<emph>P</emph><sub>&nbsp;i</sub> with {min&nbsp;occurs}, {max&nbsp;occurs} and {term} properties, generate a grammar <emph>Particle</emph><sub>&nbsp;i</sub> for evaluating instances of <emph>P</emph><sub>&nbsp;i</sub> as follows.
</p>
<p>If {term} is an element declaration, generate the grammar <emph>Term</emph><sub>&nbsp;0</sub> according to section <specref ref="elementTerms"/>. If {term} is a wildcard, generate the grammar <emph>Term</emph><sub>&nbsp;0</sub> according to section <specref ref="wildcardTerms"/> Wildcard Terms. If {term} is a model group, generate the grammar <emph>Term</emph><sub>&nbsp;0</sub> according to section <specref ref="modelGroupTerms"/>.
</p>
<p>Create {min&nbsp;occurs} copies of <emph>Term</emph><sub>&nbsp;0&nbsp;</sub>.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>G</emph><sub>&nbsp;0&nbsp;</sub>, <emph>G</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>G</emph><sub>&nbsp;{min&nbsp;occurs}-1&nbsp;</sub>
</td>
</tr>
</tbody></table>
<p>If {max&nbsp;occurs} is not unbounded, create {max&nbsp;occurs} – {min&nbsp;occurs} additional copies of <emph>Term</emph><sub>&nbsp;0&nbsp;</sub>,  </p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>G</emph><sub>&nbsp;{min&nbsp;occurs}&nbsp;</sub>, <emph>G</emph><sub>&nbsp;{min&nbsp;occurs}+1&nbsp;</sub>, &hellip;, <emph>G</emph><sub>&nbsp;{max&nbsp;occurs}-1</sub>
</td>
</tr>
</tbody></table>
<p>Add the following productions to each of the grammars that do not already have a production of this form.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>EE &nbsp;&nbsp;&nbsp;&nbsp;where {min&nbsp;occurs}&nbsp;&le;&nbsp;<emph>i</emph>&nbsp;&lt;&nbsp;{max&nbsp;occurs}</td>
</tr>
</tbody></table>
<p>indicating these instances of <emph>Term</emph><sub>&nbsp;0</sub> may be omitted from the content model. Then, create the grammar for <emph>Particle</emph><sub>&nbsp;i</sub> using the grammar concatenation operator defined in section <specref ref="grammarConcatOperator"/> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>Particle</emph><sub>&nbsp;i</sub> = <emph>G</emph><sub>&nbsp;0</sub> &oplus; <emph>G</emph><sub>&nbsp;1</sub> &oplus; &hellip; &oplus; <emph>G</emph><sub>&nbsp;{max&nbsp;occurs}-1</sub>
</td>
</tr>
</tbody></table>
<p>
Otherwise, if {max&nbsp;occurs} is unbounded, generate one additional copy of <emph>Term</emph><sub>&nbsp;0&nbsp;</sub>, <emph>G</emph><sub>&nbsp;{min&nbsp;occurs}</sub> and replace all productions of the form: 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;{min&nbsp;occurs},&nbsp;k</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>EE</td>
</tr>
</tbody></table>
<p>
with productions of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;{min&nbsp;occurs},&nbsp;k</sub> :</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td><emph>G</emph><sub>&nbsp;{min&nbsp;occurs},&nbsp;0</sub></td>
</tr>
</tbody></table>
<p>indicating this term may be repeated indefinitely. Then if there is no production of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;{min&nbsp;occurs},&nbsp;0</sub> : </td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>EE</td>
</tr>
</tbody></table>
<p>add one after the other productions with the non-terminal <emph>G</emph><sub>&nbsp;{min&nbsp;occurs},&nbsp;0</sub> on the left-hand side, indicating this term may be omitted from the content model. Then, create the grammar for <emph>Particle</emph><sub>&nbsp;i</sub> using the grammar concatenation operator defined in section <specref ref="grammarConcatOperator"/> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>Particle</emph><sub>&nbsp;i</sub> = <emph>G</emph><sub>&nbsp;0</sub> &oplus; <emph>G</emph><sub>&nbsp;1</sub> &oplus; &hellip; &oplus; <emph>G</emph><sub>&nbsp;{min&nbsp;occurs}</sub>
</td>
</tr>
</tbody></table>
</div5>
<div5 id="elementTerms">
<head>Element Terms</head>
<p>
Given a particle {term} <emph>PT</emph><sub>&nbsp;i</sub> that is an XML Schema <xspecref spec="XS1" ref="cElement_Declarations">element declaration</xspecref> 
with properties {name}, 
{substitution&nbsp;group&nbsp;affiliation} 
and {target&nbsp;namespace}, let <emph>S</emph> be the set of element declarations that directly or indirectly reaches the element declaration <emph>PT</emph><sub>&nbsp;i</sub> through the chain of {substitution&nbsp;group&nbsp;affiliation} property of the elements, plus <emph>PT</emph><sub>&nbsp;i</sub> itself if was not in the set. Sort the element declarations in <emph>S</emph> lexicographically first by {name} then by {target&nbsp;namespace}, which makes a sorted list of element declarations <emph>E<sub>&nbsp;0&nbsp;</sub></emph>, <emph>E<sub>&nbsp;1&nbsp;</sub></emph>, &hellip; <emph>E<sub>&nbsp;n&minus;1&nbsp;</sub></emph> where <emph>n</emph> is the cardinality of <emph>S</emph>. Then create the grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub> with the following grammar productions:
</p>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Syntax:</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>qname</emph><sub>&nbsp;0&nbsp;</sub>) <emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>qname</emph><sub>&nbsp;1&nbsp;</sub>) <emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&vellip;</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>qname</emph><sub>&nbsp;n&minus;1&nbsp;</sub>) <emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr><td/>
<td colspan="2">
In the productions above, <emph>qname<sub>&nbsp;x&nbsp;</sub></emph> (where 0 &le;&nbsp;<emph>x</emph> &lt; n) represents a <termref def="key-qname">qname</termref> of which local-name and uri are {name} property and {target&nbsp;namespace} property of the element declaration <emph>E<sub>&nbsp;x&nbsp;</sub></emph>, respectively.</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="3">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
</tr>
<tr><td/>
<td colspan="2">
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : SE(<emph>qname</emph>) <emph>RightHandSide</emph> are evaluated as follows:
<olist>
<item>Evaluate the element contents using the SE(<emph>qname</emph>) grammar.</item>
<item>Evaluate the remainder of the event sequence using <emph>RightHandSide</emph></item>
</olist>

</td>
</tr>
</tbody>
</table>

</div5>
<div5 id="wildcardTerms">
<head>Wildcard Terms</head>
<p>
Given a particle {term} <emph>PT</emph><sub>&nbsp;i&nbsp;</sub> that is an XML Schema <xspecref spec="XS1" ref="Wildcards">wildcard</xspecref>
with property {namespace&nbsp;constraint}, a grammar that reflects the wildcard definition is created as follows.
</p>
<p>
Create a grammar <emph>ParticleTerm</emph><sub>&nbsp;i</sub> containing the following grammar production:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody>
</table>

<p>When the wildcard's {namespace&nbsp;constraint} is 
<emph>any</emph>, or a pair of <emph>not</emph> and either a namespace name or the special value <emph>absent</emph> indicating no namespace, 
add the following production to <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(*) <emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub>
</td>
</tr>
</tbody>
</table>
<p>
Otherwise, that is, when {namespace&nbsp;constraint} is a set of values whose members are namespace names or the special value <emph>absent</emph> indicating no namespace, 

add the following production to <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>uri<sub>&nbsp;x&nbsp;</sub></emph>:&nbsp;*) <emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;1</sub>
<!-- 
&nbsp;&nbsp;&nbsp;&nbsp;(when <emph>uri<sub>&nbsp;x&nbsp;</sub></emph> is a namespace name)
-->
</td>
</tr>
<tr><td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
<p>
for each member value <emph>uri</emph><sub><emph>x</emph></sub> in {namespace&nbsp;constraint}, 

provided that it is the empty string (i.e. "") that is used as <emph>uri</emph><sub><emph>x</emph></sub> when the member value is the special value <emph>absent</emph>. 

Each <emph>uri<sub>&nbsp;x&nbsp;</sub></emph> is used to augment the uri partition of the String table.
Section <specref ref="stringTablePartitions"/> describes how these <emph>uri</emph> strings are put into String table for pre-population.
</p>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td><td/>
</tr>
<tr><td/>
<td>
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : Terminal <emph>RightHandSide</emph> where Terminal is one of SE&nbsp;(*) or SE&nbsp;(<emph>uri<sub>&nbsp;x&nbsp;</sub></emph>:&nbsp;*) are evaluated as follows:
<olist>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*)
or SE(<emph>uri<sub>&nbsp;x&nbsp;</sub></emph>:&nbsp;*)
</item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>Evaluate the remainder of the event sequence using <emph>RightHandSide</emph></item>
</olist>
</td></tr>
</tbody>
</table>
</div5>
<div5 id="modelGroupTerms">
<head>Model Group Terms</head>
<div6 id="sequenceGroupTerms">
<head>Sequence Model Groups</head>
<p>Given a particle {term} <emph>PT</emph><sub>&nbsp;i</sub> that is a model group with {compositor} equal to "sequence" and a list of <emph>n</emph> {particles} <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>P</emph><sub>&nbsp;n&minus;1&nbsp;</sub>, create a grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub> as follows:
</p>
<p>If the value of <emph>n</emph> is 0, add the following productions to the grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>
<p>Otherwise, generate a sequence of grammars <emph>Particle</emph><sub>&nbsp;0&nbsp;</sub>, <emph>Particle</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>Particle</emph><sub>&nbsp;n&minus;1&nbsp;</sub> corresponding to the list of particles <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>P</emph><sub>&nbsp;n&minus;1&nbsp;</sub> according to section <specref ref="particles"/>. Then combine the sequence of grammars using the grammar concatenation operator defined in section <specref ref="grammarConcatOperator"/> as follows:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub> = <emph>Particle</emph><sub>&nbsp;0</sub> &oplus; <emph>Particle</emph><sub>&nbsp;1</sub> &oplus; &hellip; &oplus; <emph>Particle</emph><sub>&nbsp;n&minus;1</sub></td>
</tr>
</tbody></table>
</div6>
<div6 id="choiceGroupTerms">
<head>Choice Model Groups</head>
<p>Given a particle {term} <emph>PT</emph><sub>&nbsp;i</sub> that is a model group with {compositor} equal to "choice" and a list of <emph>n</emph> {particles} <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>P</emph><sub>&nbsp;n&minus;1&nbsp;</sub>, create a grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub> as follows:
</p>
<p>
If the value of <emph>n</emph> is 0, add the following productions to the grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>
<p>Otherwise, generate a sequence of grammar productions <emph>Particle</emph><sub>&nbsp;0&nbsp;</sub>, <emph>Particle</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>Particle</emph><sub>&nbsp;n&minus;1</sub> corresponding to the list of particles <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>P</emph><sub>&nbsp;n&minus;1</sub> according to section <specref ref="particles"/>. Then create the grammar <emph>ParticleTerm</emph><sub>&nbsp;i</sub> with the following grammar productions:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>Particle</emph><sub>&nbsp;0,&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Particle</emph><sub>&nbsp;1,&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Particle</emph><sub>&nbsp;n&minus;1,&nbsp;0</sub>
</td>
</tr>
</tbody></table>
<p>
indicating the grammar for the term may accept any one of the given {particles}.
</p>
</div6>
<div6 id="allGroupTerms">
<head>All Model Groups</head>
<p>
Given a particle {term} <emph>PT</emph><sub>&nbsp;i</sub> that is a model group with {compositor} equal to "all" and a list of <emph>n</emph> &nbsp; {&nbsp;particles&nbsp;} <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, ..., <emph>P</emph><sub>&nbsp;n&minus;1&nbsp;</sub>, create a grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub> as follows:
</p>
<p>
Add the following production to the grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>

<p>If the value of <emph>n</emph> is not 0, generate a sequence of grammar productions <emph>Particle</emph><sub>&nbsp;0&nbsp;</sub>, <emph>Particle</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>Particle</emph><sub>&nbsp;n&minus;1</sub> corresponding to the list of particles <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>P</emph><sub>&nbsp;n&minus;1&nbsp;</sub> according to section <specref ref="particles"/>. 
</p>

<p>Replace all productions of the form:</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Particle</emph><sub>&nbsp;j&nbsp;,&nbsp;k</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
EE
</td>
</tr>
</tbody></table>
<p>
with productions of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Particle</emph><sub>&nbsp;j&nbsp;,&nbsp;k</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub>
</td>
</tr>
</tbody></table>
<p>
where 0 &le;&nbsp;<emph>j</emph> &lt; <emph>n</emph>, and 0 &le;&nbsp;<emph>k</emph> &lt; <emph>m</emph> with <emph>m</emph> denoting the number non-terminals in the grammar <emph>Particle</emph><sub>&nbsp;j&nbsp;</sub>.
</p>
<p>
Add the following productions to the grammar <emph>ParticleTerm</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>ParticleTerm</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>Particle</emph><sub>&nbsp;0,&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Particle</emph><sub>&nbsp;1,&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Particle</emph><sub>&nbsp;n&minus;1,&nbsp;0</sub>
</td>
</tr>
</tbody></table>

<note>
The grammar above can accept any sequence of the given {particles} in any order. This grammar is intentionally simple and succinct, enabling high-performance, low-footprint implementations on a wide range of devices, including those with very limited memory resources. More elaborate and precise grammars for the "all" group are possible; however, the associated improvement in precision is not sufficient to justify their code-footprint and memory resource requirements.  
</note>
</div6>
</div5>
</div4>
<div4 id="normalizedGrammars">
<head>EXI Normalized Grammars</head>
<p>This section describes the process for converting an EXI proto-grammar 
generated 
from an XML Schema in accordance with section <specref ref="protoGrammars"/> into an EXI normalized grammar. Each production in an EXI normalized grammar has exactly one non-terminal symbol on the left-hand side and one terminal symbol on the right-hand side followed by at most one non-terminal symbol on the right-hand side. In addition, EXI normalized grammars contain no two grammar productions with the same non-terminal on the left-hand side and the same terminal symbol on the right-hand side. This is a restricted form of Greibach normal form <bibref ref="greibach"/>. 
</p>
<p>EXI proto-grammars differ from normalized EXI grammars in that they may contain productions of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>LeftHandSide</emph> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>RightHandSide</emph>
</td>
</tr>
</tbody></table>
<p>where <emph>LeftHandSide</emph> and <emph>RightHandSide</emph> are both non-terminals. Therefore, the first step of the normalization process focuses on replacing productions in this form with productions that conform to the EXI normalized grammar rules. This process can produce a grammar that has more than one production with the same non-terminal on the left-hand side and the same terminal symbol on the right-hand side. Therefore, the second step focuses on eliminating such productions.
</p>
<p>The first step of the normalization process is described in Section <specref ref="eliminatingProductions"/>. The second step is described in section <specref ref="eliminatingSymbols"/>. Once these two steps are completed, the grammar will be an EXI normalized grammar.
</p>
<div5 id="eliminatingProductions">
<head>Eliminating Productions with no Terminal Symbol</head>
<p>
Given an EXI proto-grammar <emph>G</emph><sub>&nbsp;i&nbsp;</sub>, with non-terminals <emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub>, <emph>G</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub>, &hellip;, <emph>G</emph><sub>&nbsp;i,&nbsp;n&minus;1&nbsp;</sub>, replace each production of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>&nbsp;&nbsp;&nbsp;&nbsp;where 0&nbsp;&le;&nbsp;<emph>j</emph> &lt; <emph>n</emph> and 0&nbsp;&le;&nbsp;<emph>k</emph> &lt; <emph>n</emph>
</td>
</tr>
</tbody></table>
<p>with a set of productions:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;m-1</sub>
</td>
</tr>
</tbody></table>
<p>where <emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;0&nbsp;</sub>, <emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;1&nbsp;</sub>, &hellip;, <emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;m-1</sub> represents the right-hand side of each  production in <emph>G</emph><sub>&nbsp;i</sub> that has the non-terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub> on the left-hand side and <emph>m</emph> is the number of such productions. 
</p>
<p>
Remove such productions if any among <emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> : <emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;h</sub> where 0 &le;&nbsp;<emph>h</emph> &lt; <emph>m</emph> of which the right-hand side either is identical to the left-hand side, or has previously been replaced while applying the process described in this section to productions with <emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> on the left-hand side.
</p>
<p>Repeat this process until there are no more 
productions 
of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>&nbsp;&nbsp;&nbsp;&nbsp;where 0&nbsp;&le;&nbsp;<emph>j</emph> &lt; <emph>n</emph> and 0&nbsp;&le;&nbsp;<emph>k</emph> &lt; <emph>n</emph>
</td>
</tr>
</tbody></table>
<p>in the grammar <emph>G</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
</div5>
<div5 id="eliminatingSymbols">
<head>Eliminating Duplicate Terminal Symbols</head>
<p>Given an EXI proto-grammar <emph>G</emph><sub>&nbsp;i&nbsp;</sub>, with non-terminals <emph>G</emph><sub>&nbsp;i,&nbsp;0&nbsp;</sub>, <emph>G</emph><sub>&nbsp;i,&nbsp;1&nbsp;</sub>, &hellip;, <emph>G</emph><sub>&nbsp;i,&nbsp;n&minus;1&nbsp;</sub>, identify all pairs of productions that have the same non-terminal on the left-hand side and the same terminal symbol on the right-hand side of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;l</sub>
</td>
</tr>
</tbody></table>
<p>where <emph>k</emph> &nbsp;&ne;&nbsp; <emph>l</emph> and Terminal represents a particular terminal symbol and replace them with a single production:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;&sqcup;&nbsp;l</sub>
</td>
</tr>
</tbody></table>
<p>
where <emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;&sqcup;&nbsp;l</sub> is a distinct non-terminal that accepts the inputs accepted by <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub> and the inputs accepted by <emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>.

Here the notation "&nbsp;&nbsp;k&nbsp;&sqcup;&nbsp;l&nbsp;&nbsp;" denotes a union set of integers and is used to uniquely identify the index of such a non-terminal.
</p>
<p>
When <emph>G</emph><sub>&nbsp;i&nbsp;</sub> is a type grammar, if both <emph>k</emph> and <emph>l</emph> are smaller than <termref def="key-contentIndex"><emph>content</emph></termref> index of <emph>G</emph><sub>&nbsp;i&nbsp;</sub>, k&nbsp;&sqcup;&nbsp;l is also considered to be smaller than <emph>content</emph> for the purpose of index comparison purposes. Otherwise, if either  <emph>k</emph> or <emph>l</emph> is not smaller than <emph>content</emph>, k&nbsp;&sqcup;&nbsp;l is considered to be larger than <emph>content</emph>.
</p>
<p>
 If the non-terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;&sqcup;&nbsp;l</sub> does not exist, create it as follows: 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;&sqcup;&nbsp;l</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;m-1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;n&minus;1</sub>
</td>
</tr>
</tbody></table>
<p>where <emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;0</sub>,
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;1</sub>,
&hellip;,
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;k&nbsp;</sub>)<sub>&nbsp;m-1</sub>
and
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;0</sub>, 
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;1</sub>,
&hellip;,
<emph>RHS</emph>(<emph>G</emph><sub>&nbsp;i,&nbsp;l&nbsp;</sub>)<sub>&nbsp;n&minus;1</sub>
represent the right-hand side of each  production in the Grammar <emph>G</emph><sub>&nbsp;i</sub> that has the non-terminals <emph>G</emph><sub>&nbsp;j,&nbsp;k</sub> and <emph>G</emph><sub>&nbsp;j,&nbsp;l</sub> on the left-hand side respectively and <emph>m</emph> and <emph>n</emph> are the number of such productions. 
</p>
<p>Repeat this process until there are no more productions in the grammar <emph>G</emph><sub>&nbsp;i</sub> of the form:
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;l</sub>
</td>
</tr>
</tbody></table>
<p>Then, identify any identical productions of the following form: 
</p>
<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
Terminal <emph>G</emph><sub>&nbsp;i,&nbsp;k</sub>
</td>
</tr>
</tbody></table>
<p>
where 0 &le; <emph>k</emph> &lt; <emph>n</emph>, <emph>n</emph> is the number of productions in <emph>G</emph><sub>&nbsp;i</sub> and Terminal represents a specific terminal symbol, then remove one of them until there are no more productions remaining in the grammar <emph>G</emph><sub>&nbsp;i</sub> of this form.
</p>
</div5>
</div4>
<div4 id="eventCodeAssignment">
<head>Event Code Assignment</head>
<p>This section describes the process for assigning unique <termref def="key-eventcode">event codes</termref> to each production in a normalized EXI grammar. Given a normalized EXI grammar <emph>G</emph><sub>&nbsp;i&nbsp;</sub>, apply the following process to each unique non-terminal <emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> that occurs on the left-hand side of the productions in <emph>G</emph><sub>&nbsp;i</sub> where 0&nbsp;&le;&nbsp;<emph>j</emph> &lt; <emph>n</emph> and <emph>n</emph> is the number of such non-terminals in <emph>G</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<p>Sort all productions with <emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> on the left-hand side in the following order:
</p>
<olist>
<item>
all productions with AT(<emph>qname</emph>) on the right-hand side
sorted lexicographically by <emph>qname</emph> local-name, then by <emph>qname</emph> uri, followed by
</item>
<item>
all productions with AT(<emph>uri<sub>x</sub></emph> : *) on the right-hand side sorted lexicographically by <emph>uri</emph>, followed by
</item>
<item>
any production with AT&nbsp;(*) on the right-hand side, followed by
</item>
<item>
all productions with SE(<emph>qname</emph>) on the right-hand side sorted in schema order, followed by
</item>
<item>
all productions with SE(<emph>uri<sub>x</sub></emph> : *) on the right-hand side sorted in schema order, followed by
</item>
<item>
any production with SE(*) on the right-hand side, followed by
</item>
<item>
any production with EE on the right-hand side, followed by
</item>
<item>
any production with CH on the right-hand side.
</item>
</olist>
<p>
In step 4 and step 5, the schema order of productions with SE(<emph>qname</emph>) and SE(<emph>uri<sub>x</sub></emph> : *) on the right-hand side is determined by the order of the corresponding particles in the schema after any references to named model groups in the schema are expanded in place with the group definitions themselves. A content model of a complex type can be seen as a tree that consists of particles where particles of either element declaration terms or wildcard terms appear as leaves, and the order is assigned to those leaf particles by traversing the tree by depth-first method.
</p>
<p>Given the sorted list of productions <emph>P</emph><sub>&nbsp;0&nbsp;</sub>, <emph>P</emph><sub>&nbsp;1&nbsp;</sub>, &hellip; <emph>P</emph><sub>&nbsp;n</sub> with the non-terminal <emph>G</emph><sub>&nbsp;i,&nbsp;j</sub> on the left-hand side, assign <termref def="key-eventcode">event codes</termref> to each of the productions as follows:
</p>
<table width="100%">
<thead>
<tr>
<th colspan="2" align="left">Productions</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<emph>P</emph><sub>&nbsp;0</sub>
</td>
<td>
0
</td>
</tr>
<tr>
<td></td>
<td>
<emph>P</emph><sub>&nbsp;1</sub>
</td>
<td>
1
</td>
</tr>
<tr>
<td></td>
<td>
&vellip;
</td>
<td>
&vellip;
</td>
</tr>
<tr>
<td></td>
<td>
<emph>P</emph><sub>&nbsp;n&minus;1</sub>
</td>
<td>
<emph>n</emph>&minus;1
</td>
</tr>
</tbody></table>

</div4>
<div4 id="undeclaredProductions">
<head>Undeclared Productions</head>
<p>The normalized element and type grammars 
generated 
from a schema describe the sequences of child elements, attributes and character events that may occur in a particular EXI stream. However, there are additional events that may occur in an EXI stream that are not described by the schema, for example events representing comments, processing-instructions, schema deviations, etc. 
</p>
<p>
This section first describes the process for, in cases with <termref def="key-strictOption">strict option</termref> value set to false, augmenting the normalized element and type grammars with productions that describe events that may occur in the EXI stream, but are not explicitly declared in the schema. It then describes the way, in cases with <termref def="key-strictOption">strict option</termref> value set to true, normalized element and type grammars are supplemented with productions to be prepared for the occurrences of xsi:type and xsi:nil attributes that are permitted by the schema. 
</p>
<p>
In the normalized grammars, terminal symbols AT and CH represent attribute and character events that can be represented by the EXI datatype representations associated with their schema datatypes (see <specref ref="encodingValues"/>).
When the <termref def="key-strictOption">strict option</termref> is false, additional untyped AT and CH terminal symbols are added that can be used for representing attributes and character events that cannot be represented by the associated EXI datatype representations (e.g., schema-invalid values). The following table shows the notation used for such AT and CH terminals along with their definitions.
</p>
<table width="100%" border="1">
<colgroup align="left"/>
<colgroup/>
<thead>
<tr>
<th align="center">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Notation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Definition</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;AT&nbsp;(<emph>qname</emph>)&nbsp;[untyped&nbsp;value]</td>
<td>Terminal symbol that matches an attribute 
<!--
(AT)
--> 
event with <termref def="key-qname">qname</termref> <emph>qname</emph> and an untyped value.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;AT&nbsp;(*) [untyped&nbsp;value]</td>
<td>Terminal symbol that matches an attribute 
<!--
(AT)
--> 
event with any <termref def="key-qname">qname</termref> and an untyped value.</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;CH [untyped&nbsp;value]</td>
<td>Terminal symbol that matches a characters 
<!-- 
(CH) 
-->
event with an untyped value.</td>
</tr>
</tbody>
</table>

<div5 id="addingProductions">
<head>Adding Productions when Strict is False</head>
<p>This section describes the process for augmenting the normalized grammars when the value of the <termref def="key-strictOption">strict option</termref> is false. For each normalized element grammar <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>, create a copy <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub> of <emph>Element</emph><sub>&nbsp;i,&nbsp;content</sub> where the index "content" is the <termref def="key-contentIndex"><emph>content</emph></termref> of the type of the element from which <emph>Element</emph><sub>&nbsp;i&nbsp;</sub> was created. Then, apply the following procedures.</p>

<p>Add the following production to each non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub> that does not already include a production of the form <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> : EE, such that 0 &le; j &le; content. 
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
EE
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>

<p>Let <emph>E</emph><sub>&nbsp;i</sub> be the element declaration from which <emph>Element</emph><sub>&nbsp;i</sub> was created and <emph>T</emph><sub>&nbsp;k</sub> be the {type&nbsp;definition} of <emph>E</emph><sub>&nbsp;i&nbsp;</sub>. Let 
<termref def="key-type">
<emph>Type</emph><sub>&nbsp;k</sub> 
</termref>
and 
<termref def="key-type-empty">
<emph>TypeEmpty</emph><sub>&nbsp;k</sub> 
</termref>
be the type grammars created from <emph>T</emph><sub>&nbsp;k</sub> (see section <specref ref="typeGrammars"/>). Add the following productions to <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>.  
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
AT(xsi:type) <emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> 
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
AT(xsi:nil) <emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1)
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<p>
where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="100%">
<thead>
<tr>
<th colspan="2" align="left">Note:</th></tr>
</thead>
<tbody>
<tr><td>&nbsp;</td><td/></tr>
<tr><td/>
<td>
When xsi:type and/or xsi:nil attributes appear in an element where schema-informed grammars are in effect, they MUST occur before any other 
attribute 
events of the same element, with xsi:type placed before xsi:nil when they both occur.
</td>
</tr>
<tr><td>&nbsp;</td></tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr><td>&nbsp;</td><td/>
</tr>
<tr><td/>
<td>
All productions of the form <emph>LeftHandSide</emph> : AT&nbsp;(xsi:type) <emph>RightHandSide</emph> are evaluated as follows:
<olist>
&xsiType-matching-AT-xsiType;
</olist>
</td>
</tr>

<tr><td/>
<td>
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : AT&nbsp;(xsi:nil) <emph>RightHandSide</emph> are evaluated as follows: 
<olist>

<item>
Let <emph>nil</emph> be the value of the xsi:nil attribute.
</item>
<item>If <emph>nil</emph> is a valid Boolean, assign it the Boolean datatype representation (see <specref ref="encodingBoolean"/>) and encode it according to section <specref ref="encodingValues"/>. If <emph>nil</emph> is not a valid Boolean, represent the 
xsi:nil attribute 
event using the AT&nbsp;(*) [untyped&nbsp;value] terminal (see <specref ref="undeclaredProductions"/>). 
</item>
<item>
If the value of <emph>nil</emph> is true, evaluate the element contents using the grammar 
<emph>TypeEmpty</emph><sub>&nbsp;k</sub> 
defined above rather than <emph>RightHandSide</emph>. 
</item>
</olist>
</td>
</tr>
</tbody></table>

<p>
For each non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub>, such that 0 &le; j &le; content&nbsp;, with zero or more productions of the following form:
</p>

<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;0&nbsp;</sub>) [schema-typed value] 
<emph>NonTerminal</emph><sub>&nbsp;0&nbsp;</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;1&nbsp;</sub>) [schema-typed value]
<emph>NonTerminal</emph><sub>&nbsp;1&nbsp;</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;<emph>x</emph>-1&nbsp;</sub>) [schema-typed value]
<emph>NonTerminal</emph><sub>&nbsp;x-1&nbsp;</sub>
</td>
</tr>
</tbody></table>

<p>where <emph>x</emph> represents the number of attributes declared in the schema for this context, add the following productions:
</p>

<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
AT&nbsp;(*) <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;0&nbsp;</sub>) [untyped&nbsp;value] <emph>NonTerminal</emph><sub>&nbsp;0&nbsp;</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1).0
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;1&nbsp;</sub>) [untyped&nbsp;value] <emph>NonTerminal</emph><sub>&nbsp;1&nbsp;</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1).1
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
<td>
&nbsp;&nbsp;&nbsp;&nbsp;&vellip;
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(<emph>qname</emph><sub>&nbsp;<emph>x</emph>-1&nbsp;</sub>) [untyped&nbsp;value] <emph>NonTerminal</emph><sub>&nbsp;x-1&nbsp;</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1).(<emph>x</emph>-1)
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) [untyped&nbsp;value] <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1).(<emph>x</emph>)
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>

<!--

</td></tr>

</tbody></table>
-->



<table width="100%">
<thead>
<tr>
<th align="left">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<ulist>
<item>
The value of each 
attribute 
event that has an [untyped&nbsp;value] is represented as a String (see <specref ref="encodingString"/>).
</item>
</ulist>
</td>
</tr>
<tr>
<td>
<ulist>
<item>
Like an element, an attribute may occur in a schema-invalid context, have a untyped (e.g., schema-invalid) value or both. However, unlike an element whose occurrence and value are represented by separate SE and CH events, the occurrence and value of an attribute are represented by a single AT event. Consequently, four kinds of AT 
terminal symbols 
are needed for the four possible representations of an attribute event 
in schema-informed grammars. 
The table below shows these four kinds of AT terminal symbols 
along with the equivalent combinations of SE and CH 
terminal symbols 
for representing elements. 
<p/>
<table border="1" width="95%" id='table-at-terminals'>
<caption>
Equivalent terminal symbols 
for different attribute and element representations</caption>
<colgroup width="20%"/>
<colgroup width="40%"/>
<colgroup width="40%"/>
<thead>
<tr>
<th>&nbsp;</th>
<th>Schema-typed value</th>
<th>Untyped value</th></tr>
</thead>
<tbody>
<tr>
<th>Schema-valid occurrence</th>
<td>
<table border="0">
<tr><td>AT&nbsp;(<emph>qname</emph>) [schema-typed value]</td></tr>
<tr><td>SE&nbsp;(<emph>qname</emph>) CH [schema-typed value]</td></tr>
</table></td>
<td>
<table border="0">
<tr><td>AT&nbsp;(<emph>qname</emph>) [untyped&nbsp;value]</td></tr>
<tr><td>SE&nbsp;(<emph>qname</emph>) CH [untyped&nbsp;value]</td></tr>
</table></td>
</tr>
<tr>
<th>Schema-invalid occurrence</th>
<td>
<table border="0">
<tr><td>AT&nbsp;(*)</td></tr>
<tr><td>SE&nbsp;(*) CH [schema-typed value]</td></tr>
</table></td>
<td>
<table>
<tr><td>AT&nbsp;(*) [untyped&nbsp;value]</td></tr>
<tr><td>SE&nbsp;(*) CH [untyped&nbsp;value]</td></tr>
</table>
</td>
</tr>
</tbody></table>
<p>
Note that an attribute matching AT&nbsp;(*) terminal without [untyped&nbsp;value] predication 
in schema-informed grammars bears an untyped value unless there is a global attribute 
definition available for <emph>qname</emph> where <emph>qname</emph> is the 
<termref def="key-qname">qname</termref> of the attribute. 
When a global attribute definition is available for <emph>qname</emph>, the attribute 
value is represented according to the datatype of the global attribute.
</p>
<p>
In the above table, AT&nbsp;(*) terminal without [untyped&nbsp;value] predication is shown 
only in the bottom left cell for simplicity. To be more precise, it might well extend into the 
bottom right cell because attributes matching the terminal bear schema-typed values in
some cases or untyped values in others depending on the availability of a global 
attribute definition that denotes the attribute.
</p>
</item>
</ulist>
</td>
</tr>
<tr>
<td>
<ulist>
<item>
When xsi:type and/or xsi:nil attributes appear in an element where schema-informed grammars are in effect, they MUST occur before any other 
attribute 
events of the same element, with xsi:type placed before xsi:nil when they both occur.
</item>
</ulist>
</td>
</tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td><td/>
</tr>
<tr><td/>
<td>
In a schema-informed grammar, 
all productions of the form <emph>LeftHandSide</emph> : AT&nbsp;(*) are evaluated as follows: 
<olist>
<item>
Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the attribute matched by AT&nbsp;(*)
</item>
<item>If a global attribute definition exists for <emph>qname</emph>, let <emph>global-type</emph> be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with <emph>global-type</emph>, it SHOULD be represented  using the datatype representation associated with <emph>global-type</emph> (see <specref ref="encodingValues"/>). If the attribute value is not represented using the datatype representation associated with <emph>global-type</emph>, represent the 
attribute event 
using the AT&nbsp;(*) [untyped&nbsp;value] terminal (see <specref ref="undeclaredProductions"/>).
</item>
</olist>
</td>
</tr>

<tr>
<td colspan="2">
<note>
When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal. AT(*) [untyped value] terminal, on the other hand, can be used to represent an xsi:nil attribute when there is a production of the form <emph>LeftHandSide</emph> : AT&nbsp;(xsi:nil) where <emph>LeftHandSide</emph> is the left-hand side non-terminal of the AT(*) [untyped value] terminal in question, and the value of the xsi:nil attribute is unable to be represented using AT&nbsp;(xsi:nil) terminal. AT(*) [untyped value] terminal MUST NOT be used to represent xsi:type attributes.
</note>
</td>
</tr>
</tbody></table>

<p>
Add the following production to <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
NS <emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> 
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>

<p>
When the value of the <termref def="key-selfContained">selfContained option</termref> is true, add the following production to <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
SC <emph>Fragment</emph> 
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
</tbody></table>
<p></p>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td><td/>
</tr>
<tr><td/>
<td>
All productions of the form <emph>LeftHandSide</emph> : SC <emph>Fragment</emph> are evaluated as follows: 
<olist>
<item>
Save the string table, grammars and any implementation-specific state learned while processing this EXI Body.
</item>
<item>Initialize the string table, grammars and any implementation-specific state learned while processing this EXI Body to the state they held just prior to processing this EXI Body.
</item>
<item>Skip to the next byte-aligned boundary in the stream 
if it is not already at such a boundary.
</item>
<item>Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the SE event immediately preceding this SC event.</item>
<item>Let <emph>content</emph> be the sequence of events following this SC event that match the grammar for element <emph>qname</emph>, up to and including the terminating EE event.</item>
<item>Evaluate the sequence of events (SD, SE(<emph>qname</emph>), <emph>content</emph>, ED) according to the <emph>Fragment</emph> grammar. (see <specref ref="informedFragGrammars"/>)
</item>
<item>Skip to the next byte-aligned boundary in the stream 
if it is not already at such a boundary.
</item>
<item>Restore the string table, grammars and implementation-specific state learned while processing this EXI Body to that saved in step 1 above.
</item>
</olist>
</td>
</tr>
</tbody></table>

<p>
Add the following productions to each non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub>, such that 0 &le; j &le; content&nbsp;.
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
SE&nbsp;(*) <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub>
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1)
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
ER <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+2)
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CM <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).0
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
PI <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).1
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
<ulist>
<item>
Productions of the form <emph>LeftHandSide</emph> : CH [untyped&nbsp;value] <emph>RightHandSide</emph> match untyped character data represented as a String in the EXI stream (e.g., schema-invalid values). Character data represented using the datatype representation associated with the schema datatype of the character data are matched by productions of the form <emph>LeftHandSide</emph> : CH [schema-typed value] <emph>RightHandSide</emph> described in section <specref ref="simpleTypeGrammars"/>.
</item>
</ulist>
</td>
</tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
<td/>
</tr>
<tr>
<td/>
<td>
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : SE&nbsp;(*) <emph>RightHandSide</emph>  are evaluated as follows:
<olist>
<item>
Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*)
</item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of the event sequence using <emph>RightHandSide</emph>
</item>
</olist>
</td>
</tr>
</tbody>
</table>

<p>Add the following production to <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub> and to each non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub> that does not already include a production of the form <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> : EE, such that content &lt; <emph>j</emph> &lt; <emph>n</emph>, where <emph>n</emph> is the number of non-terminals in <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
EE
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>


<p>Add the following productions to <emph>Element</emph><sub>&nbsp;i,&nbsp;content2</sub> and to each non-terminal <emph>Element</emph><sub>&nbsp;i,&nbsp;j&nbsp;</sub>, such that content &lt; <emph>j</emph> &lt; <emph>n</emph>, where <emph>n</emph> is the number of non-terminals in <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>. 
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
SE&nbsp;(*) <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped value] <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+1)
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
ER <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+2)
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CM <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).0
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
PI <emph>Element</emph><sub>&nbsp;i,&nbsp;j</sub>
</td>
<td>
<emph>n</emph>.(<emph>m</emph>+3).1
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td>
</td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>

<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
<td/>
</tr>
<tr>
<td/>
<td>
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : SE&nbsp;(*) <emph>RightHandSide</emph>  are evaluated as follows:
<olist>
<item>
Let <emph>qname</emph> be the <termref def="key-qname">qname</termref> of the element matched by SE&nbsp;(*)
</item>
<item>
If a <termref def="key-global-element-grammar"/> does not exist for element <emph>qname</emph>, create one according to section <specref ref="builtinElemGrammars"/>. 
</item>
<item>
Evaluate the element content using the <termref def="key-global-element-grammar"/> for element <emph>qname</emph>.
</item>
<item>
Evaluate the remainder of the event sequence using <emph>RightHandSide</emph>
</item>
</olist>
</td>
</tr>
</tbody>
</table>

<p>Apply the process described above for element grammars to each normalized type grammar 
<termref def="key-type"><emph>Type</emph><sub>&nbsp;i&nbsp;</sub></termref> and
<termref def="key-type-empty"><emph>TypeEmpty</emph><sub>&nbsp;i&nbsp;</sub></termref>.
</p>
</div5>

<div5 id="addingProductionsStrict">
<head>Adding Productions when Strict is True</head>
<p>This section describes the process for augmenting the normalized grammars when the value of the <termref def="key-strictOption">strict option</termref> is true. For each normalized element grammar <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>, apply the following procedures.</p>


<p>Let <emph>E</emph><sub>&nbsp;i</sub> be the element declaration from which <emph>Element</emph><sub>&nbsp;i</sub> was created and <emph>T</emph><sub>&nbsp;k</sub> be the {type&nbsp;definition} of <emph>E</emph><sub>&nbsp;i&nbsp;</sub>. If <emph>T</emph><sub>&nbsp;k</sub> 
either has named sub-types or is a simple type definition of which {variety} is <emph>union</emph>, 
add the following production to <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>.  
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
AT(xsi:type) <emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> 
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
All productions of the form <emph>LeftHandSide</emph> : AT&nbsp;(xsi:type) <emph>RightHandSide</emph> are evaluated as follows: 
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<olist>
&xsiType-matching-AT-xsiType;
</olist>
</td>
</tr>
</tbody></table>
<p>
Let 
<termref def="key-type">
<emph>Type</emph><sub>&nbsp;k</sub> 
</termref>
and 
<termref def="key-type-empty">
<emph>TypeEmpty</emph><sub>&nbsp;k</sub> 
</termref>
be the type grammars created from <emph>T</emph><sub>&nbsp;k</sub> (see section <specref ref="typeGrammars"/>). If the {nillable} property of <emph>E</emph><sub>&nbsp;i</sub> is true, add the following production to <emph>Element</emph><sub>&nbsp;i&nbsp;</sub>.
</p>
<table width="100%">
<thead>
<tr>
<th colspan="3" align="left">Syntax</th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%">&nbsp;</td>
<td width="5%"></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td width="50%">
AT(xsi:nil) <emph>Element</emph><sub>&nbsp;i,&nbsp;0</sub>
</td>
<td>
<emph>n</emph>.<emph>m</emph>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="3">
<p>where <emph>n</emph>.<emph>m</emph> represents the next available <termref def="key-eventcode">event code</termref> with length 2. 
</p>
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody></table>
<table width="100%">
<thead>
<tr>
<th align="left" colspan="2">Semantics:</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
In a schema-informed grammar, all productions of the form <emph>LeftHandSide</emph> : AT&nbsp;(xsi:nil) <emph>RightHandSide</emph> are evaluated as follows: 
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<olist>
<item>
Let <emph>nil</emph> be the value of the xsi:nil attribute.
</item>

<item>If <emph>nil</emph> is a valid Boolean, assign it the Boolean datatype representation (see 
<specref ref="encodingBoolean"/>) and encode it according to section <specref ref="encodingValues"/>. Otherwise, the value of the <emph>nil</emph> is schema-invalid and cannot be represented when the value of the <termref def="key-strictOption">strict option</termref> is true. 
</item>
<item>
If the value of <emph>nil</emph> is true, evaluate the element contents using the grammar 
<emph>TypeEmpty</emph><sub>&nbsp;k</sub> 
defined above rather than <emph>RightHandSide</emph>. 
</item>
</olist>
</td>
</tr>
</tbody></table>

<table width="100%" id="strictRestrictions">
<thead>
<tr>
<th colspan="2" align="left">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<ulist>
<item>
When xsi:type or xsi:nil attributes appear in an element where schema-informed grammars are in effect with <termref def="key-strictOption">strict option</termref> value <emph>true</emph>, they MUST occur before any other attribute events of the same element.
</item>
</ulist>
</td>
</tr>
<tr>
<td colspan="2">
<ulist>
<item>
There are several restrictions peculiar to schema-informed element and type grammars created with <termref def="key-strictOption">strict option</termref> value <emph>true</emph> in the ability to represent a small number of uncommon element information item formulations yet valid to the schemas. This is a consequence of intentional grammar simplification aimed to make the grammars compact enough for and the amount of footprint necessary to process the grammars amenable even to extremely resource-deprived devices. Itemized below are such restrictions. Those restrictions need to be given heed to in the process of making a decision to choose the right <termref def="key-strictOption">strict option</termref> value that works best for each use case.
</item>
</ulist>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>
<ulist type="circle">
<item>
It is not possible to use xsi:type and xsi:nil attributes together on the same element. 
This is due to the fact that xsi:type specifies a target type definition, but xsi:nil is only permitted on nillable elements, not type definitions.
</item>
</ulist>
</td>
</tr>
<tr>
<td/>
<td>
<ulist type="circle">
<item>
It is not possible to use xsi:type for explicitly denoting the natural type (i.e. the type immediately given to an element definition in the schema) of the element unless such a type has named sub-types or is a simple type definition of which {variety} is <emph>union</emph>.
</item>
</ulist>
</td>
</tr>
<tr>
<td/>
<td>
<ulist type="circle">
<item>
Namespace declarations are not available instream. A consequence of this is that instream namespace declarations otherwise available when <termref def="key-strictOption">strict option</termref> value is <emph>false</emph> cannot be turned to for helping decompose <xspecref spec="NS" ref="dt-qualname">qualified names</xspecref> in AT or CH values into pairs of uri and local-name, including xsi:type attribute values encoded with the <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> option value <emph>true</emph> wherein the qualified names are represented using String datatype representation (see <specref ref="encodingString"/>) instead of QName datatype representation (see <specref ref="encodingQName"/>).
</item>
</ulist>
</td>
</tr>
<tr>
<td/>
<td>
<ulist type="circle">
<item>
The attributes xsi:schemaLocation and xsi:noNamespaceSchemaLocation can appear only when they match specific schema declarations (i.e., wildcards or ur-types). 
</item>
</ulist>
</td>
</tr>



</tbody></table>

</div5>

</div4>
</div3></div2></div1>
<div1 id="compression">
<head>EXI Compression</head>
<p>
The use of EXI compression increases compactness utilizing additional computational resources. EXI compression combines knowledge of XML with a widely adopted, standard compression algorithm to achieve higher compression ratios than would be achievable by applying compression to the entire stream.</p>
<p>
EXI compression is applied when <termref def="key-compressionOption">compression</termref> is turned on or when <termref def="key-alignmentOption">alignment </termref> is set to <termref def="key-precompression">pre-compression</termref>. Byte-aligned representations of <termref def="key-eventcode">event codes</termref> and <termref def="key-content-item">content items</termref> are more amenable to compression algorithms compared to unaligned representations because most compression algorithms operate on series of bytes to identify redundancies in the octets. Therefore, when EXI compression is used, <termref def="key-eventcode">event codes</termref> and <termref def="key-content-item">content items</termref> of EXI events are encoded as aligned bytes in accordance with <specref ref="encodingEventCodes"/> and <specref ref="encodingValues" />.</p>

<p>EXI compression splits a sequence of EXI events into a number of contiguous blocks of events.
Events that belong to the same block are transformed into lower entropy groups of similar values called <emph>channels</emph>, which are individually well suited for standard compression algorithms. To reduce compression overhead, smaller channels are combined before compressing them, while larger channels are compressed independently. The criteria EXI compression uses to define and combine channels is intentionally simple to facilitate implementation, reduce processing overhead, and avoid the need to encode channel ordering or grouping information in the format. The figure below presents a schematic view of the steps involved in EXI compression.
</p>

<graphic source="compression.png" alt="EXI Compression Overview"/>

<p>In the following sections, <specref ref="blocks"/> defines blocks and explains how EXI events are partitioned into blocks.
Section <specref ref="channels"/> defines channels, their organization as well as how a group of channels correlate to its corresponding block of events.
Section <specref ref="CompressedStreams"/> describes how some channels are combined as needed in preparation for applying compression algorithms on channels.
</p>

<div2 id="blocks">
<head>Blocks</head>
<p>EXI compression partitions the sequence of EXI events into a sequence of one or more non-overlapping blocks. Each block preceding the final block contains the minimum set of consecutive events that result in exactly <termref def="key-blockSizeOption">blockSize</termref>&nbsp;<emph>values</emph> in its value channels (see <specref ref="ValueChannels"/>), where blockSize is the block size of the EXI stream (see <specref ref="options"/>). The final block contains 
less than the minimum set of consecutive events that result in blockSize <emph>values</emph> in its value channels. 
</p>
</div2>

<div2 id="channels">
<head>Channels</head>
<p>Events inside each block are multiplexed into channels. The first channel of each block is the structure channel described in Section <specref ref="StructureChannel"/>. The remaining channels in each block are value channels described in Section <specref ref="ValueChannels"/>.
The diagram below presents an exemplary view of the transformation in which events within a block are multiplexed into channels in one way and channels are demultiplexed into events in the other way.</p>
<graphic source="channels.png" alt="Multiplexing EXI events into channels"/>

<div3 id="StructureChannel">
<head>Structure Channel</head>
<p>The structure channel of each block defines the overall order and structure of the events in that block. It contains the <termref def="key-eventcode">event codes</termref> and associated content for each event in the block, except for Attribute (AT) and Character (CH) 
<termref def="key-valueContentItem"><emph>values</emph></termref>, 
which are stored in the value channels. In addition, there are two kinds of attribute events whose <emph>values</emph> are stored in the structure channel instead of in value channels. The <emph>value</emph> of each xsi:type attribute is stored in the structure channel. 
The <emph>value</emph> of each xsi:nil attribute that matches a schema-informed grammar production 
that does not include the AT (*) [untyped value] terminal is also stored in the structure channel. These attribute events are intrinsic to the grammar system thus are essential in processing the structure channel because their values affect the grammar to be used for processing the rest of the elements on which they appear. All <termref def="key-eventcode">event codes</termref> and content in the structure stream occur in the same order as they occur in the EXI event sequence.</p>
</div3>

<div3 id="ValueChannels">
<head>Value Channels</head>
<p>The <emph>values</emph> of the Attribute (AT) and Character (CH) events in each block are organized into separate channels based on the <emph>qname</emph> of the associated attribute or element. Specifically, the <emph>value</emph> of each Attribute (AT) event is placed in the channel identified by the <emph>qname</emph> of the Attribute and the <emph>value</emph> of each Character (CH) event is placed in the channel identified by the <emph>qname</emph> of its parent Start Element (SE) event. Each block contains exactly one channel for each distinct element or attribute <emph>qname</emph> that occurs in the block. The <emph>values</emph> in each channel occur in the order they occur in the EXI event sequence.</p>
</div3>
</div2>

<div2 id="CompressedStreams">
<head>Compressed Streams</head>
<p>The channels in a block are further organized into compressed streams. Smaller channels are combined into the same compressed stream, while others are each compressed separately. Below are the rules applied within the scope of a block used to determine the channels to be combined together, the order of the compressed streams and the order amongst the channels that are combined into the same compressed stream.</p>

<p>If the value channels of the block contain at most 100 <emph>values</emph>, the block will contain only 1 compressed stream containing the structure channel followed by all of the value channels. The order of the value channels within the compressed stream is defined by the order in which the first <emph>value</emph> in each channel occurs in the EXI event sequence.</p>

<p>If the value channels of the block contain more than 100 <emph>values</emph>, the first compressed stream contains only the structure channel. The second compressed stream contains all value channels that contain at most 100 <emph>values</emph>. And the remaining compressed streams each contain only one channel, each having more than 100 <emph>values</emph>. The order of the value channels within the second compressed stream is defined by the order in which the first <emph>value</emph> in each channel occurs in the EXI event sequence. Similarly, the order of the compressed streams following the second compressed stream in the block is defined by the order in which the first <emph>value</emph> of the channel inside each compressed stream occurs in the EXI event sequence.</p>

<note>EXI compression changes the order in which <termref def="key-eventcode">event codes</termref> and <emph>value</emph>s are read and written to and from an EXI stream.

<termref def="key-exiprocessor">EXI processors</termref> must encode and decode <emph>value</emph>s in this revised order so order sensitive constructs like the string table (see <specref ref="stringTable"/>) work properly.</note>

<p>
When the value of the <termref def="key-compressionOption">compression</termref> option is set to true, each compressed stream in a block is stored using the standard DEFLATE Compressed Data Format defined by RFC 1951 <bibref ref="RFC1951"/>. Otherwise, when the value of the <termref def="key-alignmentOption">alignment </termref> option is set to <termref def="key-precompression">pre-compression</termref>, each compressed stream in a block is stored directly without the DEFLATE algorithm.</p>

<note>
Some EXI events have zero-byte representations and are not explicitly represented in the EXI stream. If all the events in a channel have zero-byte representations, the channel has a zero-byte representation and is not explicitly represented in a compressed stream. Implementations must take care to avoid creating an empty DEFLATE stream when all the channels that would have otherwise been organized into a compressed stream are implicit. E.g., this can occur if the final block contains only zero-length EE and ED events.
</note>

</div2>

</div1>

<div1 id="conformance">
<head>Conformance</head>

<div2 id="streamConformance">
<head>EXI Stream Conformance</head>
<p>
<termdef id="key-conformantExiStream" term="conformant EXI stream">A <term>conformant EXI stream</term> consists of a sequence of octets that follows the syntax of <termref def="key-existream">EXI stream</termref> that is defined in this document. </termdef>
<termdef id="key-extendedExiStream" term="extended EXI stream">
EXI format provides a way to involve user-defined datatype representations in EXI streams processing, which is an extension point that, when used in conjunction with relevant datatype representations specifications external to this document, leads to the formulation of <term>Extended EXI streams</term>.
</termdef>
</p>
<p>
Conformance of extended EXI streams is relative to the syntax defined by the relevant user-defined datatype representations specifications. The definitions of user-defined datatype representations syntax are out of the scope of this document. 

<termdef id="key-conformantExtendedExiStream" term="conformant extended EXI stream">
An extended EXI stream is a <term>conformant extended EXI stream</term> if replacing value items represented using user-defined datatype representations with their intrinsic representations would make the stream a <termref def="key-conformantExiStream">conformant EXI stream</termref>. 
</termdef>

An extended EXI stream described as an "EXI stream with regards to datatype representations <emph>S</emph>&nbsp;" where <emph>S</emph> is the set of datatype representations can be processed by an <termref def="key-exidecoder">EXI stream decoder</termref> only if the processor has the shared knowledge about each one of the datatype representations in the set <emph>S</emph>. 
</p>
<p>The structural syntax of <termref def="key-existream">EXI streams</termref> and <termref def="key-extendedExiStream">extended EXI streams</termref> is described by the abstract EXI grammar system defined in this document. Although this document specifies the normative way in which XML Schema schemas are mapped into the EXI grammar system to make schema-informed grammars, EXI allows the use of other schema languages to process EXI streams or extended EXI streams so far as there is a well known EXI grammar binding of the schema language and the binding preserves the semantics of the EXI grammar system. EXI streams or extended EXI streams generated using schemas of such schema language are still conformant. The definitions of grammar bindings for schema languages other than XML Schema are out of the scope of this document, and each schema language community is encouraged to define its own binding in order to make it possible to harness the utmost efficiency out of EXI when schemas of the language are available.
</p>
</div2>

<div2 id="processorConformance">
<head>EXI Processor Conformance</head>
<p>
The conformance of EXI Processors is defined separately for each of the two processor roles, <termref def="key-exiencoder">EXI stream encoders</termref> and <termref def="key-exidecoder">EXI stream decoders</termref>; the conformance of the former is described in terms of the conformance of the <termref def="key-existream">EXI streams</termref> or <termref def="key-extendedExiStream">extended EXI streams</termref> that they produce, while that of the latter is based on the set of format features that EXI stream decoders are prepared 
for in the processing of 
<termref def="key-conformantExiStream">conformant EXI streams</termref> or <termref def="key-conformantExtendedExiStream">conformant extended EXI streams</termref>.
</p>
<p>
An <termref def="key-exiencoder">EXI stream encoder</termref> is conformant if and only if it is capable of generating <termref def="key-conformantExiStream">conformant EXI streams</termref> or <termref def="key-conformantExtendedExiStream">conformant extended EXI streams</termref> given any input structured data it is made to work on.
On the other hand, <termref def="key-exidecoder">EXI stream decoders</termref> MUST support all format features described in this document as they are explained, except for the capability of handling 
<termref def="key-datatypeRepresentationMaps">Datatype Representation Map</termref> 
which is an optional feature. 
EXI stream decoders that do not implement 
<termref def="key-datatypeRepresentationMaps">Datatype Representation Map</termref> 
feature MUST report an error with a meaningful message upon encountering a <termref def="key-datatypeRepresentationOption">"datatypeRepresentationMap"</termref> element while processing <termref def="key-optionsDoc">EXI options documents</termref> in <termref def="key-exiheader">EXI headers</termref>.
</p>

<p>Except where required for interoperability with limited computing platforms (e.g, mobile and  embedded devices), this specification avoids placing arbitrary limits on the magnitude of specific numeric values required for implementation. So, in theory it is possible for EXI grammars, event codes, strings, enumeration lists, etc. to be arbitrarily large. In practice, however, it is not the intent of this specification to require conforming implementations to adopt exotic or inefficient numeric representations for handling arbitrarily large EXI documents and grammars on specific platforms. 
</p>

</div2>

</div1>
    </body>
    <back>
<div1 id="References">
<head>References</head>

    <div2 id='Normative-References'>
        <head>Normative References</head>

	<blist>
	  <bibl key="IETF RFC 1951" href="http://www.ietf.org/rfc/rfc1951.txt" id="RFC1951">
	    <titleref>DEFLATE Compressed Data Format Specification version 1.3</titleref>, P. Deutsch, Author. Internet
	    Engineering Task Force, May 1996. Available at
	    http://www.ietf.org/rfc/rfc1951.txt.
	  </bibl>

	  <bibl key="IETF RFC 2119" href="http://www.ietf.org/rfc/rfc2119.txt" id="RFC2119">
	    <titleref>Key words for use in RFCs to Indicate
	    Requirement Levels</titleref>, S. Bradner, Author. Internet
	    Engineering Task Force, June 1999. Available at
	    http://www.ietf.org/rfc/rfc2119.txt.
	  </bibl>

	  <bibl key="IETF RFC 3023" href="http://www.ietf.org/rfc/rfc3023.txt" id="RFC3023">
	    <titleref>XML Media Types</titleref>, 
	    M. Murata, S. St.Laurent and D. Kohn, Author. Internet
	    Engineering Task Force, January 2001. Available at
	    http://www.ietf.org/rfc/rfc3023.txt.
	  </bibl>

	  <bibl id="ISO10646" key="ISO/IEC 10646">
	    <titleref>ISO/IEC 10646-1:2000. Information technology &mdash; Universal Multiple-Octet Coded Character Set (UCS) &mdash; Part 1: Architecture and Basic Multilingual Plane</titleref> and <titleref>ISO/IEC 10646-2:2001. Information technology &mdash; Universal Multiple-Octet Coded Character Set (UCS) &mdash; Part 2: Supplementary Planes</titleref>, as, from time to time, amended, replaced by a new edition or expanded by the addition of new parts. [Geneva]: International Organization for Standardization. (See <loc href="http://www.iso.org">http://www.iso.org</loc> for the latest version.)
</bibl>
    <bibl id="Unicode" key="UNICODE" href="http://www.unicode.org/">
      <titleref>The Unicode Standard</titleref>, The Unicode Consortium
</bibl>
	  <bibl id="XML10" key="XML 1.0" href="http://www.w3.org/TR/2008/REC-xml-20081126/">
	    <titleref>
Extensible Markup Language (XML) 1.0 (Fifth Edition)
</titleref>,
	    T.  Bray, J. Paoli, C. M. Sperberg-McQueen, E. Maler, and F. Yergeau, Editors.
	    World Wide Web Consortium, 10 February 1998, revised 26 November 2008.
	    This version is http://www.w3.org/TR/2008/REC-xml-20081126.
	    The latest version is available at
	    <loc href="http://www.w3.org/TR/REC-xml/">
	    http://www.w3.org/TR/REC-xml</loc>.
	  </bibl>
	  <bibl id="XML11" key="XML 1.1" href="http://www.w3.org/TR/2006/REC-xml11-20060816/">
	    <titleref>
Extensible Markup Language (XML) 1.1 (Second Edition)
</titleref>,
	    T.  Bray, J. Paoli, C. M. Sperberg-McQueen, E. Maler, F. Yergeau, and J. Cowan, Editors.
	    World Wide Web Consortium, 04 February 2004, revised 16 August 2006.
	    This version is http://www.w3.org/TR/2006/REC-xml11-20060816.
	    The latest version is available at
	    <loc href="http://www.w3.org/TR/xml11/">
	    http://www.w3.org/TR/xml11</loc>.
	  </bibl>
	  <bibl id="XMLNS10" key="Namespaces in XML" href="http://www.w3.org/TR/2006/REC-xml-names-20060816/">
	    <titleref>
Namespaces in XML 1.0 (Second Edition)
</titleref>,
	    T. Bray, D. Hollander, A. Layman, and R. Tobin, Editors.
	    World Wide Web Consortium, 14 January 1999, revised 16 August 2006.
	    This version is http://www.w3.org/TR/2006/REC-xml-names-20060816 .
	    The latest version is available at
	    <loc href="http://www.w3.org/TR/xml-names">
	    http://www.w3.org/TR/xml-names</loc>.
	  </bibl>
	  <bibl id='XMLInfoset' key='XML Information Set' href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204/'>
	    <titleref>XML Information Set (Second Edition)</titleref>,
	    J. Cowan and R. Tobin, Editors. World Wide Web Consortium,
	    24 October 2001, revised 4 February 2004.
	    This version is http://www.w3.org/TR/2004/REC-xml-infoset-20040204.
	    The latest version is available at
	    <loc href='http://www.w3.org/TR/xml-infoset/'>
	    http://www.w3.org/TR/xml-infoset</loc>.
	  </bibl>
	  <bibl id="schema1" key="XML Schema Structures" href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/">
	    <titleref>XML Schema Part 1: Structures Second
	    Edition</titleref>, H. Thompson, D. Beech, M. Maloney, and
	    N. Mendelsohn, Editors. World Wide Web Consortium, 2 May
	    2001, revised 28 October 2004. 
	    This version is http://www.w3.org/TR/2004/REC-xmlschema-1-20041028.
	    The latest version is available at
	    <loc href='http://www.w3.org/TR/xmlschema-1/'>
	    http://www.w3.org/TR/xmlschema-1</loc>.
	  </bibl>
	  <bibl key="XML Schema Datatypes" id="schema2"
		href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/">
	    <titleref>XML Schema Part 2: Datatypes Second
	    Edition</titleref>, P. Byron and A. Malhotra,
	    Editors. World Wide Web Consortium, 2 May 2001, revised 28
	    October 2004.
	    This version is http://www.w3.org/TR/2004/REC-xmlschema-2-20041028.
	    The latest version is available at
	    <loc href='http://www.w3.org/TR/xmlschema-2/'>
	    http://www.w3.org/TR/xmlschema-2</loc>.
	  </bibl>
	</blist>
    </div2>
    <div2 id='Informative-References'>
      <head>Other References</head>
      <blist>
	<bibl id="efx" key="Efficient XML"
	  href="http://www.w3.org/TR/2007/WD-exi-measurements-20070725/#contributions-efx">
	  <titleref>Efficient XML</titleref>, part of <bibref ref="eximeas"/> independently referenced.
	  The latest version is available at
	  <loc href="http://www.w3.org/TR/exi-measurements/#contributions-efx">
	  http://www.w3.org/TR/exi-measurements/#contributions-efx</loc>.
	</bibl>
	<bibl id="exieval" key="EXI Evaluation Note"
	      href="http://www.w3.org/TR/2008/WD-exi-evaluation-20080728/">
	  <titleref>Efficient XML Interchange Evaluation</titleref>, 
	  Carine Bournez, Editor. 
	  World Wide Web Consortium. 
	  The latest version is available at 
	  <loc href="http://www.w3.org/TR/exi-evaluation/">
	  http://www.w3.org/TR/exi-evaluation/</loc>.
	</bibl>
	<bibl id="exiimpacts" key="EXI Impacts Note"
	      href="http://www.w3.org/TR/2008/WD-exi-impacts-20080903/">
	  <titleref>Efficient XML Interchange (EXI) Impacts</titleref>, 
	  Jaakko Kangasharju, Editor. 
	  World Wide Web Consortium. 
	  The latest version is available at 
	  <loc href="http://www.w3.org/TR/exi-impacts/">
	  http://www.w3.org/TR/exi-impacts/</loc>.
	</bibl>
	<bibl id="eximeas" key="EXI Measurements Note"
	      href="http://www.w3.org/TR/2007/WD-exi-measurements-20070725/">
	  <titleref>Efficient XML Interchange Measurements Note</titleref>,
	  Greg White, Jaakko Kangasharju, Don Brutzman and Stephen Williams, Editors.
	  World Wide Web Consortium.
	  The latest version is available at
	  <loc href="http://www.w3.org/TR/exi-measurements/">
	  http://www.w3.org/TR/exi-measurements/</loc>.
	</bibl>
	<bibl id="exiprimer" key="EXI Primer"
	      href="http://www.w3.org/TR/2009/WD-exi-primer-20091208/">
	  <titleref>
	  Efficient XML Interchange (EXI) Primer
	  </titleref>,
	  Daniel Peintner, Santiago Pericas-Geertsen, Editors.
	  World Wide Web Consortium.
	  The latest version is available at
	  <loc href="http://www.w3.org/TR/exi-primer/">
	  http://www.w3.org/TR/exi-primer/</loc>.
	</bibl>
	<bibl id="greibach" key="Greibach Normal Form">
	  <titleref>
	  A New Normal-Form Theorem for Context-Free Phrase Structure Grammars
          </titleref>, 
	  Sheila A. Greibach, Author.
	  Journal of the ACM Volume 12&nbsp; Issue 1, January 1965, pp. 42–52.
	</bibl>
	<bibl id="huffman" key="Huffman Coding"
	      href="http://compression.ru/download/articles/huff/huffman_1952_minimum-redundancy-codes.pdf">
	  <titleref>A Method for the Construction of
	  Minimum-Redundancy Codes</titleref>, D. A. Huffman,
	  Author. Proceedings of the I.R.E., September 1952, pp.
	  1098-1102.
	</bibl>
	<bibl id="ieeefloat" key="IEEE 754-2008"
	      href="http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?arnumber=4610935">
	    <titleref>IEEE Standard for Floating-Point Arithmetic</titleref>
	</bibl>
	<bibl id="relaxng" key="ISO/IEC 19757-2:2003"
	      href="
http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=37605">
	    <titleref>Document Schema Definition Language (DSDL) -- Part 2: Regular-grammar-based validation -- RELAX NG</titleref>
	  </bibl>
	<bibl id="soap12" key="SOAP 1.2"
	      href="http://www.w3.org/TR/2003/REC-soap12-part1-20030624/">
	  <titleref>SOAP Version 1.2 Part 1: Messaging
	  Framework</titleref>, M. Gudgin, M.  Hadley, N. Mendelsohn,
	  J-J. Moreau, H. Frystyk Nielsen, Editors. World Wide Web
	  Consortium, 24 June 2003.
	  This version is http://www.w3.org/TR/2003/REC-soap12-part1-20030624/.
	  The latest version is available at
	  <loc href='http://www.w3.org/TR/soap12-part1/'>
	  http://www.w3.org/TR/soap12-part1/</loc>.
	</bibl>
	<bibl id="xbcmeas" key="XBC Measurement Methodologies"
	      href="http://www.w3.org/TR/2005/NOTE-xbc-measurement-20050331/">
	  <titleref>XML Binary Characterization Measurement
	  Methodologies</titleref>, S. D. Williams and P. Haggar,
	  Editors. World Wide Web Consortium, 31 March 2005.
	  This version is http://www.w3.org/TR/2005/NOTE-xbc-measurement-20050331/.
	  The latest version is available at
	  <loc href='http://www.w3.org/TR/xbc-measurement/'>
	  http://www.w3.org/TR/xbc-measurement</loc>.
	</bibl>
	<bibl id="xbcusecases" key="XBC Use Cases"
	      href="http://www.w3.org/TR/2005/NOTE-xbc-use-cases-20050331/">
	  <titleref>XML Binary Characterization Use Cases</titleref>,
	  Mike Cokus and Santiago Pericas-Geertsen, Editors.
	  World Wide Web Consortium, 31 March 2005.
	  This version is http://www.w3.org/TR/2005/NOTE-xbc-use-cases-20050331/.
	  The latest version is available at
	  <loc href="http://www.w3.org/TR/xbc-use-cases/">
	  http://www.w3.org/TR/xbc-use-cases</loc>.
	</bibl>
	<bibl id="xbcproperties" key="XBC Properties"
	      href="http://www.w3.org/TR/2005/NOTE-xbc-properties-20050331/">
	  <titleref>XML Binary Characterization Properties</titleref>,
	  Mike Cokus and Santiago Pericas-Geertsen, Editors.
	  World Wide Web Consortium, 31 March 2005.
	  This version is http://www.w3.org/TR/2005/NOTE-xbc-properties-20050331/
	  The latest version is available at
	  <loc href="http://www.w3.org/TR/xbc-properties/">
	  http://www.w3.org/TR/xbc-properties/</loc>.
	</bibl>
      </blist>
    </div2>
</div1>
<!--
<div1 id="media-type">
    <head>The application/exi Media Type</head>
    <p>This appendix defines the <attval>application/exi</attval>
    media type which can be used to describe Efficient XML Interchange
    documents.</p>
	<ednote>
		<name>John</name>
		<edtext>This section is mainly a placeholder at this time.</edtext>
	</ednote>
    <div2 id="ietf-reg">
        <head>Registration</head>
        <glist>
            <gitem><label>MIME media type name:</label><def><p>application</p></def></gitem>
            <gitem><label>MIME subtype name:</label><def><p>exi</p></def></gitem>
            <gitem><label>Required parameters:</label><def><p>none</p></def></gitem>
            <gitem><label>Optional parameters:</label>
                <def>
                    <glist>
                        <gitem><label>charset</label>
                            <def><p>This parameter has identical semantics to the charset parameter
                                of the <attval>application/xml</attval> media type as specified in
                                <bibref ref="RFC3023"/>.</p></def></gitem>
                        
                    </glist></def></gitem>
            <gitem><label>Encoding considerations:</label>
                <def><p>Identical to those of <attval>application/xml</attval>
                    as described in <bibref ref="RFC3023"/>,
                    section 3.2, as applied to the Web Services Policy document Infoset.</p></def></gitem>
            <gitem><label>Security considerations:</label>
                <def><p>See section <specref ref="Security_Considerations"/> in this document.</p></def></gitem>
            <gitem><label>Interoperability considerations:</label>
                <def><p>TBD.</p></def></gitem>
            <gitem><label>Published specifications:</label>
                <def><p>This document.</p></def></gitem>
            <gitem><label>Applications which use this media type:</label>
                <def><p>This new media type is being registered to allow for deployment of Efficient
	    XML Interchange on the World Wide Web.</p></def></gitem>
            <gitem>
                <label>Additional information:</label>
                <def><glist>
                    <gitem>
                        <label>File extension:</label>
                        <def><p>exi</p></def>
                    </gitem>
                    <gitem>
                        <label>Fragment identifiers:</label>
                        <def><p>A syntax identical to that of
                            <attval>application/xml</attval> as described in <bibref
                                ref="RFC3023"/>.</p></def>
                    </gitem>
                    <gitem>
                        <label>Base URI:</label>
                        <def><p>As specified in <bibref ref="RFC3023"/>, section 6.</p>
                        </def>
                    </gitem>
                    <gitem>
                        <label>Macintosh File Type code:</label>
                        <def><p>TEXT</p></def>
                    </gitem>
                    <gitem>
                        <label>Person and email address to contact for further information:</label>
                        <def><p>World Wide Web Consortium &lt;web-human@w3.org&gt;</p></def></gitem>
                    <gitem>
                        <label>Intended usage:</label><def><p>COMMON</p></def></gitem>
                    <gitem>
                        <label>Author/Change controller:</label>
                        <def><p>The Efficient XML Interchange specification set is a work product of the World Wide
                    Web Consortium's 
                    <loc
                        href="http://www.w3.org/XML/EXI/"
                        >Efficient XML Interchange Working Group</loc>.
                    The W3C has change control over these specifications.</p></def></gitem>
                </glist>
            </def>
            </gitem>
        </glist>
    </div2>
</div1>
-->
<div1 id="InfosetMapping">
  <head>Infoset Mapping</head>

  <p>
    This appendix contains the mappings between the XML Information
    Set <bibref ref="XMLInfoset"/> model and the EXI format.
    Starting from the document information item,
    each <term>information item</term> definition is mapped to its respective
    unordered set of EXI event types 
(see <specref ref="eventTypes"/>). 
The actual order amongst information set items when it is relevant reflects the occurrence order of EXI events or their references in an EXI stream that correlate to the infoset items. As used in the XML Information
    Set specification, the Infoset property names are shown in square
    brackets, <emph role="infoset-property">thus</emph>.
  </p>

  <note>
  <p>As has been prescribed in section <specref ref="principles"/>, EXI is designed to be compatible with the XML Information Set. While this approach is both legitimate and practical for designing a succinct format interoperable with XML family of specifications and technologies, it entails that some lexical constructs of XML not recognized by the XML Information Set are not represented by EXI, either. Examples of such unrepresented lexical constructs of XML include white space outside the document element, white space within tags, the kind of quotation marks (single or double) used to quote attribute values, and the boundaries of CDATA marked sections.
</p>
<p>
    No constructs in EXI format facilitate the representation of 
    <emph role="infoset-property">character encoding scheme</emph>,
    <emph role="infoset-property">standalone</emph> and <emph role="infoset-property">version</emph> 
    properties which are available in the definition of Document Information Item of XML Information Set 
    (see <specref ref="DocumentInformationItem"/>). EXI is made agnostic about 
    <emph role="infoset-property">character encoding scheme</emph> and <emph role="infoset-property">version</emph> 
    properties as they are in XML Information Set, and considers them to be the properties of 
    XML serializers in use. EXI forgoes <emph role="infoset-property">standalone</emph> property 
    because simply having no references to any external markup declarations practically 
    serves the purpose with less complexity.
</p>
  </note>

  <div2 id='DocumentInformationItem'>
      <head>Document Information Item</head>
      <p>
	A document information item maps to a pair of 
Start Document (SD) 
and 
End Document (ED) events 
with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping between the document information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">children</emph></td>
	    <td>CM* PI* DT? [SE, EE]</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">document element</emph></td>
	    <td>[SE, EE]</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">notations</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT 
to which each notation information set item maps.</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">unparsed entities</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT 
to which each unparsed entity information set item maps.</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">base URI</emph></td>
	    <td>The base URI of the EXI stream</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">character encoding scheme</emph></td>
	    <td>N/A</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">standalone</emph></td>
	    <td>Not available</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">version</emph></td>
	    <td>Not available</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">all declarations processed</emph></td>
	    <td>True if all declarations contained directly or indirectly in DT are processed, otherwise false, which is the processor quality as opposed to the information provided by the format.</td>
	  </tr>
	</tbody>
      </table>
  </div2>


    <div2 id='ElementInformationItem'>
      <head>Element Information Items</head>
      <p>
	An element information item maps to a pair of a 
Start Element (SE) 
event and the corresponding 
End Element (EE) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>

      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the element information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">namespace name</emph></td>
	    <td>SE</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">local name</emph></td>
	    <td>SE</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">prefix</emph></td>
	    <td>SE</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">children</emph></td>
	    <td>[SE, EE]* PI* CM* CH* ER*</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">attributes</emph></td>
	    <td>AT*</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">namespace attributes</emph></td>
	    <td>NS*</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">in-scope namespaces</emph></td>
	    <td>
	      The namespace information items computed using the <emph
	      role="infoset-property">namespace attributes</emph>
	      properties of this information item and its ancestors
	    </td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">base URI</emph></td>
	    <td>The base URI of the element information item</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event if any, or computed based on the SD event</td>
	  </tr>
	</tbody>
      </table>

  </div2>


    <div2 id='AttributeInformationItem'>
      <head>Attribute Information Item</head>
      <p>
	An attribute information item maps to an 
Attribute (AT) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>

      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the attribute information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">namespace name</emph></td>
	    <td>AT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">local name</emph></td>
	    <td>AT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">prefix</emph></td>
	    <td>AT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">normalized value</emph></td>
	    <td>The <emph>value</emph> of AT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">specified</emph></td>
	    <td>True if the item maps to AT, otherwise false</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">attribute type</emph></td>
	    <td>
	      Computed based on AT and DT
	    </td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">references</emph></td>
	    <td>
	      Computed based on <emph role="infoset-property">attribute type</emph> and <emph>value</emph> of AT
	    </td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">owner element</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="ProcessingInstructionInformationItem">
      <head>Processing Instruction Information Item</head> 
      <p>
	A processing instruction information maps to a 
Processing Instruction (PI) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the processing instruction information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">target</emph></td>
	    <td>PI</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">content</emph></td>
	    <td>PI</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">base URI</emph></td>
	    <td>The base URI of the processing information item</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">notation</emph></td>
	    <td>
	      Computed based on the availability of the internal DTD subset
	    </td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event type</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="UnexpandedEntityInformationItem">
    <head>Unexpanded Entity Reference Information item</head>

      <p>
	An unexpanded entity reference information item maps to an 
Entity Reference (ER) event 
with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the entity reference information item properties to
	the EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">name</emph></td>
	    <td>ER</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">system identifier</emph></td>
	    <td>Based on the availability of the internal DTD subset</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">public identifier</emph></td>
	    <td>Based on the availability of the internal DTD subset</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">declaration base URI</emph></td>
	    <td>The base URI of the unexpanded entity reference information item</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event type</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="CharacterInformationItem">
    <head>Character Information item</head>

      <p>
	A character information item maps to the individual characters contained in a 
Characters (CH) 
event following a SE event that did not get a matching EE event.
      </p>
    
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the character information item properties and the EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">character code</emph></td>
	    <td>Each character in CH</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">element content whitespace</emph></td>
	    <td>Computed based on <emph role="infoset-property">parent</emph> and DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="CommentInformationItem">
    <head>Comment Information item</head>

      <p>
	A comment information item maps to a 
Comment (CM) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>
    
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the comment information item properties and the EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">content</emph></td>
	    <td><emph>text</emph> content item of CM</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the last SE event encountered that did
	    not get a matching EE event, or the SD event</td>
	  </tr>
	</tbody>
      </table>

  </div2>

  <div2 id="DocumentTypeDeclaractionInformationItem">
    <head>Document Type Declaration Information item</head>

      <p>
	A document type declaration information item maps to a 
DOCTYPE (DT) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the document type declaration information item properties to the EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">system identifier</emph></td>
	    <td>DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">public identifier</emph></td>
	    <td>DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">children</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">parent</emph></td>
	    <td>Computed based on the SD event</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="UnparsedEntityInformationItem">
      <head>Unparsed Entity Information Item</head>
      <p>
	An unparsed entity information item maps to part of the
	<emph>text</emph> content item of 
DOCTYPE (DT) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>

      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the unparsed entity information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">name</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">system identifier</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">public identifier</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">declaration base URI</emph></td>
	    <td>The base URI of the unparsed entity information item</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">notation name</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">notation</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="NotationMapping">
    <head>Notation Information Item</head>
      <p>
	An notation information item maps to part of the
	<emph>text</emph> content item of 
DOCTYPE (DT) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the notation information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">name</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">system identifier</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">public identifier</emph></td>
	    <td>Computed based on <emph>text</emph> content item of DT</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">declaration base URI</emph></td>
	    <td>The base URI of the notation information item</td>
	  </tr>
	</tbody>
      </table>
  </div2>

  <div2 id="NamespaceInformationItem">
    <head>Namespace Information Item</head>
      <p>
	An namespace information item 
maps to a Namespace Declaration (NS) 
event with each of its properties subject to further mapping as shown in the following table.
      </p>
      <table border='1' cellpadding='3' width="100%">
	<caption>Mapping of the namespace information item properties to EXI event types</caption>
	<thead>
	  <tr>
	    <th width="35%">Property</th>
	    <th width="60%">EXI event types</th>
	  </tr>
	</thead>
	<tbody>
	  <tr>
	    <td><emph role="infoset-property">prefix</emph></td>
	    <td>NS</td>
	  </tr>
	  <tr>
	    <td><emph role="infoset-property">namespace name</emph></td>
	    <td>NS</td>
	  </tr>
	</tbody>
      </table>
  </div2>

</div1>
<div1 id="optionsSchema">
<head>XML Schema for EXI Options Document</head>
<p>The following schema describes the EXI options header. It is
designed to produce smaller headers for option combinations used when
compactness is critical.</p>

<eg xml:space="preserve">
&lt;xsd:schema targetNamespace="&exins;"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified"&gt;

  &lt;xsd:element name="header"&gt;
    &lt;xsd:complexType&gt;
      &lt;xsd:sequence&gt;
        &lt;xsd:element name="lesscommon" minOccurs="0"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence&gt;
              &lt;xsd:element name="uncommon" minOccurs="0"&gt;
                &lt;xsd:complexType&gt;
                  &lt;xsd:sequence&gt;
                    &lt;xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" 
                             processContents="skip" /&gt;
                    &lt;xsd:element name="alignment" minOccurs="0"&gt;
                      &lt;xsd:complexType&gt;
                        &lt;xsd:choice&gt;
                          &lt;xsd:element name="byte"&gt;
                            &lt;xsd:complexType /&gt;
                          &lt;/xsd:element&gt;
                          &lt;xsd:element name="pre-compress"&gt;
                            &lt;xsd:complexType /&gt;
                          &lt;/xsd:element&gt;
                        &lt;/xsd:choice&gt;
                      &lt;/xsd:complexType&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="selfContained" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="valueMaxLength" minOccurs="0"&gt;
                      &lt;xsd:simpleType&gt;
                        &lt;xsd:restriction base="xsd:unsignedInt" /&gt; 
                      &lt;/xsd:simpleType&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="valuePartitionCapacity" minOccurs="0"&gt;
                      &lt;xsd:simpleType&gt;
                        &lt;xsd:restriction base="xsd:unsignedInt" /&gt; 
                      &lt;/xsd:simpleType&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="datatypeRepresentationMap" 
                                 minOccurs="0" maxOccurs="unbounded"&gt;
                      &lt;xsd:complexType&gt;
                        &lt;xsd:sequence&gt;
                          &lt;!-- schema datatype --&gt;
                          &lt;xsd:any namespace="##other" processContents="skip" /&gt; 
                          &lt;!-- datatype representation --&gt;
                          &lt;xsd:any processContents="skip" /&gt; 
                        &lt;/xsd:sequence&gt;
                      &lt;/xsd:complexType&gt;
                    &lt;/xsd:element&gt;
                  &lt;/xsd:sequence&gt;
                &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="preserve" minOccurs="0"&gt;
                &lt;xsd:complexType&gt;
                  &lt;xsd:sequence&gt;
                    &lt;xsd:element name="dtd" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="prefixes" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="lexicalValues" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;<!--
                    &lt;xsd:element name="whitespace" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt; -->
                    &lt;xsd:element name="comments" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;
                    &lt;xsd:element name="pis" minOccurs="0"&gt;
                      &lt;xsd:complexType /&gt;
                    &lt;/xsd:element&gt;
                  &lt;/xsd:sequence&gt;
                &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="blockSize" minOccurs="0"&gt;
                &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:unsignedInt"&gt;
                    &lt;xsd:minInclusive value="1" /&gt;
                  &lt;/xsd:restriction&gt; 
                &lt;/xsd:simpleType&gt;
              &lt;/xsd:element&gt;                 
            &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
        &lt;xsd:element name="common" minOccurs="0"&gt;
          &lt;xsd:complexType&gt;
            &lt;xsd:sequence&gt;
              &lt;xsd:element name="compression" minOccurs="0"&gt;
                &lt;xsd:complexType /&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="fragment" minOccurs="0"&gt;
                &lt;xsd:complexType /&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="schemaId" minOccurs="0" nillable="true"&gt;
                &lt;xsd:simpleType&gt;
                  &lt;xsd:restriction base="xsd:string" /&gt;
                &lt;/xsd:simpleType&gt;
              &lt;/xsd:element&gt;
            &lt;/xsd:sequence&gt;
          &lt;/xsd:complexType&gt;
        &lt;/xsd:element&gt;
        &lt;xsd:element name="strict" minOccurs="0"&gt;
          &lt;xsd:complexType /&gt;
        &lt;/xsd:element&gt;
      &lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;

  &lt;!-- Built-in EXI Datatype IDs for use in datatype representation maps --&gt;
  &lt;xsd:simpleType name="base64Binary"&gt;
     &lt;xsd:restriction base="xsd:base64Binary"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="hexBinary" &gt;
     &lt;xsd:restriction base="xsd:hexBinary"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="boolean" &gt;
     &lt;xsd:restriction base="xsd:boolean"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="decimal" &gt;
     &lt;xsd:restriction base="xsd:decimal"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="double" &gt;
     &lt;xsd:restriction base="xsd:double"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="integer" &gt;
     &lt;xsd:restriction base="xsd:integer"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="string" &gt;
     &lt;xsd:restriction base="xsd:string"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="dateTime" &gt;
     &lt;xsd:restriction base="xsd:dateTime"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="date" &gt;
     &lt;xsd:restriction base="xsd:date"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="time" &gt;
     &lt;xsd:restriction base="xsd:time"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="gYearMonth" &gt;
     &lt;xsd:restriction base="xsd:gYearMonth"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="gMonthDay" &gt;
     &lt;xsd:restriction base="xsd:gMonthDay"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="gYear" &gt;
     &lt;xsd:restriction base="xsd:gYear"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="gMonth" &gt;
     &lt;xsd:restriction base="xsd:gMonth"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="gDay" &gt;
     &lt;xsd:restriction base="xsd:gDay"/&gt;
  &lt;/xsd:simpleType&gt;

  &lt;!-- Qnames reserved for future use in datatype representation maps --&gt;
  &lt;xsd:simpleType name="ieeeBinary32" &gt;
     &lt;xsd:restriction base="xsd:float"/&gt;
  &lt;/xsd:simpleType&gt;
  &lt;xsd:simpleType name="ieeeBinary64" &gt;
     &lt;xsd:restriction base="xsd:double"/&gt;
  &lt;/xsd:simpleType&gt;
&lt;/xsd:schema&gt;
</eg>
<note>
The <termref def="key-qname">qnames</termref> exi:ieeeBinary32 and exi:ieeeBinary64 defined above are reserved for future use in Datatype Representation Maps to identify the 32-bit and 64-bit Binary Interchange Formats defined by the IEEE 754-2008 standard <bibref ref="ieeefloat"/>.
</note>
</div1>
<div1 id="initialStringValues">
<head>Initial Entries in String Table Partitions</head>
<div2 id="initialUriValues">
<head>Initial Entries in Uri Partition</head>
<p>The following table lists the entries that are initially populated in uri partitions, where partition name URI denotes that they are entries in the uri partition.</p>
<table border="1">
<caption>Initial values in <emph>uri</emph> partition</caption>
<colgroup span="2" align="center"></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th>Partition</th>
<th>Compact ID</th>
<th>String Value</th></tr>
</thead>
<tbody>
<tr>
<td>URI</td>
<td>0</td>
<td>"" [empty string]</td></tr>
<tr>
<td>URI</td>
<td>1</td>
<td>"http://www.w3.org/XML/1998/namespace"</td></tr>
<tr>
<td>URI</td>
<td>2</td>
<td>"http://www.w3.org/2001/XMLSchema-instance"</td></tr>
<!-- tr>
<td>URI</td>
<td>3</td>
<td>"http://www.w3.org/2001/XMLSchema"</td></tr -->
</tbody></table>

<p>When XML Schemas are used to inform the grammars for processing EXI body, there is an additional entry that is appended to the uri partition, 
regardless of the XML Schema in use. 
</p>

<table border="1">
<caption>Additional entry when XML Schemas are used</caption>
<colgroup span="2" align="center"></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th>Partition</th>
<th>Compact ID</th>
<th>String Value</th></tr>
</thead>
<tbody>
<tr>
<td>URI</td>
<td>3</td>
<td>"http://www.w3.org/2001/XMLSchema"</td></tr></tbody></table>

<p>
Additionally, when XML Schemas are used, the uri partition is also pre-populated with some of the namespace URIs used in the schemas. Section <specref ref="stringTablePartitions"/> describes the way this has to be done. All string values in uri partition are unique.
</p>

</div2>

<div2 id="initialPrefixValues">
<head>Initial Entries in Prefix Partitions</head>
<p>The following table lists the entries that are initially populated in prefix partitions, 
where XML-PF represents the partition for <emph>prefixes</emph> in
the <el>"http://www.w3.org/XML/1998/namespace"</el> namespace and XSI-PF
represents the partition for <emph>prefixes</emph> in the
<el>"http://www.w3.org/2001/XMLSchema-instance"</el> namespace.</p>
<table border="1">
<caption>Initial 
<emph>prefix</emph> string table entries</caption>
<colgroup span="2" align="center"></colgroup>
<colgroup></colgroup>
<thead>
<tr>
<th>Partition</th>
<th>Compact ID</th>
<th>String Value</th></tr>
</thead>
<tbody>
<tr>
<td>""</td>
<td>0</td>
<td>"" [empty string]</td></tr>
<tr>
<td>XML-PF</td>
<td>0</td>
<td>"xml"</td></tr>
<tr>
<td>XSI-PF</td>
<td>0</td>
<td>"xsi"</td></tr>
</tbody></table>
</div2>
<div2 id="initialLocalNames">
<head>Initial Entries in Local-Name Partitions</head>
<p>The following tables list the string values that are initially populated and made available 
in local-name partitions, where XML&nbhyphen;NS represents the partition for <emph>local-names</emph>
in the <el>"http://www.w3.org/XML/1998/namespace"</el> namespace, XSI&nbhyphen;NS
represents the partition for <emph>local-names</emph> in the
<el>"http://www.w3.org/2001/XMLSchema-instance"</el> namespace, and XSD&nbhyphen;NS
represents the partition for <emph>local-names</emph> in the
<el>"http://www.w3.org/2001/XMLSchema"</el> namespace. 
</p>
<table border="1" cellpadding="5" id="initialLocalNamesSchemaLess">
<caption>
String&nbsp;values&nbsp;initially&nbsp;available&nbsp;in&nbsp;XML&nbhyphen;NS&nbsp;and&nbsp;XSI&nbhyphen;NS&nbsp;partition
</caption>
<colgroup span="2" align="center"></colgroup>
<thead>
<tr>
<th>Partition</th>
<th>String Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>XML&nbhyphen;NS</td>
<td>"base", "id", "lang", "space"</td></tr>
<tr>
<td>XSI&nbhyphen;NS</td>
<td>"nil", "type"</td></tr>
</tbody>
</table>
<p>
When XML Schemas are used to inform the grammars for processing EXI body, those string values listed in the next table are available in XSD&nbhyphen;NS partition.
</p>
<table border="1" cellpadding="5" id="initialLocalNamesSchemaInformed">
<caption>
String values initially available in XSD&nbhyphen;NS partition for schema-informed EXI streams
</caption>
<colgroup span="2" align="center"></colgroup>
<thead>
<tr>
<th>Partition</th>
<th>String Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>XSD&nbhyphen;NS</td>
<td style="line-height: 1.5;">"ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", "NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name", "QName", "anySimpleType", "anyType", "anyURI", "base64Binary", "boolean", "byte", "date", "dateTime", "decimal", "double", "duration", "float", "gDay", "gMonth", "gMonthDay", "gYear", "gYearMonth", "hexBinary", "int", "integer", "language", "long", "negativeInteger", "nonNegativeInteger", "nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string", "time", "token", "unsignedByte", "unsignedInt", "unsignedLong", "unsignedShort"</td></tr>
</tbody>
</table>

<p>Additionally, when a schema is provided, the string table is also pre-populated with the local-name of each attribute, element and type explicitly declared in the schema, partitioned by namespace URI. 
</p>
<p>
All string values within each partition containing local-names is then sorted lexicographically. Assign each string value a compact identifier in the sorted order, with the initial identifier number 0 assigned to the first string value, incremented by 1 before each subsequent assignment.
</p>

</div2>
</div1>
<div1 id="regexToCharset">
<head>Deriving 
Set of Characters 
from XML Schema Regular Expressions</head>

<p>
XML Schema datatypes specification <bibref ref="schema2"/> defines a <xspecref spec="XS2" ref="regexs">regular expression</xspecref> syntax for use in pattern facets of simple type definitions. Pattern facets constrain the set of valid values to those that lexically match the specified regular expression. This section describes the rules for deriving the set of characters allowed in a string value that conforms to a given regular expression in an XML Schema. 
In the following description, the term "set-of-chars" is used as the shorthand form of "set of characters". 
</p>

<p>At the top level, 
the XML Schema regular expression 
syntax is summarized by the following production excerpted here from <bibref ref="schema2"/>. Note the notation used for the numbers that tag the productions. "XSD:" is prefixed to the original numeric tags to make it easier to discern them as belonging to XML Schema specification.
</p>

<p id="regExp">&nbsp;&nbsp;<xspecref spec="XS2" ref="regex">[XSD:1]</xspecref>&nbsp;&nbsp;regExp&nbsp;&nbsp;::=&nbsp;&nbsp;branch&nbsp;&nbsp;(&nbsp;&nbsp;'|'&nbsp;&nbsp;branch&nbsp;&nbsp;)*  
</p>

<p>The set-of-chars for a regex that conforms to the syntax above is the union of the set-of-chars defined for each branch. Each branch of a regex is described by the following production:
</p>

<p>&nbsp;&nbsp;<xspecref spec="XS2" ref="branch">[XSD:2]</xspecref>&nbsp;&nbsp;branch&nbsp;&nbsp;::=&nbsp;&nbsp;piece* 
</p>

<p>The set-of-chars for each branch of a regex is the union of the set-of-chars for each piece of the branch. Each piece of a branch is described by the following production:
</p>

<p>&nbsp;&nbsp;<xspecref spec="XS2" ref="piece">[XSD:3]</xspecref>&nbsp;&nbsp;piece&nbsp;&nbsp;::=&nbsp;&nbsp;atom&nbsp;&nbsp;quantifier? 
</p>

<p>The set-of-chars for each piece of a branch is the set-of-chars for the atom portion of the piece. The atom portion of a piece is described by the following production:
</p>

<p>&nbsp;&nbsp;<xspecref spec="XS2" ref="atom">[XSD:9]</xspecref>&nbsp;&nbsp;atom&nbsp;&nbsp;::=&nbsp;&nbsp;Char&nbsp;&nbsp;|&nbsp;&nbsp;charClass&nbsp;&nbsp;|&nbsp;&nbsp;(&nbsp;&nbsp;'('&nbsp;&nbsp;regExp&nbsp;&nbsp;')'&nbsp;&nbsp;) 
</p>

<p>The set-of-chars for the atom is the set-of-chars for the Char, charClass or regExp that constitutes the atom. 
</p>

<p>
The set-of-chars for a Char that constitutes an atom contains the single character that matches the <xspecref spec="XS2" ref="char">Char expression</xspecref>. 

The set-of-chars for a charClass that constitutes an atom is the set of characters specified by the <xspecref spec="XS2" ref="charClass">charClass expression </xspecref>. 

The set-of-chars for a regExp sub-expression enclosed in parenthesis that constitutes an atom is the set-of-chars for the regExp itself derived by recursively applying the rule defined above. 
</p>

<p>
For stability and interoperability of restricted character sets across different versions of the Unicode standard, certain pattern facets cannot be used for deriving restricted character sets. In particular, pattern facets that contain one or more <xspecref spec="XS2" ref="nt-catEsc">category escapes</xspecref>, <xspecref spec="XS2" ref="nt-complEsc">category complement escapes</xspecref> or <xspecref spec="XS2" ref="nt-MultiCharEsc">multi-character escapes</xspecref> other than \s do not have restricted character sets.
</p>
</div1>

<div1 id="mediaTypeRegistration">
<head>Content Coding and Internet Media Type</head>
<p>
Two labels are defined for identifying and negotiating the use of EXI for representing XML information in higher-level protocols. They serve two distinct roles. One is for content coding and the other is for internet media type. 
</p>

<div2 id="contentCoding">
<head>Content Coding</head>
<p>
The content-coding value "exi" is registered with the Internet Assigned Numbers Authority (IANA) for use with EXI. Protocols that can identify and negotiate the content coding of 
XML 
information independent of its media type, 
<!-- (e.g. HTTP 1.1) -->
SHOULD use the content coding "exi" (case-insensitive) to convey the acceptance or actual use of EXI encoding for XML information.
</p>
</div2>

<div2 id="internetMediaType">
<head>Internet Media Type</head>
<p>
A new media type registration "application/exi" described below is being proposed for community review, with the intent to eventually submit it to the IESG for review, approval, and registration with IANA.

<!-- In the introduction to the relevant section, say that this registration is for community review and will be submitted to the IESG for review, approval, and registration with IANA. -->


</p>
<glist>
<gitem>
<label>Type name:</label>
<def>
<p>
application
</p>
</def>
</gitem>
<gitem>
<label>Subtype name:</label>
<def>
<p>
exi
</p>
</def>
</gitem>
<gitem>
<label>Required parameters:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Optional parameters:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Encoding considerations:</label>
<def>
<p>
binary
</p>
</def>
</gitem>
<gitem>
<label>Security considerations:</label>
<def>
<p>
When used as an XML replacement in an application, EXI shares
the same security concerns as XML, described in IETF RFC 3023 <bibref ref="RFC3023"/>,
section 10.
</p>
<p>
In addition to concerns shared with XML, the schema identifier
refers to information external to the EXI document itself. If
an attacker is able to substitute another schema in place of
the intended one, the semantics of the EXI document could be
changed in some ways. As an example, EXI is sensitive to the
order of the values in an enumeration. It is not known whether
such an attack is possible on the actual structure of the
document.
</p>
<p>
Also, EXI supports user-defined datatype representations, and such
representations, if present in a document and purportedly understood by
a processor, can be a security weakness. Definitions of these
representations are expected to be external, often application- or
industry-specific, so any definition needs to be analyzed carefully from
the security perspective before being adopted.
</p>
</def>
</gitem>
<gitem>
<label>Interoperability considerations:</label>
<def>
<p>
The datatype representation map feature of EXI requires
coordination between the producer and consumer of an EXI
document, and is not recommended except in controlled
environments or using standardized datatype representations
potentially defined in the future.
</p>
<p>
EXI permits information necessary to decode a document to be
omitted with the expectation that such information has been
communicated out of band. Such omissions hinder
interoperability in uncontrolled environments.
</p>
</def>
</gitem>
<gitem>
<label>Published specification:</label>
<def>
<p>
Efficient XML Interchange (EXI) Format 1.0, World Wide Web
Consortium
</p>
</def>
</gitem>
<gitem>
<label>Applications that use this media type:</label>
<def>
<p>
No known applications currently use this media type.
</p>
</def>
</gitem>
<gitem>
<label>Additional information:</label>
<def>
<table>
<tbody>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr align="left">
<th colspan="2">
Magic number(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>
The first four octets may be hexadecimal 24 45 58 49 ("$EXI").
The first octet after these, or the first octet of the whole
content if they are not present, has its high two bits set to
values 1 and 0 in that order.
</td>
</tr>
</tbody>
</table>
<table width="100%">
<tbody>
<tr align="left">
<th colspan="2">
File extension(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>.exi</td>
</tr>
</tbody>
</table>
<table width="100%">
<tbody>
<tr align="left">
<th colspan="2">
Macintosh file type code(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>APPL</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr align="left">
<th colspan="2">
Consideration of alternatives :
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>
<p>
When transferring EXI streams over a protocol that can identify and negotiate the content coding of XML information independent of its media-type, the content-coding should be used to identify and negotiate how the XML information is encoded and the media-type should be used to negotiate and identify what type of information is transferred. 
<!-- 
Whenever possible and in particular when transferring EXI streams
over HTTP, the media type of the XML dialect or XML-based format
relevant to the transferred data should be used instead of
application/exi and the EXI encoding should be denoted by an
appropriate mechanism. 
E.g., in HTTP messages, <code>Content-Encoding</code> header with
the registered token value "exi" must be present to indicate the use 
of EXI encoding.
-->
</p>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</tbody>
</table>
</def>
</gitem>
<gitem>
<label>Person &amp; email address to contact for further information:</label>
<def>
<p>
World Wide Web Consortium &lt;web-human@w3.org&gt;
</p>
</def>
</gitem>
<gitem>
<label>Intended usage:</label>
<def>
<p>
COMMON
</p>
</def>
</gitem>
<gitem>
<label>Restrictions on usage:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Author/Change controller:</label>
<def>
<p>
The EXI specification is the product of the World Wide Web
Consortium's Efficient XML Interchange Working Group. The W3C
has change control over this specification.
</p>
</def>
</gitem>

</glist>

</div2>

</div1>

<!-- div1 id="mediaTypeRegistration">
<head>
Internet Media Type
</head>

<p>
A new media type registration "application/exi" described below is being proposed for community review, with the intent to eventually submit it to the IESG for review, approval, and registration with IANA. 
It is a metadata that helps to identify that the data being retrieved or sent is an XML Information Set represented as an EXI stream. 
</p>

<glist>
<gitem>
<label>Type name:</label>
<def>
<p>
application
</p>
</def>
</gitem>
<gitem>
<label>Subtype name:</label>
<def>
<p>
exi
</p>
</def>
</gitem>
<gitem>
<label>Required parameters:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Optional parameters:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Encoding considerations:</label>
<def>
<p>
binary
</p>
</def>
</gitem>
<gitem>
<label>Security considerations:</label>
<def>
<p>
When used as an XML replacement in an application, EXI shares
the same security concerns as XML, described in IETF RFC 3023 <bibref ref="RFC3023"/>,
section 10.
</p>
<p>
In addition to concerns shared with XML, the schema identifier
refers to information external to the EXI document itself. If
an attacker is able to substitute another schema in place of
the intended one, the semantics of the EXI document could be
changed in some ways. As an example, EXI is sensitive to the
order of the values in an enumeration. It is not known whether
such an attack is possible on the actual structure of the
document.
</p>
<p>
Also, EXI supports user-defined datatype representations, and such
representations, if present in a document and purportedly understood by
a processor, can be a security weakness. Definitions of these
representations are expected to be external, often application- or
industry-specific, so any definition needs to be analyzed carefully from
the security perspective before being adopted.
</p>
</def>
</gitem>
<gitem>
<label>Interoperability considerations:</label>
<def>
<p>
The datatype representation map feature of EXI requires
coordination between the producer and consumer of an EXI
document, and is not recommended except in controlled
environments or using standardized datatype representations
potentially defined in the future.
</p>
<p>
EXI permits information necessary to decode a document to be
omitted with the expectation that such information has been
communicated out of band. Such omissions hinder
interoperability in uncontrolled environments.
</p>
</def>
</gitem>
<gitem>
<label>Published specification:</label>
<def>
<p>
Efficient XML Interchange (EXI) Format 1.0, World Wide Web
Consortium
</p>
</def>
</gitem>
<gitem>
<label>Applications that use this media type:</label>
<def>
<p>
No known applications currently use this media type.
</p>
</def>
</gitem>
<gitem>
<label>Additional information:</label>
<def>
<table>
<tbody>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr align="left">
<th colspan="2">
Magic number(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>
The first four octets may be hexadecimal 24 45 58 49 ("$EXI").
The first octet after these, or the first octet of the whole
content if they are not present, has its high two bits set to
values 1 and 0 in that order.
</td>
</tr>
</tbody>
</table>
<table width="100%">
<tbody>
<tr align="left">
<th colspan="2">
File extension(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>.exi</td>
</tr>
</tbody>
</table>
<table width="100%">
<tbody>
<tr align="left">
<th colspan="2">
Macintosh file type code(s):
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>APPL</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr align="left">
<th colspan="2">
Consideration of alternatives :
</th>
</tr>
<tr>
<td width="5%">&nbsp;</td>
<td>
<p>
When transferring EXI streams over a protocol that supports to indicate 
the encoding transformation of the XML data being transferred with regards 
to the XML Information Set, the media type of the XML dialect or XML-based format
relevant to the transferred data should be used instead of
application/exi and the EXI encoding should be denoted by an
appropriate mechanism. 
</p>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</tbody>
</table>
</def>
</gitem>
<gitem>
<label>Person &amp; email address to contact for further information:</label>
<def>
<p>
World Wide Web Consortium &lt;web-human@w3.org&gt;
</p>
</def>
</gitem>
<gitem>
<label>Intended usage:</label>
<def>
<p>
COMMON
</p>
</def>
</gitem>
<gitem>
<label>Restrictions on usage:</label>
<def>
<p>
none
</p>
</def>
</gitem>
<gitem>
<label>Author/Change controller:</label>
<def>
<p>
The EXI specification is the product of the World Wide Web
Consortium's Efficient XML Interchange Working Group. The W3C
has change control over this specification.
</p>
</def>
</gitem>

</glist>

</div1 -->

<inform-div1 id="example">
<head>Example Encoding</head>
<p>
EXI Primer <bibref ref="exiprimer"/> contains a section that explains the workings of EXI format using simple example documents. Those examples are intended to serve as a tool to confirm the understanding of the EXI format in action by going through encoding and decoding processes step by step.
</p>
</inform-div1>
<inform-div1 id="grammarExamples">
<head>Schema-informed Grammar Examples</head>

<p>As an example to exercise the process to produce schema-informed element grammars, consider the following XML Schema fragment declaring two complex-typed elements, &lt;product&gt; and &lt;order&gt;:</p>
<example>
<head>Example XML Schema fragment</head>
<eg xml:space="preserve">
&lt;xs:element name=&quot;product&quot;&gt; 
  &lt;xs:complexType&gt; 
    &lt;xs:sequence maxOccurs=&quot;2&quot;&gt; 
      &lt;xs:element name=&quot;description&quot; type=&quot;xs:string&quot; minOccurs=&quot;0&quot;/&gt; 
      &lt;xs:element name=&quot;quantity&quot; type=&quot;xs:integer&quot; /&gt; 
      &lt;xs:element name=&quot;price&quot; type=&quot;xs:float&quot; /&gt; 
    &lt;/xs:sequence&gt; 
    &lt;xs:attribute name=&quot;sku&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /&gt; 
    &lt;xs:attribute name=&quot;color&quot; type=&quot;xs:string&quot; use=&quot;optional&quot; /&gt; 
  &lt;/xs:complexType&gt; 
&lt;/xs:element&gt; 

&lt;xs:element name=&quot;order&quot;&gt; 
  &lt;xs:complexType&gt; 
    &lt;xs:sequence&gt; 
      &lt;xs:element ref=&quot;product&quot; maxOccurs=&quot;unbounded&quot; /&gt; 
    &lt;/xs:sequence&gt; 
  &lt;/xs:complexType&gt; 
&lt;/xs:element&gt; 
</eg>
</example>
<p>Section <specref ref="exampleProtoGrammars"/> guides you through the process of 
generating 
EXI proto-grammars from the schema components available in the example schema above. EXI grammars in the normalized form that correspond to the proto-grammars are shown in section <specref ref="exampleNormGrammars"/>. Section <specref ref="exampleCompleteGrammars"/> shows the complete EXI grammars for elements &lt;product&gt; and &lt;order&gt;.
</p>
<div2 id="exampleProtoGrammars">
<head>Proto-Grammar Examples</head>
<p>Grammars for element declaration terms "description", "quantity" and "price" are as follows. See section <specref ref="elementTerms"/> for the rules used to 
generate grammars for element terms.
</p>
<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="termDescription">
<thead>
<tr>
<th align="left" colspan="3"><emph>Term_description</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_description</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"description"</emph>) <emph>Term_description</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="80%" id="termQuantity">
<thead>
<tr>
<th align="left" colspan="3"><emph>Term_quantity</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"quantity"</emph>) <emph>Term_quantity</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="80%" id="termPrice">
<thead>
<tr>
<th align="left" colspan="3"><emph>Term_price</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_price</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"price"</emph>) <emph>Term_price</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>The grammar for element particle "description" is 

created based on 
<termref def="termDescription"><emph>Term_description</emph></termref> given {&nbsp;minOccurs&nbsp;} value of 0 and {&nbsp;maxOccurs&nbsp;} value of 1. See section <specref ref="particles"/> for the rules used to 
generate grammars for particles.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="particleDescription">
<thead>
<tr>
<th align="left" colspan="3"><emph>Particle_description</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_description</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"description"</emph>) <emph>Term_description</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>Grammars for element particle "quantity" and "prices" are the same as those of their terms (<termref def="termQuantity"><emph>Term_quantity</emph></termref> and <termref def="termPrice"><emph>Term_price</emph></termref>, respectively) because {minOccurs} and {maxOccurs} are both 1.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="particleQuantity">
<thead>
<tr>
<th align="left" colspan="3"><emph>Particle_quantity</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"quantity"</emph>) <emph>Term_quantity</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="80%" id="particlePrice">
<thead>
<tr>
<th align="left" colspan="3"><emph>Particle_price</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_price</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"price"</emph>) <emph>Term_price</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>The grammar for the sequence group term in &lt;product&gt; element declaration is 
created based on 
the grammars of subordinate particles as follows. See section <specref ref="sequenceGroupTerms"/> for the rules used to 
generate grammars for sequence groups.

</p>

<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>Term_sequence</emph> = <termref def="particleDescription"><emph>Particle_description</emph></termref> &oplus; <termref def="particleQuantity"><emph>Particle_quantity</emph></termref> &oplus; <termref def="particlePrice"><emph>Particle_price</emph></termref>
</td>
</tr>
</tbody></table>

<p>which yields the following grammars for <emph>Term_sequence</emph>.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="termSequence">
<thead>
<tr>
<th align="left" colspan="3"><emph>Term_sequence</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_description</emph><sub>0</sub> : 
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE("description") <emph>Term_description</emph><sub>1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph> <sub>0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph> <sub>1</sub> :  
</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph> <sub>0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph> <sub>0</sub> : 
</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph> <sub>1</sub> : 
</td></tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_price</emph> <sub>0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph> <sub>0</sub> : 
</td></tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph> <sub>1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph> <sub>1</sub> :  
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>The grammar for the particle that is the content model of element &lt;product&gt; 
is created based on 
<termref def="termSequence"><emph>Term_sequence</emph></termref> (shown above) given {minOccurs} value of 1 and {maxOccurs} value of 2. See section <specref ref="particles"/> for the rules used to 
generate grammars for particles.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="particleSequence">
<thead>
<tr>
<th align="left" colspan="3"><emph>Particle_sequence</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_description</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_price</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_description</emph><sub>1,0</sub>  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_price</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody>
</table>
</example>

<p>Grammars for attribute uses of attributes "sku" and "color" are as follows. See section <specref ref="attributeUses"/> for the rules used to 
generate grammars for attribute uses.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="useSku">
<thead>
<tr>
<th align="left" colspan="3"><emph>Use_sku</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Use_sku</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Use_sku</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody>
</table>

<table width="80%" id="useColor">
<thead>
<tr>
<th align="left" colspan="3"><emph>Use_color</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Use_color</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("color") [schema-typed value] <emph>Use_color</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Use_color</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody>
</table>
</example>

<p>
Note the subtle difference between 
the forms of the two 
grammars <termref def="useSku"><emph>Use_sku</emph></termref> and <termref def="useColor"><emph>Use_color</emph></termref>. 
At the outset of the grammars, 
only <termref def="useColor"><emph>Use_color</emph></termref> contains a production of which the right-hand side starts with EE, which 
is the result of 
the difference in their occurrence 
requirement 
defined in the schema. 
</p>

<p>Finally, the grammar for the element &lt;product&gt; is 
created based on 
the grammars of its attribute uses and content model particle as follows. See section <specref ref="complexTypeGrammars"/> for the rules used to 
generate grammars for complex types.
</p>

<table width="100%">
<tbody>
<tr>
<td width="5%"></td>
<td>
<emph>ProtoG_ProductElement</emph> = <termref def="useColor"><emph>Use_color</emph></termref> &oplus; <termref def="useSku"><emph>Use_sku</emph></termref> &oplus; <termref def="particleSequence"><emph>Particle_sequence</emph></termref>
</td>
</tr>
</tbody></table>

<p>which yields the following grammar for element &lt;product&gt;.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="protoProductElement">
<thead>
<tr>
<th align="left" colspan="3"><emph>ProtoG_ProductElement</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Use_color</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("color") [schema-typed value] <emph>Use_color</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Use_sku</emph> <sub>0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Use_color</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Use_sku</emph> <sub>0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Use_sku</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Use_sku</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_description</emph><sub>0,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_price</emph><sub>0,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_description</emph><sub>1,0</sub>  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_quantity</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_price</emph><sub>1,0</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody>
</table>
</example>

<p>The other element declaration &lt;order&gt; can be processed 
to generate its proto-grammar in a similar fashion as follows.
</p>

<example>
<table width="80%" id="termProduct">
<thead>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th align="left" colspan="3"><emph>Term_product</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="5%"></td>
<td colspan="2">
<emph>Term_product</emph><sub>&nbsp;0</sub> :</td></tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE(<emph>"product"</emph>) <emph>Term_product</emph><sub>&nbsp;1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph><sub>&nbsp;1</sub> :
</td></tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>
The grammar for element particle "product" is created based on <termref def="termProduct"><emph>Term_product</emph></termref> given {&nbsp;minOccurs&nbsp;} value of 1 and {&nbsp;maxOccurs&nbsp;} value of <emph>unbounded</emph>. See section <specref ref="particles"/> for the rules used to generate grammars for particles.
</p>

<example>
<table width="80%">
<thead>
<tr>
<th>&nbsp;</th>
</tr>
<tr>
<th align="left" colspan="3"><emph>Particle_product</emph> &nbsp;&nbsp;(before simplification)</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%">
<tbody>
<tr>
<td width="5%"></td>
<td width="5%"></td>
<td/>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>0,1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,1</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

</tbody>
</table>
</example>

<p>In the above grammars, two grammars <emph>Term_product</emph> <sub>0,1</sub> and <emph>Term_product</emph> <sub>1,1</sub> are redundant because they serve for no other purpose than simply relaying one non-terminal to another. Though it is not required, the uses of non-terminals <emph>Term_product</emph> <sub>0,1</sub> and <emph>Term_product</emph> <sub>1,1</sub> are each replaced by <emph>Term_product</emph> <sub>1,0</sub> and <emph>Term_product</emph> <sub>1,0</sub>, which produces the following 
simplified 
proto-grammars.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<!-- table width="80%" id="protoOrderElement" -->
<table width="80%" id="particleProduct">
<thead>
<tr>
<!-- th align="left" colspan="3"><emph>ProtoG_OrderElement</emph></th -->
<th align="left" colspan="3"><emph>Particle_product</emph> &nbsp;&nbsp;(after simplification)</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">

</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>

</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

</tbody>
</table>
</example>

<p>The proto-grammar of the element &lt;order&gt; equates to <termref def="particleProduct"><emph>Particle_product</emph></termref> because the type definition of element &lt;order&gt; has no attribute uses, and its content model has both {&nbsp;minOccurs&nbsp;} and {&nbsp;maxOccurs&nbsp;} property values of 1 where the element particle "product" is the sole member of the content model. 
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="protoOrderElement">
<thead>
<tr>
<th align="left" colspan="3"><emph>ProtoG_OrderElement</emph></th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="2">

</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>

</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>0,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_product</emph> <sub>1,1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<emph>Term_product</emph> <sub>1,0</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

</tbody>
</table>
</example>

</div2>

<div2 id="exampleNormGrammars">
<head>Normalized Grammar Examples</head>

<p>The element proto-grammars <termref def="protoProductElement"><emph>ProtoG_ProductElement</emph></termref> and <termref def="protoOrderElement"><emph>ProtoG_OrderElement</emph></termref> produced in the previous section can be turned into their normalized forms which are shown below with an <termref def="key-eventcode">event code</termref> assigned to each production. See section <specref ref="normalizedGrammars"/> for the process that converts proto-grammars into normalized grammars, and section <specref ref="eventCodeAssignment"/> for the rules that determine the <termref def="key-eventcode">event codes</termref> of productions in normalized grammars.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="normProductElement">
<thead>
<tr>
<th align="left" colspan="4"><emph>NormG_ProductElement</emph></th>
</tr>
<tr>
<th colspan="3"></th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Use_color</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("color") [schema-typed value] <emph>Use_color</emph> <sub>1</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Use_color</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td width="5%"></td>
<td colspan="2">
<emph>Use_sku</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("sku") <emph>Use_sku</emph> <sub>1</sub>
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Use_sku</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
<td>1</td>
</tr>

<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_description</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_quantity</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>0,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>0,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_price</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
<td>2</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_description</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_description</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_quantity</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_quantity</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<!-- tr>
<td></td>
<td colspan="2">
<emph>Term_price</emph><sub>1,0</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>1,1</sub> 
</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr -->

<tr>
<td></td>
<td colspan="3">
<emph>Term_price</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="80%" id="normOrderElement">
<thead>
<tr>
<th align="left" colspan="4"><emph>NormG_OrderElement</emph></th>
</tr>
<tr>
<th colspan="3"></th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Term_product</emph> <sub>0,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>0</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Term_product</emph> <sub>1,0</sub>:
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE
</td>
<td>1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>
</example>

<p>


Note that some 
productions 
that were present in the proto-grammars have been removed in the normalized grammars. 

Those 
productions 
were culled upon the completion of grammar normalization because their left-hand-side non-terminals are not referenced from right-hand side of any available productions, 

and yet those non-terminals are not the first non-terminals of the grammar they belong to.
.
</p>

</div2>

<div2 id="exampleCompleteGrammars">
<head>Complete Grammar Examples</head>
<p>The normalized grammars <termref def="normProductElement"><emph>NormG_ProductElement</emph></termref> and <termref def="normOrderElement"><emph>NormG_OrderElement</emph></termref> are augmented with undeclared productions to become complete grammars.
See section <specref ref="undeclaredProductions"/> for the process 
to augment normalized grammars with productions for accepting terminal symbols not declared in schemas.
The complete grammars for elements &lt;product&gt; and &lt;order&gt; are shown below.
Note that the default grammar settings (i.e. the settings that can be described by an empty header options document &lt;exi:header/&gt; is used for the sake of this augmentation process, and those productions that accept ER, NS, CM and PI have been pruned according to the rules described in section <specref ref="pruningProductions"/> since those 
terminal symbols 
are not preserved in the default grammar settings.
</p>

<example>
<table width="80%">
<tbody>
<tr>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table width="80%" id="completeProductElement">
<thead>
<tr>
<th align="left" colspan="4">Complete grammar for element &lt;product&gt;</th>
</tr>
<tr>
<th colspan="3"></th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Use_color</emph> <sub>0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
AT("color") [schema-typed value] <emph>Use_color</emph> <sub>1</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT(xsi:type) <emph>Use_color</emph> <sub>0</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT(xsi:nil) <emph>Use_color</emph> <sub>0</sub>
</td>
<td>2.2</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) <emph>Use_color</emph> <sub>0</sub>
</td>
<td>2.3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("color") [untyped&nbsp;value] 
<emph>Use_color</emph><sub>1</sub> 
</td>
<td>2.4.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [untyped&nbsp;value] 
<emph>Use_sku</emph><sub>1</sub> 
</td>
<td>2.4.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) [untyped&nbsp;value] <emph>Use_color</emph> <sub>0</sub>
</td>
<td>2.4.2</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>2.5</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>2.6</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<td></td>
<td colspan="3">
<emph>Use_color</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [schema-typed value] <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) <emph>Use_color</emph> <sub>1</sub>
</td>
<td>1.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT("sku") [untyped&nbsp;value] 
<emph>Use_sku</emph> <sub>1</sub> 
</td>
<td>1.2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) [untyped&nbsp;value] <emph>Use_color</emph> <sub>1</sub>
</td>
<td>1.2.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>1.3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>1.4</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Use_sku</emph> <sub>1</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) [untyped&nbsp;value] <emph>Use_sku</emph> <sub>1</sub>
</td>
<td>2.2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>2.3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>2.4</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Use_sku</emph> <sub>1_copied</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>
2.1 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Use_sku</emph> <sub>1_copied</sub> 
</td>
<td>
2.2 
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_description</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_description</emph><sub>0,1</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_description</emph><sub>0,1</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_quantity</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>0,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_quantity</emph><sub>0,1</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_quantity</emph><sub>0,1</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_price</emph><sub>0,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("description") <emph>Term_description</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE  <sub>&nbsp;</sub>
</td>
<td>2</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_price</emph><sub>0,1</sub>
</td>
<td>3.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_price</emph><sub>0,1</sub>
</td>
<td>3.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_description</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("quantity") <emph>Term_quantity</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_description</emph><sub>1,1</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_description</emph><sub>1,1</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_quantity</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("price") <emph>Term_price</emph><sub>1,1</sub> 
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_quantity</emph><sub>1,1</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_quantity</emph><sub>1,1</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_price</emph><sub>1,1</sub> :  
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_price</emph><sub>1,1</sub>
</td>
<td>1.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_price</emph><sub>1,1</sub>
</td>
<td>1.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>

<table width="80%" id="completeOrderElement">
<thead>
<tr>
<th align="left" colspan="4">Complete grammar for element &lt;order&gt;</th>
</tr>
<tr>
<th colspan="3"></th>
<th align="left">Event Code</th>
</tr>
</thead>
<tbody>
<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Term_product</emph> <sub>0,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT(xsi:type) <emph>Term_product</emph> <sub>0,0</sub>
</td>
<td>1.1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT(xsi:nil) <emph>Term_product</emph> <sub>0,0</sub>
</td>
<td>1.2</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) <emph>Term_product</emph> <sub>0,0</sub>
</td>
<td>1.3</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
AT&nbsp;(*) [untyped&nbsp;value] <emph>Term_product</emph> <sub>0,0</sub>
</td>
<td>1.4.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Term_product</emph> <sub>0,0_copied</sub> 
</td>
<td>1.5</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Term_product</emph> <sub>0,0_copied</sub> 
</td>
<td>1.6</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td width="5%"></td>
<td colspan="3">
<emph>Term_product</emph> <sub>0,0_copied</sub> :
</td>
</tr>
<tr>
<td></td>
<td width="5%"></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) 
<emph>Term_product</emph> <sub>0,0_copied</sub> 
</td>
<td>
1.1 
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] 
<emph>Term_product</emph> <sub>0,0_copied</sub> 
</td>
<td>
1.2 
</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>

<tr>
<td></td>
<td colspan="3">
<emph>Term_product</emph> <sub>1,0</sub> :
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE("product") <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
EE <sub>&nbsp;</sub>
</td>
<td>1</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
SE(*) <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>2.0</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
CH [untyped&nbsp;value] <emph>Term_product</emph> <sub>1,0</sub>
</td>
<td>2.1</td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table>
</example>
</div2>
</inform-div1>
<inform-div1 id="changes">
<head>Recent Specification Changes</head>
<div2 id="changes7">
<head>Changes from Candidate Recommendation</head>
<ulist>
<item>Clarified that string table hits are always represented using a compact identifier.
(see <specref ref="encodingOptimizedForMisses"/>)
</item>
</ulist>
<ulist>
<item>
Added a note to clarify that Preserve.prefixes fidelity option SHOULD be turned on when 
xsi:type attributes are used in EXI streams that has Preserve.lexicalValues fidelity option 
value set to <emph>true</emph>.
(see <specref ref="fidelityOptions"/>)
</item>
</ulist>
<ulist>
<item>
Section <specref ref="encodingEnumerations"/> now explicitly states that a value of an enumerated type can be represented using the ordinal position of any of the items in the enumeration that represent the value.
</item>
</ulist>
<ulist>
<item>
Corrected <specref ref="encodingDateTime"/> by making the previous change about  
Hour, Minute and Second values apply similarly to TimeZone so as to represent all datetime numbers consistenty in base 2.
</item>
</ulist>
<ulist>
<item>
Clarified how local-names in schemas are fed into the string table as part of the string table pre-population process when schemas are in use. 
(see <specref ref="stringTablePartitions"/>)
</item>
</ulist>
<ulist>
<item>
Clarified that mantissa or exponent values outside of the accepted range MUST NOT be used in the Float datatype representation.
(see <specref ref="encodingFloat"/>)
</item>
</ulist>
<ulist>
<item>
Clarified that when a schema is provided which contains attribute declaration, element declaration or type declaration components with their target namespaces being one of <el>"http://www.w3.org/XML/1998/namespace"</el>, <el>"http://www.w3.org/2001/XMLSchema-instance"</el> and <el>"http://www.w3.org/2001/XMLSchema"</el>, the local-names of such schema components are also pre-populated into the string table, partitioned by their namespace URI, then sorted together with the string values listed for the respective namespace URI shown in appendix <specref ref="initialLocalNames"/>.
</item>
</ulist>
<ulist>
<item id="changes100623">The provision that was set out to permit xsi:type and xsi:nil attributes to be represented using AT(*) terminal in schema-informed grammars was removed for improved implementation simplicity, based on observation derived from implementation experiences.
(see <specref ref="informedElementFragGrammar"/>, <specref ref="complexTypeGrammars"/>, <specref ref="anyTypeGrammar"/> and <specref ref="addingProductions"/>)
</item>
</ulist>
<ulist>
<item id="changes100701a">
Clarified how a production of the form <emph>LeftHandSide</emph> : AT (<emph>xsi:type</emph>) <emph>RightHandSide</emph> that has already been added to the built-in grammar is evaluated.
(see <specref ref="builtinElemGrammars"/>)
</item>
</ulist>
<ulist>
<item id="changes100707a">
Clarified that the special encoding provision described for the Integer datatype representation applies only when the associated schema datatype is derived from xsd:integer.
(see <specref ref="encodingInteger"/>)
</item>
</ulist>
<ulist>
<item id="changes100713a">
Clarified that only those attributes explicitly declared in schemas are considered for inclusion in the construction of schema-informed element fragment grammar.
(see <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item id="changes100721a">
Enumerated restrictions that are implicated by the use of strict option.
(see <specref ref="addingProductionsStrict"/>)
</item>
</ulist>
<ulist>
<item id="changes100914a">
Clarified the criteria used to determine which values of xsi:nil attributes are included in the structure channel (as opposed to value channels) when EXI compression is used.
(see <specref ref="StructureChannel"/>)
</item>
</ulist>
<ulist>
<item id="changes100916a">
Clarified the preamble text of <specref ref="informedGrammars"/> by adding a mention that the section describes only the process for deriving schema-informed grammars from XML Schemas. 
</item>
</ulist>
<ulist>
<item id="changes100920a">
Clarified that the number of values used to dichotomize the compressed stream representation only includes values in value channels but not those occasional values of xsi:type and xsi:nil in the structure channel.
(see <specref ref="CompressedStreams"/>)
</item>
</ulist>
<ulist>
<item id="changes101105a">
Clarified that a channel of which all the events have zero-byte representations has a zero-byte representation and is not explicitly represented in a compressed stream. 
(see <specref ref="CompressedStreams"/>)
</item>
</ulist>
<ulist>
<item id="changes101105b">
The definition of blockSize element was clarified to indicate the element can have only values that are greater than or equal to 1.
(see <specref ref="optionsSchema"/>)
</item>
</ulist>
<ulist>
<item>
Described the numeric ranges that must be supported by implementations.
(see <specref ref="processorConformance"/>)
</item>
</ulist>
<ulist>
<item>
Clarified that regular expressions that contain category escapes, category complement escapes or multi-character escapes other than \s (whitespace) do not have corresponding restricted character sets.
(see <specref ref="regexToCharset"/>)
</item>
</ulist>
<ulist>
<item>
Fixed an error in <emph>ElementFragment</emph> grammar to make sure the grammar when <termref def="key-strictOption">strict option</termref> value set to false, after undeclared productions are added, do not end up making AT terminals available following the first occurrence of SE or CH events.
(see <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Fixed errors in <specref ref="builtInEXITypes"/> by removing unnecessary associations that were found to have been causing an interoperability problem.
</item>
</ulist>
<ulist>
<item>
Clarified appendix <specref ref="initialUriValues"/> by having it explicitly mentioned that some additional namespace URIs are added to the uri partition the process of which had been defined elsewhere in section <specref ref="stringTablePartitions"/>.
</item>
</ulist>
<ulist>
<item>
Relaxed the format constraint that had required xsi:type attribute to occur before all other attributes. It is now legitimate that other attributes occur before xsi:type so long as that xsi:type would not have caused grammar switch if it appeared as the first attribute. 
(See <specref ref="encodingEvents"/> and <specref ref="builtinElemGrammars"/>)
</item>
</ulist>
<ulist>
<item>
Clarified that the derivation methods "extension" or "restriction" are indicated (but not "list" or "union") when this specification mentions one type is derived from another or refers to the notion of type hierarchy. 
(See <specref ref="conventions"/>)
</item>
</ulist>
</div2>
<div2 id="changes6">
<head>Changes from Last Call Working Draft</head>
<ulist>
<item>
Defined schema-order used for sorting productions in schema-informed element and type grammars.
(see <specref ref="eventCodeAssignment"/>)
</item>
</ulist>
<ulist>
<item>
Added a caveat regarding the use of content-coding in EXI, clarifying that it is applicable only to XML documents and it is neither byte- nor character-preserving.
(see <specref ref="contentCoding"/>)
</item>
</ulist>
<!-- ulist>
<item>
Clarified that only BMP characters indicated by each category are included in the set of characters for use in restricted character set computation.
(see <specref ref="regexToCharset"/>)
</item>
</ulist -->
<ulist>
<item>
Hour, Minute and Second values are comparted into separate sequence of bits in order to make it easier to retrieve each values from Date-Time representation.
(see <specref ref="encodingDateTime"/>)
</item>
</ulist>
<ulist>
<item>
Made it clear that value content items of type xsd:QName and xsd:NOTATION are represented as String
with exception of xsi:type attribute whose representation uses xsd:QName.
(see <specref ref="builtInEXITypes"/>)
</item>
</ulist>
<ulist>
<item>
Described the behaviour expected of an EXI processor when it encountered EXI streams that have EXI versions not implemented by the processor.
(see <specref ref="version"/>)
</item>
</ulist>
<ulist>
<item>
AT&nbsp;(*) and/or SE&nbsp;(*) have been permitted on the right-hand side of Schema-informed Element Fragment Grammar.
(see <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item>
A condition was specified that makes those elements of the same name be excluded from the application of Relaxed Element Fragment grammar. Likewise, a condition that excludes attributes of the same name from the alternative application of String datatype representation.
(see <specref ref="informedFragGrammars"/> and <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Schema-informed Element Fragment Grammar is treated as though it was derived from an element declaration with a {nillable} property value of true and a type declaration that has named sub-types, when the grammar goes through the process of undeclared productions augmentation.
(see <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Added missing semantics for AT&nbsp;(*) productions in Complex Type Grammars and Complex Ur-Type Grammar.
(see <specref ref="complexTypeGrammars"/> and <specref ref="anyTypeGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Added a note indicating xsi:type and xsi:nil attributes cannot be used together on the same element when strict is true.(see <specref ref="addingProductionsStrict"/>)
</item>
</ulist>
<ulist>
<item>
Clarified conditions under which xsi:nil values are stored in structure channel.
(see <specref ref="StructureChannel"/>)
</item>
</ulist>
<ulist>
<item>
Added simple-type definitions for built-in EXI datatype representations to EXI options document schema.
(see <specref ref="optionsSchema"/>)
</item>
</ulist>
<ulist>
<item>
Fixed issue in semantics that prohibited learning of AT(xsi:type) and AT(xsi:nil) in <termref def="key-builtin-elem-grammar"/>.
(see <specref ref="builtinElemGrammars"/>)
</item>
</ulist>
<ulist>
<item>In appendix section <specref ref="regexToCharset"/>,
the terms "character set" and "charset" have been rephrased as "set of characters" and "set-of-chars", respectively. This is so as to avoid conjuring up some different connotations that these terms often bear in documents such as XML Schema specification. 
</item>
</ulist>
<ulist>
<item>It was made clear that "strict" element is not permitted to appear alongside "selfContained" element in an options document. (see the term definitions of <specref ref="key-strictOption"/> and <specref ref="key-selfContained"/>)
</item>
</ulist>
<ulist>
<item>xsi:type is now allowed on all union types when <termref def="key-strictOption">strict option</termref> is true. (see <specref ref="addingProductionsStrict"/>)
</item>
</ulist>
<ulist>
<item>
It has been made clearer that xsi:type and/or xsi:nil attribute events MUST occur before any other attribute events of the same element.(see <specref ref="builtinElemGrammars"/>, <specref ref="complexTypeGrammars"/>, <specref ref="addingProductions"/> and <specref ref="addingProductionsStrict"/>)
</item>
</ulist>
<ulist>
<item>
The order of attribute occurrences when schema-informed grammar is in effect was relaxed to be in any order as long as the grammar permits it. (see <specref ref="encodingEvents"/>)
</item>
</ulist>
<ulist>
<item>
The event after a self-contained element starts at an octet boundary. (see <specref ref="builtinElemGrammars"/> and see <specref ref="addingProductions"/>)
</item>
</ulist>
<ulist>
<item>
The provision for selfContained option was removed from section <specref ref="addingProductionsStrict"/>.
This removal does not cause any change to the format, because selfContained and strict options are mutually exclusive, therefore the provision there could never be utilized thus was simply extraneous.
</item>
</ulist>
<ulist>
<item>
SE(*) semantics has been clarified with regards to how grammars are resolved given an element <emph>qname</emph>.
</item>
</ulist>
<ulist>
<item>
The initial entries of local-name string table partitions has been split into two, where the second contains entries for the XSD-NS partition and gets appended to first only when XML Schemas are used. (see <specref ref="initialLocalNames"/>)
</item>
</ulist>
<ulist>
<item>
It is now explicitly stated that Preserve.prefixes fidelity option SHOULD be turned on when qualified names are used in value content items. (see <specref ref="fidelityOptions"/>)
</item>
</ulist>
<ulist>
<item>
Defined the term "<termref def="key-global-element-grammar">global element grammars</termref>" for use in describing the SE&nbsp;(*) semantics.
</item>
</ulist>
<ulist>
<item>
Fixed various bugs that were present in the examples described in <specref ref="grammarExamples"/>.
</item>
</ulist>
<ulist>
<item>
Sorted the initial entries in local-name partition of string tables were sorted in lexicographical order. 
(see <specref ref="initialLocalNames"/>)
</item>
</ulist>
<ulist>
<item>
Simplified the way in which restricted character sets are derived from datatypes with pattern facets.
(see <specref ref="restrictedCharSet"/> and <specref ref="regexToCharset"/>)
</item>
</ulist>
<ulist>
<item>
Added references to XML 1.1 alongside those of XML 1.0 to consistently indicate that EXI can be used with both versions of XML. 
(see <specref ref="concepts"/> and <specref ref="DistinguishingBits"/>)
</item>
</ulist>
<ulist>
<item>
Round-robin style mechanism of entry reuse for <emph>value</emph> string table partitions is described.
(see <specref ref="encodingOptimizedForMisses"/>)
</item>
</ulist>
<ulist>
<item>
Added exi:time, exi:date, exi:gYearMonth, exi:gYear, exi:gMonthDay, exi:gDay and exi:gMonth to 
<specref ref="builtInRestrictedStrings"/>.
</item>
</ulist>
<ulist>
<item>
Appended an empty content grammar to the definition of <emph>TypeEmpty</emph><sub>&nbsp;i</sub> in "8.5.4.1.3.2 Complex Type Grammars".
(see <specref ref="complexTypeGrammars"/>)
</item>
</ulist>
<ulist>
<item>
Changed the threshold number used for determining the use of restricted character sets from 255 to 256.
(see <specref ref="restrictedCharSet"/>)
</item>
</ulist>
<ulist>
<item>
Implementations are allowed to choose whether to use local or global table hit when both are available 
for representing string values. 
(see <specref ref="encodingOptimizedForMisses"/>)
</item>
</ulist>
<ulist>
<item>
Pattern facets defined for built-in schema datatypes are disregarded when computing restricted character sets. 
(see <specref ref="restrictedCharSet"/>)
</item>
</ulist>
<ulist>
<item>
The prefix string table partitions are made use of in the encoding of the prefix component of QName.
(see <specref ref="encodingQName"/>)
</item>
</ulist>
<ulist>
<item>
Changed the default value of schemaId, datatypeRepresentationMap and [user defined meta-data] options to "no default value" in 
<specref ref="exiOptionsInOptionsField"/>.
</item>
</ulist>
<ulist>
<item>
It is made clear that [user defined meta-data] option cannot modify the EXI format. 
(see <specref ref="options"/>)
</item>
</ulist>
<ulist>
<item>
The predicates used for AT and CH terminal symbols (i.e. those previously denoted as [schema-valid value] and [schema-invalid value]) have been changed to [schema-typed value] and [untyped&nbsp;value] to more accurately reflect the associated semantics. 
</item>
</ulist>
<ulist>
<item>
Updated the section on content coding to reflect that the "exi" content coding is now in the IANA registry.
(see <specref ref="contentCoding"/>)
</item>
</ulist>
<ulist>
<item>
Added a non-terminal <emph>TypeEmpty</emph><sub>&nbsp;ur-type,</sub><sub>&nbsp;1&nbsp;</sub> to the complex ur-type grammar <emph>TypeEmpty</emph><sub>&nbsp;ur-type&nbsp;</sub>, and defined the content index of the <emph>TypeEmpty</emph><sub>&nbsp;ur-type&nbsp;</sub> grammar.
(see <specref ref="anyTypeGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Removed the paragraph that described the processor conformance defining the minimal value range required of blockSize option support.
(see <specref ref="processorConformance"/>)
</item>
</ulist>
<ulist>
<item>
It was made clear that the datatypeRepresentationMap option does not take effect when the value of the Preserve.lexicalValues fidelity option is true.
(See the definition of datatypeRepresentationMap in <specref ref="options"/>)
</item>
</ulist>
<ulist>
<item>
It was made clear that the section <specref ref="restrictedCharSet"/> only applies to datatypes
derived from xsd:string.
</item>
</ulist>
<ulist>
<item>
The maximum size of the range used for determining the use of <emph>n</emph>-bit Unsigned Integer for representing values of xsd:integer was changed from 4095 to 4096. 
(see <specref ref="builtInEXITypes"/> and <specref ref="encodingBoundedUnsigned"/>).
</item>
</ulist>
<ulist>
<item>
Corrected the semantics associated with the production of the form <emph>LeftHandSide</emph> : EE in section 
<specref ref="builtinElemGrammars"/>.
</item>
</ulist>
<ulist>
<item>
Added <emph>ElementFragmentTypeEmpty</emph> grammar to the schema-informed element fragment grammar, and defined the <emph>content</emph> index of grammars <emph>ElementFragment</emph> and <emph>ElementFragmentTypeEmpty</emph>.
(see <specref ref="informedElementFragGrammar"/>)
</item>
</ulist>
<ulist>
<item>
The target namespace name of the XML Schema for EXI options document was changed to "&exins;".
(see <specref ref="optionsSchema"/>)
</item>
</ulist>
<ulist>
<item>
Updated the semantics associated with xsi:type and xsi:nil attributes to ensure they are encoded property when the value of Preserve.lexicalValues option is true.
</item>
</ulist>
<ulist>
<item>
Removed the reference to Unicode 5.0.0 character database. Section <specref ref="regexToCharset"/> no longer has dependency on Unicode 5.0.0. A normative reference to XML Schema datatypes specification <bibref ref="schema2"/> in  regards to processing regular expressions effectively have <xspecref spec="XS2" ref="dt-cces">character class escapes</xspecref> be each resolved into a set of characters using the exact version of XML and Unicode, namely XML 1.0 (Second Edition) and Unicode 3.1.0.
</item>
</ulist>
<ulist>
<item>
Added the "processContents" attribute with value "skip" to the wildcard terms in the XML Schema for EXI options document. 
(see <specref ref="optionsSchema"/>)
</item>
</ulist>
<ulist>
<item>
Added a statement that suggests turning on Preserve.prefixes fidelity option when the Preserve.lexicalValues fidelity option is true and xsi:type attributes are used in the EXI stream. 
(see <specref ref="fidelityOptions"/>)
</item>
</ulist>
<ulist>
<item>
The EXI datatype identifier exi:integer represents the Integer datatype representation, and <specref ref="builtInEXITypes"/> has been updated to accurately reflect the association. The rule previously applied to xsd:Integer datatype in that table is now described in section <specref ref="encodingInteger"/>.
</item>
</ulist>
<ulist>
<item>
Two qname definitions "ieeeBinary32" and "ieeeBinary64" have been given in the EXI options document schema.
(see <specref ref="optionsSchema"/>)
</item>
</ulist>
<ulist>
<item>
Implementations are required to support all Unsigned Integer values less than 2147483648, whereas the threshold value was previously 4294967296.
(see <specref ref="encodingUnsignedInteger"/>)
</item>
</ulist>
</div2>
<div2 id="changes5">
<head>Changes from Fourth Public Working Draft</head>
<ulist>
<item>
Added the section <specref ref="mediaTypeRegistration"/>.
</item>
</ulist>
</div2>
<div2 id="changes4">
<head>
Changes from Third Public Working Draft
</head>
<ulist>
<item>
Added the section <specref ref="conformance"/>.
</item>
</ulist>
<ulist>
<item>
<termref def="key-exiCookie">EXI Cookie</termref> was introduced in the EXI header in order to provide a facility to distinguish EXI streams from a broader range of document types used on the Web. (see <specref ref="EXICookie"/>)
</item>
</ulist>
<ulist>
<item>
Header options fields <termref def="key-valueMaxLengthOption">valueMaxLength</termref> and <termref def="key-valuePartitionCapacityOption">valuePartitionCapacity</termref> have been added in EXI options to limit the length of a string and the total number of strings that are put into value partitions of a string table.
</item>
</ulist>
<ulist>
<item>
Added support for mixed and empty content model in complex type grammar generation.
(see <specref ref="complexTypeGrammars"/>)
</item>
</ulist>
<ulist>
<item>
Described how <termref def="key-builtin-elem-grammar">built-in element grammars</termref> handle xsi:type and xsi:nil attribute occurrences in schema-informed EXI streams.
(see <specref ref="builtinElemGrammars"/>)
</item>
</ulist>
<ulist>
<item>
Defined the grammar that represents xsd:anyType.
(see <specref ref="anyTypeGrammar"/>)
</item>
</ulist>
<ulist>
<item>
Described the restricted character sets used for certain typed values when <termref def="key-preserveLexicalValuesOption">Preserve.lexicalValues</termref> is true.
(see <specref ref="builtInRestrictedStrings"/>)
</item>
</ulist>
<ulist>
<item>
Added a section <specref ref="informedElementFragGrammar"/>
describing the content of elements declared with the same qname when they occur inside an EXI fragment or EXI Element Fragment.
</item>
</ulist>
<ulist>
<item>
Added <termref def="key-selfContained">selfContained</termref> option for creating elements that can be indexed for random access.
(see <specref ref="options"/>)
</item>
</ulist>
<ulist>
<item>
Added mention of Unsigned Integer size that EXI processors SHOULD and MUST support.
(see <specref ref="encodingUnsignedInteger"/>)
</item>
</ulist>
<ulist>
<item>
Changed the order of productions representing CH events 
during event code assignment. 
(see <specref ref="eventCodeAssignment"/>)
</item>
</ulist>
<ulist>
<item>
Added semantics for empty "schemaId" element value.
(see <specref ref="options"/>)
</item>
</ulist>
<ulist>
<item>
The term "CODEC" has been replaced by a more appropriate term "datatype representation" throughout this document.
</item>
</ulist>
<ulist>
<item>
Added support for parameterized attribute wildcards in the generation of complex type grammars.
(see <specref ref="complexTypeGrammars"/>)
</item>
</ulist>

</div2>
<div2 id="changes3">
<head>
Changes from Second Public Working Draft
</head>
<ulist>
<item>
Added <termref def="key-strictOption">strict option</termref> (see <specref ref="options"/> and <specref ref="addingProductionsStrict"/>).
</item>
</ulist>
<ulist>
<item>
The order of content items for NS event has been corrected. (see <specref ref="eventTypes"/>)
</item>
</ulist>
<ulist>
<item>
Improved the description of <termref def="key-options">EXI Options document</termref> to make it clear that its representation does not start with an EXI header (see section <specref ref="options"/>). 
</item>
</ulist>
<ulist>
<item>
Reworked the section <specref ref="undeclaredProductions"/> for grammar system accuracy as well as describing how grammars are augmented with undeclared productions when <termref def="key-strictOption">strict option</termref> is true.
<!--
Reworked the note for the set of productions <emph>UndeclaredStartTagItems</emph> to articulate the role of each participating production (see section <specref ref="undeclaredTerminalSymbols"/>).
-->
</item>
</ulist>
<ulist>
<item>
The indicator content item in NS event type has been renamed to "local-element-ns", and improved its description for clarity (see section <specref ref="streams"/>).
</item>
</ulist>
<ulist>
<item>
The calculus of the MonthDay component used in Date-Time representation has been corrected (see section <specref ref="encodingDateTime"/>).
</item>
</ulist>
<ulist>
<item>
<emph>TypeEmpty</emph> is created for each type grammars to facilitate xsi:nil handling (see section <specref ref="typeGrammars"/>).
</item>
</ulist>
<ulist>
<item>
Described how the use of substitution groups in schemas affects the grammars (see section <specref ref="elementTerms"/>).
</item>
</ulist>
<ulist>
<item>
Described how the namespace constraints of wildcard terms are factored into the grammars. (see section <specref ref="wildcardTerms"/>).
</item>
</ulist>
<ulist>
<item>
Regular expressions do not apply to constrain character sets when regexps contain certain category escapes (see section <specref ref="regexToCharset"/>).
</item>
</ulist>
</div2>
<div2 id="changes2">
<head>
Changes from First Public Working Draft
</head>
<ulist>
<item>

Specified how schema-informed grammars are derived from available XML Schemas (see section <specref ref="informedElemGrammars"/>).

</item>
</ulist>
<ulist>
<item>

Described how QNames are represented with prefixes when prefix preservation is turned on (see section <specref ref="encodingQName"/>).

</item>
</ulist>
<ulist>
<item>

The <termref def="key-alignmentOption">alignment</termref> option was introduced in <termref def="key-options">EXI Options</termref> to support <termref def="key-precompression">pre-compression</termref> stream as well as plain <termref def="key-bytealignment">byte-alignment</termref> stream, in addition to the default <termref def="key-unaligned">bit-packed</termref> representation.

</item>
</ulist>
<ulist>
<item>

Described how the presence of pattern facets affects the encoding of EXI Boolean (see section <specref ref="encodingBoolean"/>) and EXI String (see section <specref ref="encodingString"/>) representation.

</item>
</ulist>
<ulist>
<item>

Values typed as integer with bounded range of 4095 or smaller are now represented as <emph>n</emph>-bit Unsigned Integers (see section <specref ref="encodingBoundedUnsigned"/>).

</item>
</ulist>
<ulist>
<item>

Added a section <!-- (see section <specref ref="otherProposedFeatures"/>) --> that lists additional items that have been advised and are currently under consideration.

</item>
</ulist>
</div2>
</inform-div1>
<inform-div1 id="acknowledgements">
<head>Acknowledgements</head>

<p>This document is the work of the <loc href="http://www.w3.org/XML/EXI/">Efficient XML Interchange (EXI) WG</loc>.</p>

<p>Members of the Working Group are (at the time of writing, sorted alphabetically by last name): </p>
<ulist>
<item>Carine Bournez, W3C/ERCIM (<emph>staff contact</emph>)</item>
<item>Don Brutzman, Web3D Consortium</item>
<item>Michael Cokus, MITRE Corporation 
(<emph>co-chair</emph>)
</item>
<item>Youenn Fablet, Canon, Inc.</item>
<item>Jun Fujisawa, Canon, Inc.</item>
<item>Joerg Heuer, Siemens AG</item>
<item>Alan Hudson, Web3D Consortium</item>
<item>Takuki Kamiya, Fujitsu Laboratories of America, Inc. 
(<emph>co-chair</emph>)
</item>
<item>Jaakko Kangasharju, University of Helsinki</item>
<item>Richard Kuntschke, Siemens AG</item>
<item>Nan Ma, China Electronics Standardization Institute</item>
<item>Don McGregor, Web3D Consortium</item>
<item>Hideyuki Moribe, Fujitsu Laboratories of America, Inc.</item>
<item>Daniel Peintner, Siemens AG</item>
<item>Liam Quin, W3C/MIT (<emph>staff contact</emph>)</item>
<item>Rich Rollman, AgileDelta, Inc.</item>
<item>John Schneider, AgileDelta, Inc.</item>
<item>Sheldon Snyder, Web3D Consortium</item>
<item>Greg White, Stanford University (<emph>former co-chair</emph>)</item>
</ulist>
<p>The EXI Working Group would like to acknowledge the following former members of the group for their leadership, guidance and expertise they provided throughout their individual tenure in the WG. (sorted in chronologically)
</p>
<ulist>
<item>Oliver Goldman, Adobe Systems, Inc. (<emph>former co-chair</emph>) (until 08 June 2006) </item>
<item>Robin Berjon, Expway (<emph>former co-chair</emph>) (until 17 October 2006) </item>
<item>Peter Haggar, IBM (until 07 March 2007) </item>
<item>Paul Thorpe, OSS Nokalva, Inc. (until 11 Sept 2007)</item>
<item>Kimmo Raatikainen, Nokia (until 13 March 2008)</item>
<item>Daniel Vogelheim, Invited Expert (<emph>former co-chair</emph> then from Siemens AG) (until 15 July 2008)</item>
<item>Stephen Williams, High Performance Technologies, Inc. (until 8 Aug 2008)</item>
<item>Ed Day, Objective Systems, Inc. (until 23 Oct 2009)</item>
<item>Santiago Pericas-Geertsen, Sun Microsystems, Inc. (until 06 May 2010)</item>
<item>Paul Sandoz, Sun Microsystems, Inc. (until 06 May 2010)</item>
</ulist>
<p>
The EXI working group owes so much to our distinguished colleague from Nokia, Kimmo Raatikainen (1955-2008), on the progress of our work, who succumbed to an ailment on March 13, 2008. His breadth of knowledge, depth of insight, ingenuity and courage to speak up constantly shed a light onto us whenever the group seemed to stray into a futile path of disagreements during the course. We shall never forget and will always appreciate his presence in us, and great contribution that is omnipresent in every aspect of our work throughout.
</p>
</inform-div1>
</back></spec>
