•               
    <html lang="en-US"><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Efficient XML Interchange (EXI) Format 1.0 (Second Edition)</title><style type="text/css">
    code           { font-family: monospace; }
    
    div.constraint,
    div.issue,
    div.note       { margin-left: 2em; }
    div.notice     { margin-left: 2em; font-weight: bold; font-size: larger; color: red }
    
    ol.enumar      { list-style-type: decimal; }
    ol.enumla      { list-style-type: lower-alpha; }
    ol.enumlr      { list-style-type: lower-roman; }
    ol.enumua      { list-style-type: upper-alpha; }
    ol.enumur      { list-style-type: upper-roman; }
    
    
    div.exampleInner pre { margin-left: 1em;
                           margin-top: 0em; margin-bottom: 0em}
    div.exampleOuter {border: 4px double gray;
                      margin: 0em; padding: 0em}
    div.exampleInner { background-color: #d5dee3;
                       border-top-width: 4px;
                       border-top-style: double;
                       border-top-color: #d3d3d3;
                       border-bottom-width: 4px;
                       border-bottom-style: double;
                       border-bottom-color: #d3d3d3;
                       padding: 4px; margin: 0em }
    div.exampleWrapper { margin: 4px }
    div.exampleHeader { font-weight: bold;
                        margin: 4px}
    
       div.reprdef { border: 4px double gray;
                     margin: 0em 0em; padding: 0em }
       div.reprHeader { margin: 4px;
                        font-weight: bold }
       span.reprdef { color: #A52A2A }
       div.reprBody { border-top-width: 4px;
                      border-top-style: double;
                      border-top-color: #d3d3d3;
                      padding: 0px ; margin: 0em}
       span.termdef { color: #850021 }
       span.arrow { font-style: normal; font-weight: bold }
       span.termdef { color: #850021 }
       a.termdef:visited, a.termdef:link { font-family: sans-serif;
                                  font-style: normal;
                                  color: #850021;
                                  text-decoration: none }
       a.termdefxspecref:visited, a.termdefxspecref:link { font-family: sans-serif;
                                  font-style: normal;
                                  color: #850021 }
       a.termref:visited, a.termref:link { font-family: sans-serif;
                                  font-style: normal;
                                  color: #850021;
                                  text-decoration: none }
       tr.bitcell { height: 2em }
       td.bitcell { width: 2em }
       .del { text-decoration: line-through }
       .chg { color: red }
       .add { color: fuchsia }
    
       sup small { font-style: italic;
                   color: #8F8F8F }
    
       div.notice { margin-left: 2em; font-weight: bold; font-size: larger; color: #005A9C; }
    
    </style><link rel="stylesheet" type="text/css" href="https://www.w3.org/StyleSheets/TR/W3C-REC.css"></head><body><div class="head"><p><img src="https://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width="72"></p>
    <h1>Efficient XML Interchange (EXI) Format 1.0 (Second Edition)</h1>
    <h2>W3C Recommendation 11 February 2014</h2><dl><dt>This version:</dt><dd>
    http://www.w3.org/TR/2014/REC-exi-20140211/
    </dd><dt>Latest version:</dt><dd>
    http://www.w3.org/TR/exi/</dd><dt>Previous version:</dt><dd>
        http://www.w3.org/TR/2013/PER-exi-20131022/
        </dd><dt>Editors:</dt><dd>John Schneider, AgileDelta, Inc. (First Edition)</dd><dd>Takuki Kamiya, Fujitsu Laboratories of America, Inc. (First Edition)</dd><dd>Daniel Peintner, Siemens AG (Second Edition)</dd><dd>Rumen Kyusakov, Invited Expert, Luleå University of Technology (Second Edition)</dd></dl>
        <p>Please check the
    	errata
    	for any errors or issues reported since
    	publication.</p>
        <p>See also translations.</p><p class="copyright">Copyright © 2014 W3C<sup>®</sup> (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.</p></div><hr><div>
    <h2>Abstract</h2><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></div><div>
    <h2>Status of this Document</h2><p>
    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 W3C technical reports index at http://www.w3.org/TR/.</p><p>This is the Second Edition Recommendation of the Efficient XML Interchange Format 1.0.
       The Second Edition incorporates a number of corrections that were published as
       errata
       against the First Edition, as well as other changes that help make the specification more readable and unambiguous.
       It has been produced by the EXI Working Group, which is part of the Extensible Markup Language (XML) Activity.
    The goals of the EXI Working Group are discussed in the charter.
        </p><p>Changes since the First Edition Recommendation are listed in the Change Log. A diff-marked version against the previous version of this document is also available.  </p><p> The EXI Working Group has produced a
        test suite testing the interoperability of this specification, and an interoperability test report. </p><p>This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.</p><p>Individuals are invited to send feedback on this document by email to [email protected], a mailing list with a public archive. This mailing list is reserved for comments, it is inappropriate to send discussion email to this address. Discussion should take place on the [email protected] mailing list (public archive).</p><p>This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. </p></div><div class="toc">
    <h2>Table of Contents</h2><p class="toc">1. Introduction<br>
        1.1 History and Design<br>
        1.2 Notational Conventions and Terminology<br>
    2. Design Principles<br>
    3. Basic Concepts<br>
    4. EXI Streams<br>
    5. EXI Header<br>
        5.1 EXI Cookie<br>
        5.2 Distinguishing Bits<br>
        5.3 EXI Format Version<br>
        5.4 EXI Options<br>
    6. Encoding EXI Streams<br>
        6.1 Determining Event Codes<br>
        6.2 Representing Event Codes<br>
        6.3 Fidelity Options<br>
    7. Representing Event Content<br>
        7.1 Built-in EXI Datatype Representations<br>
            7.1.1 Binary<br>
            7.1.2 Boolean<br>
            7.1.3 Decimal<br>
            7.1.4 Float<br>
            7.1.5 Integer<br>
            7.1.6 Unsigned Integer<br>
            7.1.7 QName<br>
            7.1.8 Date-Time<br>
            7.1.9 n-bit Unsigned Integer<br>
            7.1.10 String<br>
                7.1.10.1 Restricted Character Sets<br>
            7.1.11 List<br>
        7.2 Enumerations<br>
        7.3 String Table<br>
            7.3.1 String Table Partitions<br>
            7.3.2 Partitions Optimized for Frequent use of Compact Identifiers<br>
            7.3.3 Partitions Optimized for Frequent use of String Literals<br>
        7.4 Datatype Representation Map<br>
    8. EXI Grammars<br>
        8.1 Grammar Notation<br>
            8.1.1 Fixed Event Codes<br>
            8.1.2 Variable Event Codes<br>
        8.2 Grammar Event Codes<br>
        8.3 Pruning Unneeded Productions<br>
        8.4 Built-in XML Grammars<br>
            8.4.1 Built-in Document Grammar<br>
            8.4.2 Built-in Fragment Grammar<br>
            8.4.3 Built-in Element Grammar<br>
        8.5 Schema-informed Grammars<br>
            8.5.1 Schema-informed Document Grammar<br>
            8.5.2 Schema-informed Fragment Grammar<br>
            8.5.3 Schema-informed Element Fragment Grammar<br>
            8.5.4 Schema-informed Element and Type Grammars<br>
                8.5.4.1 EXI Proto-Grammars<br>
                    8.5.4.1.1 Grammar Concatenation Operator<br>
                    8.5.4.1.2 Element Grammars<br>
                    8.5.4.1.3 Type Grammars<br>
                        8.5.4.1.3.1 Simple Type Grammars<br>
                        8.5.4.1.3.2 Complex Type Grammars<br>
                    8.5.4.1.4 Attribute Uses<br>
                    8.5.4.1.5 Particles<br>
                    8.5.4.1.6 Element Terms<br>
                    8.5.4.1.7 Wildcard Terms<br>
                    8.5.4.1.8 Model Group Terms<br>
                        8.5.4.1.8.1 Sequence Model Groups<br>
                        8.5.4.1.8.2 Choice Model Groups<br>
                        8.5.4.1.8.3 All Model Groups<br>
                8.5.4.2 EXI Normalized Grammars<br>
                    8.5.4.2.1 Eliminating Productions with no Terminal Symbol<br>
                    8.5.4.2.2 Eliminating Duplicate Terminal Symbols<br>
                8.5.4.3 Event Code Assignment<br>
                8.5.4.4 Undeclared Productions<br>
                    8.5.4.4.1 Adding Productions when Strict is False<br>
                    8.5.4.4.2 Adding Productions when Strict is True<br>
    9. EXI Compression<br>
        9.1 Blocks<br>
        9.2 Channels<br>
            9.2.1 Structure Channel<br>
            9.2.2 Value Channels<br>
        9.3 Compressed Streams<br>
    10. Conformance<br>
        10.1 EXI Stream Conformance<br>
        10.2 EXI Processor Conformance<br>
    </p>
    <h3>Appendices</h3><p class="toc">A References<br>
        A.1 Normative References<br>
        A.2 Other References<br>
    B Infoset Mapping<br>
        B.1 Document Information Item<br>
        B.2 Element Information Items<br>
        B.3 Attribute Information Item<br>
        B.4 Processing Instruction Information Item<br>
        B.5 Unexpanded Entity Reference Information item<br>
        B.6 Character Information item<br>
        B.7 Comment Information item<br>
        B.8 Document Type Declaration Information item<br>
        B.9 Unparsed Entity Information Item<br>
        B.10 Notation Information Item<br>
        B.11 Namespace Information Item<br>
    C XML Schema for EXI Options Document<br>
    D Initial Entries in String Table Partitions<br>
        D.1 Initial Entries in Uri Partition<br>
        D.2 Initial Entries in Prefix Partitions<br>
        D.3 Initial Entries in Local-Name Partitions<br>
    E Deriving
    Set of Characters
    from XML Schema Regular Expressions<br>
    F Content Coding and Internet Media Type<br>
        F.1 Content Coding<br>
        F.2 Internet Media Type<br>
    G Example Encoding (Non-Normative)<br>
    H Schema-informed Grammar Examples (Non-Normative)<br>
        H.1 Proto-Grammar Examples<br>
        H.2 Normalized Grammar Examples<br>
        H.3 Complete Grammar Examples<br>
    I Recent Specification Changes (Non-Normative)<br>
        I.1 Changes from First Edition Recommendation<br>
        I.2 Changes from previous versions of the document<br>
    J Acknowledgements (Non-Normative)<br>
    </p></div><hr><div class="body"><div class="div1">
    <h2>1. Introduction</h2><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, <span class="arrow"></span>EXI processors<span class="arrow"></span> are relatively simple and
    can be implemented on devices with limited capacity. </p><p>EXI is schema
    "informed", 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><span class="termdef">[Definition:]  A program module
    called an EXI processor, whether it is software or
    hardware, is used by application programs to encode their structured data
    into <span class="arrow"></span>EXI streams<span class="arrow"></span> and/or to decode
    <span class="arrow"></span>EXI streams<span class="arrow"></span> to make the structured
    data accessible.</span>
    
    The former and latter aforementioned roles of EXI processors are called <span class="termdef">[Definition:]  EXI stream encoder</span> and <span class="termdef">[Definition:]  EXI stream decoder</span>, respectively.
    
    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 [EXI Primer].
    </p><div class="div2">
    <h3>1.1 History and Design</h3><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 [XBC Measurement Methodologies]), and then, if it appeared
    suitable, to formulate a recommendation for a W3C format
    specification. The measurements results and analyses, are presented
    elsewhere [EXI Measurements Note]. 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 [XBC Properties].
    Those properties were derived from a very broad set of use cases also
    identified by the XBC working group [XBC Use Cases].
    </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 [Efficient XML], 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 [XML Information Set] 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></div><div class="div2">
    <h3>1.2 Notational Conventions and Terminology</h3><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 [IETF RFC 2119]. Other terminology used to describe the EXI
    format is defined in the body of this specification.
    </p><p>The term event and stream is used throughout this document to denote <span class="arrow"></span>EXI event<span class="arrow"></span> and <span class="arrow"></span>EXI stream<span class="arrow"></span> 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 italics. Grammar productions are
    represented as follows: </p><table width="100%"><tbody><tr><td width="5%"></td><td>
    LeftHandSide :  
    Terminal  NonTerminal</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 <span class="arrow"></span>event codes<span class="arrow"></span> 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">
    LeftHandSide :</td></tr><tr><td></td><td width="5%"></td><td width="75%">
    Terminal<sub> 1</sub>  NonTerminal<sub> 1</sub></td><td>EventCode<sub> 1</sub></td></tr><tr><td></td><td></td><td>
    Terminal<sub> 2</sub>  NonTerminal<sub> 2</sub></td><td>EventCode<sub> 2</sub></td></tr><tr><td></td><td></td><td>
    Terminal<sub> 3</sub>  NonTerminal<sub> 3</sub></td><td>EventCode<sub> 3</sub></td></tr><tr><td></td><td></td><td>...</td><td></td></tr><tr><td></td><td></td><td>
    Terminal<sub> n</sub>  NonTerminal<sub> n</sub></td><td>EventCode<sub> n</sub></td></tr></tbody></table><p>Section 8.1 Grammar Notation introduces additional notations for describing productions and <span class="arrow"></span>event codes<span class="arrow"></span> in grammars. Those additional notations facilitate concise representation of the EXI grammar system.
    </p><p>
    <span class="termdef">[Definition:]  
    In this document, the term qname is used to denote a
    QName<sup><small>XS2</small></sup>.
    </span>
    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%" span="1"></colgroup><colgroup span="1"></colgroup><thead><tr><th align="center">Wildcard</th><th>Definition</th></tr></thead><tbody><tr><td>    SE (*)</td><td>The terminal symbol that matches a start element (SE) event with any qname.</td></tr><tr><td>    SE (uri : *)</td><td>The terminal symbol that matches a start element (SE) event with any local-name in namespace uri.</td></tr><tr><td>    AT (*)</td><td>The terminal symbol that matches an attribute (AT) event with any qname.</td></tr><tr><td>    AT (uri : *)</td><td>The terminal symbol that matches an attribute (AT) event with any local-name in namespace uri.</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%" span="1"></colgroup><colgroup span="1"></colgroup><thead><tr><th align="center">Prefix</th><th>Namespace Name</th></tr></thead><tbody><tr><td>    exi</td><td>          
    http://www.w3.org/2009/exi
    </td></tr><tr><td>    xsd</td><td>          
    http://www.w3.org/2001/XMLSchema</td></tr><tr><td>    xsi</td><td>          
    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 ⌈x⌉ where x represents a real number denotes the ceiling of x, that is, the smallest integer greater than or equal to x.
    </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></div></div><div class="div1">
    <h2>2. Design Principles</h2><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><dl><dt class="label">General:</dt><dd><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></dd><dt class="label">Minimal:</dt><dd><p>To reach the broadest set of small, mobile and embedded applications, simple, elegant approaches are preferred to large, analytical or complex ones. </p></dd><dt class="label">Efficient:</dt><dd><p>EXI must be competitive with hand-optimized binary formats so it can be used by applications that require this level of efficiency. </p></dd><dt class="label">Flexible:</dt><dd><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></dd><dt class="label">Interoperable:</dt><dd><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 [XML Information Set], without significant subsetting or supersetting, in order to maintain interoperability with existing and prospective XML specifications.</p></dd></dl></div><div class="div1">
    <h2>3. Basic Concepts</h2><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 [XML Schema Structures]
      [XML Schema Datatypes], RELAX NG schemas [ISO/IEC 19757-2:2008], DTDs
    [XML 1.0]   [XML 1.1] 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 <span class="arrow"></span>EXI stream encoder<span class="arrow"></span> uses the grammar to map a stream of XML information items onto a smaller, lower entropy, stream of <span class="arrow"></span>events<span class="arrow"></span>. </p><p>The <span class="arrow"></span>EXI stream encoder<span class="arrow"></span> then represents the stream of events using a set of simple variable length codes called <span class="arrow"></span>event codes<span class="arrow"></span>. <span class="arrow"></span>Event codes<span class="arrow"></span> are similar to Huffman codes [Huffman Coding], 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 <span class="arrow"></span>EXI compression<span class="arrow"></span> algorithm, which replaces frequently occurring event patterns to further reduce size. </p></div><div class="div1">
    <h2>4. EXI Streams</h2><p><span class="termdef">[Definition:]  An EXI stream is an
    <span class="arrow"></span>EXI header<span class="arrow"></span>
    followed by an EXI body.</span> <span class="termdef">[Definition:]  The EXI body carries the content of the document, while the EXI header communicates the options used for encoding the EXI body.</span> Section
    5. EXI Header describes the <span class="arrow"></span>EXI header<span class="arrow"></span>.
    </p><p><span class="termdef">[Definition:]  The building block of an EXI body is an EXI event.</span> An EXI body consists of a sequence of EXI events representing an <span class="arrow"></span>EXI document<span class="arrow"></span> or an <span class="arrow"></span>EXI fragment<span class="arrow"></span>.
    </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 8. EXI 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.
    <span class="termdef">[Definition:]  
    EXI documents are EXI bodies with a single root element that conform to the Built-in Document Grammar (See 8.4.1 Built-in Document Grammar) or Schema-informed Document Grammar (See 8.5.1 Schema-informed Document Grammar).
    </span>
    <span class="termdef">[Definition:]  
    EXI fragments are EXI bodies with zero or more root elements that conform to the Built-in Fragment Grammar (See 8.4.2 Built-in Fragment Grammar) or Schema-informed Fragment Grammar (See 8.5.2 Schema-informed Fragment Grammar).
    </span>
    </p><p>
    <span class="termdef">[Definition:]  When schema information is available to describe the contents of an EXI body, such an EXI stream is a schema-informed EXI stream and the EXI body is interpreted according to the Schema-informed Document Grammar (See 8.5.1 Schema-informed Document Grammar) or Schema-informed Fragment Grammar (See 8.5.2 Schema-informed Fragment Grammar).</span>
    <span class="termdef">[Definition:]  Otherwise, an EXI stream is a schema-less EXI stream, and the EXI body is interpreted according to the Built-in Document Grammar (See 8.4.1 Built-in Document Grammar) or Built-in Fragment Grammar (See 8.4.2 Built-in Fragment Grammar).</span>
    </p><p>The following table summarizes the EXI event types and associated event content that occur in an EXI stream.
    <span class="termdef">[Definition:]  
    The content of an event consists of content items,
    </span>
    and the content items appear in an EXI stream in the order they are shown in the table
    following their respective <span class="arrow"></span>event codes<span class="arrow"></span> that
    each marks the start of an <span class="arrow"></span>event<span class="arrow"></span>.
    In addition, the table includes the grammar notation used to represent each <span class="arrow"></span>event<span class="arrow"></span> in this specification. Each <span class="arrow"></span>event<span class="arrow"></span> in an EXI stream participates in a mapping system that relates <span class="arrow"></span>events<span class="arrow"></span> 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 B Infoset Mapping describes the mapping system in detail.</p><table border="1"><caption>Table 4-1. 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> </td><td>SD</td><td rowspan="2">B.1 Document Information Item</td></tr><tr><td>End Document</td><td> </td><td>ED</td></tr><tr><td rowspan="3">Start Element</td><td rowspan="3">qname
    </td><td>SE ( qname )</td><td rowspan="4">B.2 Element Information Items</td></tr><tr><td>SE ( * )</td></tr><tr><td>
    SE ( uri : * )
    </td></tr><tr><td>End Element</td><td> </td><td>EE</td></tr><tr><td rowspan="3">Attribute</td><td rowspan="3">qname, value</td><td>AT ( qname )</td><td rowspan="3">B.3 Attribute Information Item</td></tr><tr><td>AT ( * )</td></tr><tr><td>
    AT ( uri : * )
    </td></tr><tr><td>Characters</td><td>value</td><td>CH</td><td>B.6 Character Information item</td></tr><tr><td>Namespace Declaration</td><td>
    
    uri
    , 
    prefix
    ,
    local-element-ns
    </td><td>NS</td><td>B.11 Namespace Information Item</td></tr><tr><td>Comment</td><td>
    text</td><td>CM</td><td>B.7 Comment Information item</td></tr><tr><td>Processing Instruction</td><td>
    name, text</td><td>PI</td><td>B.4 Processing Instruction Information Item</td></tr><tr><td>DOCTYPE</td><td>
    name, public, system, text</td><td>DT</td><td>B.8 Document Type Declaration Information item</td></tr><tr><td>Entity Reference</td><td>
    name</td><td>ER</td><td>B.5 Unexpanded Entity Reference Information item</td></tr><tr><td>Self Contained</td><td> </td><td>SC</td><td> </td></tr></tbody></table><p>Section
    6. Encoding EXI Streams describes the algorithm used to encode <span class="arrow"></span>events<span class="arrow"></span> in the EXI stream.
    As indicated in the table above, there are some event types that carry content with their <span class="arrow"></span>event<span class="arrow"></span> 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 local-element-ns 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 local-element-ns flag of all local NS events is false and the prefix of the element is set according to the prefix component of the element qname. The series of NS events associated with a particular element may include at most one NS event with its
    local-element-ns flag
     set to true. The uri of a NS event with its
    local-element-ns flag
     set to true MUST match the uri of the associated SE event.
    </p><p>The namespace of elements and attributes is specified as part of SE and AT events and hence namespace declarations can be omitted from the EXI stream if preservation of prefixes is not required by the applications. As prescribed by Table B-2 and Table B-11, [namespace attributes] representing namespace declarations are mapped to NS events and SHOULD NOT be represented by AT events. This also implies that the following AT events SHOULD NOT occur in EXI streams: (1) AT events with qname whose uri is "http://www.w3.org/2000/xmlns/"; (2) AT events with qname which has empty uri ("") and local name either of the form "xmlns" or "xmlns:*", where "*" represents a string with 0 or more characters.</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 <span class="arrow"></span>event codes<span class="arrow"></span> which identify the event type and start each event is described in 6.2 Representing Event Codes.
    Each item in the event content has a
    datatype representation
    associated with it as shown in the following table. The content of each <span class="arrow"></span>event<span class="arrow"></span>, 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%"><caption>Table 4-2. Datatype representations of event content items</caption><colgroup width="20%" span="1"></colgroup><colgroup width="30%" span="1"></colgroup><colgroup width="50%" span="1"></colgroup><thead><tr><th>Content item</th><th>Used in</th><th>
    Datatype representation
    </th></tr></thead><tbody><tr><td id="key-nameContentItem">
    name</td><td>PI, DT, ER</td><td>
    7.1.10 String</td></tr><tr><td id="key-prefixContentItem">
    prefix</td><td>NS</td><td>
    7.1.10 String</td></tr><tr><td id="key-indicatorContentItem">
    local-element-ns
    </td><td>NS</td><td>
    7.1.2 Boolean</td></tr><tr><td id="key-publicContentItem">
    public</td><td>DT</td><td>
    7.1.10 String</td></tr><tr><td id="key-qnameContentItem">
    qname</td><td>SE, AT</td><td>
    7.1.7 QName</td></tr><tr><td id="key-systemContentItem">
    system</td><td>DT</td><td>
    7.1.10 String</td></tr><tr><td id="key-textContentItem">
    text</td><td>CM, PI, DT</td><td>
    7.1.10 String</td></tr><tr><td id="key-uriContentItem">
    uri</td><td>NS</td><td>
    7.1.10 String</td></tr><tr><td id="key-valueContentItem">
    value</td><td>CH, AT</td><td>According to the schema datatype (see
    7. Representing Event Content) if any is in effect, otherwise 7.1.10 String</td></tr></tbody></table><p>The datatype representation
    used for each <span class="arrow"></span>value<span class="arrow"></span> content item depends on the schema
    datatype<sup><small>XS2</small></sup>
    if any that is in effect for that <span class="arrow"></span>value<span class="arrow"></span>.
    The String datatype representation (see 7.1.10 String)
    is used for <span class="arrow"></span>values<span class="arrow"></span> 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
    7. Representing Event Content describes how each of the types listed above are encoded in an EXI stream. </p><div class="note"><p class="prefix">Note:</p>
    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.
    </div></div><div class="div1">
    <h2>5. EXI Header</h2><p>
    Each <span class="arrow"></span>EXI stream<span class="arrow"></span> begins with an EXI header.
    <span class="termdef">[Definition:]  
    The EXI header
    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.
    </span>
    The EXI header has the following structure:
    </p><table border="1" rules="cols"><tbody><tr><td align="center" rowspan="2">
    <span class="arrow"></span>
     [ EXI Cookie ] 
    <span class="arrow"></span>
    
    </td><td align="center" rowspan="2">
    <span class="arrow"></span>
     Distinguishing Bits 
    <span class="arrow"></span></td><td align="center">
     Presence Bit 
    </td><td align="center">
    <span class="arrow"></span>
     EXI Format 
    <span class="arrow"></span>
    </td><td align="center" rowspan="2">
     [<span class="arrow"></span>EXI Options<span class="arrow"></span>] 
    </td><td align="center" rowspan="2">
     [Padding Bits] 
    </td></tr><tr><td align="center">
     for EXI Options 
    </td><td align="center">
    <span class="arrow"></span>
     Version 
    <span class="arrow"></span>
    </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 <span class="arrow"></span>Distinguishing Bits<span class="arrow"></span>. The presence and absence is indicated by the value 1 and 0, respectively.
    </p><p>When the <span class="arrow"></span>compression<span class="arrow"></span> option is true, or the <span class="arrow"></span>alignment<span class="arrow"></span> option is <span class="arrow"></span>byte-alignment<span class="arrow"></span> or <span class="arrow"></span>pre-compression<span class="arrow"></span>,
    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 <span class="arrow"></span>bit-packed<span class="arrow"></span>.
    The padding bits field
    if it is present
    can contain any values of bits as its contents.
    </p><p>
    The details of the
    <span class="arrow"></span>EXI Cookie<span class="arrow"></span>,
    
    <span class="arrow"></span>Distinguishing Bits<span class="arrow"></span>, <span class="arrow"></span>EXI Format Version<span class="arrow"></span> and <span class="arrow"></span>EXI Options<span class="arrow"></span> are described in the following sections.
    </p><div class="div2">
    <h3>5.1 EXI Cookie</h3><p>
    <span class="termdef">[Definition:]  
    An <span class="arrow"></span>EXI header<span class="arrow"></span> MAY start with an EXI Cookie,
    which is a four byte field that serves to indicate that the stream of which it is a part is an EXI stream.</span> The four byte field consists of four characters
    " $ " , " E ", " X " and " I "
    
    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> </sup>$<sub> </sub>'</td><td align="center" class="bitcell">'<sup> </sup>E<sub> </sub>'</td><td align="center" class="bitcell">'<sup> </sup>X<sub> </sub>'</td><td align="center" class="bitcell">'<sup> </sup>I<sub> </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 <span class="arrow"></span>Distinguishing Bits<span class="arrow"></span>,  whose role is more narrowly focused on distinguishing EXI streams from XML documents.
    </p></div><div class="div2">
    <h3>5.2 Distinguishing Bits</h3><p>
    <span class="termdef">[Definition:]  
    The second part in the EXI header is the Distinguishing Bits,
    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.</span>
    </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 <span class="arrow"></span>EXI cookie<span class="arrow"></span>.
    
    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 [XML 1.0]   [XML 1.1].
    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></div><div class="div2">
    <h3>5.3 EXI Format Version</h3><p><span class="termdef">[Definition:]  
    The fourth part in the EXI header is the EXI Format Version, which identifies the version of the EXI format being used.</span>
    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 <span class="arrow"></span>EXI processor<span class="arrow"></span> 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>
    1. Read next 4 bits as an unsigned integer value.
    2. Add the value that was just read to the version number.
    3. 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.
    <p>The following are example EXI format version numbers.</p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 5-1. </span>EXI Format Version Examples</div><table border="1"><thead><tr><th width="200">EXI Format Version Field</th><th width="200">Description</th></tr></thead><tbody><tr><td>  1 0000</td><td>  Preview version 1</td></tr><tr><td>  0 0000</td><td>  Final version 1</td></tr><tr><td>  0 1110</td><td>  Final version 15</td></tr><tr><td>  0 1111 0000</td><td>  Final version 16</td></tr><tr><td>  0 1111 0001</td><td>  Final version 17</td></tr></tbody></table></div><p><span class="arrow"></span>EXI processors<span class="arrow"></span> conforming with the final version of this specification MUST use the 5-bit value 0 0000 as the version number.</p></div><div class="div2"> <h3>5.4 EXI Options</h3><p><span class="termdef">[Definition:]  The fifth part of the EXI header is the EXI Options, which provides a way to specify the options used to encode the body of the EXI stream</span>. <span class="termdef">[Definition:]   The EXI Options are represented as an EXI Options document, which is an XML document encoded using the EXI format described in this specification. </span> 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 <span class="arrow"></span>Distinguishing Bits<span class="arrow"></span>. 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> <span class="arrow"></span>EXI processors<span class="arrow"></span> MAY provide external means for applications or users to specify EXI Options when the EXI Options document is absent. Such <span class="arrow"></span>EXI processors<span class="arrow"></span> 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"><caption>Table 5-1. EXI Options in Options Document</caption><thead><tr><th>EXI Option</th><th>Description</th><th>Default Value</th></tr></thead><tbody><tr><td> <span class="arrow"></span>alignment<span class="arrow"></span> </td><td> Alignment of <span class="arrow"></span>event codes<span class="arrow"></span> and <span class="arrow"></span>content items<span class="arrow"></span> </td><td> <span class="arrow"></span>bit-packed<span class="arrow"></span> </td></tr><tr><td><span class="arrow"></span>compression<span class="arrow"></span></td><td>EXI compression is used to achieve better compactness</td><td>false</td></tr><tr><td><span class="arrow"></span>strict<span class="arrow"></span></td><td>Strict interpretation of schemas is used to achieve better compactness</td><td>false</td></tr><tr><td><span class="arrow"></span>fragment<span class="arrow"></span></td><td>Body is encoded as an <span class="arrow"></span>EXI fragment<span class="arrow"></span> instead of an <span class="arrow"></span>EXI document<span class="arrow"></span> </td><td>false</td></tr><tr><td><span class="arrow"></span>preserve<span class="arrow"></span></td><td> Specifies whether the support for the preservation of comments, pis, etc. is each enabled </td><td>all false</td></tr><tr><td><span class="arrow"></span>selfContained<span class="arrow"></span></td><td>Enables self-contained elements</td><td>false</td></tr><tr><td><span class="arrow"></span>schemaId<span class="arrow"></span></td><td>Identify the schema information, if any, used to encode the body</td><td> no default value </td></tr><tr><td><span class="arrow"></span> datatypeRepresentationMap <span class="arrow"></span></td><td> Specify alternate datatype representations for typed <span class="arrow"></span>values<span class="arrow"></span> in the <span class="arrow"></span>EXI body<span class="arrow"></span> </td><td> no default value </td></tr><tr><td><span class="arrow"></span>blockSize<span class="arrow"></span></td><td>Specifies the block size used for EXI compression</td><td>1,000,000</td></tr><tr><td> <span class="arrow"></span>valueMaxLength<span class="arrow"></span> </td><td> Specifies the maximum string length of <span class="arrow"></span>value<span class="arrow"></span> content items to be considered for addition to the string table. </td><td> unbounded </td></tr><tr><td> <span class="arrow"></span>valuePartitionCapacity<span class="arrow"></span> </td><td> Specifies the total capacity of value partitions in a string table </td><td> unbounded </td></tr><tr><td><span class="arrow"></span>[user defined meta-data]<span class="arrow"></span></td><td>User defined meta-data may be added</td><td>no default value</td></tr></tbody></table><p>Appendix C XML Schema for EXI Options Document provides an XML Schema describing <span class="arrow"></span>the EXI Options document<span class="arrow"></span>. This schema is designed to produce smaller headers for option combinations used when compactness is critical.</p><p> The <span class="arrow"></span>EXI Options document<span class="arrow"></span> is represented as an <span class="arrow"></span>EXI body<span class="arrow"></span> 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><div class="reprdef"><div class="reprHeader"><span class="reprdef">Header options used for encoding the <span class="arrow"></span>EXI Options document<span class="arrow"></span></span></div><div class="reprBody"><pre> <header xmlns="http://www.w3.org/2009/exi"> <strict/> </header> </pre></div></div><p>Note that this specification does not require <span class="arrow"></span>EXI processors<span class="arrow"></span> to read and process the schema prescribed for EXI options document (C XML Schema for EXI Options Document), 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 8.5 Schema-informed Grammars describes the system to derive schema-informed grammars from XML Schemas. </p><p>Below is a brief description of each EXI option.</p><p><span class="termdef">[Definition:]  The alignment option is used to control the alignment of <span class="arrow"></span>event codes<span class="arrow"></span> and <span class="arrow"></span>content items<span class="arrow"></span>.</span> The value is one of <span class="arrow"></span>bit-packed<span class="arrow"></span>, <span class="arrow"></span>byte-alignment<span class="arrow"></span> or <span class="arrow"></span>pre-compression<span class="arrow"></span>, of which <span class="arrow"></span>bit-packed<span class="arrow"></span> is the default value assumed when the "alignment" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span>. The option values <span class="arrow"></span>byte-alignment<span class="arrow"></span> and <span class="arrow"></span>pre-compression<span class="arrow"></span> are effected when "byte" and "pre-compress" elements are present in the EXI Options document, respectively. When the value of <span class="arrow"></span>compression option<span class="arrow"></span> is set to true, alignment of the EXI Body is governed by the rules specified in 9. EXI 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><span class="termdef">[Definition:]  The alignment option value bit-packed indicates that the <span class="arrow"></span>event codes<span class="arrow"></span> and associated content are packed in bits without any padding in-between.</span> </p><p><span class="termdef">[Definition:]  The alignment option value byte-alignment indicates that the <span class="arrow"></span>event codes<span class="arrow"></span> and associated content are aligned on byte boundaries.</span> 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> <span class="termdef">[Definition:]  The alignment option value pre-compression indicates that all steps involved in compression (see section 9. EXI Compression) are to be done with the exception of the final step of applying the DEFLATE algorithm.</span> 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> <span class="termdef">[Definition:]  The compression option is a Boolean used to increase compactness using additional computational resources.</span> The default value "false" is assumed when the "compression" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span> whereas its presence denotes the value "true". When set to true, the <span class="arrow"></span>event codes<span class="arrow"></span> and associated content are compressed according to 9. EXI Compression regardless of the <span class="arrow"></span>alignment<span class="arrow"></span> option value. As mentioned above, the "compression" element MUST NOT appear in an EXI options document when the "alignment" element is present. </p><p> <span class="termdef">[Definition:]  The strict option 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.</span> The default value "false" is assumed when the "strict" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span> 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 8.5.4.4.2 Adding Productions when Strict is True describes some additional restrictions consequential of the use of this option. The "strict" element MUST NOT appear in an <span class="arrow"></span>EXI options document<span class="arrow"></span> when one of "dtd", "prefixes", "comments", "pis" or "selfContained" element is present in the same options document. </p><p> <span class="termdef">[Definition:]  The fragment option is a Boolean that indicates whether the <span class="arrow"></span>EXI body<span class="arrow"></span> is an <span class="arrow"></span>EXI document<span class="arrow"></span> or an <span class="arrow"></span>EXI fragment<span class="arrow"></span>.</span> When set to true, the <span class="arrow"></span>EXI body<span class="arrow"></span> is an <span class="arrow"></span>EXI fragment<span class="arrow"></span>. Otherwise, the <span class="arrow"></span>EXI body<span class="arrow"></span> is an <span class="arrow"></span>EXI document<span class="arrow"></span>. The default value "false" is assumed when the "fragment" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span> whereas its presence denotes the value "true". </p><p><span class="termdef">[Definition:]  The preserve option 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. </span> Section 6.3 Fidelity Options 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 <span class="arrow"></span>EXI options document<span class="arrow"></span> 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><span class="termdef">[Definition:]  The selfContained option is a Boolean used to enable the use of self-contained elements in the EXI stream.</span> 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 <span class="arrow"></span>EXI options document<span class="arrow"></span> 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 <span class="arrow"></span>EXI Options document<span class="arrow"></span> whereas its presence denotes the value "true". </p><p><span class="termdef">[Definition:]  The schemaId option may be used to identify the schema information used for processing the EXI body.</span> When the "schemaId" element in the <span class="arrow"></span>EXI options document<span class="arrow"></span> contains the xsi:nil attribute with its value set to true, no schema information is used for processing the EXI body (i.e. a <span class="arrow"></span>schema-less EXI stream<span class="arrow"></span>). 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><span class="termdef">[Definition:]  The datatypeRepresentationMap option specifies an alternate set of datatype representations for typed <span class="arrow"></span>values<span class="arrow"></span> in the <span class="arrow"></span>EXI body<span class="arrow"></span> as described in 7.4 Datatype Representation Map.</span> When there are no "datatypeRepresentationMap" elements in the <span class="arrow"></span>EXI Options document<span class="arrow"></span>, 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 6.3 Fidelity Options), or when the <span class="arrow"></span>EXI stream<span class="arrow"></span> is a <span class="arrow"></span>schema-less EXI stream.<span class="arrow"></span> </p><p><span class="termdef">[Definition:]  The blockSize option specifies the block size used for EXI compression.</span> When the "blockSize" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span>, 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> <span class="termdef">[Definition:]   The valueMaxLength option specifies the maximum length of <span class="arrow"></span>value<span class="arrow"></span> content items to be considered for addition to the string table. </span> The default value "unbounded" is assumed when the "valueMaxLength" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span>. </p><p> <span class="termdef">[Definition:]   The valuePartitionCapacity option specifies the maximum number of <span class="arrow"></span>value<span class="arrow"></span> content items in the string table at any given time. </span> The default value "unbounded" is assumed when the "valuePartitionCapacity" element is absent in the <span class="arrow"></span>EXI Options document<span class="arrow"></span>. Section 7.3.3 Partitions Optimized for Frequent use of String Literals specifies the behavior of the string table when this capacity is reached. </p><p> <span class="termdef">[Definition:]   The user defined meta-data conveys auxiliary information that applications may use to facilitate interpretation of the EXI stream. </span> 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 <span class="arrow"></span>alignment<span class="arrow"></span> option. </p></div></div><div class="div1"> <h2>6. Encoding EXI Streams</h2><p>The rules for encoding a series of <span class="arrow"></span>events<span class="arrow"></span> as an <span class="arrow"></span>EXI stream<span class="arrow"></span> are very simple and are driven by a declarative set of grammars that describes the structure of an <span class="arrow"></span>EXI stream<span class="arrow"></span>. Every <span class="arrow"></span>event<span class="arrow"></span> in the stream is encoded using the same set of encoding rules, which are summarized as follows: </p>
    1. Get the next event data to be encoded
    2. If fidelity options (see 6.3 Fidelity Options) indicate this event type is not processed, go to step 1
    3. Use the grammars to determine the <span class="arrow"></span>event code<span class="arrow"></span> of the <span class="arrow"></span>event<span class="arrow"></span>
    4. Encode the <span class="arrow"></span>event code<span class="arrow"></span> followed by the event content (see Table 4-1)
    5. Evaluate the grammar production matched by the <span class="arrow"></span>event<span class="arrow"></span>
    6. Repeat until the End Document (ED) event is encoded
    <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 <span class="arrow"></span>built-in element grammar<span class="arrow"></span> (see 8.4.3 Built-in Element Grammar) or a <span class="arrow"></span>schema-informed element fragment grammar<span class="arrow"></span> (see 8.5.3 Schema-informed Element Fragment Grammar), the remaining attribute (AT) events can occur in any order. Otherwise, when the grammar in effect is a <span class="arrow"></span>schema-informed element grammar<span class="arrow"></span> or a <span class="arrow"></span>schema-informed type grammar<span class="arrow"></span> (see 8.5.4 Schema-informed Element and Type Grammars), 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 qname local-name then by qname uri for achieving better compactness, where a qname is a <span class="arrow"></span>qname<span class="arrow"></span> of an attribute. </p><div class="note"><p class="prefix">Note:</p> Under certain circumstances, 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 8.4.3 Built-in Element Grammar for details. </div><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><span class="termdef">[Definition:]  An event code 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.</span> (See 8.2 Grammar Event Codes for more description of event codes.) </p><p>Section 6.1 Determining Event Codes describes in detail how the grammar is used to determine the event code of an <span class="arrow"></span>event<span class="arrow"></span>. Section 6.2 Representing Event Codes describes in detail how event codes are represented as bits. Section 6.3 Fidelity Options describes available fidelity options and how they affect the EXI stream. Section 7. Representing Event Content describes how the typed event contents are represented as bits. </p><div class="div2"> <h3>6.1 Determining Event Codes</h3><p>The structure of an EXI stream is described by the EXI grammars, which are formally specified in section 8. EXI Grammars. Each grammar defines which events are permitted to occur at any given point in the EXI stream and provides a pre-assigned <span class="arrow"></span>event code<span class="arrow"></span> 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 <span class="arrow"></span>event code<span class="arrow"></span> for each one. See 8.5.1 Schema-informed Document Grammar for the process used for generating the grammar productions below from the schema. </p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 6-1. </span>Example productions with event codes</div><table width="95%"><thead><tr><th colspan="4"> </th></tr><tr><th align="left" colspan="3">  Syntax</th><th align="left">Event Code</th></tr></thead><tbody><tr><td width="5%"></td><td colspan="3">DocContent</td></tr><tr><td></td><td width="5%"></td><td width="75%">SE ("A") DocEnd</td><td>0</td></tr><tr><td></td><td width="5%"></td><td width="75%">SE ("B") DocEnd</td><td>1</td></tr><tr><td></td><td width="5%"></td><td width="75%">SE ("C") DocEnd</td><td>2</td></tr><tr><td></td><td width="5%"></td><td width="75%">SE ("D") DocEnd</td><td>3</td></tr><tr><td></td><td width="5%"></td><td width="75%">SE (*) DocEnd</td><td>4</td></tr><tr><td></td><td></td><td>DT DocContent</td><td>5.0</td></tr><tr><td></td><td></td><td>CM DocContent</td><td>5.1.0</td></tr><tr><td></td><td></td><td>PI DocContent</td><td>5.1.1</td></tr></tbody></table></div><p>At the point in an EXI stream where the above grammar productions are in effect, the <span class="arrow"></span>event code<span class="arrow"></span> 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></div><div class="div2"> <h3>6.2 Representing Event Codes</h3><p>Each <span class="arrow"></span>event code<span class="arrow"></span> is represented by a sequence of 1 to 3 parts that uniquely identify an event. <span class="arrow"></span>Event code<span class="arrow"></span> parts are encoded in order starting with the first part followed by subsequent parts.</p><p> The i-th part of an <span class="arrow"></span>event code<span class="arrow"></span> is encoded as an n-bit unsigned integer (7.1.9 n-bit Unsigned Integer), where n is ⌈ log<sub> 2</sub> m ⌉ and m is the number of distinct values used as the i-th part of its own and all its sibling event codes in the current grammar. Two <span class="arrow"></span>event codes<span class="arrow"></span> are siblings at the i-th part if and only if they share the same values in all preceding parts. All <span class="arrow"></span>event codes<span class="arrow"></span> are siblings at the first part. </p><p> If 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 = 0 bytes). </p><p>For example, the eight <span class="arrow"></span>event codes<span class="arrow"></span> shown in the DocContent 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 <span class="arrow"></span>event codes<span class="arrow"></span>. Therefore, the first part can be encoded as an n-bit unsigned integer where n = ⌈ log<sub> 2</sub> 6 ⌉ = 3. In the same fashion, the second and third part (if present) are represented as n-bit unsigned integers where n is ⌈ log<sub> 2</sub> 2 ⌉ = 1  and ⌈ log<sub> 2</sub> 2 ⌉ = 1  respectively. </p><p> When the value of the <span class="arrow"></span>compression option<span class="arrow"></span> is false and <span class="arrow"></span>bit-packed<span class="arrow"></span> alignment is used, n-bit unsigned integers are represented using n bits. The first table below illustrates how the <span class="arrow"></span>event codes<span class="arrow"></span> of each event matched by the DocContent grammar above are represented in this case.</p><p> When the value of <span class="arrow"></span>compression option<span class="arrow"></span> is true, or either <span class="arrow"></span>byte-alignment<span class="arrow"></span> or <span class="arrow"></span>pre-compression<span class="arrow"></span> alignment option is used, n-bit unsigned integers are represented using the minimum number of bytes required to store n bits. The second table below illustrates how the <span class="arrow"></span>event codes<span class="arrow"></span> of each event matched by the DocContent grammar above are represented in this case. </p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 6-2. </span>Example event code encoding</div><p></p><table border="1" width="95%"><caption>Table 6-1. Example event code encoding when EXI compression is not in effect and <span class="arrow"></span>bit-packed<span class="arrow"></span> alignment option is used </caption><colgroup span="1"></colgroup><colgroup span="3" align="center"></colgroup><colgroup span="1"></colgroup><colgroup align="center" span="1"></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> </td><td> </td><td>000</td><td>3</td></tr><tr><td>SE ("B")</td><td>1</td><td> </td><td> </td><td>001</td><td>3</td></tr><tr><td>SE ("C")</td><td>2</td><td> </td><td> </td><td>010</td><td>3</td></tr><tr><td>SE ("D")</td><td>3</td><td> </td><td> </td><td>011</td><td>3</td></tr><tr><td>SE (*)</td><td>4</td><td>  </td><td> </td><td>100 </td><td>3</td></tr><tr><td>DT</td><td>5</td><td>0</td><td> </td><td>101  0</td><td>4</td></tr><tr><td>CM</td><td>5</td><td>1</td><td>0</td><td>101  1  0</td><td>5</td></tr><tr><td>PI</td><td>5</td><td>1</td><td>1</td><td>101  1  1</td><td>5</td></tr></tbody></table><table border="1" width="95%"><colgroup span="1"></colgroup><colgroup span="3" align="center"></colgroup><colgroup span="1"></colgroup><colgroup span="1"></colgroup><tbody><tr><td width="30%"># distinct values (m)</td><td>6</td><td>2</td><td>2</td><td width="40%"> </td><td width="10%"> </td></tr><tr><td><table border="0"><tr><td># bits per part</td></tr><tr><td>  ⌈ log <sub>2</sub> m ⌉</td></tr></table></td><td>3</td><td>1</td><td>1</td><td> </td><td> </td></tr></tbody></table><p></p><table border="1" width="95%"><caption>Table 6-2. Example event code encoding when EXI compression is in effect, or either <span class="arrow"></span>byte-alignment<span class="arrow"></span> or <span class="arrow"></span>pre-compression<span class="arrow"></span> alignment option is used </caption><colgroup span="1"></colgroup><colgroup span="3" align="center"></colgroup><colgroup span="1"></colgroup><colgroup align="center" span="1"></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> </td><td> </td><td>00000000</td><td>1</td></tr><tr><td>SE ("B")</td><td>1</td><td> </td><td> </td><td>00000001</td><td>1</td></tr><tr><td>SE ("C")</td><td>2</td><td> </td><td> </td><td>00000010</td><td>1</td></tr><tr><td>SE ("D")</td><td>3</td><td> </td><td> </td><td>00000011</td><td>1</td></tr><tr><td>SE (*)</td><td>4</td><td> </td><td> </td><td>00000100 </td><td>1</td></tr><tr><td>DT</td><td>5</td><td>0</td><td> </td><td>00000101  00000000</td><td>2</td></tr><tr><td>CM</td><td>5</td><td>1</td><td>0</td><td>00000101  00000001  00000000</td><td>3</td></tr><tr><td>PI</td><td>5</td><td>1</td><td>1</td><td>00000101  00000001  00000001</td><td>3</td></tr></tbody></table><table border="1" width="95%"><colgroup span="1"></colgroup><colgroup span="3" align="center"></colgroup><colgroup span="1"></colgroup><colgroup span="1"></colgroup><tbody><tr><td width="30%"># distinct values (m)</td><td>6</td><td>2</td><td>2</td><td width="40%"> </td><td width="10%"> </td></tr><tr><td><table border="0"><tr><td># bytes per part</td></tr><tr><td>  ⌈ (log <sub>2</sub> m) / 8 ⌉</td></tr></table></td><td>1</td><td>1</td><td>1</td><td> </td><td> </td></tr></tbody></table></div></div><div class="div2"> <h3>6.3 Fidelity Options</h3><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 [SOAP 1.2] 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 <span class="arrow"></span>preserve option<span class="arrow"></span> 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 <span class="arrow"></span>preserve option<span class="arrow"></span> to specify the set of fidelity options they require. As specified in section 8.3 Pruning Unneeded Productions, 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 <span class="arrow"></span>EXI stream<span class="arrow"></span>. </p><table border="1"><caption>Table 6-3. 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 <span class="arrow"></span>value<span class="arrow"></span> content items </td></tr></tbody></table><p> When qualified names [Namespaces in XML 1.0]   [Namespaces in XML 1.1] are used in the <span class="arrow"></span>values<span class="arrow"></span> 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 true. </p><p>See section 4. EXI Streams for the definition of EXI event types and their associated <span class="arrow"></span>content items<span class="arrow"></span>. </p></div></div><div class="div1"> <h2>7. Representing Event Content</h2><p> The <span class="arrow"></span>event code<span class="arrow"></span> of each event in an EXI body is represented as a sequence of n-bit unsigned integers (7.1.9 n-bit Unsigned Integer). See section 6.2 Representing Event Codes for the description of the event code representation. The <span class="arrow"></span>content items<span class="arrow"></span> of an event are represented according to their datatype representations (see Table 4-2). In the absence of an associated datatype representation, attribute and character <span class="arrow"></span>values<span class="arrow"></span> are represented as String (7.1.10 String). </p><p><span class="termdef">[Definition:]  EXI defines a minimal set of datatype representations called Built-in EXI datatype representations that define how <span class="arrow"></span>content items<span class="arrow"></span> as well as the parts of an <span class="arrow"></span>event code<span class="arrow"></span> are represented in EXI streams.</span> When the <span class="arrow"></span>Preserve.lexicalValues<span class="arrow"></span> option is false, <span class="arrow"></span>values<span class="arrow"></span> are represented using built-in EXI datatype representations (see 7.1 Built-in EXI Datatype Representations) or user-defined datatype representations (see 7.4 Datatype Representation Map) associated with the schema datatypes<sup><small>XS2</small></sup>. Otherwise, <span class="arrow"></span>values<span class="arrow"></span> are represented as Strings with restricted character sets (see Table 7-2 below).</p><p> The following Table 7-1 lists the built-in EXI datatype representations, associated EXI datatype identifiers and the XML Schema built-in datatypes<sup><small>XS2</small></sup> each EXI datatype representation is used to represent by default. When that default association is in effect, datatypes derived from the XML Schema datatypes are also represented according to the associated <span class="arrow"></span>built-in EXI datatype representation<span class="arrow"></span>. When there are more than one XML Schema datatypes from which a datatype is derived directly or indirectly, the closest ancestor is used to determine the <span class="arrow"></span>built-in EXI datatype representation<span class="arrow"></span>. For example, a value of XML Schema datatype xsd:int is represented according to the same <span class="arrow"></span>built-in EXI datatype representation<span class="arrow"></span> 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><table border="1"><caption>Table 7-1. 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"> Binary </td><td> exi:base64Binary </td><td colspan="2">base64Binary</td></tr><tr><td> exi:hexBinary </td><td colspan="2">hexBinary</td></tr><tr><td> Boolean </td><td> exi:boolean </td><td colspan="2">boolean</td></tr><tr><td rowspan="8"> Date-Time </td><td> exi:dateTime </td><td colspan="2">dateTime</td></tr><tr><td> exi:time </td><td colspan="2">time</td></tr><tr><td> exi:date </td><td colspan="2">date</td></tr><tr><td> exi:gYearMonth </td><td colspan="2">gYearMonth</td></tr><tr><td> exi:gYear </td><td colspan="2">gYear</td></tr><tr><td> exi:gMonthDay </td><td colspan="2">gMonthDay</td></tr><tr><td> exi:gDay </td><td colspan="2">gDay</td></tr><tr><td> exi:gMonth </td><td colspan="2">gMonth</td></tr><tr><td> Decimal </td><td> exi:decimal </td><td colspan="2">decimal</td></tr><tr><td> Float </td><td> exi:double </td><td colspan="2">float, double</td></tr><tr><td> Integer </td><td> exi:integer </td><td colspan="2"> integer </td></tr><tr><td> String </td><td> exi:string </td><td colspan="2"> string, anySimpleType and all types directly derived by union </td></tr><tr><td> n-bit Unsigned Integer </td><td> </td><td colspan="2"> Not associated with any datatype directly, but used by Integer datatype representation for some bounded integers (see 7.1.5 Integer) </td></tr><tr><td> Unsigned Integer </td><td> </td><td colspan="2"> Not associated with any datatype directly, but used by Integer datatype representation for unsigned integers (see 7.1.5 Integer) </td></tr><tr><td> List </td><td> </td><td colspan="2">All types directly derived by list, including NMTOKENS, IDREFS and ENTITIES</td></tr><tr><td> QName </td><td> </td><td colspan="2"> xsi:type attribute values when <span class="arrow"></span>Preserve.lexicalValues<span class="arrow"></span> option value is false  </td></tr></tbody></table><p>Each EXI datatype identifier above is a <span class="arrow"></span>qname<span class="arrow"></span> that uniquely identifies one of the <span class="arrow"></span>built-in EXI datatype representations.<span class="arrow"></span> EXI datatype identifiers are used in <span class="arrow"></span>Datatype Representation Maps<span class="arrow"></span> to change the datatype representations used for specific schema datatypes<sup><small>XS2</small></sup> and their sub-types. Only <span class="arrow"></span>built-in EXI datatype representations<span class="arrow"></span> that have been assigned identifiers are usable in <span class="arrow"></span>Datatype Representation Maps<span class="arrow"></span>. </p><p>When the <span class="arrow"></span>Preserve.lexicalValues<span class="arrow"></span> option is true, all <span class="arrow"></span>values<span class="arrow"></span> are represented as Strings. The table below defines restricted character sets for several of the built-in EXI datatypes. Each <span class="arrow"></span>value<span class="arrow"></span> 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%"><caption>Table 7-2. Restricted Character Sets for Built-in EXI Datatype Representations </caption><colgroup width="20%" span="1"></colgroup><colgroup width="80%" span="1"></colgroup><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><tr><td> exi:string </td><td>no restricted character set</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 restricted character set for a value that would be represented as an EXI enumeration is the restricted character set of the EXI datatype representation of the enumeration base type.</p><p>The rules used to represent values of String depend on the <span class="arrow"></span>content items<span class="arrow"></span> to which the values belong. There are certain <span class="arrow"></span>content items<span class="arrow"></span> whose value representation involve the use of string tables while other <span class="arrow"></span>content items<span class="arrow"></span> are represented using the encoding rule described in 7.1.10 String without involvement of string tables. The <span class="arrow"></span>content items<span class="arrow"></span> that use string tables and how each of such <span class="arrow"></span>content items<span class="arrow"></span> uses string tables to represent their values are described in 7.3 String Table.</p><p>Schemas can provide one or more enumerated values for datatypes. When the <span class="arrow"></span>Preserve.lexicalValues<span class="arrow"></span> 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 7.2 Enumerations. Datatypes that are directly 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 either a list datatype<sup><small>XS2</small></sup>, or one of QName, Notation or a datatype derived therefrom by restriction are also not affected by enumerated values if any. </p><div class="div2"> <h3>7.1 Built-in EXI Datatype Representations</h3><p>The following sections describe the <span class="arrow"></span>built-in EXI datatype representations<span class="arrow"></span> used for representing <span class="arrow"></span>event codes<span class="arrow"></span> and <span class="arrow"></span>content items<span class="arrow"></span> in EXI streams. Unless otherwise stated, individual items in an EXI stream are packed into bytes most significant bit first. </p><div class="div3"> <h4>7.1.1 Binary</h4><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 7.1.6 Unsigned Integer). </p></div><div class="div3"> <h4>7.1.2 Boolean</h4><p>When the associated schema datatype is directly or indirectly derived from xsd:boolean and pattern facets are available in the schema datatype, the Boolean datatype representation is a n-bit unsigned integer (7.1.9 n-bit Unsigned Integer), where n 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>Otherwise, the Boolean datatype representation is a n-bit unsigned integer (7.1.9 n-bit Unsigned Integer), where n is one (1). The value zero (0) represents false and the value one (1) represents true.</p> </div><div class="div3"> <h4>7.1.3 Decimal</h4><p>The Decimal datatype representation is a Boolean sign (see 7.1.2 Boolean) followed by two Unsigned Integers (see 7.1.6 Unsigned Integer). 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><div class="note"><p class="prefix">Note:</p> Some implementers may assume and try to find a parallel between Decimal and 7.1.5 Integer datatype representations. However, note that there are enough discrepancies that may make sharing implementation codes between the two more involved than some would have presumed. In particular 7.1.5 Integer cannot represent minus zero. </div></div><div class="div3"> <h4>7.1.4 Float</h4><p>The Float datatype representation is two consecutive Integers (see 7.1.5 Integer). 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. Examples of such productions are those whose terminal symbol on the right-hand side is AT(qname) [untyped value], AT(*) [untyped value] or CH [untyped value] (See 8.5.4.4.1 Adding Productions when Strict is False). </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>
    1. Retrieve the mantissa value using the procedure described in 7.1.5 Integer.
    2. Retrieve the exponent value using the procedure described in 7.1.5 Integer.
    3. 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 m × 10<sup>e</sup> where m is the mantissa and e is the exponent obtained in the preceding steps.
    </div><div class="div3"> <h4>7.1.5 Integer</h4><p>The Integer datatype representation supports signed integer numbers of arbitrary magnitude. The specific representation used depends on the facet<sup><small>XS2</small></sup> values of the associated schema datatype<sup><small>XS2</small></sup> as follows. </p><p> If the associated schema datatype is directly or indirectly derived from xsd:integer and the bounded range determined by its minInclusive<sup><small>XS2</small></sup>, minExclusive<sup><small>XS2</small></sup>, maxInclusive<sup><small>XS2</small></sup> and maxExclusive<sup><small>XS2</small></sup> facets has 4096 or fewer values, the value is represented as an n-bit Unsigned Integer offset from the minimum value in the range where n is ⌈ log<sub>2</sub> m ⌉ and m is the bounded range of the schema datatype.</p><p>Otherwise, if the associated schema datatype is directly or indirectly derived from xsd:integer and the minInclusive<sup><small>XS2</small></sup> or minExclusive<sup><small>XS2</small></sup> facets specify a lower bound greater than or equal to zero (0), the value is represented as an Unsigned Integer.</p><p> Otherwise, the value is represented as a Boolean sign (see 7.1.2 Boolean) followed by an Unsigned Integer (see 7.1.6 Unsigned Integer). 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></div><div class="div3"> <h4>7.1.6 Unsigned Integer</h4><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><p>The Unsigned Integer datatype representation can be decoded by going through the following steps.</p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 7-1. </span> Example algorithm for decoding an Unsigned Integer </div>
    1. Start with the initial value set to 0 and the initial multiplier set to 1.
    2. Read the next octet.
    3. 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.
    4. Multiply the multiplier by 128.
    5. If the most significant bit of the octet was 1, go back to step 2.
    </div><p></p></div><div class="div3"> <h4>7.1.7 QName</h4><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 <span class="arrow"></span>Preserve.prefixes<span class="arrow"></span> option is set to true. </p><p>When the QName value is specified by a schema-informed grammar using the SE (qname) or AT (qname) 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 (uri: *) or AT (uri: *) terminal symbols, URI is implicit thus omitted in the representation, and only the local-name component is encoded as a String (see 7.1.10 String). 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 n-bit unsigned integers (7.1.9 n-bit Unsigned Integer), where n is ⌈ log<sub>2</sub>(N) ⌉ and N is the number of prefixes 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 the given prefix exists in the associated prefix string table partition, it is represented using the compact identifier assigned by the partition. If the given prefix 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><div class="note"><p class="prefix">Note:</p> When N is one, the prefix is represented using zero bits (i.e. omitted). </div><p>Given a n-bit unsigned integer m 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>
    1. If the prefix string table partition associated with the URI of the QName assigns the compact identifier m to a prefix value, select this prefix value as the candidate prefix value. Otherwise, there is no candidate prefix value.
    2. If the QName value is part of an SE event followed by an associated NS event with its <span class="arrow"></span>local-element-ns<span class="arrow"></span> flag value set to true, the prefix value is the prefix of this NS event. Otherwise, the prefix value is the candidate value, if any, selected in step 1 above.
    </div><div class="div3"> <h4>7.1.8 Date-Time</h4><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. The value ranges of the date-time components follow the definitions of the XML Schema specification [XML Schema Datatypes] which for example prescribes the value range of the seconds to be between 0 and 60 to account for leap second representation and hour between 0 and 24 among others.</p><table border="1"><caption>Table 7-3. Date-Time components</caption><thead><tr><th>Component</th><th>Value</th><th>Type</th></tr></thead><tbody><tr><td>Year</td><td>Offset from 2000</td><td>Integer ( 7.1.5 Integer)</td></tr><tr><td>MonthDay</td><td> Month * 32 + Day </td><td> 9-bit Unsigned Integer (7.1.9 n-bit Unsigned Integer) 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 (7.1.9 n-bit Unsigned Integer) where Hour is a value in the range 0-24, Minutes is a value in the range 0-59 and seconds is a value in the range 0-60</td></tr><tr><td>FractionalSecs</td><td>Fractional seconds</td><td>Unsigned Integer ( 7.1.6 Unsigned Integer) representing the fractional part of the seconds with digits in reverse order to preserve leading zeros</td></tr><tr><td>TimeZone</td><td> TZHours * 64 + TZMinutes </td><td>11-bit Unsigned Integer (7.1.9 n-bit Unsigned Integer) representing a signed integer offset by 896 ( = 14 * 64 ) where TZHours is a value in the range [-14 .. 14] and TZMinutes is a value in the range [-59 .. 59]</td></tr><tr><td>presence</td><td>Boolean presence indicator</td><td>Boolean (7.1.2 Boolean)</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>Table 7-4. Assortment of Date-Time components</caption><thead><tr><th>XML Schema Datatype</th><th>Included Components</th></tr></thead><tbody><tr><td>gYear<sup><small>XS2</small></sup></td><td>Year, presence, [TimeZone]</td></tr><tr><td>gYearMonth<sup><small>XS2</small></sup></td><td rowspan="2">Year, MonthDay, presence, [TimeZone]</td></tr><tr><td>date<sup><small>XS2</small></sup></td></tr><tr><td>dateTime<sup><small>XS2</small></sup></td><td>Year, MonthDay, Time, presence, [FractionalSecs], presence, [TimeZone]</td></tr><tr><td>gMonth<sup><small>XS2</small></sup></td><td rowspan="3">MonthDay, presence, [TimeZone]</td></tr><tr><td>gMonthDay<sup><small>XS2</small></sup></td></tr><tr><td>gDay<sup><small>XS2</small></sup></td></tr><tr><td>time<sup><small>XS2</small></sup></td><td>Time, presence, [FractionalSecs], presence, [TimeZone]</td></tr></tbody></table></div><div class="div3"> <h4>7.1.9 n-bit Unsigned Integer</h4><p> When the value of the <span class="arrow"></span>compression option<span class="arrow"></span> is false and the <span class="arrow"></span>bit-packed<span class="arrow"></span> alignment is used, the n-bit Unsigned Integer datatype representation is an unsigned binary integer using n bits. Otherwise, it is an unsigned integer using the minimum number of bytes required to store n bits. Bytes are ordered with the least significant byte first.</p><p> The n-bit unsigned integer is used for representing <span class="arrow"></span>event codes<span class="arrow"></span>, the prefix component of QNames (see 7.1.7 QName) and certain <span class="arrow"></span>value<span class="arrow"></span> content items, as described in respective relevant parts of this document. As described in section 7.1.5 Integer, integers with a bounded range size m equal to 4096 or smaller are represented as n-bit unsigned integers with n being ⌈ log <sub>2</sub> m ⌉, as an offset from the minimum value in the range. </p></div><div class="div3"> <h4>7.1.10 String</h4><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 7.1.6 Unsigned Integer). If a restricted character set is defined for the string (see 7.1.10.1 Restricted Character Sets), each character is represented as an n-bit Unsigned Integer (see 7.1.9 n-bit Unsigned Integer). Otherwise, each character is represented by its Unicode [UNICODE] code point encoded as an Unsigned Integer (see 7.1.6 Unsigned Integer). </p><p>EXI uses a string table to represent certain <span class="arrow"></span>content items<span class="arrow"></span> more efficiently. Section 7.3 String Table describes the string table and how it is applied to different content items.</p><div class="div4"> <h5>7.1.10.1 Restricted Character Sets</h5><p>If a string value is associated with a schema datatype<sup><small>XS2</small></sup> directly or indirectly 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 primitive datatypes<sup><small>XS2</small></sup> starting from the datatype. If the target datatype definition is a definition for a built-in datatype<sup><small>XS2</small></sup>, 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 E Deriving Set of Characters from XML Schema Regular Expressions. 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 n-bit Unsigned Integer (see 7.1.9 n-bit Unsigned Integer), where n is ⌈ log<sub>2</sub>(N + 1) ⌉ and N is the number of characters in the restricted character set.</p><p>The characters in the restricted character set are sorted by Unicode [UNICODE] code point and represented by integer values in the range (0 ... N−1) according to their ordinal position in the set. Characters that are not in this set are represented by the n-bit Unsigned Integer N 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><div class="figure" style="text-align: center"><br><img src="restrictedCharset.png" alt="String Processing Model"><p><span>Figure 7-1. </span>String Processing Model</p><br></div></div></div><div class="div3"> <h4>7.1.11 List</h4><p>Values of type List are encoded as a length prefixed sequence of values. The length is encoded as an Unsigned Integer (see 7.1.6 Unsigned Integer) and each value is encoded according to its type (see 7. Representing Event Content).</p></div></div><div class="div2"> <h3>7.2 Enumerations</h3><p> When the <span class="arrow"></span>Preserve.lexicalValues<span class="arrow"></span> option is false, enumerated values are encoded as n-bit Unsigned Integers (7.1.9 n-bit Unsigned Integer) where n = ⌈ log <sub>2</sub> m ⌉ and m 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 union datatypes<sup><small>XS2</small></sup> , list datatypes<sup><small>XS2</small></sup>, as well as 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></div><div class="div2"> <h3>7.3 String Table</h3><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 <span class="arrow"></span>content items<span class="arrow"></span> are encoded using a string table: </p><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 <span class="arrow"></span>value<span class="arrow"></span> content item and fails to satisfy the criteria in effect by virtue of <span class="arrow"></span>valuePartitionCapacity<span class="arrow"></span> and <span class="arrow"></span>valueMaxLength<span class="arrow"></span> 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 7.3.1 String Table Partitions describes how EXI string table is partitioned. Section 7.3.2 Partitions Optimized for Frequent use of Compact Identifiers describes how string values are encoded when the associated partition is optimized for more frequent use of compact identifiers. Section 7.3.3 Partitions Optimized for Frequent use of String Literals 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><div class="div3"> <h4>7.3.1 String Table Partitions</h4><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 <span class="arrow"></span>content items<span class="arrow"></span> are assigned to specific partitions as described below. </p><p><span class="arrow"></span>Uri<span class="arrow"></span> content items and the URI portion of <span class="arrow"></span>qname<span class="arrow"></span> 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 D.1 Initial Entries in Uri Partition. 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 8.5.4.1.7 Wildcard Terms and 8.5.4.1.3.2 Complex Type Grammars, respectively for the condition), appended in lexicographical order.</p><p><span class="arrow"></span>Prefix<span class="arrow"></span> content items are assigned to partitions based on their associated namespace URI. Partitions containing prefix content items are optimized for frequent use of compact identifiers and the string table is pre-populated with entries as described in D.2 Initial Entries in Prefix Partitions.</p><p> The local-name portion of <span class="arrow"></span>qname<span class="arrow"></span> content items are assigned to partitions based on the namespace URI of the qname 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 D.3 Initial Entries in Local-Name Partitions. </p><p> Each <span class="arrow"></span>value<span class="arrow"></span> content item is assigned to both the global value partition and a "local" value partition based on the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute or element in context at the time the value is added to the value partitions. Partitions containing <span class="arrow"></span>value <span class="arrow"></span> content items are optimized for frequent use of string literals and are initially empty. <span class="termdef">[Definition:]   The variable globalID is a non-negative integer representing the compact identifier of the next item added to the global value partition. </span> Its value is initially set to 0 (zero) and changes while processing an EXI stream per the rule described in 7.3.3 Partitions Optimized for Frequent use of String Literals. </p></div><div class="div3"> <h4>7.3.2 Partitions Optimized for Frequent use of Compact Identifiers</h4><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 <span class="arrow"></span>uri<span class="arrow"></span> partition and all partitions containing <span class="arrow"></span>prefix<span class="arrow"></span> 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 (i+1) encoded as an n-bit Unsigned Integer (7.1.9 n-bit Unsigned Integer), where i is the value of the compact identifier, n is ⌈ log<sub>2</sub> (m+1) ⌉ and m 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 n-bit Unsigned Integer, followed by the string literal encoded as a String (7.1.10 String). After encoding the String value, it is added to the string table partition and assigned the next available compact identifier m.</p></div><div class="div3"> <h4>7.3.3 Partitions Optimized for Frequent use of String Literals</h4><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 <span class="arrow"></span>value<span class="arrow"></span> 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 7.1.6 Unsigned Integer) followed by the compact identifier of the string value. The compact identifier of the string value is encoded as an n-bit unsigned integer (7.1.9 n-bit Unsigned Integer), where n is ⌈ log<sub>2</sub> m ⌉ and m 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 7.1.10 String) 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 m.</p><p>As described above, each <span class="arrow"></span>value<span class="arrow"></span> 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 7.1.6 Unsigned Integer) 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 7.1.6 Unsigned Integer) followed by the compact identifier of the String value in the global value partition. The compact identifier is encoded as an n-bit unsigned integer (7.1.9 n-bit Unsigned Integer), where n is ⌈ log<sub>2</sub>m ⌉ and m is the number of entries in the associated partition at the time of the operation.</p><p>When a string value S is not found in the global or "local" value partition, its string literal is encoded as a String (see 7.1.10 String) with the length L + 2 (incremented by two) where L is the number of characters in the string value. If <span class="arrow"></span>valuePartitionCapacity<span class="arrow"></span> is not zero, and L is greater than zero and no more than <span class="arrow"></span>valueMaxLength<span class="arrow"></span>, the string S is added to the associated "local" value partition using the next available compact identifier m and added to the global value partition using the compact identifier <span class="arrow"></span>globalID<span class="arrow"></span>. When S is added to the global value partition and there was already a string V in the global value partition associated with the compact identifier <span class="arrow"></span>globalID<span class="arrow"></span>, the string S replaces the string V in the global table, and the string V 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 <span class="arrow"></span>globalID<span class="arrow"></span> is incremented by one (1). If the resulting value of <span class="arrow"></span>globalID<span class="arrow"></span> is equal to <span class="arrow"></span>valuePartitionCapacity<span class="arrow"></span>, its value is reset to zero (0) </p></div></div><div class="div2"> <h3>7.4 Datatype Representation Map</h3><p>By default, each typed value in an EXI stream is represented using its default built-in EXI datatype representation (see Table 7-1). However, <span class="termdef">[Definition:]  <span class="arrow"></span>EXI processors<span class="arrow"></span> MAY provide the capability to specify alternate built-in EXI datatype representations or user-defined datatype representations for specific schema datatypes<sup><small>XS2</small></sup>. This capability is called a Datatype Representation Map</span>. </p><div class="note"><p class="prefix">Note:</p> 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. </div><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. For XML Schema datatypes with enumerated values, the encoding rule described in 7.2 Enumerations is used as the representation when the closest ancestor datatype with an associated datatype representation has no enumerated values. </p><p>When an EXI processor encodes an EXI stream using a Datatype Representation Map and the <span class="arrow"></span>EXI Options<span class="arrow"></span> 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 <span class="arrow"></span>qname<span class="arrow"></span> of the first child element identifies the schema datatype that is not represented using the default built-in EXI datatype representation and the <span class="arrow"></span>qname<span class="arrow"></span> 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 Table 7-1. </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 directly or indirectly 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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 7-2. </span>datatypeRepresentationMap indicating all Decimal values are represented using built-in String datatype representation</div><div class="exampleInner"><pre> <exi:datatypeRepresentationMap xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:decimal/> <exi:string/> </exi:datatypeRepresentationMap> </pre></div></div><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 user-defined simple type geo:geometricSurface and the datatypes derived from it by restriction are represented using the user-defined datatype representation geo:geometricInterpolator: </p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 7-3. </span>datatypeRepresentationMap illustrating a user-defined type represented by a user-defined datatype representation</div><div class="exampleInner"><pre> <exi:datatypeRepresentationMap xmlns:geo="http://example.com/Geometry"> <geo:geometricSurface/> <geo:geometricInterpolator/> </exi:datatypeRepresentationMap> </pre></div></div><div class="note"><p class="prefix">Note:</p> 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 <span class="arrow"></span>qnames<span class="arrow"></span> in "datatypeRepresentationMap" elements. A datatype representation is omnipresent only if its <span class="arrow"></span>qname<span class="arrow"></span> is one of those that represent built-in EXI datatype representations. For datatype representations of other <span class="arrow"></span>qnames<span class="arrow"></span>, 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. </div></div></div><div class="div1"> <h2>8. EXI Grammars</h2><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><div class="note"><p class="prefix">Note:</p>The grammar semantics in this specification are written for clarity and generality. They do not prescribe a particular implementation approach. </div><div class="div2"> <h3>8.1 Grammar Notation</h3><div class="div3"> <h4>8.1.1 Fixed Event Codes</h4><p>Each grammar production has an <span class="arrow"></span>event code<span class="arrow"></span>, which is represented by a sequence of one to three parts separated by periods ("."). Each part is an unsigned integer. The following are examples of grammar productions with <span class="arrow"></span>event codes<span class="arrow"></span> as they appear in this specification. </p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-1. </span>Example productions with fixed event codes</div><table width="95%"><thead><tr><th colspan="4"> </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"> </td></tr><tr><td></td><td colspan="3"> LeftHandSide<sub> 1</sub> :</td></tr><tr><td></td><td width="5%"></td><td width="75%"> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1</td></tr><tr><td></td><td></td><td> Terminal<sub> 3</sub>    NonTerminal<sub> 3</sub></td><td>2.0</td></tr><tr><td></td><td></td><td> Terminal<sub> 4</sub>    NonTerminal<sub> 4</sub></td><td>2.1</td></tr><tr><td></td><td></td><td> Terminal<sub> 5</sub>    NonTerminal<sub> 5</sub></td><td>2.2.0</td></tr><tr><td></td><td></td><td> Terminal<sub> 6</sub>    NonTerminal<sub> 6</sub></td><td>2.2.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> LeftHandSide<sub> 2</sub> :</td></tr><tr><td></td><td></td><td> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1.0</td></tr><tr><td></td><td></td><td> Terminal<sub> 3</sub>    NonTerminal<sub> 3</sub></td><td>1.1</td></tr></tbody></table></div><p>The number of parts in a given <span class="arrow"></span>event code<span class="arrow"></span> 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 <span class="arrow"></span>event code<span class="arrow"></span>. </p></div><div class="div3"> <h4>8.1.2 Variable Event Codes</h4><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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-2. </span>Example productions that use macro non-terminal symbols</div><table width="95%"><thead><tr><td colspan="4"> </td></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> ABigProduction<sub> 1</sub> :</td></tr><tr><td></td><td width="5%"></td><td width="75%"> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1</td></tr><tr><td></td><td></td><td> LEFTHANDSIDE <sub>1</sub> (2.0)</td><td>2.0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> ABigProduction<sub> 2</sub> :</td></tr><tr><td></td><td></td><td> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td> LEFTHANDSIDE <sub>1</sub> (1.1)</td><td>1.1</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1.2</td></tr></tbody></table></div><p> Because non-terminal macros are injected into the right-hand side of more than one production, the <span class="arrow"></span>event codes<span class="arrow"></span> 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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-3. </span>Example non-terminal macros and its productions with variable event codes</div><table width="95%"><thead><tr><td colspan="4"> </td></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> LEFTHANDSIDE<sub> 1</sub> (n.m) :</td></tr><tr><td></td><td width="5%"></td><td width="75%"> TERMINAL<sub> 1</sub>   NONTERMINAL<sub> 1</sub></td><td> n.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 2</sub>   NONTERMINAL<sub> 2</sub></td><td> n.1</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 3</sub>   NONTERMINAL<sub> 3</sub></td><td> n. m+2</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 4</sub>   NONTERMINAL<sub> 4</sub></td><td> n. m+3</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 5</sub>   NONTERMINAL<sub> 5</sub></td><td> n. m+4.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 6</sub>   NONTERMINAL<sub> 6</sub></td><td> n. m+4.1</td></tr></tbody></table></div><p>Unless otherwise specified, the variable n evaluates to the first part of the <span class="arrow"></span>event code<span class="arrow"></span> of the production in which the macro non-terminal LEFTHANDSIDE<sub> 1 </sub> appears on the right-hand side. Similarly, the expression n. m represents the first two parts of the <span class="arrow"></span>event code<span class="arrow"></span> of the production in which the macro non-terminal LEFTHANDSIDE<sub> 1 </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, ABigProduction<sub> 1</sub> and ABigProduction<sub> 2 </sub> shown in the preceding example are equivalent to the following set of productions obtained by expanding the non-terminal macro symbol LEFTHANDSIDE<sub> 1 </sub> and evaluating the variable event codes. </p><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-4. </span>Expanded productions equivalent to the productions used above</div><table width="95%"><thead><tr><td colspan="4"> </td></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> ABigProduction<sub> 1</sub> :</td></tr><tr><td></td><td width="5%"></td><td> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 1</sub>   NONTERMINAL<sub> 1</sub></td><td>2.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 2</sub>   NONTERMINAL<sub> 2</sub></td><td>2.1</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 3</sub>   NONTERMINAL<sub> 3</sub></td><td>2.2</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 4</sub>   NONTERMINAL<sub> 4</sub></td><td>2.3</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 5</sub>   NONTERMINAL<sub> 5</sub></td><td>2.4.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 6</sub>   NONTERMINAL<sub> 6</sub></td><td>2.4.1</td></tr><tr><td colspan="5"> </td></tr><tr><td width="5%"></td><td colspan="4"> ABigProduction<sub> 2</sub> :</td></tr><tr><td></td><td></td><td> Terminal<sub> 1</sub>    NonTerminal<sub> 1</sub></td><td>0</td></tr><tr><td></td><td></td><td width="75%"> TERMINAL<sub> 1</sub>   NONTERMINAL<sub> 1</sub></td><td>1.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 2</sub>   NONTERMINAL<sub> 2</sub></td><td>1.1</td></tr><tr><td></td><td></td><td> Terminal<sub> 2</sub>    NonTerminal<sub> 2</sub></td><td>1.2</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 3</sub>   NONTERMINAL<sub> 3</sub></td><td>1.3</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 4</sub>   NONTERMINAL<sub> 4</sub></td><td>1.4</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 5</sub>   NONTERMINAL<sub> 5</sub></td><td>1.5.0</td></tr><tr><td></td><td></td><td> TERMINAL<sub> 6</sub>   NONTERMINAL<sub> 6</sub></td><td>1.5.1</td></tr></tbody></table></div></div></div><div class="div2"> <h3>8.2 Grammar Event Codes</h3><p>Each production rule in the EXI grammar includes an <span class="arrow"></span>event code<span class="arrow"></span> 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 <span class="arrow"></span>event codes<span class="arrow"></span> determine the value(s) by which each non-terminal symbol will be represented in the EXI stream. </p><p>To understand how a given <span class="arrow"></span>event code<span class="arrow"></span> approximates the likelihood a given production will match, it is useful to visualize the <span class="arrow"></span>event codes<span class="arrow"></span> 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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-5. </span>Example productions with event codes</div><table width="95%"><tbody><tr><td width="5%"></td><td colspan="4"> ElementContent :</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 (*)  ElementContent</td><td>1.0</td></tr><tr><td></td><td></td><td>CH  ElementContent</td><td>1.1</td></tr><tr><td></td><td></td><td>ER  ElementContent</td><td>1.2</td></tr><tr><td></td><td></td><td>CM  ElementContent</td><td>1.3.0</td></tr><tr><td></td><td></td><td>PI  ElementContent</td><td>1.3.1</td></tr></tbody></table></div><p>represents a set of information items that might occur as element content after the start tag. Using the production <span class="arrow"></span>event codes<span class="arrow"></span>, we can visualize this set of productions as follows: </p><div class="figure" style="text-align: center"><br><img src="eventCodeTree.png" alt="Event code tree for ElementContent grammar"><p><span>Figure 8-1. </span>Event code tree for ElementContent grammar</p><br></div><p> where the terminal symbols are represented by the leaf nodes of the tree, and the <span class="arrow"></span>event code<span class="arrow"></span> 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 [Huffman Coding] 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 <span class="arrow"></span>event code<span class="arrow"></span> 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></div><div class="div2"> <h3>8.3 Pruning Unneeded Productions</h3><p>As discussed in section 6.3 Fidelity Options, 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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-6. </span>Example productions with full fidelity</div><table width="95%"><tbody><tr><td width="5%"></td><td colspan="3"> ElementContent :</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 (*)  ElementContent</td><td>1.0</td></tr><tr><td></td><td></td><td>CH  ElementContent</td><td>1.1</td></tr><tr><td></td><td></td><td>ER  ElementContent</td><td>1.2</td></tr><tr><td></td><td></td><td>CM  ElementContent</td><td>1.3.0</td></tr><tr><td></td><td></td><td>PI  ElementContent</td><td>1.3.1</td></tr></tbody></table></div><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><div class="exampleOuter"> <div class="exampleHeader"><span>Example 8-7. </span>Example productions after pruning</div><table width="95%"><tbody><tr><td width="5%"></td><td colspan="4"> ElementContent :</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 (*)  ElementContent</td><td>1.0</td></tr><tr><td></td><td></td><td>CH  ElementContent</td><td>1.1</td></tr></tbody></table></div><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 <span class="arrow"></span>event codes<span class="arrow"></span> 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></div><div class="div2"> <h3>8.4 Built-in XML Grammars</h3><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 <span class="arrow"></span>built-in element grammars<span class="arrow"></span> 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 <span class="arrow"></span>built-in element grammars<span class="arrow"></span> are <span class="arrow"></span>global element grammars<span class="arrow"></span>. </p><p><span class="termdef">[Definition:]  A global element grammar is a grammar describing the content of an element that has global scope (i.e. a global element).</span> 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 global. Each <span class="arrow"></span>built-in element grammar<span class="arrow"></span> created while processing an EXI stream is added to the set of global element grammars. Each global element grammar has a unique <span class="arrow"></span>qname<span class="arrow"></span>.</p><div class="div3"> <h4>8.4.1 Built-in Document Grammar</h4><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 <span class="arrow"></span>EXI document<span class="arrow"></span>. </p><table width="100%"><tbody><tr><th align="left" colspan="3">Syntax</th><th align="left">Event Code</th></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> Document :</td></tr><tr><td></td><td width="5%"></td><td width="60%">SD DocContent</td><td width="30%">0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> DocContent :</td></tr><tr><td></td><td></td><td>SE (*) DocEnd</td><td>0</td></tr><tr><td></td><td></td><td>DT DocContent</td><td>1.0</td></tr><tr><td></td><td></td><td>CM DocContent</td><td>1.1.0</td></tr><tr><td></td><td></td><td>PI DocContent</td><td>1.1.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> DocEnd :</td></tr><tr><td></td><td></td><td>ED</td><td>0</td></tr><tr><td></td><td></td><td>CM DocEnd</td><td>1.0</td></tr><tr><td></td><td></td><td>PI DocEnd</td><td>1.1</td></tr></tbody></table><p></p><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td><p>All productions in the built-in document grammars of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of event sequence using RightHandSide.
    </td></tr></tbody></table></div><div class="div3"> <h4>8.4.2 Built-in Fragment Grammar</h4><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 <span class="arrow"></span>EXI fragment<span class="arrow"></span>. 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"> </td></tr><tr><td width="5%"></td><td colspan="3"> Fragment :</td></tr><tr><td></td><td width="5%"></td><td width="60%">SD FragmentContent</td><td width="30%">0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> FragmentContent :</td></tr><tr><td></td><td></td><td>SE (*) FragmentContent</td><td>0</td></tr><tr><td></td><td></td><td>ED</td><td>1</td></tr><tr><td></td><td></td><td>CM FragmentContent</td><td>2.0</td></tr><tr><td></td><td></td><td>PI FragmentContent</td><td>2.1</td></tr></tbody></table><p></p><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td> <p>All productions in the built-in fragment grammars of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Create a production of the form LeftHandSide : SE (qname) RightHandSide with an <span class="arrow"></span>event code<span class="arrow"></span> 0
    4. Increment the first part of the <span class="arrow"></span>event code<span class="arrow"></span> of each production in the current grammar with the non-terminal LeftHandSide on the left-hand side
    5. Add the production created in step 3 to the grammar
    6. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    7. Evaluate the remainder of event sequence using RightHandSide.
    <p>All productions of the form LeftHandSide : SE (qname) RightHandSide that were previously added to the grammar upon the first occurrence of the element that has the <span class="arrow"></span>qname<span class="arrow"></span> qname are evaluated as follows when they are matched: </p>
    1. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname
    2. Evaluate the remainder of event sequence using RightHandSide.
    </td></tr></tbody></table></div><div class="div3"> <h4>8.4.3 Built-in Element Grammar</h4><p><span class="termdef">[Definition:]  When no grammar exists for an element occurring in an EXI stream, a built-in element grammar is created for that element.</span> 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 <span class="arrow"></span>global element grammar<span class="arrow"></span>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 <span class="arrow"></span>built-in element grammars<span class="arrow"></span>. The semantics describe how productions are added to each <span class="arrow"></span>built-in element grammar<span class="arrow"></span> 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"> </td></tr><tr><td width="5%"></td><td colspan="3"> StartTagContent :</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 (*) StartTagContent</td><td>0.1</td></tr><tr><td></td><td></td><td>NS StartTagContent</td><td>0.2</td></tr><tr><td></td><td></td><td>SC Fragment</td><td>0.3</td></tr><tr><td></td><td></td><td> ChildContentItems (0.4)</td><td></td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> ElementContent :</td></tr><tr><td></td><td></td><td>EE</td><td>0</td></tr><tr><td></td><td></td><td> ChildContentItems (1.0)</td><td></td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> ChildContentItems (n.m) :</td></tr><tr><td></td><td></td><td>SE (*) ElementContent</td><td> n. m</td></tr><tr><td></td><td></td><td>CH ElementContent</td><td> n.(m+1)</td></tr><tr><td></td><td></td><td>ER ElementContent</td><td> n.(m+2)</td></tr><tr><td></td><td></td><td>CM ElementContent</td><td> n.(m+3).0</td></tr><tr><td></td><td></td><td>PI ElementContent</td><td> n.(m+3).1</td></tr></tbody></table><p></p><table width="100%"><thead><tr><th align="left">Note:</th></tr></thead><tbody><tr><td>  </td></tr><tr><td>
    • When the value of the <span class="arrow"></span>selfContained option<span class="arrow"></span> 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 ChildContentItems that has StartTagContent non-terminal on the left-hand side (shown in bold above) gets expanded with variable values (0.3) instead of (0.4) used above.
    </td></tr><tr id="builtInGrammarOrderNotes"><td> </td></tr><tr><td> </td></tr></tbody></table><p></p><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td> <p>All productions in the <span class="arrow"></span>built-in element grammar<span class="arrow"></span> of the form LeftHandSide: AT (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute matched by AT (*)
    2. If qname is not xsi:type or if a production of the form LeftHandSide : AT (xsi:type) with an <span class="arrow"></span>event code<span class="arrow"></span> of length 1 does not exist in the current element grammar, create a production of the form LeftHandSide : AT (qname) RightHandSide with an <span class="arrow"></span>event code<span class="arrow"></span> 0 and increment the first part of the event code of each production in the current grammar with the non-terminal LeftHandSide on the left-hand side. Add this production to the grammar.
    3. If qname is xsi:type, let target-type be the value of the xsi:type attribute and assign it the QName datatype representation (see 7.1.7 QName). If there is no namespace in scope for the specified qname prefix, set the uri of target-type to empty ("") and the localName to the full lexical value of the QName, including the prefix. Encode target-type according to section 7. Representing Event Content. If a grammar can be found for the target-type type using the encoded target-type representation, evaluate the element contents using the grammar for target-type type instead of RightHandSide.
    <p>The production of the form LeftHandSide : AT (xsi:type) RightHandSide 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>
    1. Let target-type be the value of the xsi:type attribute and assign it the QName datatype representation (see 7.1.7 QName).
    2. If there is no namespace in scope for the specified <span class="arrow"></span>qname<span class="arrow"></span> prefix, set the uri of target-type to empty ("") and the localName to the full lexical value of the QName, including the prefix.
    3. Represent the value of target-type according to section 7. Representing Event Content.
    4. If a grammar can be found for the target-type type using the encoded target-type representation, evaluate the element contents using the grammar for target-type type instead of RightHandSide.
    <p>All productions of the form LeftHandSide : SC Fragment are evaluated as follows: </p>
    1. Save the string table, grammars and any implementation-specific state learned while processing this EXI Body.
    2. 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.
    3. Skip to the next byte-aligned boundary in the stream if it is not already at such a boundary.
    4. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the SE event immediately preceding this SC event.
    5. Let content be the sequence of events following this SC event that match the grammar for element qname, up to and including the terminating EE event.
    6. Evaluate the sequence of events (SD, SE(qname), content, ED) according to the Fragment grammar (see 8.4.2 Built-in Fragment Grammar).
    7. Skip to the next byte-aligned boundary in the stream if it is not already at such a boundary.
    8. Restore the string table, grammars and implementation-specific state learned while processing this EXI Body to that saved in step 1 above.
    <p>All productions in the <span class="arrow"></span>built-in element grammar<span class="arrow"></span> of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Create a production of the form LeftHandSide : SE (qname) RightHandSide with an <span class="arrow"></span>event code<span class="arrow"></span> 0
    4. Increment the first part of the <span class="arrow"></span>event code<span class="arrow"></span> of each production in the current grammar with the non-terminal LeftHandSide on the left-hand side
    5. Add the production created in step 3 to the grammar
    6. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    7. Evaluate the remainder of event sequence using RightHandSide.
    <p>All productions of the form LeftHandSide : SE (qname) RightHandSide that were previously added to the grammar upon the first occurrence of the element that has the <span class="arrow"></span>qname<span class="arrow"></span> qname are evaluated as follows when they are matched: </p>
    1. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname
    2. Evaluate the remainder of event sequence using RightHandSide.
    <p>All productions in the <span class="arrow"></span>built-in element grammar<span class="arrow"></span> of the form LeftHandSide : CH RightHandSide are evaluated as follows: </p>
    1. If a production of the form, LeftHandSide : CH RightHandSide with an <span class="arrow"></span>event code<span class="arrow"></span> 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 LeftHandSide on the left-hand side.
    2. Add the production created in step 1 to the grammar
    3. Evaluate the remainder of event sequence using RightHandSide.
    <p>All productions in the <span class="arrow"></span>built-in element grammar<span class="arrow"></span> of the form LeftHandSide : EE are evaluated as follows: </p>
    1. If a production of the form, LeftHandSide : EE with an <span class="arrow"></span>event code<span class="arrow"></span> 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 LeftHandSide on the left-hand side.
    2. Add the production created in step 1 to the grammar
    </td></tr></tbody></table></div></div><div class="div2"> <h3>8.5 Schema-informed Grammars</h3><p>This section describes the schema-informed grammars used by EXI when schema information is available to describe the contents of the <span class="arrow"></span>EXI stream<span class="arrow"></span>. Schema information used for processing an EXI stream is either indicated by the header option <span class="arrow"></span>schemaId<span class="arrow"></span>, or communicated out-of-band in the absence of <span class="arrow"></span>schemaId<span class="arrow"></span>. </p><p>Schema-informed grammars accept all XML documents and fragments regardless of whether and how closely they match the schema. The <span class="arrow"></span>EXI stream encoder<span class="arrow"></span> 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><p>It is important to note that schema-informed and built-in grammars are often used together within the context of a single <span class="arrow"></span>EXI stream<span class="arrow"></span>. 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 8.4 Built-in XML Grammars. </p><div class="div3"> <h4>8.5.1 Schema-informed Document Grammar</h4><p>When schema information is available to describe the contents of an <span class="arrow"></span>EXI stream<span class="arrow"></span>, the following grammar describes the events that will occur in an <span class="arrow"></span>EXI document<span class="arrow"></span>. </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"> </td></tr><tr><td width="5%"></td><td colspan="3"> Document :</td></tr><tr><td></td><td width="5%"></td><td width="75%">SD DocContent</td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> DocContent :</td></tr><tr><td></td><td></td><td>SE (G <sub>0</sub>) DocEnd</td><td>0</td></tr><tr><td></td><td></td><td>SE (G <sub>1</sub>) DocEnd</td><td>1</td></tr><tr><td></td><td></td><td>  â‹®</td><td>â‹®</td></tr><tr><td></td><td></td><td>SE (G <sub>n−1</sub>) DocEnd</td><td>n−1</td></tr><tr><td></td><td></td><td>SE (*) DocEnd</td><td> n</td></tr><tr><td></td><td></td><td>DT DocContent</td><td> (n+1).0</td></tr><tr><td></td><td></td><td>CM DocContent</td><td> (n+1).1.0</td></tr><tr><td></td><td></td><td>PI DocContent</td><td> (n+1).1.1</td></tr><tr><td colspan="4"> </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">
    • The variable n in the grammar above is the number of global elements declared in the schema. G <sub>0</sub>, G <sub>1</sub>, ... G <sub>n−1</sub> represent all the <span class="arrow"></span>qnames<span class="arrow"></span> of global elements sorted lexicographically, first by local-name, then by uri.
    </td></tr><tr><td></td><td colspan="3"> DocEnd :</td></tr><tr><td></td><td></td><td>ED</td><td>0</td></tr><tr><td></td><td></td><td>CM DocEnd</td><td>1.0</td></tr><tr><td></td><td></td><td>PI DocEnd</td><td>1.1</td></tr></tbody></table><p></p><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td> <p> In a schema-informed grammar, all productions of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of event sequence using RightHandSide
    </td></tr></tbody></table></div><div class="div3"> <h4>8.5.2 Schema-informed Fragment Grammar</h4><p>When schema information is available to describe the contents of an <span class="arrow"></span>EXI stream<span class="arrow"></span>, the following grammar describes the events that will occur in an <span class="arrow"></span>EXI fragment<span class="arrow"></span>. </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"> </td></tr><tr><td width="5%"></td><td colspan="3"> Fragment :</td></tr><tr><td></td><td width="5%"></td><td width="75%">SD FragmentContent</td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> FragmentContent :</td></tr><tr><td></td><td></td><td>SE (F <sub>0</sub>) FragmentContent</td><td>0</td></tr><tr><td></td><td></td><td>SE (F <sub>1</sub>) FragmentContent</td><td>1</td></tr><tr><td></td><td></td><td>  â‹®</td><td>â‹®</td></tr><tr><td></td><td></td><td>SE (F <sub>n−1</sub>) FragmentContent</td><td>n−1</td></tr><tr><td></td><td></td><td>SE (*) FragmentContent</td><td>n</td></tr><tr><td></td><td></td><td>ED</td><td> n+1</td></tr><tr><td></td><td></td><td>CM FragmentContent</td><td>(n+2).0</td></tr><tr><td></td><td></td><td>PI FragmentContent</td><td>(n+2).1</td></tr><tr><td colspan="4"> </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"> </td></tr></tbody></table><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td> <p> In a schema-informed grammar, all productions of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of event sequence using RightHandSide
    </td></tr></tbody></table></div><div class="div3"> <h4>8.5.3 Schema-informed Element Fragment Grammar</h4><p><span class="termdef">[Definition:]   When schema information is available to describe the contents of an <span class="arrow"></span>EXI stream<span class="arrow"></span> and more than one element is declared with the same <span class="arrow"></span>qname<span class="arrow"></span>, but not all such elements have the same type name and {nillable} property value, the Schema-informed Element Fragment Grammar are used for processing the events that may occur in such elements when they occur inside an EXI fragment or EXI Element Fragment. </span> The schema-informed element fragment grammar consists of ElementFragment and ElementFragmentTypeEmpty which are defined below. ElementFragment is a grammar that accounts both element declarations and attribute declarations in the schemas, whereas ElementFragmentTypeEmpty 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"> </td></tr><tr><td width="5%"></td><td colspan="3"> ElementFragment<sub> 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td width="75%">AT (<sub> </sub>A<sub> 0 </sub>) [schema-typed value] ElementFragment<sub> 0</sub></td><td>0</td></tr><tr><td></td><td></td><td>AT (<sub> </sub>A<sub> 1 </sub>) [schema-typed value] ElementFragment<sub> 0</sub></td><td>1</td></tr><tr><td></td><td></td><td>  â‹®</td><td>â‹®</td></tr><tr><td></td><td></td><td>AT (<sub> </sub>A<sub> n−1 </sub>) [schema-typed value] ElementFragment<sub> 0</sub></td><td>n−1</td></tr><tr><td></td><td></td><td> AT (<sub> </sub>*<sub> </sub>) ElementFragment<sub> 0</sub> </td><td>n</td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>0 </sub>) ElementFragment<sub> 2</sub> </td><td>n+1</td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>1 </sub>) ElementFragment<sub> 2</sub> </td><td>n+2</td></tr><tr><td></td><td></td><td>  â‹®</td><td>â‹®</td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>m-1 </sub>) ElementFragment<sub> 2</sub> </td><td>n+m</td></tr><tr><td></td><td></td><td> SE (<sub> </sub>*<sub> </sub>) ElementFragment<sub> 2</sub> </td><td>n+m+1</td></tr><tr><td></td><td></td><td>EE</td><td> n+m+2</td></tr><tr><td></td><td></td><td>CH [untyped value] ElementFragment<sub> 2</sub> </td><td> n+m+3</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> ElementFragment<sub> 1</sub> : </td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>0 </sub>) ElementFragment<sub> 2</sub> </td><td>0</td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>1 </sub>) ElementFragment<sub> 2</sub> </td><td>1</td></tr><tr><td></td><td></td><td>  â‹®</td><td>â‹®</td></tr><tr><td></td><td></td><td>SE (<sub> </sub>F<sub>m-1 </sub>) ElementFragment<sub> 2</sub> </td><td>m-1</td></tr><tr><td></td><td></td><td> SE (<sub> </sub>*<sub> </sub>) ElementFragment<sub> 2 </sub> </td><td>m</td></tr><tr><td></td><td></td><td>EE</td><td> m+1</td></tr><tr><td></td><td></td><td>CH [untyped value] ElementFragment<sub> 2</sub> </td><td> m+2</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> ElementFragment<sub> 2</sub> : </td></tr><tr><td></td><td></td><td> SE (<sub> </sub>F<sub>0 </sub>) ElementFragment<sub> 2</sub> </td><td> 0 </td></tr><tr><td></td><td></td><td> SE (<sub> </sub>F<sub>1 </sub>) ElementFragment<sub> 2</sub> </td><td>1</td></tr><tr><td></td><td></td><td>   â‹® </td><td> â‹® </td></tr><tr><td></td><td></td><td> SE (<sub> </sub>F<sub>m-1 </sub>) ElementFragment<sub> 2</sub> </td><td> m-1 </td></tr><tr><td></td><td></td><td> SE (<sub> </sub>*<sub> </sub>) ElementFragment<sub> 2</sub> </td><td> m </td></tr><tr><td></td><td></td><td> EE </td><td> m+1 </td></tr><tr><td></td><td></td><td> CH [untyped value] ElementFragment<sub> 2</sub> </td><td> m+2 </td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> ElementFragmentTypeEmpty<sub> 0</sub> : </td></tr><tr><td></td><td></td><td> AT (<sub> </sub>A <sub>0 </sub>) [schema-typed value] ElementFragmentTypeEmpty<sub> 0</sub> </td><td>0</td></tr><tr><td></td><td></td><td> AT (<sub> </sub>A <sub>1 </sub>) [schema-typed value] ElementFragmentTypeEmpty<sub> 0</sub> </td><td>1</td></tr><tr><td></td><td></td><td>   â‹® </td><td>â‹®</td></tr><tr><td></td><td></td><td> AT (<sub> </sub>A <sub>n−1 </sub>) [schema-typed value] ElementFragmentTypeEmpty<sub> 0</sub> </td><td>n−1</td></tr><tr><td></td><td></td><td> AT (<sub> </sub>*<sub> </sub>) ElementFragmentTypeEmpty<sub> 0</sub> </td><td>n</td></tr><tr><td></td><td></td><td> EE </td><td> n+1</td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> ElementFragmentTypeEmpty<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td><td>0</td></tr><tr><td colspan="4"> </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">
    • The variable m in the grammar above represents the number of unique element <span class="arrow"></span>qnames<span class="arrow"></span> declared in the schema. The variables F<sub>0 </sub>, F<sub>1 </sub>, ... F<sub>m-1 </sub> represent these qnames sorted lexicographically, first by local-name, then by uri. If there is more than one element declared with the same <span class="arrow"></span>qname<span class="arrow"></span>, 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.
    </td></tr></tbody></table><table><tbody><tr><th colspan="2" align="left">Semantics:</th></tr><tr><td> </td><td></td></tr><tr><td></td><td> <p> In a schema-informed grammar, all productions of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of event sequence using RightHandSide
    <p>All productions in the schema-informed element fragment grammar of the form LeftHandSide: AT (*) RightHandSide are evaluated as follows: </p>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute matched by AT (*)
    2. If a global attribute definition exists for qname, let global-type be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with global-type, it SHOULD be represented using the datatype representation associated with global-type (see 7. Representing Event Content). If the attribute value is not represented using the datatype representation associated with global-type, represent the attribute event using the AT (*) [untyped value] terminal (see 8.5.4.4 Undeclared Productions).
    <div class="note"><p class="prefix">Note:</p> When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal. </div> </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 8.5.4.4 Undeclared Productions. 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 ElementFragmentTypeEmpty is used to serve as the <span class="arrow"></span>TypeEmpty<span class="arrow"></span> of the type in the process. </p></div><div class="div3"> <h4>8.5.4 Schema-informed Element and Type Grammars</h4><p><span class="termdef">[Definition:]  When one or more XML Schema is available to describe the contents of an EXI stream, a schema-informed element grammar Element<sub> i </sub> is derived for each element declaration E<sub> i </sub> described by the schemas, where 0 ≤ i < n and n is the number of element declarations in the schema.</span> </p><p><span class="termdef">[Definition:]  When one or more XML Schema is available to describe the contents of an EXI stream, a schema-informed type grammar Type<sub> i </sub> is derived for each named type declaration T<sub> i </sub> described by the schemas as well as for each of the built-in primitive types<sup><small>XS2</small></sup> and built-in derived types<sup><small>XS2</small></sup>, the complex ur-type<sup><small>XS1</small></sup> and the simple ur-type<sup><small>XS2</small></sup> defined by XML Schema specification [XML Schema Structures][XML Schema Datatypes], where 0 ≤ i < n and n is the total number of such available types. </span> </p><p>Each schema-informed element grammar and type grammar is constructed according to the following four steps:</p>
    1. Create a proto-grammar that describes the content model according to available schema information (see section 8.5.4.1 EXI Proto-Grammars).
    2. Normalize the proto-grammar into an EXI grammar (see section 8.5.4.2 EXI Normalized Grammars).
    3. Assign <span class="arrow"></span>event codes<span class="arrow"></span> to each production in the normalized EXI grammar (see section 8.5.4.3 Event Code Assignment).
    4. 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 8.5.4.4 Undeclared Productions).
    <p>Each element grammar Element<sub> i </sub> includes a sequence of n non-terminals Element<sub> i, j </sub>, where 0 ≤ j < n. The content of the entire element is described by the first non-terminal Element<sub> i, 0 </sub>. The remaining non-terminals describe portions of the element content. Likewise, each type grammar Type<sub> i </sub> includes a sequence of n non-terminals Type<sub> i, j </sub> and the content of the entire type is described by the first non-terminal Type<sub> i, 0 </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 <span class="arrow"></span>event codes<span class="arrow"></span> that generate EXI encodings that match those produced by the grammars described here. </p><p> An example is provided in the appendix (see H Schema-informed Grammar Examples) that demonstrates the process described in this section to generate a complete schema-informed element grammar from an element declaration in a schema. </p><div class="div4"> <h5>8.5.4.1 EXI Proto-Grammars</h5><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"> LeftHandSide :</td></tr><tr><td></td><td width="5%"></td><td>RightHandSide</td></tr></tbody></table><p>where LeftHandSide and RightHandSide 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 [Greibach Normal Form]. </p><p>EXI proto-grammars are derived from XML Schema in a straight-forward manner and can easily be normalized with simple algorithm (see 8.5.4.2 EXI Normalized Grammars). </p><div class="div5"> <h6>8.5.4.1.1 Grammar Concatenation Operator</h6><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 ⊕ 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 Grammar<sup> L</sup> and a right operand Grammar<sup> R</sup>, the following operation </p><table width="100%"><tbody><tr><td width="5%"></td><td> Grammar<sup> L</sup>Grammar<sup> R</sup> </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"> Grammar<sup> L</sup><sub>k</sub> : </td></tr><tr><td></td><td width="5%"></td><td> EE </td></tr></tbody></table><p>where 0 ≤ k < n and n is the number of non-terminals that occur on the left-hand side of productions in Grammar<sup> L</sup>, with a production of the form </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Grammar<sup> L</sup><sub>k</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Grammar<sup> R</sup><sub>0</sub> </td></tr></tbody></table><p>connecting each accept state of Grammar<sup> L</sup> with the start state of Grammar<sup> R</sup>. </p></div><div class="div5"> <h6>8.5.4.1.2 Element Grammars</h6><p>This section describes the process for creating an EXI element grammar from an XML Schema element declaration<sup><small>XS1</small></sup>. </p><p>Given an element declaration E<sub> i </sub>, with properties {name}, {target namespace}, {type definition}, {scope} and {nillable}, create a corresponding EXI grammar Element<sub> i </sub> for evaluating the contents of elements in the specified {scope} with qname local-name = {name} and qname uri = {target namespace} where qname is the <span class="arrow"></span>qname<span class="arrow"></span> of the elements. </p><p>Let T<sub> j</sub> be the {type definition} of E<sub> i </sub> and Type<sub> j </sub> be the type grammar created from T<sub> j </sub>. The grammar Element<sub> i </sub> describing the content model of E<sub> i </sub> is created as follows. </p><table width="100%"><thead><tr><th>Syntax:</th><th colspan="2"> </th></tr></thead><tbody><tr><td width="5%"></td><td colspan="2"> Element<sub> i , 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Type<sub> j , 0</sub> </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><div class="div5"> <h6>8.5.4.1.3 Type Grammars</h6><p>Given an XML Schema type definition T<sub> i </sub> with properties {name} and {target namespace}, two type grammars are created, which are denoted by Type<sub> i </sub> and TypeEmpty<sub> i </sub>. <span class="termdef">[Definition:]  Type<sub> i</sub> is a grammar that fully reflects the type definition of T<sub> i </sub></span>, whereas <span class="termdef">[Definition:]  TypeEmpty<sub> i</sub> is a grammar that regards only the attribute uses and attribute wildcards of T<sub> i </sub>, if any</span>. </p><p>The grammar Type<sub> i </sub> is used for evaluating the content of elements that are defined to be of type T<sub> i </sub> in the schema. <span class="termdef">[Definition:]  Type<sub> i </sub> is a global type grammar when T<sub> i </sub> is a named type. </span> Type<sub> i </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 <span class="arrow"></span>qname<span class="arrow"></span> with local-name = {name} and uri = {target namespace}. TypeEmpty<sub> i </sub> is used in place of Type<sub> i </sub> when the element instance that is being evaluated has a xsi:nil attribute with the value true. </p><p> Sections 8.5.4.1.3.1 Simple Type Grammars and 8.5.4.1.3.2 Complex Type Grammars describe the processes for creating Type<sub> i </sub> and TypeEmpty<sub> i </sub> from XML Schema simple type definitions<sup><small>XS1</small></sup> and complex type definitions<sup><small>XS1</small></sup> defined in schemas as well as built-in primitive types<sup><small>XS2</small></sup>, built-in derived types<sup><small>XS2</small></sup>, simple ur-type<sup><small>XS2</small></sup> and complex ur-type<sup><small>XS1</small></sup> defined by XML Schema specification [XML Schema Datatypes]. </p><div class="div6"> <h6>8.5.4.1.3.1 Simple Type Grammars</h6> <p>This section describes the process for creating an EXI type grammar from an XML Schema simple type definition<sup><small>XS1</small></sup>.</p> <p>Given a simple type definition T<sub> i </sub>, create two new EXI grammars <span class="arrow"></span>Type<span class="arrow"></span><sub> i</sub> and <span class="arrow"></span>TypeEmpty<span class="arrow"></span><sub> i</sub> following the procedure described below. </p> <p>Add the following grammar productions to Type<sub> i </sub> and TypeEmpty<sub> i </sub> : </p> <table width="100%"><thead><tr><th>Syntax:</th><th colspan="2"> </th></tr></thead><tbody><tr><td width="5%"></td><td colspan="2"> Type<sub> i, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>CH [schema-typed value] Type<sub> i, 1 </sub></td></tr><tr><td></td><td colspan="2"> Type<sub> i, 1 </sub> :</td></tr><tr><td></td><td></td><td>EE</td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> TypeEmpty<sub> i, 0 </sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table> <table><tbody><tr><th align="left">Note:</th></tr><tr><td></td><td> Productions of the form LeftHandSide : CH [schema-typed value] RightHandSide represent typed character data that can be represented using the EXI datatype representation associated with the simple type definition (see 7. Representing Event Content). 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 LeftHandSide : CH [untyped value] RightHandSide described in section 8.5.4.4 Undeclared Productions. </td></tr></tbody></table> </div><div class="div6"> <h6>8.5.4.1.3.2 Complex Type Grammars</h6> <p>This section describes the process for creating an EXI type grammar from an XML Schema complex type definition<sup><small>XS1</small></sup>.</p> <p>Given a complex type definition T<sub> i </sub>, with properties {name}, {target namespace}, {attribute uses}, {attribute wildcard} and {content type}, create two EXI grammars <span class="arrow"></span>Type<span class="arrow"></span><sub> i </sub> and <span class="arrow"></span>TypeEmpty<span class="arrow"></span><sub> i </sub> following the procedure described below. </p> <p>Generate a grammar Attribute<sub> i </sub>, for each attribute use A<sub> i</sub> in {attribute uses} according to section 8.5.4.1.4 Attribute Uses. </p> <p>Sort the attribute use grammars first by qname local-name, then by qname uri to form a sequence of grammars G<sub> 0 </sub>, G<sub> 1 </sub>, …, G<sub> n−1 </sub>, where n is the number of attribute uses in {attribute uses}. </p> <p> If an {attribute wildcard} is specified, increment n and generate additional attribute use grammars G<sub> n−1 </sub> as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> n−1, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>EE</td></tr></tbody></table> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> n−1, 1 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>EE</td></tr></tbody></table> <p> When the {attribute wildcard}'s {namespace constraint} is any, or a pair of not and either a namespace name or the special value absent indicating no namespace, add the following production to each grammar G<sub> i </sub> generated above, where 0 ≤ i < n : </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>AT (*) G<sub> i, 0 </sub></td></tr></tbody></table> <p> Otherwise, that is, when {namespace constraint} is a set of values whose members are namespace names or the special value absent indicating no namespace, add the following production to each grammar G<sub> i </sub> generated above where 0 ≤ i < n : </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>AT(uri<sub>x</sub> : *) G<sub> i, 0 </sub></td></tr><tr><td colspan="3"> </td></tr><tr><td colspan="3"> <p> where uri<sub>x</sub> is a member value of {namespace constraint}, provided that it is the empty string (i.e. "") that is used as uri<sub>x</sub> when the member value is the special value absent. Each uri<sub> x </sub> is used to augment the uri partition of the String table. Section 7.3.1 String Table Partitions describes how these uri strings are put into String table for pre-population. </p> </td></tr><tr><td colspan="3"> </td></tr><tr><td colspan="3"> <p>If there is neither an attribute use nor an {attribute wildcard}, G<sub> 0 </sub> of the following form is used as an attribute use grammar. </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> 0, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>EE</td></tr></tbody></table> </td></tr><tr><td colspan="3"> </td></tr><tr><td colspan="3"> <table><tbody><tr><th align="left">Note:</th></tr><tr><td> </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"> </td></tr><tr><td colspan="3"> <table><tbody><tr><th align="left">Semantics:</th></tr><tr><td> </td></tr><tr><td> <p> In complex type grammars, all productions of the form LeftHandSide: AT (*) RightHandSide and LeftHandSide: AT(uri<sub>x</sub> : *) RightHandSide that stem from attribute wildcards are evaluated as follows: </p> </td></tr></tbody></table>
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute matched by AT (*) or AT(uri<sub>x</sub> : *)
    2. If a global attribute definition exists for qname, let global-type be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with global-type, it SHOULD be represented using the datatype representation associated with global-type (see 7. Representing Event Content). If the attribute value is not represented using the datatype representation associated with global-type, represent the attribute event using the AT (*) [untyped value] terminal (see 8.5.4.4 Undeclared Productions).
    <div class="note"><p class="prefix">Note:</p> When a schema-informed grammar is in effect, xsi:type and xsi:nil attributes MUST NOT be represented using AT(*) terminal. </div> </td></tr></tbody></table> <p> The grammar TypeEmpty<sub> 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> TypeEmpty<sub> i</sub> = G<sub> 0</sub> ⊕ G<sub> 1</sub> ⊕ … ⊕ G<sub> n−1</sub> ⊕ Content<sub> i</sub> </td></tr></tbody></table> <p> where the grammar Content<sub> i</sub> is created as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Content<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> EE </td></tr></tbody></table> <p> The grammar Type<sub> i</sub> is generated as follows. </p> <p>If {content type} is a simple type definition T<sub> j</sub> , generate a grammar Content<sub> i</sub> as Type<sub> j</sub> according to section 8.5.4.1.3.1 Simple Type Grammars. If {content type} has a content model particle, generate a grammar Content<sub> i</sub> according to section 8.5.4.1.5 Particles. Otherwise, if {content type} is empty, create a grammar Content<sub> i</sub> as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Content<sub> 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 Content<sub> i , j </sub> in Content<sub> i </sub> as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Content<sub> i, j </sub> :</td></tr><tr><td></td><td width="5%"></td><td>CH [untyped value] Content<sub> i, j </sub></td></tr></tbody></table> <table width="100%"><thead><tr><th align="left" colspan="2">Note:</th></tr></thead><tbody><tr><td>    </td><td> The value of each Characters event that has an [untyped value] is represented as a String (see 7.1.10 String). </td></tr></tbody></table> <p>Then, create a copy H<sub> i </sub> of each attribute use grammar G<sub> i </sub> and create the grammar Type<sub> i</sub> by combining this sequence of attribute use grammars and the Content<sub> i</sub> grammar using the grammar concatenation operator defined in section 8.5.4.1.1 Grammar Concatenation Operator as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td> Type<sub> i</sub> = H<sub> 0</sub> ⊕ H<sub> 1</sub> ⊕ … ⊕ H<sub> n−1</sub> ⊕ Content<sub> i</sub> </td></tr></tbody></table> </div></div><div class="div5"> <h6>8.5.4.1.4 Attribute Uses</h6><p> Given an attribute use A<sub> i</sub> with properties {required} and {attribute declaration}, where {attribute declaration} has properties {name}, {target namespace}, {type definition} and {scope}, generate a new EXI grammar Attribute<sub> i </sub> for evaluating attributes in the specified {scope} with qname local-name = {name} and qname uri = {target namespace} where qname is the <span class="arrow"></span>qname<span class="arrow"></span> of the attributes. Add the following grammar productions to Attribute<sub> i </sub>: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Attribute<sub> i, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>AT(qname) [schema-typed value] Attribute<sub> i, 1 </sub></td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Attribute<sub> i, 1 </sub> :</td></tr><tr><td></td><td></td><td>EE</td></tr></tbody></table><p>If the {required} property of A<sub> 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"> Attribute<sub> i, 0 </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 LeftHandSide : AT(qname) [schema-typed value] RightHandSide 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 definition} (see 7. Representing Event Content). Attributes that occur in schema-valid contexts that can be represented using the EXI datatype representation associated with the attribute's {type 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 8.5.4.4 Undeclared Productions. </td></tr></tbody></table></div><div class="div5"> <h6>8.5.4.1.5 Particles</h6><p>Given an XML Schema particle<sup><small>XS1</small></sup> P<sub> i</sub> with {min occurs}, {max occurs} and {term} properties, generate a grammar Particle<sub> i</sub> for evaluating instances of P<sub> i</sub> as follows. </p><p>If {term} is an element declaration, generate the grammar Term<sub> 0</sub> according to section 8.5.4.1.6 Element Terms. If {term} is a wildcard, generate the grammar Term<sub> 0</sub> according to section 8.5.4.1.7 Wildcard Terms Wildcard Terms. If {term} is a model group, generate the grammar Term<sub> 0</sub> according to section 8.5.4.1.8 Model Group Terms. </p><p>Create {min occurs} copies of Term<sub> 0 </sub>. </p><table width="100%"><tbody><tr><td width="5%"></td><td> G<sub> 0 </sub>, G<sub> 1 </sub>, …, G<sub> {min occurs}-1 </sub> </td></tr></tbody></table><p>If {max occurs} is not unbounded, create {max occurs} – {min occurs} additional copies of Term<sub> 0 </sub>, </p><table width="100%"><tbody><tr><td width="5%"></td><td> G<sub> {min occurs} </sub>, G<sub> {min occurs}+1 </sub>, …, G<sub> {max 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"> G<sub> i, 0 </sub> :</td></tr><tr><td></td><td width="5%"></td><td>EE     where {min occurs} ≤ i < {max occurs}</td></tr></tbody></table><p>indicating these instances of Term<sub> 0</sub> may be omitted from the content model. Then, create the grammar for Particle<sub> i</sub> using the grammar concatenation operator defined in section 8.5.4.1.1 Grammar Concatenation Operator as follows: </p><table width="100%"><tbody><tr><td width="5%"></td><td> Particle<sub> i</sub> = G<sub> 0</sub> ⊕ G<sub> 1</sub> ⊕ … ⊕ G<sub> {max occurs}-1</sub> </td></tr></tbody></table><p> Otherwise, if {max occurs} is unbounded, generate one additional copy of Term<sub> 0 </sub>, G<sub> {min occurs}</sub> and replace all productions of the form: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> {min occurs}, 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"> G<sub> {min occurs}, k</sub> :</td></tr><tr><td></td><td width="5%"></td><td>G<sub> {min occurs}, 0</sub></td></tr></tbody></table><p>indicating this term may be repeated indefinitely. Then, when there is no more production of the form: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> {min occurs}, 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 G<sub> {min occurs}, 0</sub> on the left-hand side, indicating this term may be omitted from the content model. Then, create the grammar for Particle<sub> i</sub> using the grammar concatenation operator defined in section 8.5.4.1.1 Grammar Concatenation Operator as follows: </p><table width="100%"><tbody><tr><td width="5%"></td><td> Particle<sub> i</sub> = G<sub> 0</sub> ⊕ G<sub> 1</sub> ⊕ … ⊕ G<sub> {min occurs}</sub> </td></tr></tbody></table></div><div class="div5"> <h6>8.5.4.1.6 Element Terms</h6><p> Given a particle {term} PT<sub> i</sub> that is an XML Schema element declaration<sup><small>XS1</small></sup> with properties {name}, {substitution group affiliation} and {target namespace}, let S be the set of element declarations that directly or indirectly reaches the element declaration PT<sub> i</sub> through the chain of {substitution group affiliation} property of the elements, plus PT<sub> i</sub> itself if was not in the set. Sort the element declarations in S lexicographically first by {name} then by {target namespace}, which makes a sorted list of element declarations E<sub> 0 </sub>, E<sub> 1 </sub>, … E<sub> n−1 </sub> where n is the cardinality of S. Then create the grammar ParticleTerm<sub> i </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"> </td></tr><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE(qname<sub> 0 </sub>) ParticleTerm<sub> i, 1</sub> </td></tr><tr><td></td><td width="5%"></td><td> SE(qname<sub> 1 </sub>) ParticleTerm<sub> i, 1</sub> </td></tr><tr><td></td><td></td><td>    â‹®</td></tr><tr><td></td><td width="5%"></td><td> SE(qname<sub> n−1 </sub>) ParticleTerm<sub> i, 1</sub></td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> ParticleTerm<sub> i, 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="3">Note:</th></tr></thead><tbody><tr><td> </td><td colspan="2"> </td></tr><tr><td></td><td colspan="2"> In the productions above, qname<sub> x </sub> (where 0 ≤ x < n) represents a <span class="arrow"></span>qname<span class="arrow"></span> of which local-name and uri are {name} property and {target namespace} property of the element declaration E<sub> x </sub>, respectively.</td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="3">Semantics:</th></tr></thead><tbody><tr><td> </td><td colspan="2"> </td></tr><tr><td></td><td colspan="2"> In a schema-informed grammar, all productions of the form LeftHandSide : SE(qname) RightHandSide are evaluated as follows:
    1. Evaluate the element contents using the SE(qname) grammar.
    2. Evaluate the remainder of the event sequence using RightHandSide
    </td></tr></tbody></table></div><div class="div5"> <h6>8.5.4.1.7 Wildcard Terms</h6><p> Given a particle {term} PT<sub> i </sub> that is an XML Schema wildcard<sup><small>XS1</small></sup> with property {namespace constraint}, a grammar that reflects the wildcard definition is created as follows. </p><p> Create a grammar ParticleTerm<sub> i</sub> containing the following grammar production: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 1</sub> : </td></tr><tr><td></td><td width="5%"></td><td> EE </td></tr></tbody></table><p>When the wildcard's {namespace constraint} is any, or a pair of not and either a namespace name or the special value absent indicating no namespace, add the following production to ParticleTerm<sub> i </sub>. </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE(*) ParticleTerm<sub> i, 1</sub> </td></tr></tbody></table><p> Otherwise, that is, when {namespace constraint} is a set of values whose members are namespace names or the special value absent indicating no namespace, add the following production to ParticleTerm<sub> i </sub>: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE(uri<sub> x </sub>: *) ParticleTerm<sub> i, 1</sub> </td></tr><tr><td colspan="3"> </td></tr></tbody></table><p> for each member value uri<sub>x</sub> in {namespace constraint}, provided that it is the empty string (i.e. "") that is used as uri<sub>x</sub> when the member value is the special value absent. Each uri<sub> x </sub> is used to augment the uri partition of the String table. Section 7.3.1 String Table Partitions describes how these uri 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> </td><td></td></tr><tr><td></td><td> In a schema-informed grammar, all productions of the form LeftHandSide : Terminal RightHandSide where Terminal is one of SE (*) or SE (uri<sub> x </sub>: *) are evaluated as follows:
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*) or SE(uri<sub> x </sub>: *)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of the event sequence using RightHandSide
    </td></tr></tbody></table></div><div class="div5"> <h6>8.5.4.1.8 Model Group Terms</h6><div class="div6"> <h6>8.5.4.1.8.1 Sequence Model Groups</h6> <p>Given a particle {term} PT<sub> i</sub> that is a model group with {compositor} equal to "sequence" and a list of n {particles} P<sub> 0 </sub>, P<sub> 1 </sub>, …, P<sub> n−1 </sub>, create a grammar ParticleTerm<sub> i </sub> as follows: </p> <p>If the value of n is 0, add the following productions to the grammar ParticleTerm<sub> i </sub>. </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> EE </td></tr></tbody></table> <p>Otherwise, generate a sequence of grammars Particle<sub> 0 </sub>, Particle<sub> 1 </sub>, …, Particle<sub> n−1 </sub> corresponding to the list of particles P<sub> 0 </sub>, P<sub> 1 </sub>, …, P<sub> n−1 </sub> according to section 8.5.4.1.5 Particles. Then combine the sequence of grammars using the grammar concatenation operator defined in section 8.5.4.1.1 Grammar Concatenation Operator as follows: </p> <table width="100%"><tbody><tr><td width="5%"></td><td> ParticleTerm<sub> i </sub> = Particle<sub> 0</sub> ⊕ Particle<sub> 1</sub> ⊕ … ⊕ Particle<sub> n−1</sub></td></tr></tbody></table> </div><div class="div6"> <h6>8.5.4.1.8.2 Choice Model Groups</h6> <p>Given a particle {term} PT<sub> i</sub> that is a model group with {compositor} equal to "choice" and a list of n {particles} P<sub> 0 </sub>, P<sub> 1 </sub>, …, P<sub> n−1 </sub>, create a grammar ParticleTerm<sub> i </sub> as follows: </p> <p> If the value of n is 0, add the following productions to the grammar ParticleTerm<sub> i </sub>. </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 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 Particle<sub> 0 </sub>, Particle<sub> 1 </sub>, …, Particle<sub> n−1</sub> corresponding to the list of particles P<sub> 0 </sub>, P<sub> 1 </sub>, …, P<sub> n−1</sub> according to section 8.5.4.1.5 Particles. Then create the grammar ParticleTerm<sub> i</sub> with the following grammar productions: </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Particle<sub> 0, 0</sub> </td></tr><tr><td></td><td></td><td> </td></tr><tr><td></td><td></td><td> Particle<sub> 1, 0</sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> Particle<sub> n−1, 0</sub> </td></tr></tbody></table> <p> indicating the grammar for the term may accept any one of the given {particles}. </p> </div><div class="div6"> <h6>8.5.4.1.8.3 All Model Groups</h6> <p> Given a particle {term} PT<sub> i</sub> that is a model group with {compositor} equal to "all" and a list of n   { particles } P<sub> 0 </sub>, P<sub> 1 </sub>, ..., P<sub> n−1 </sub>, create a grammar ParticleTerm<sub> i </sub> as follows: </p> <p> Add the following production to the grammar ParticleTerm<sub> i </sub>. </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> EE </td></tr></tbody></table> <p>If the value of n is not 0, generate a sequence of grammar productions Particle<sub> 0 </sub>, Particle<sub> 1 </sub>, …, Particle<sub> n−1</sub> corresponding to the list of particles P<sub> 0 </sub>, P<sub> 1 </sub>, …, P<sub> n−1 </sub> according to section 8.5.4.1.5 Particles. </p> <p>Replace all productions of the form:</p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Particle<sub> j , 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"> Particle<sub> j , k</sub> : </td></tr><tr><td></td><td width="5%"></td><td> ParticleTerm<sub> i, 0</sub> </td></tr></tbody></table> <p> where 0 ≤ j < n, and 0 ≤ k < m with m denoting the number non-terminals in the grammar Particle<sub> j </sub>. </p> <p> Add the following productions to the grammar ParticleTerm<sub> i </sub>. </p> <table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> ParticleTerm<sub> i, 0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Particle<sub> 0, 0</sub> </td></tr><tr><td></td><td></td><td> </td></tr><tr><td></td><td></td><td> Particle<sub> 1, 0</sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> Particle<sub> n−1, 0</sub> </td></tr></tbody></table> <div class="note"><p class="prefix">Note:</p> 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. </div> </div></div></div><div class="div4"> <h5>8.5.4.2 EXI Normalized Grammars</h5><p>This section describes the process for converting an EXI proto-grammar generated from an XML Schema in accordance with section 8.5.4.1 EXI Proto-Grammars 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 [Greibach Normal Form]. </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"> LeftHandSide : </td></tr><tr><td></td><td width="5%"></td><td> RightHandSide </td></tr></tbody></table><p>where LeftHandSide and RightHandSide 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 8.5.4.2.1 Eliminating Productions with no Terminal Symbol. The second step is described in section 8.5.4.2.2 Eliminating Duplicate Terminal Symbols. Once these two steps are completed, the grammar will be an EXI normalized grammar. </p><div class="div5"> <h6>8.5.4.2.1 Eliminating Productions with no Terminal Symbol</h6><p> Given an EXI proto-grammar G<sub> i </sub>, with non-terminals G<sub> i, 0 </sub>, G<sub> i, 1 </sub>, …, G<sub> i, n−1 </sub>, replace each production of the form: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> G<sub> i, k</sub>    where 0 ≤ j < n and 0 ≤ k < n </td></tr></tbody></table><p>with a set of productions: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> RHS(G<sub> i, k </sub>)<sub> 0</sub> </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, k </sub>)<sub> 1</sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, k </sub>)<sub> m-1</sub> </td></tr></tbody></table><p>where RHS(G<sub> i, k </sub>)<sub> 0 </sub>, RHS(G<sub> i, k </sub>)<sub> 1 </sub>, …, RHS(G<sub> i, k </sub>)<sub> m-1</sub> represents the right-hand side of each production in G<sub> i</sub> that has the non-terminal G<sub> i, k</sub> on the left-hand side and m is the number of such productions. </p><p> Remove such productions if any among G<sub> i, j</sub> : RHS(G<sub> i, k </sub>)<sub> h</sub> where 0 ≤ h < m 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 G<sub> i, 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"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> G<sub> i, k</sub>    where 0 ≤ j < n and 0 ≤ k < n </td></tr></tbody></table><p>in the grammar G<sub> i </sub>. </p></div><div class="div5"> <h6>8.5.4.2.2 Eliminating Duplicate Terminal Symbols</h6><p>Given an EXI proto-grammar G<sub> i </sub>, with non-terminals G<sub> i, 0 </sub>, G<sub> i, 1 </sub>, …, G<sub> i, n−1 </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"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Terminal G<sub> i, k</sub> </td></tr><tr><td></td><td></td><td> Terminal G<sub> i, l</sub> </td></tr></tbody></table><p>where k  ≠  l 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"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Terminal G<sub> i, k âŠ” l</sub> </td></tr></tbody></table><p> where G<sub> i, k âŠ” l</sub> is a distinct non-terminal that accepts the inputs accepted by G<sub> i, k</sub> and the inputs accepted by G<sub> i, l </sub>. Here the notation "  k âŠ” l  " denotes a union set of integers and is used to uniquely identify the index of such a non-terminal. </p><p> If the non-terminal G<sub> i, k âŠ” l</sub> does not exist, create it as follows: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, k âŠ” l</sub> : </td></tr><tr><td></td><td width="5%"></td><td> RHS(G<sub> i, k </sub>)<sub> 0</sub> </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, k </sub>)<sub> 1</sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, k </sub>)<sub> m-1</sub> </td></tr><tr><td></td><td></td><td> </td></tr><tr><td></td><td></td><td>   </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, l </sub>)<sub> 0</sub> </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, l </sub>)<sub> 1</sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> RHS(G<sub> i, l </sub>)<sub> n−1</sub> </td></tr></tbody></table><p>where RHS(G<sub> i, k </sub>)<sub> 0</sub>, RHS(G<sub> i, k </sub>)<sub> 1</sub>, …, RHS(G<sub> i, k </sub>)<sub> m-1</sub> and RHS(G<sub> i, l </sub>)<sub> 0</sub>, RHS(G<sub> i, l </sub>)<sub> 1</sub>, …, RHS(G<sub> i, l </sub>)<sub> n−1</sub> represent the right-hand side of each production in the Grammar G<sub> i</sub> that has the non-terminals G<sub> j, k</sub> and G<sub> j, l</sub> on the left-hand side respectively and m and n are the number of such productions. </p><p>Repeat this process until there are no more productions in the grammar G<sub> i</sub> of the form: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Terminal G<sub> i, k</sub> </td></tr><tr><td></td><td></td><td> Terminal G<sub> i, 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"> G<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> Terminal G<sub> i, k</sub> </td></tr><tr><td></td><td></td><td> Terminal G<sub> i, k</sub> </td></tr></tbody></table><p> where 0 ≤ k < n, n is the number of productions in G<sub> i</sub> and Terminal represents a specific terminal symbol, then remove one of them until there are no more productions remaining in the grammar G<sub> i</sub> of this form. </p></div></div><div class="div4"> <h5>8.5.4.3 Event Code Assignment</h5><p>This section describes the process for assigning unique <span class="arrow"></span>event codes<span class="arrow"></span> to each production in a normalized EXI grammar. Given a normalized EXI grammar G<sub> i </sub>, apply the following process to each unique non-terminal G<sub> i, j</sub> that occurs on the left-hand side of the productions in G<sub> i</sub> where 0 ≤ j < n and n is the number of such non-terminals in G<sub> i </sub>. </p><p>Sort all productions with G<sub> i, j</sub> on the left-hand side in the following order: </p>
    1. all productions with AT(qname) on the right-hand side sorted lexicographically by qname local-name, then by qname uri, followed by
    2. all productions with AT(uri<sub>x</sub> : *) on the right-hand side sorted lexicographically by uri, followed by
    3. any production with AT (*) on the right-hand side, followed by
    4. all productions with SE(qname) on the right-hand side sorted in schema order, followed by
    5. all productions with SE(uri<sub>x</sub> : *) on the right-hand side sorted in schema order, followed by
    6. any production with SE(*) on the right-hand side, followed by
    7. any production with EE on the right-hand side, followed by
    8. any production with CH on the right-hand side.
    <p> In step 4 and step 5, the schema order of productions with SE(qname) and SE(uri<sub>x</sub> : *) 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 P<sub> 0 </sub>, P<sub> 1 </sub>, … P<sub> n</sub> with the non-terminal G<sub> i, j</sub> on the left-hand side, assign <span class="arrow"></span>event codes<span class="arrow"></span> 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> P<sub> 0</sub> </td><td> 0 </td></tr><tr><td></td><td> P<sub> 1</sub> </td><td> 1 </td></tr><tr><td></td><td> â‹® </td><td> â‹® </td></tr><tr><td></td><td> P<sub> n−1</sub> </td><td> n−1 </td></tr></tbody></table></div><div class="div4"> <h5>8.5.4.4 Undeclared Productions</h5><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 <span class="arrow"></span>strict option<span class="arrow"></span> 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 <span class="arrow"></span>strict option<span class="arrow"></span> 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 7. Representing Event Content). When the <span class="arrow"></span>strict option<span class="arrow"></span> 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" span="1"></colgroup><colgroup span="1"></colgroup><thead><tr><th align="center">                            Notation                           </th><th>Definition</th></tr></thead><tbody><tr><td>    AT (qname) [untyped value]</td><td>Terminal symbol that matches an attribute event with <span class="arrow"></span>qname<span class="arrow"></span> qname and an untyped value.</td></tr><tr><td>    AT (*) [untyped value]</td><td>Terminal symbol that matches an attribute event with any <span class="arrow"></span>qname<span class="arrow"></span> and an untyped value.</td></tr><tr><td>    CH [untyped value]</td><td>Terminal symbol that matches a characters event with an untyped value.</td></tr></tbody></table><div class="div5"> <h6>8.5.4.4.1 Adding Productions when Strict is False</h6><p>This section describes the process for augmenting the normalized grammars when the value of the <span class="arrow"></span>strict option<span class="arrow"></span> is false.</p><p> <span class="termdef">[Definition:]  For each normalized element grammar Element<sub> i </sub>, an unique index number content is determined such that: for each set of grammar productions with left-hand side non-terminal symbol of index smaller than content there is at least one production with AT terminal symbol and the rest of the productions in Element<sub> i </sub> with left-hand side non-terminal symbols of indices equal or greater than content do not have AT terminal symbols. The left-hand side non-terminal symbols indices are assigned in ascending order with the entry non-terminal symbol of Element<sub> i </sub> being assigned index 0 (zero). If there are no productions in Element<sub> i </sub> that have AT terminal symbols on their right-hand side, the content index is 0.</span> </p><p> For each normalized element grammar Element<sub> i </sub>, create a copy Element<sub> i, content2</sub> of Element<sub> i, content</sub> where the index "content" is the <span class="arrow"></span>content<span class="arrow"></span> of the Element<sub> i </sub> grammar. Then, apply the following procedures.</p><p>Add the following production to each non-terminal Element<sub> i, j </sub> that does not already include a production of the form Element<sub> i, j</sub> : EE, such that 0 ≤ j ≤ 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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td></td><td width="50%"> EE </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </td></tr><tr><td colspan="4"> </td></tr></tbody></table><p>Let E<sub> i</sub> be the element declaration from which Element<sub> i</sub> was created and T<sub> k</sub> be the {type definition} of E<sub> i </sub>. Let <span class="arrow"></span> Type<sub> k</sub> <span class="arrow"></span> and <span class="arrow"></span> TypeEmpty<sub> k</sub> <span class="arrow"></span> be the type grammars created from T<sub> k</sub> (see section 8.5.4.1.3 Type Grammars). Add the following productions to Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, 0</sub> : </td></tr><tr><td></td><td></td><td width="50%"> AT(xsi:type) Element<sub> i, 0</sub> </td><td> n.m </td></tr><tr><td></td><td></td><td width="50%"> AT(xsi:nil) Element<sub> i, 0</sub> </td><td> n.(m+1) </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> <p> where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th colspan="2" align="left">Note:</th></tr></thead><tbody><tr><td> </td><td></td></tr><tr><td></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> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td> </td><td></td></tr><tr><td></td><td> All productions of the form LeftHandSide : AT (xsi:type) RightHandSide are evaluated as follows:
    1. Let target-type be the value of the xsi:type attribute and assign it the QName datatype representation (see 7.1.7 QName).
    2. If there is no namespace in scope for the specified <span class="arrow"></span>qname<span class="arrow"></span> prefix, set the uri of target-type to empty ("") and the localName to the full lexical value of the QName, including the prefix.
    3. Represent the value of target-type according to section 7. Representing Event Content.
    4. If a grammar can be found for the target-type type using the encoded target-type representation, evaluate the element contents using the grammar for target-type type instead of RightHandSide.
    </td></tr><tr><td></td><td> In a schema-informed grammar, all productions of the form LeftHandSide : AT (xsi:nil) RightHandSide are evaluated as follows:
    1. Let nil be the value of the xsi:nil attribute.
    2. If nil is a valid Boolean, assign it the Boolean datatype representation (see 7.1.2 Boolean) and encode it according to section 7. Representing Event Content. If nil is not a valid Boolean, represent the xsi:nil attribute event using the AT (*) [untyped value] terminal (see 8.5.4.4 Undeclared Productions).
    3. If the value of nil is true, evaluate the element contents using the grammar TypeEmpty<sub> k</sub> defined above rather than RightHandSide.
    </td></tr></tbody></table><p> For each non-terminal Element<sub> i, j </sub>, such that 0 ≤ j ≤ content , with zero or more productions of the following form: </p><table width="100%"><tbody><tr><td width="5%"></td><td colspan="2"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT (qname<sub> 0 </sub>) [schema-typed value] NonTerminal<sub> 0 </sub> </td></tr><tr><td></td><td></td><td> AT (qname<sub> 1 </sub>) [schema-typed value] NonTerminal<sub> 1 </sub> </td></tr><tr><td></td><td></td><td>     â‹® </td></tr><tr><td></td><td></td><td> AT (qname<sub> x-1 </sub>) [schema-typed value] NonTerminal<sub> x-1 </sub> </td></tr></tbody></table><p>where x 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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td></td><td width="50%"> AT (*) Element<sub> i, j</sub> </td><td> n.m </td></tr><tr><td></td><td></td><td> AT (qname<sub> 0 </sub>) [untyped value] NonTerminal<sub> 0 </sub> </td><td> n.(m+1).0 </td></tr><tr><td></td><td></td><td> AT (qname<sub> 1 </sub>) [untyped value] NonTerminal<sub> 1 </sub> </td><td> n.(m+1).1 </td></tr><tr><td></td><td></td><td>     â‹® </td><td>     â‹® </td></tr><tr><td></td><td></td><td> AT (qname<sub> x-1 </sub>) [untyped value] NonTerminal<sub> x-1 </sub> </td><td> n.(m+1).(x-1) </td></tr><tr><td></td><td></td><td> AT (*) [untyped value] Element<sub> i, j</sub> </td><td> n.(m+1).(x) </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left">Note:</th></tr></thead><tbody><tr><td>  </td></tr><tr><td>
    • The value of each attribute event that has an [untyped value] is represented as a String (see 7.1.10 String).
    </td></tr><tr><td>
    • 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></p><table border="1" width="95%"><caption>Table 8-1. Equivalent terminal symbols for different attribute and element representations</caption><colgroup width="20%" span="1"></colgroup><colgroup width="40%" span="1"></colgroup><colgroup width="40%" span="1"></colgroup><thead><tr><th> </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 (qname) [schema-typed value]</td></tr><tr><td>SE (qname) CH [schema-typed value]</td></tr></table></td><td> <table border="0"><tr><td>AT (qname) [untyped value]</td></tr><tr><td>SE (qname) CH [untyped value]</td></tr></table></td></tr><tr><th>Schema-invalid occurrence</th><td> <table border="0"><tr><td>AT (*)</td></tr><tr><td>SE (*) CH [schema-typed value]</td></tr></table></td><td> <table><tr><td>AT (*) [untyped value]</td></tr><tr><td>SE (*) CH [untyped value]</td></tr></table> </td></tr></tbody></table><p> Note that an attribute matching AT (*) terminal without [untyped value] predication in schema-informed grammars bears an untyped value unless there is a global attribute definition available for qname where qname is the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute. When a global attribute definition is available for qname, the attribute value is represented according to the datatype of the global attribute. </p><p> In the above table, AT (*) terminal without [untyped 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>
    </td></tr><tr><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></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td> </td><td></td></tr><tr><td></td><td> In a schema-informed grammar, all productions of the form LeftHandSide : AT (*) are evaluated as follows:
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the attribute matched by AT (*)
    2. If a global attribute definition exists for qname, let global-type be the datatype of the global attribute. If the attribute value can be represented using the datatype representation associated with global-type, it SHOULD be represented using the datatype representation associated with global-type (see 7. Representing Event Content). If the attribute value is not represented using the datatype representation associated with global-type, represent the attribute event using the AT (*) [untyped value] terminal (see 8.5.4.4 Undeclared Productions).
    </td></tr><tr><td colspan="2"> <div class="note"><p class="prefix">Note:</p> 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 LeftHandSide : AT (xsi:nil) where LeftHandSide 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 (xsi:nil) terminal. AT(*) [untyped value] terminal MUST NOT be used to represent xsi:type attributes. </div> </td></tr></tbody></table><p> Add the following production to Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, 0</sub> : </td></tr><tr><td></td><td></td><td width="50%"> NS Element<sub> i, 0</sub> </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><p> When the value of the <span class="arrow"></span>selfContained option<span class="arrow"></span> is true, add the following production to Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, 0</sub> : </td></tr><tr><td></td><td></td><td width="50%"> SC Fragment </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> 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> </td><td></td></tr><tr><td></td><td> All productions of the form LeftHandSide : SC Fragment are evaluated as follows:
    1. Save the string table, grammars and any implementation-specific state learned while processing this EXI Body.
    2. 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.
    3. Skip to the next byte-aligned boundary in the stream if it is not already at such a boundary.
    4. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the SE event immediately preceding this SC event.
    5. Let content be the sequence of events following this SC event that match the grammar for element qname, up to and including the terminating EE event.
    6. Evaluate the sequence of events (SD, SE(qname), content, ED) according to the Fragment grammar. (see 8.5.2 Schema-informed Fragment Grammar)
    7. Skip to the next byte-aligned boundary in the stream if it is not already at such a boundary.
    8. Restore the string table, grammars and implementation-specific state learned while processing this EXI Body to that saved in step 1 above.
    </td></tr></tbody></table><p> Add the following productions to each non-terminal Element<sub> i, j </sub>, such that 0 ≤ j ≤ 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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td></td><td width="50%"> SE (*) Element<sub> i, content2</sub> </td><td> n.m </td></tr><tr><td></td><td></td><td> CH [untyped value] Element<sub> i, content2</sub> </td><td> n.(m+1) </td></tr><tr><td></td><td></td><td> ER Element<sub> i, content2</sub> </td><td> n.(m+2) </td></tr><tr><td></td><td></td><td> CM Element<sub> i, content2</sub> </td><td> n.(m+3).0 </td></tr><tr><td></td><td></td><td> PI Element<sub> i, content2</sub> </td><td> n.(m+3).1 </td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left">Note:</th></tr></thead><tbody><tr><td>  </td></tr><tr><td>
    • Productions of the form LeftHandSide : CH [untyped value] RightHandSide 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 LeftHandSide : CH [schema-typed value] RightHandSide described in section 8.5.4.1.3.1 Simple Type Grammars.
    </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td> </td><td></td></tr><tr><td></td><td> In a schema-informed grammar, all productions of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows:
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of the event sequence using RightHandSide
    </td></tr></tbody></table><p>Add the following production to Element<sub> i, content2</sub> and to each non-terminal Element<sub> i, j </sub> that does not already include a production of the form Element<sub> i, j</sub> : EE, such that content < j < n, where n is the number of non-terminals in Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td></td><td width="50%"> EE </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><p>Add the following productions to Element<sub> i, content2</sub> and to each non-terminal Element<sub> i, j </sub>, such that content < j < n, where n is the number of non-terminals in Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, j</sub> : </td></tr><tr><td></td><td></td><td width="50%"> SE (*) Element<sub> i, j</sub> </td><td> n.m </td></tr><tr><td></td><td></td><td> CH [untyped value] Element<sub> i, j</sub> </td><td> n.(m+1) </td></tr><tr><td></td><td></td><td> ER Element<sub> i, j</sub> </td><td> n.(m+2) </td></tr><tr><td></td><td></td><td> CM Element<sub> i, j</sub> </td><td> n.(m+3).0 </td></tr><tr><td></td><td></td><td> PI Element<sub> i, j</sub> </td><td> n.(m+3).1 </td></tr><tr><td colspan="4"> </td></tr><tr><td> </td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td> </td><td></td></tr><tr><td></td><td> In a schema-informed grammar, all productions of the form LeftHandSide : SE (*) RightHandSide are evaluated as follows:
    1. Let qname be the <span class="arrow"></span>qname<span class="arrow"></span> of the element matched by SE (*)
    2. If a <span class="arrow"></span>global element grammar<span class="arrow"></span> does not exist for element qname, create one according to section 8.4.3 Built-in Element Grammar.
    3. Evaluate the element content using the <span class="arrow"></span>global element grammar<span class="arrow"></span> for element qname.
    4. Evaluate the remainder of the event sequence using RightHandSide
    </td></tr></tbody></table><p>Apply the process described above for element grammars to each normalized type grammar <span class="arrow"></span>Type<sub> i </sub><span class="arrow"></span> and <span class="arrow"></span>TypeEmpty<sub> i </sub><span class="arrow"></span>. </p></div><div class="div5"> <h6>8.5.4.4.2 Adding Productions when Strict is True</h6><p>This section describes the process for augmenting the normalized grammars when the value of the <span class="arrow"></span>strict option<span class="arrow"></span> is true. For each normalized element grammar Element<sub> i </sub>, apply the following procedures.</p><p>Let E<sub> i</sub> be the element declaration from which Element<sub> i</sub> was created and T<sub> k</sub> be the {type definition} of E<sub> i </sub>. If T<sub> k</sub> either has named sub-types or is a simple type definition of which {variety} is union, add the following production to Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, 0</sub> : </td></tr><tr><td></td><td></td><td width="50%"> AT(xsi:type) Element<sub> i, 0</sub> </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td colspan="2">  </td></tr><tr><td colspan="2"> All productions of the form LeftHandSide : AT (xsi:type) RightHandSide are evaluated as follows: </td></tr><tr><td>     </td><td>     </td></tr><tr><td>     </td><td>
    1. Let target-type be the value of the xsi:type attribute and assign it the QName datatype representation (see 7.1.7 QName).
    2. If there is no namespace in scope for the specified <span class="arrow"></span>qname<span class="arrow"></span> prefix, set the uri of target-type to empty ("") and the localName to the full lexical value of the QName, including the prefix.
    3. Represent the value of target-type according to section 7. Representing Event Content.
    4. If a grammar can be found for the target-type type using the encoded target-type representation, evaluate the element contents using the grammar for target-type type instead of RightHandSide.
    </td></tr></tbody></table><p> Let <span class="arrow"></span> Type<sub> k</sub> <span class="arrow"></span> and <span class="arrow"></span> TypeEmpty<sub> k</sub> <span class="arrow"></span> be the type grammars created from T<sub> k</sub> (see section 8.5.4.1.3 Type Grammars). If the {nillable} property of E<sub> i</sub> is true, add the following production to Element<sub> i </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%"> </td><td width="5%"></td><td></td><td></td></tr><tr><td></td><td colspan="3"> Element<sub> i, 0</sub> : </td></tr><tr><td></td><td></td><td width="50%"> AT(xsi:nil) Element<sub> i, 0</sub> </td><td> n.m </td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> <p>where n.m represents the next available <span class="arrow"></span>event code<span class="arrow"></span> with length 2. </p> </td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="100%"><thead><tr><th align="left" colspan="2">Semantics:</th></tr></thead><tbody><tr><td colspan="2">  </td></tr><tr><td colspan="2"> In a schema-informed grammar, all productions of the form LeftHandSide : AT (xsi:nil) RightHandSide are evaluated as follows: </td></tr><tr><td>     </td><td>     </td></tr><tr><td>     </td><td>
    1. Let nil be the value of the xsi:nil attribute.
    2. If nil is a valid Boolean, assign it the Boolean datatype representation (see 7.1.2 Boolean) and encode it according to section 7. Representing Event Content. Otherwise, the value of the nil is schema-invalid and cannot be represented when the value of the <span class="arrow"></span>strict option<span class="arrow"></span> is true.
    3. If the value of nil is true, evaluate the element contents using the grammar TypeEmpty<sub> k</sub> defined above rather than RightHandSide.
    </td></tr></tbody></table><table width="100%"><thead><tr><th colspan="2" align="left">Note:</th></tr></thead><tbody><tr><td colspan="2">  </td></tr><tr><td colspan="2"> </td></tr><tr><td colspan="2">
    • There are several restrictions peculiar to schema-informed element and type grammars created with <span class="arrow"></span>strict option<span class="arrow"></span> value true 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 <span class="arrow"></span>strict option<span class="arrow"></span> value that works best for each use case.
    </td></tr><tr><td>    </td><td>
    • 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.
    </td></tr><tr><td></td><td>
    • 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 union.
    </td></tr><tr><td></td><td> </td></tr><tr><td></td><td>
    • The attributes xsi:schemaLocation and xsi:noNamespaceSchemaLocation can appear only when they match specific schema declarations (i.e., wildcards or ur-types).
    </td></tr></tbody></table></div></div></div></div></div><div class="div1"> <h2>9. EXI Compression</h2><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 <span class="arrow"></span>compression<span class="arrow"></span> is turned on or when <span class="arrow"></span>alignment <span class="arrow"></span> is set to <span class="arrow"></span>pre-compression<span class="arrow"></span>. Byte-aligned representations of <span class="arrow"></span>event codes<span class="arrow"></span> and <span class="arrow"></span>content items<span class="arrow"></span> 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, <span class="arrow"></span>event codes<span class="arrow"></span> and <span class="arrow"></span>content items<span class="arrow"></span> of EXI events are encoded as aligned bytes in accordance with 6.2 Representing Event Codes and 7. Representing Event Content.</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 channels, 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><div class="figure" style="text-align: center"><br><img src="compression.png" alt="EXI Compression Overview"><p><span>Figure 9-1. </span>EXI Compression Overview</p><br></div><p>In the following sections, 9.1 Blocks defines blocks and explains how EXI events are partitioned into blocks. Section 9.2 Channels defines channels, their organization as well as how a group of channels correlate to its corresponding block of events. Section 9.3 Compressed Streams describes how some channels are combined as needed in preparation for applying compression algorithms on channels. </p><div class="div2"> <h3>9.1 Blocks</h3><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 <span class="arrow"></span>blockSize<span class="arrow"></span> values in its value channels (see 9.2.2 Value Channels), where blockSize is the block size of the EXI stream (see 5.4 EXI Options). The final block contains less than the minimum set of consecutive events that result in blockSize values in its value channels. </p></div><div class="div2"> <h3>9.2 Channels</h3><p>Events inside each block are multiplexed into channels. The first channel of each block is the structure channel described in Section 9.2.1 Structure Channel. The remaining channels in each block are value channels described in Section 9.2.2 Value Channels. 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><div class="figure" style="text-align: center"><br><img src="channels.png" alt="Multiplexing EXI events into channels"><p><span>Figure 9-2. </span>Multiplexing EXI events into channels</p><br></div><div class="div3"> <h4>9.2.1 Structure Channel</h4><p>The structure channel of each block defines the overall order and structure of the events in that block. It contains the <span class="arrow"></span>event codes<span class="arrow"></span> and associated content for each event in the block, except for Attribute (AT) and Character (CH) <span class="arrow"></span>values<span class="arrow"></span>, which are stored in the value channels. In addition, there are two kinds of attribute events whose values are stored in the structure channel instead of in value channels. The value of each xsi:type attribute is stored in the structure channel. The value 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 <span class="arrow"></span>event codes<span class="arrow"></span> and content in the structure stream occur in the same order as they occur in the EXI event sequence.</p></div><div class="div3"> <h4>9.2.2 Value Channels</h4><p>The values of the Attribute (AT) and Character (CH) events in each block are organized into separate channels based on the qname of the associated attribute or element. Specifically, the value of each Attribute (AT) event is placed in the channel identified by the qname of the Attribute and the value of each Character (CH) event is placed in the channel identified by the qname of its parent Start Element (SE) event. Each block contains exactly one channel for each distinct element or attribute qname that occurs in the block. The values in each channel occur in the order they occur in the EXI event sequence.</p></div></div><div class="div2"> <h3>9.3 Compressed Streams</h3><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 values, 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 value in each channel occurs in the EXI event sequence.</p><p>If the value channels of the block contain more than 100 values, the first compressed stream contains only the structure channel. The second compressed stream contains all value channels that contain at most 100 values. And the remaining compressed streams each contain only one channel, each having more than 100 values. The order of the value channels within the second compressed stream is defined by the order in which the first value 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 value of the channel inside each compressed stream occurs in the EXI event sequence.</p><div class="note"><p class="prefix">Note:</p>EXI compression changes the order in which <span class="arrow"></span>event codes<span class="arrow"></span> and values are read and written to and from an EXI stream. <span class="arrow"></span>EXI processors<span class="arrow"></span> must encode and decode values in this revised order so order sensitive constructs like the string table (see 7.3 String Table) work properly.</div><p> When the value of the <span class="arrow"></span>compression<span class="arrow"></span> option is set to true, each compressed stream in a block is stored using the standard DEFLATE Compressed Data Format defined by RFC 1951 [IETF RFC 1951]. Otherwise, when the value of the <span class="arrow"></span>alignment <span class="arrow"></span> option is set to <span class="arrow"></span>pre-compression<span class="arrow"></span>, each compressed stream in a block is stored directly without the DEFLATE algorithm.</p><div class="note"><p class="prefix">Note:</p> 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. </div></div></div><div class="div1"> <h2>10. Conformance</h2><div class="div2"> <h3>10.1 EXI Stream Conformance</h3><p> <span class="termdef">[Definition:]  A conformant EXI stream consists of a sequence of octets that follows the syntax of <span class="arrow"></span>EXI stream<span class="arrow"></span> that is defined in this document. </span> <span class="termdef">[Definition:]   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 Extended EXI streams. </span> </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. <span class="termdef">[Definition:]   An extended EXI stream is a conformant extended EXI stream if replacing value items represented using user-defined datatype representations with their intrinsic representations would make the stream a <span class="arrow"></span>conformant EXI stream<span class="arrow"></span>. </span> An extended EXI stream described as an "EXI stream with regards to datatype representations S " where S is the set of datatype representations can be processed by an <span class="arrow"></span>EXI stream decoder<span class="arrow"></span> only if the processor has the shared knowledge about each one of the datatype representations in the set S. </p><p>The structural syntax of <span class="arrow"></span>EXI streams<span class="arrow"></span> and <span class="arrow"></span>extended EXI streams<span class="arrow"></span> 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></div><div class="div2"> <h3>10.2 EXI Processor Conformance</h3><p> The conformance of EXI Processors is defined separately for each of the two processor roles, <span class="arrow"></span>EXI stream encoders<span class="arrow"></span> and <span class="arrow"></span>EXI stream decoders<span class="arrow"></span>; the conformance of the former is described in terms of the conformance of the <span class="arrow"></span>EXI streams<span class="arrow"></span> or <span class="arrow"></span>extended EXI streams<span class="arrow"></span> 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 <span class="arrow"></span>conformant EXI streams<span class="arrow"></span> or <span class="arrow"></span>conformant extended EXI streams<span class="arrow"></span>. </p><p> An <span class="arrow"></span>EXI stream encoder<span class="arrow"></span> is conformant if and only if it is capable of generating <span class="arrow"></span>conformant EXI streams<span class="arrow"></span> or <span class="arrow"></span>conformant extended EXI streams<span class="arrow"></span> given any input structured data it is made to work on. On the other hand, <span class="arrow"></span>EXI stream decoders<span class="arrow"></span> MUST support all format features described in this document as they are explained, except for the capability of handling <span class="arrow"></span>Datatype Representation Map<span class="arrow"></span> which is an optional feature. EXI stream decoders that do not implement <span class="arrow"></span>Datatype Representation Map<span class="arrow"></span> feature MUST report an error with a meaningful message upon encountering a <span class="arrow"></span>"datatypeRepresentationMap"<span class="arrow"></span> element while processing <span class="arrow"></span>EXI options documents<span class="arrow"></span> in <span class="arrow"></span>EXI headers<span class="arrow"></span>. </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></div></div></div><div class="back"><div class="div1"> <h2>A References</h2><div class="div2"> <h3>A.1 Normative References</h3><dl><dt class="label">IETF RFC 1951</dt><dd> <cite>DEFLATE Compressed Data Format Specification version 1.3</cite>, P. Deutsch, Author. Internet Engineering Task Force, May 1996. Available at http://www.ietf.org/rfc/rfc1951.txt. </dd><dt class="label">IETF RFC 2119</dt><dd> <cite>Key words for use in RFCs to Indicate Requirement Levels</cite>, S. Bradner, Author. Internet Engineering Task Force, June 1999. Available at http://www.ietf.org/rfc/rfc2119.txt. </dd><dt class="label">IETF RFC 3023</dt><dd> <cite>XML Media Types</cite>, M. Murata, S. St.Laurent and D. Kohn, Author. Internet Engineering Task Force, January 2001. Available at http://www.ietf.org/rfc/rfc3023.txt. </dd><dt class="label">ISO/IEC 10646</dt><dd> <cite>ISO/IEC 10646-1:2000. Information technology — Universal Multiple-Octet Coded Character Set (UCS) — Part 1: Architecture and Basic Multilingual Plane</cite> and <cite>ISO/IEC 10646-2:2001. Information technology — Universal Multiple-Octet Coded Character Set (UCS) — Part 2: Supplementary Planes</cite>, 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 http://www.iso.org for the latest version.) </dd><dt class="label">UNICODE</dt><dd> <cite>The Unicode Standard</cite>, The Unicode Consortium </dd><dt class="label">XML 1.0</dt><dd> <cite> Extensible Markup Language (XML) 1.0 (Fifth Edition) </cite>, 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 http://www.w3.org/TR/REC-xml. </dd><dt class="label">XML 1.1</dt><dd> <cite> Extensible Markup Language (XML) 1.1 (Second Edition) </cite>, 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 http://www.w3.org/TR/xml11. </dd><dt class="label">Namespaces in XML 1.0</dt><dd> <cite>Namespaces in XML 1.0 (Third Edition)</cite>, T. Bray, D. Hollander, A. Layman, R. Tobin, and H. Thompson, Editors. World Wide Web Consortium, 14 January 1999, revised 8 December 2009. This version is http://www.w3.org/TR/2009/REC-xml-names-20091208. The latest version is available at http://www.w3.org/TR/xml-names/. </dd><dt class="label">Namespaces in XML 1.1</dt><dd> <cite>Namespaces in XML 1.1 (Second Edition)</cite>, T. Bray, D. Hollander, A. Layman, and R. Tobin, Editors. World Wide Web Consortium, 4 February 2004, revised 16 August 2006. This version is http://www.w3.org/TR/2006/REC-xml-names11-20060816. The latest version is available at http://www.w3.org/TR/xml-names11/. </dd><dt class="label">XML Information Set</dt><dd> <cite>XML Information Set (Second Edition)</cite>, 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 http://www.w3.org/TR/xml-infoset. </dd><dt class="label">XML Schema Structures</dt><dd> <cite>XML Schema Part 1: Structures Second Edition</cite>, 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 http://www.w3.org/TR/xmlschema-1. </dd><dt class="label">XML Schema Datatypes</dt><dd> <cite>XML Schema Part 2: Datatypes Second Edition</cite>, 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 http://www.w3.org/TR/xmlschema-2. </dd></dl></div><div class="div2"> <h3>A.2 Other References</h3><dl><dt class="label">Efficient XML</dt><dd> <cite>Efficient XML</cite>, part of [EXI Measurements Note] independently referenced. The latest version is available at http://www.w3.org/TR/exi-measurements/#contributions-efx. </dd><dt class="label">EXI Evaluation Note</dt><dd> <cite>Efficient XML Interchange Evaluation</cite>, Carine Bournez, Editor. World Wide Web Consortium. The latest version is available at http://www.w3.org/TR/exi-evaluation/. </dd><dt class="label">EXI Impacts Note</dt><dd> <cite>Efficient XML Interchange (EXI) Impacts</cite>, Jaakko Kangasharju, Editor. World Wide Web Consortium. The latest version is available at http://www.w3.org/TR/exi-impacts/. </dd><dt class="label">EXI Measurements Note</dt><dd> <cite>Efficient XML Interchange Measurements Note</cite>, Greg White, Jaakko Kangasharju, Don Brutzman and Stephen Williams, Editors. World Wide Web Consortium. The latest version is available at http://www.w3.org/TR/exi-measurements/. </dd><dt class="label">EXI Primer</dt><dd> <cite> Efficient XML Interchange (EXI) Primer </cite>, Daniel Peintner, Santiago Pericas-Geertsen, Editors. World Wide Web Consortium. The latest version is available at http://www.w3.org/TR/exi-primer/. </dd><dt class="label">Greibach Normal Form</dt><dd> <cite> A New Normal-Form Theorem for Context-Free Phrase Structure Grammars </cite>, Sheila A. Greibach, Author. Journal of the ACM Volume 12  Issue 1, January 1965, pp. 42–52. </dd><dt class="label">Huffman Coding</dt><dd> <cite>A Method for the Construction of Minimum-Redundancy Codes</cite>, D. A. Huffman, Author. Proceedings of the I.R.E., September 1952, pp. 1098-1102. </dd><dt class="label">IEEE 754-2008</dt><dd> <cite>IEEE Standard for Floating-Point Arithmetic</cite> </dd><dt class="label">ISO/IEC 19757-2:2008</dt><dd> <cite>Document Schema Definition Language (DSDL) -- Part 2: Regular-grammar-based validation -- RELAX NG</cite> </dd><dt class="label">SOAP 1.2</dt><dd> <cite>SOAP Version 1.2 Part 1: Messaging Framework (Second Edition)</cite>, M. Gudgin, M. Hadley, N. Mendelsohn, J-J. Moreau, H. Frystyk Nielsen, A. Karmarkar, and Y. Lafon, Editors. World Wide Web Consortium, 24 June 2003, revised 27 April 2007. This version is http://www.w3.org/TR/2007/REC-soap12-part1-20070427/á Ž. The latest version is available at http://www.w3.org/TR/soap12-part1/. </dd><dt class="label">XBC Measurement Methodologies</dt><dd> <cite>XML Binary Characterization Measurement Methodologies</cite>, 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 http://www.w3.org/TR/xbc-measurement. </dd><dt class="label">XBC Use Cases</dt><dd> <cite>XML Binary Characterization Use Cases</cite>, 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 http://www.w3.org/TR/xbc-use-cases. </dd><dt class="label">XBC Properties</dt><dd> <cite>XML Binary Characterization Properties</cite>, 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 http://www.w3.org/TR/xbc-properties/. </dd></dl></div></div><div class="div1"> <h2>B Infoset Mapping</h2><p> This appendix contains the mappings between the XML Information Set [XML Information Set] model and the EXI format. Starting from the document information item, each information item definition is mapped to its respective unordered set of EXI event types (see Table 4-1). 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, [thus]. </p><div class="note"><p class="prefix">Note:</p><p>As has been prescribed in section 2. Design 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 [character encoding scheme], [standalone] and [version] properties which are available in the definition of Document Information Item of XML Information Set (see B.1 Document Information Item). EXI is made agnostic about [character encoding scheme] and [version] properties as they are in XML Information Set, and considers them to be the properties of XML serializers in use. EXI forgoes [standalone] property because simply having no references to any external markup declarations practically serves the purpose with less complexity. </p></div><div class="div2"> <h3>B.1 Document Information Item</h3><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>Table B-1. 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>[children]</td><td>CM* PI* DT? [SE, EE]</td></tr><tr><td>[document element]</td><td>[SE, EE]</td></tr><tr><td>[notations]</td><td>Computed based on text content item of DT to which each notation information set item maps.</td></tr><tr><td>[unparsed entities]</td><td>Computed based on text content item of DT to which each unparsed entity information set item maps.</td></tr><tr><td>[base URI]</td><td>The base URI of the EXI stream</td></tr><tr><td>[character encoding scheme]</td><td>N/A</td></tr><tr><td>[standalone]</td><td>Not available</td></tr><tr><td>[version]</td><td>Not available</td></tr><tr><td>[all declarations processed]</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></div><div class="div2"> <h3>B.2 Element Information Items</h3><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>Table B-2. 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>[namespace name]</td><td>SE</td></tr><tr><td>[local name]</td><td>SE</td></tr><tr><td>[prefix]</td><td>SE</td></tr><tr><td>[children]</td><td>[SE, EE]* PI* CM* CH* ER*</td></tr><tr><td>[attributes]</td><td>AT*</td></tr><tr><td>[namespace attributes]</td><td>NS*</td></tr><tr><td>[in-scope namespaces]</td><td> The namespace information items computed using the [namespace attributes] properties of this information item and its ancestors </td></tr><tr><td>[base URI]</td><td>The base URI of the element information item</td></tr><tr><td>[parent]</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></div><div class="div2"> <h3>B.3 Attribute Information Item</h3><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>Table B-3. 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>[namespace name]</td><td>AT</td></tr><tr><td>[local name]</td><td>AT</td></tr><tr><td>[prefix]</td><td>AT</td></tr><tr><td>[normalized value]</td><td>The value of AT</td></tr><tr><td>[specified]</td><td>True if the item maps to AT, otherwise false</td></tr><tr><td>[attribute type]</td><td> Computed based on AT and DT </td></tr><tr><td>[references]</td><td> Computed based on [attribute type] and value of AT </td></tr><tr><td>[owner element]</td><td>Computed based on the last SE event encountered that did not get a matching EE event</td></tr></tbody></table></div><div class="div2"> <h3>B.4 Processing Instruction Information Item</h3><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>Table B-4. 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>[target]</td><td>PI</td></tr><tr><td>[content]</td><td>PI</td></tr><tr><td>[base URI]</td><td>The base URI of the processing information item</td></tr><tr><td>[notation]</td><td> Computed based on the availability of the internal DTD subset </td></tr><tr><td>[parent]</td><td>Computed based on the last SE event encountered that did not get a matching EE event type</td></tr></tbody></table></div><div class="div2"> <h3>B.5 Unexpanded Entity Reference Information item</h3><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>Table B-5. 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>[name]</td><td>ER</td></tr><tr><td>[system identifier]</td><td>Based on the availability of the internal DTD subset</td></tr><tr><td>[public identifier]</td><td>Based on the availability of the internal DTD subset</td></tr><tr><td>[declaration base URI]</td><td>The base URI of the unexpanded entity reference information item</td></tr><tr><td>[parent]</td><td>Computed based on the last SE event encountered that did not get a matching EE event type</td></tr></tbody></table></div><div class="div2"> <h3>B.6 Character Information item</h3><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>Table B-6. 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>[character code]</td><td>Each character in CH</td></tr><tr><td>[element content whitespace]</td><td>Computed based on [parent] and DT</td></tr><tr><td>[parent]</td><td>Computed based on the last SE event encountered that did not get a matching EE event</td></tr></tbody></table></div><div class="div2"> <h3>B.7 Comment Information item</h3><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>Table B-7. 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>[content]</td><td>text content item of CM</td></tr><tr><td>[parent]</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></div><div class="div2"> <h3>B.8 Document Type Declaration Information item</h3><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>Table B-8. 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>[system identifier]</td><td>DT</td></tr><tr><td>[public identifier]</td><td>DT</td></tr><tr><td>[children]</td><td>Computed based on text content item of DT</td></tr><tr><td>[parent]</td><td>Computed based on the SD event</td></tr></tbody></table></div><div class="div2"> <h3>B.9 Unparsed Entity Information Item</h3><p> An unparsed entity information item maps to part of the text 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>Table B-9. 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>[name]</td><td>Computed based on text content item of DT</td></tr><tr><td>[system identifier]</td><td>Computed based on text content item of DT</td></tr><tr><td>[public identifier]</td><td>Computed based on text content item of DT</td></tr><tr><td>[declaration base URI]</td><td>The base URI of the unparsed entity information item</td></tr><tr><td>[notation name]</td><td>Computed based on text content item of DT</td></tr><tr><td>[notation]</td><td>Computed based on text content item of DT</td></tr></tbody></table></div><div class="div2"> <h3>B.10 Notation Information Item</h3><p> An notation information item maps to part of the text 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>Table B-10. 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>[name]</td><td>Computed based on text content item of DT</td></tr><tr><td>[system identifier]</td><td>Computed based on text content item of DT</td></tr><tr><td>[public identifier]</td><td>Computed based on text content item of DT</td></tr><tr><td>[declaration base URI]</td><td>The base URI of the notation information item</td></tr></tbody></table></div><div class="div2"> <h3>B.11 Namespace Information Item</h3><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>Table B-11. 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>[prefix]</td><td>NS</td></tr><tr><td>[namespace name]</td><td>NS</td></tr></tbody></table></div></div><div class="div1"> <h2>C XML Schema for EXI Options Document</h2><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><div class="exampleInner"><pre> <xsd:schema targetNamespace="http://www.w3.org/2009/exi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:element name="header"> <xsd:complexType> <xsd:sequence> <xsd:element name="lesscommon" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:element name="uncommon" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="skip" /> <xsd:element name="alignment" minOccurs="0"> <xsd:complexType> <xsd:choice> <xsd:element name="byte"> <xsd:complexType /> </xsd:element> <xsd:element name="pre-compress"> <xsd:complexType /> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> <xsd:element name="selfContained" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="valueMaxLength" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:unsignedInt" /> </xsd:simpleType> </xsd:element> <xsd:element name="valuePartitionCapacity" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:unsignedInt" /> </xsd:simpleType> </xsd:element> <xsd:element name="datatypeRepresentationMap" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <!-- schema datatype --> <xsd:any namespace="##other" processContents="skip" /> <!-- datatype representation --> <xsd:any processContents="skip" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="preserve" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:element name="dtd" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="prefixes" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="lexicalValues" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="comments" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="pis" minOccurs="0"> <xsd:complexType /> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="blockSize" minOccurs="0"> <xsd:simpleType> <xsd:restriction base="xsd:unsignedInt"> <xsd:minInclusive value="1" /> </xsd:restriction> </xsd:simpleType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="common" minOccurs="0"> <xsd:complexType> <xsd:sequence> <xsd:element name="compression" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="fragment" minOccurs="0"> <xsd:complexType /> </xsd:element> <xsd:element name="schemaId" minOccurs="0" nillable="true"> <xsd:simpleType> <xsd:restriction base="xsd:string" /> </xsd:simpleType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="strict" minOccurs="0"> <xsd:complexType /> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <!-- Built-in EXI Datatype IDs for use in datatype representation maps --> <xsd:simpleType name="base64Binary"> <xsd:restriction base="xsd:base64Binary"/> </xsd:simpleType> <xsd:simpleType name="hexBinary" > <xsd:restriction base="xsd:hexBinary"/> </xsd:simpleType> <xsd:simpleType name="boolean" > <xsd:restriction base="xsd:boolean"/> </xsd:simpleType> <xsd:simpleType name="decimal" > <xsd:restriction base="xsd:decimal"/> </xsd:simpleType> <xsd:simpleType name="double" > <xsd:restriction base="xsd:double"/> </xsd:simpleType> <xsd:simpleType name="integer" > <xsd:restriction base="xsd:integer"/> </xsd:simpleType> <xsd:simpleType name="string" > <xsd:restriction base="xsd:string"/> </xsd:simpleType> <xsd:simpleType name="dateTime" > <xsd:restriction base="xsd:dateTime"/> </xsd:simpleType> <xsd:simpleType name="date" > <xsd:restriction base="xsd:date"/> </xsd:simpleType> <xsd:simpleType name="time" > <xsd:restriction base="xsd:time"/> </xsd:simpleType> <xsd:simpleType name="gYearMonth" > <xsd:restriction base="xsd:gYearMonth"/> </xsd:simpleType> <xsd:simpleType name="gMonthDay" > <xsd:restriction base="xsd:gMonthDay"/> </xsd:simpleType> <xsd:simpleType name="gYear" > <xsd:restriction base="xsd:gYear"/> </xsd:simpleType> <xsd:simpleType name="gMonth" > <xsd:restriction base="xsd:gMonth"/> </xsd:simpleType> <xsd:simpleType name="gDay" > <xsd:restriction base="xsd:gDay"/> </xsd:simpleType> <!-- Qnames reserved for future use in datatype representation maps --> <xsd:simpleType name="ieeeBinary32" > <xsd:restriction base="xsd:float"/> </xsd:simpleType> <xsd:simpleType name="ieeeBinary64" > <xsd:restriction base="xsd:double"/> </xsd:simpleType> </xsd:schema> </pre></div><div class="note"><p class="prefix">Note:</p> The <span class="arrow"></span>qnames<span class="arrow"></span> 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 [IEEE 754-2008]. </div></div><div class="div1"> <h2>D Initial Entries in String Table Partitions</h2><div class="div2"> <h3>D.1 Initial Entries in Uri Partition</h3><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>Table D-1. Initial values in uri partition</caption><colgroup span="2" align="center"></colgroup><colgroup span="1"></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></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>Table D-2. Additional entry when XML Schemas are used</caption><colgroup span="2" align="center"></colgroup><colgroup span="1"></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 7.3.1 String Table Partitions describes the way this has to be done. All string values in uri partition are unique. </p></div><div class="div2"> <h3>D.2 Initial Entries in Prefix Partitions</h3><p>The following table lists the entries that are initially populated in prefix partitions, where XML-PF represents the partition for prefixes in the "http://www.w3.org/XML/1998/namespace" namespace and XSI-PF represents the partition for prefixes in the "http://www.w3.org/2001/XMLSchema-instance" namespace.</p><table border="1"><caption>Table D-3. Initial prefix string table entries</caption><colgroup span="2" align="center"></colgroup><colgroup span="1"></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></div><div class="div2"> <h3>D.3 Initial Entries in Local-Name Partitions</h3><p>The following tables list the string values that are initially populated and made available in local-name partitions, where XML‑NS represents the partition for local-names in the "http://www.w3.org/XML/1998/namespace" namespace, XSI‑NS represents the partition for local-names in the "http://www.w3.org/2001/XMLSchema-instance" namespace, and XSD‑NS represents the partition for local-names in the "http://www.w3.org/2001/XMLSchema" namespace. </p><table border="1" cellpadding="5"><caption>Table D-4. String values initially available in XML‑NS and XSI‑NS partition </caption><colgroup span="2" align="center"></colgroup><thead><tr><th>Partition</th><th>String Values</th></tr></thead><tbody><tr><td>XML‑NS</td><td>"base", "id", "lang", "space"</td></tr><tr><td>XSI‑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‑NS partition. </p><table border="1" cellpadding="5"><caption>Table D-5. String values initially available in XSD‑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‑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></div></div><div class="div1"> <h2>E Deriving Set of Characters from XML Schema Regular Expressions</h2><p> XML Schema datatypes specification [XML Schema Datatypes] defines a regular expression<sup><small>XS2</small></sup> 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 [XML Schema Datatypes]. 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">  [XSD:1]<sup><small>XS2</small></sup>  regExp  ::=  branch  (  '|'  branch  )* </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>  [XSD:2]<sup><small>XS2</small></sup>  branch  ::=  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>  [XSD:3]<sup><small>XS2</small></sup>  piece  ::=  atom  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>  [XSD:9]<sup><small>XS2</small></sup>  atom  ::=  Char  |  charClass  |  (  '('  regExp  ')'  ) </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 Char expression<sup><small>XS2</small></sup>. The set-of-chars for a charClass that constitutes an atom is the set of characters specified by the charClass expression <sup><small>XS2</small></sup>. 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 category escapes<sup><small>XS2</small></sup>, category complement escapes<sup><small>XS2</small></sup> or multi-character escapes<sup><small>XS2</small></sup> other than \s do not have restricted character sets. </p></div><div class="div1"> <h2>F Content Coding and Internet Media Type</h2><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><div class="div2"> <h3>F.1 Content Coding</h3><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, SHOULD use the content coding "exi" (case-insensitive) to convey the acceptance or actual use of EXI encoding for XML information. </p></div><div class="div2"> <h3>F.2 Internet Media Type</h3><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. </p><dl><dt class="label">Type name:</dt><dd><p> application </p></dd><dt class="label">Subtype name:</dt><dd><p> exi </p></dd><dt class="label">Required parameters:</dt><dd><p> none </p></dd><dt class="label">Optional parameters:</dt><dd><p> none </p></dd><dt class="label">Encoding considerations:</dt><dd><p> binary </p></dd><dt class="label">Security considerations:</dt><dd><p> When used as an XML replacement in an application, EXI shares the same security concerns as XML, described in IETF RFC 3023 [IETF RFC 3023], 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></dd><dt class="label">Interoperability considerations:</dt><dd><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></dd><dt class="label">Published specification:</dt><dd><p> Efficient XML Interchange (EXI) Format 1.0, World Wide Web Consortium </p></dd><dt class="label">Applications that use this media type:</dt><dd><p> No known applications currently use this media type. </p></dd><dt class="label">Additional information:</dt><dd><table><tbody><tr><td colspan="2"> </td></tr><tr align="left"><th colspan="2"> Magic number(s): </th></tr><tr><td width="5%"> </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%"> </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%"> </td><td>APPL</td></tr></tbody></table><table><tbody><tr align="left"><th colspan="2"> Consideration of alternatives : </th></tr><tr><td width="5%"> </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. </p> </td></tr><tr><td colspan="2"> </td></tr></tbody></table></dd><dt class="label">Person & email address to contact for further information:</dt><dd><p> World Wide Web Consortium <[email protected]> </p></dd><dt class="label">Intended usage:</dt><dd><p> COMMON </p></dd><dt class="label">Restrictions on usage:</dt><dd><p> none </p></dd><dt class="label">Author/Change controller:</dt><dd><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></dd></dl></div></div><div class="div1"> <h2>G Example Encoding (Non-Normative)</h2><p> EXI Primer [EXI Primer] 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></div><div class="div1"> <h2>H Schema-informed Grammar Examples (Non-Normative)</h2><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, <product> and <order>:</p><div class="exampleOuter"> <div class="exampleHeader"><span>Example H-1. </span>Example XML Schema fragment</div><div class="exampleInner"><pre> <xs:element name="product"> <xs:complexType> <xs:sequence maxOccurs="2"> <xs:element name="description" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:integer" /> <xs:element name="price" type="xs:float" /> </xs:sequence> <xs:attribute name="sku" type="xs:string" use="required" /> <xs:attribute name="color" type="xs:string" use="optional" /> </xs:complexType> </xs:element> <xs:element name="order"> <xs:complexType> <xs:sequence> <xs:element ref="product" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> </pre></div></div><p>Section H.1 Proto-Grammar Examples 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 H.2 Normalized Grammar Examples. Section H.3 Complete Grammar Examples shows the complete EXI grammars for elements <product> and <order>. </p><div class="div2"> <h3>H.1 Proto-Grammar Examples</h3><p>Grammars for element declaration terms "description", "quantity" and "price" are as follows. See section 8.5.4.1.6 Element Terms for the rules used to generate grammars for element terms. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Term_description</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_description<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("description") Term_description<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Term_quantity</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_quantity<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("quantity") Term_quantity<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Term_price</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_price<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("price") Term_price<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>The grammar for element particle "description" is created based on <span class="arrow"></span>Term_description<span class="arrow"></span> given { minOccurs } value of 0 and { maxOccurs } value of 1. See section 8.5.4.1.5 Particles for the rules used to generate grammars for particles. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Particle_description</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_description<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("description") Term_description<sub> 1</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>Grammars for element particle "quantity" and "prices" are the same as those of their terms (<span class="arrow"></span>Term_quantity<span class="arrow"></span> and <span class="arrow"></span>Term_price<span class="arrow"></span>, respectively) because {minOccurs} and {maxOccurs} are both 1. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Particle_quantity</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_quantity<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("quantity") Term_quantity<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Particle_price</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_price<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("price") Term_price<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>The grammar for the sequence group term in <product> element declaration is created based on the grammars of subordinate particles as follows. See section 8.5.4.1.8.1 Sequence Model Groups for the rules used to generate grammars for sequence groups. </p><table width="100%"><tbody><tr><td width="5%"></td><td> Term_sequence = <span class="arrow"></span>Particle_description<span class="arrow"></span><span class="arrow"></span>Particle_quantity<span class="arrow"></span><span class="arrow"></span>Particle_price<span class="arrow"></span> </td></tr></tbody></table><p>which yields the following grammars for Term_sequence. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Term_sequence</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_description<sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE("description") Term_description<sub>1</sub> </td></tr><tr><td></td><td></td><td> Term_quantity <sub>0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description <sub>1</sub> : </td></tr><tr><td></td><td></td><td> Term_quantity <sub>0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity <sub>0</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity <sub>1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity <sub>1</sub> : </td></tr><tr><td></td><td></td><td> Term_price <sub>0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price <sub>0</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price <sub>1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price <sub>1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>The grammar for the particle that is the content model of element <product> is created based on <span class="arrow"></span>Term_sequence<span class="arrow"></span> (shown above) given {minOccurs} value of 1 and {maxOccurs} value of 2. See section 8.5.4.1.5 Particles for the rules used to generate grammars for particles. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Particle_sequence</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_description<sub>0,0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE("description") Term_description<sub>0,1</sub> </td></tr><tr><td></td><td></td><td> Term_quantity<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_quantity<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_price<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>0,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_description<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>1,1</sub> </td></tr><tr><td></td><td></td><td> Term_quantity<sub>1,0</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> Term_quantity<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>1,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> Term_price<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>1,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>Grammars for attribute uses of attributes "sku" and "color" are as follows. See section 8.5.4.1.4 Attribute Uses for the rules used to generate grammars for attribute uses. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Use_sku</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Use_sku <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Use_sku <sub>1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Use_color</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Use_color <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("color") [schema-typed value] Use_color <sub>1</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Use_color <sub>1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p> Note the subtle difference between the forms of the two grammars <span class="arrow"></span>Use_sku<span class="arrow"></span> and <span class="arrow"></span>Use_color<span class="arrow"></span>. At the outset of the grammars, only <span class="arrow"></span>Use_color<span class="arrow"></span> 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 <product> is created based on the grammars of its attribute uses and content model particle as follows. See section 8.5.4.1.3.2 Complex Type Grammars for the rules used to generate grammars for complex types. </p><table width="100%"><tbody><tr><td width="5%"></td><td> ProtoG_ProductElement = <span class="arrow"></span>Use_color<span class="arrow"></span><span class="arrow"></span>Use_sku<span class="arrow"></span><span class="arrow"></span>Particle_sequence<span class="arrow"></span> </td></tr></tbody></table><p>which yields the following grammar for element <product>. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">ProtoG_ProductElement</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Use_color <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("color") [schema-typed value] Use_color <sub>1</sub> </td></tr><tr><td></td><td></td><td> Use_sku <sub>0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Use_color <sub>1</sub> : </td></tr><tr><td></td><td></td><td> Use_sku <sub>0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Use_sku <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Use_sku <sub>1</sub> : </td></tr><tr><td></td><td></td><td> Term_description<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>0,1</sub> </td></tr><tr><td></td><td></td><td> Term_quantity<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_quantity<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_price<sub>0,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>0,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_description<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>1,1</sub> </td></tr><tr><td></td><td></td><td> Term_quantity<sub>1,0</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_description<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> Term_quantity<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>1,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_quantity<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> Term_price<sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>1,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_price<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>The other element declaration <order> can be processed to generate its proto-grammar in a similar fashion as follows. </p><div class="exampleOuter"><table width="80%"><thead><tr><th> </th></tr><tr><th align="left" colspan="3">Term_product</th></tr></thead><tbody><tr><td colspan="3"> </td></tr><tr><td width="5%"></td><td colspan="2"> Term_product<sub> 0</sub> :</td></tr><tr><td></td><td width="5%"></td><td> SE("product") Term_product<sub> 1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product<sub> 1</sub> : </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p> The grammar for element particle "product" is created based on <span class="arrow"></span>Term_product<span class="arrow"></span> given { minOccurs } value of 1 and { maxOccurs } value of unbounded. See section 8.5.4.1.5 Particles for the rules used to generate grammars for particles. </p><div class="exampleOuter"><table width="80%"><thead><tr><th> </th></tr><tr><th align="left" colspan="3">Particle_product   (before simplification)</th></tr></thead><tbody><tr><td> </td></tr></tbody></table><table width="80%"><tbody><tr><td width="5%"></td><td width="5%"></td><td></td></tr><tr><td></td><td colspan="2"> Term_product <sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>0,1</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> Term_product <sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,1</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> Term_product <sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>In the above grammars, two grammars Term_product <sub>0,1</sub> and Term_product <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 Term_product <sub>0,1</sub> and Term_product <sub>1,1</sub> are each replaced by Term_product <sub>1,0</sub> and Term_product <sub>1,0</sub>, which produces the following simplified proto-grammars. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">Particle_product   (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"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,0</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div><p>The proto-grammar of the element <order> equates to <span class="arrow"></span>Particle_product<span class="arrow"></span> because the type definition of element <order> has no attribute uses, and its content model has both { minOccurs } and { maxOccurs } property values of 1 where the element particle "product" is the sole member of the content model. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="3">ProtoG_OrderElement</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"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>0,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,0</sub> </td></tr><tr><td colspan="3"> </td></tr><tr><td></td><td colspan="2"> Term_product <sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,0</sub> </td></tr><tr><td></td><td></td><td> EE </td></tr><tr><td colspan="3"> </td></tr></tbody></table></div></div><div class="div2"> <h3>H.2 Normalized Grammar Examples</h3><p>The element proto-grammars <span class="arrow"></span>ProtoG_ProductElement<span class="arrow"></span> and <span class="arrow"></span>ProtoG_OrderElement<span class="arrow"></span> produced in the previous section can be turned into their normalized forms which are shown below with an <span class="arrow"></span>event code<span class="arrow"></span> assigned to each production. See section 8.5.4.2 EXI Normalized Grammars for the process that converts proto-grammars into normalized grammars, and section 8.5.4.3 Event Code Assignment for the rules that determine the <span class="arrow"></span>event codes<span class="arrow"></span> of productions in normalized grammars. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="4">NormG_ProductElement</th></tr><tr><th colspan="3"></th><th align="left">Event Code</th></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> Use_color <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("color") [schema-typed value] Use_color <sub>1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td><td>1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Use_color <sub>1</sub> : </td></tr><tr><td></td><td></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Use_sku <sub>1</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>0,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td><td>1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_description<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_quantity<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>0,1</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_price<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>1,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<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"> </td></tr><tr><td></td><td colspan="3"> Term_description<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>1,1</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_quantity<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>1,1</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_price<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> EE </td><td>0</td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="4">NormG_OrderElement</th></tr><tr><th colspan="3"></th><th align="left">Event Code</th></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> Term_product <sub>0,0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE("product") Term_product <sub>1,0</sub> </td><td>0</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_product <sub>1,0</sub>: </td></tr><tr><td></td><td></td><td> SE("product") Term_product <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"> </td></tr></tbody></table></div><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></div><div class="div2"> <h3>H.3 Complete Grammar Examples</h3><p>The normalized grammars <span class="arrow"></span>NormG_ProductElement<span class="arrow"></span> and <span class="arrow"></span>NormG_OrderElement<span class="arrow"></span> are augmented with undeclared productions to become complete grammars. See section 8.5.4.4 Undeclared Productions for the process to augment normalized grammars with productions for accepting terminal symbols not declared in schemas. The complete grammars for elements <product> and <order> are shown below. Note that the default grammar settings (i.e. the settings that can be described by an empty header options document <exi:header/> 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 8.3 Pruning Unneeded Productions since those terminal symbols are not preserved in the default grammar settings. </p><div class="exampleOuter"><table width="80%"><tbody><tr><td> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="4">Complete grammar for element <product></th></tr><tr><th colspan="3"></th><th align="left">Event Code</th></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> Use_color <sub>0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> AT("color") [schema-typed value] Use_color <sub>1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td><td>1</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> AT(xsi:type) Use_color <sub>0</sub> </td><td>2.1</td></tr><tr><td></td><td></td><td> AT(xsi:nil) Use_color <sub>0</sub> </td><td>2.2</td></tr><tr><td></td><td></td><td> AT (*) Use_color <sub>0</sub> </td><td>2.3</td></tr><tr><td></td><td></td><td> AT("color") [untyped value] Use_color<sub>1</sub> </td><td>2.4.0</td></tr><tr><td></td><td></td><td> AT("sku") [untyped value] Use_sku<sub>1</sub> </td><td>2.4.1</td></tr><tr><td></td><td></td><td> AT (*) [untyped value] Use_color <sub>0</sub> </td><td>2.4.2</td></tr><tr><td></td><td></td><td> SE(*) Use_sku <sub>1_copied</sub> </td><td>2.5</td></tr><tr><td></td><td></td><td> CH [untyped value] Use_sku <sub>1_copied</sub> </td><td>2.6</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Use_color <sub>1</sub> : </td></tr><tr><td></td><td></td><td> AT("sku") [schema-typed value] Use_sku <sub>1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1.0</td></tr><tr><td></td><td></td><td> AT (*) Use_color <sub>1</sub> </td><td>1.1</td></tr><tr><td></td><td></td><td> AT("sku") [untyped value] Use_sku <sub>1</sub> </td><td>1.2.0</td></tr><tr><td></td><td></td><td> AT (*) [untyped value] Use_color <sub>1</sub> </td><td>1.2.1</td></tr><tr><td></td><td></td><td> SE(*) Use_sku <sub>1_copied</sub> </td><td>1.3</td></tr><tr><td></td><td></td><td> CH [untyped value] Use_sku <sub>1_copied</sub> </td><td>1.4</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Use_sku <sub>1</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>0,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td><td>1</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> AT (*) Use_sku <sub>1</sub> </td><td>2.1</td></tr><tr><td></td><td></td><td> AT (*) [untyped value] Use_sku <sub>1</sub> </td><td>2.2.0</td></tr><tr><td></td><td></td><td> SE(*) Use_sku <sub>1_copied</sub> </td><td>2.3</td></tr><tr><td></td><td></td><td> CH [untyped value] Use_sku <sub>1_copied</sub> </td><td>2.4</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Use_sku <sub>1_copied</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>0,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td><td>1</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> SE(*) Use_sku <sub>1_copied</sub> </td><td> 2.1 </td></tr><tr><td></td><td></td><td> CH [untyped value] Use_sku <sub>1_copied</sub> </td><td> 2.2 </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_description<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>0,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1</td></tr><tr><td></td><td></td><td> SE(*) Term_description<sub>0,1</sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_description<sub>0,1</sub> </td><td>2.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_quantity<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>0,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1</td></tr><tr><td></td><td></td><td> SE(*) Term_quantity<sub>0,1</sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_quantity<sub>0,1</sub> </td><td>2.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_price<sub>0,1</sub> : </td></tr><tr><td></td><td></td><td> SE("description") Term_description<sub>1,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>1,1</sub> </td><td>1</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>2</td></tr><tr><td></td><td></td><td> SE(*) Term_price<sub>0,1</sub> </td><td>3.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_price<sub>0,1</sub> </td><td>3.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_description<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> SE("quantity") Term_quantity<sub>1,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1</td></tr><tr><td></td><td></td><td> SE(*) Term_description<sub>1,1</sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_description<sub>1,1</sub> </td><td>2.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_quantity<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> SE("price") Term_price<sub>1,1</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1</td></tr><tr><td></td><td></td><td> SE(*) Term_quantity<sub>1,1</sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_quantity<sub>1,1</sub> </td><td>2.1</td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_price<sub>1,1</sub> : </td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>0</td></tr><tr><td></td><td></td><td> SE(*) Term_price<sub>1,1</sub> </td><td>1.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_price<sub>1,1</sub> </td><td>1.1</td></tr><tr><td colspan="4"> </td></tr></tbody></table><table width="80%"><thead><tr><th align="left" colspan="4">Complete grammar for element <order></th></tr><tr><th colspan="3"></th><th align="left">Event Code</th></tr></thead><tbody><tr><td width="5%"></td><td colspan="3"> Term_product <sub>0,0</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE("product") Term_product <sub>1,0</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1.0</td></tr><tr><td></td><td></td><td> AT(xsi:type) Term_product <sub>0,0</sub> </td><td>1.1</td></tr><tr><td></td><td></td><td> AT(xsi:nil) Term_product <sub>0,0</sub> </td><td>1.2</td></tr><tr><td></td><td></td><td> AT (*) Term_product <sub>0,0</sub> </td><td>1.3</td></tr><tr><td></td><td></td><td> AT (*) [untyped value] Term_product <sub>0,0</sub> </td><td>1.4.0</td></tr><tr><td></td><td></td><td> SE(*) Term_product <sub>0,0_copied</sub> </td><td>1.5</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_product <sub>0,0_copied</sub> </td><td>1.6</td></tr><tr><td colspan="4"> </td></tr><tr><td width="5%"></td><td colspan="3"> Term_product <sub>0,0_copied</sub> : </td></tr><tr><td></td><td width="5%"></td><td> SE("product") Term_product <sub>1,0</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1.0</td></tr><tr><td></td><td></td><td> SE(*) Term_product <sub>0,0_copied</sub> </td><td> 1.1 </td></tr><tr><td></td><td></td><td> CH [untyped value] Term_product <sub>0,0_copied</sub> </td><td> 1.2 </td></tr><tr><td colspan="4"> </td></tr><tr><td></td><td colspan="3"> Term_product <sub>1,0</sub> : </td></tr><tr><td></td><td></td><td> SE("product") Term_product <sub>1,0</sub> </td><td>0</td></tr><tr><td></td><td></td><td> EE <sub> </sub> </td><td>1</td></tr><tr><td></td><td></td><td> SE(*) Term_product <sub>1,0</sub> </td><td>2.0</td></tr><tr><td></td><td></td><td> CH [untyped value] Term_product <sub>1,0</sub> </td><td>2.1</td></tr><tr><td colspan="4"> </td></tr></tbody></table></div></div></div><div class="div1"> <h2>I Recent Specification Changes (Non-Normative)</h2><div class="div2"> <h3>I.1 Changes from First Edition Recommendation</h3>
    • Clarified the offset of Integer datatype for bounded range schema types. (see 27 June 2013)
    • Add a references to Namespaces in XML 1.1 specification. (see 26 June 2013)
    • Clarified the valid value range of the time components in Date-Time datatype. (see 13 June 2013)
    • Clarified that the namespace declarations are mapped to NS events and should not be represented by AT events. (see 06 May 2013)
    • Clarified when patterns if any are relevant in Boolean datatype representation. (see Patterns in Boolean)
    </div><div class="div2"> <h3>I.2 Changes from previous versions of the document</h3></div></div><div class="div1"> <h2>J Acknowledgements (Non-Normative)</h2><p>This document is the work of the Efficient XML Interchange (EXI) WG.</p><p>Members of the Working Group are (at the time of writing, sorted alphabetically by last name): </p>
    • Carine Bournez, W3C/ERCIM (staff contact)
    • Don Brutzman, Web3D Consortium
    • Michael Cokus, MITRE Corporation
    • Yusuke Doi, Toshiba Corporation
    • Youenn Fablet, Canon, Inc.
    • Jun Fujisawa, Canon, Inc.
    • Joerg Heuer, Siemens AG
    • Sebastian Käbisch, Siemens AG
    • Takuki Kamiya, Fujitsu Laboratories of America, Inc. (chair)
    • Rumen Kyusakov, Invited Expert, Luleå University of Technology
    • Richard Kuntschke, Siemens AG
    • Don McGregor, Web3D Consortium
    • Daniel Peintner, Siemens AG
    • Liam Quin, W3C/MIT (staff contact)
    • Mohamed Zergaoui, INNOVIMAX
    <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>
    • Oliver Goldman, Adobe Systems, Inc. (former co-chair) (until 8 June 2006)
    • Robin Berjon, Expway (former co-chair) (until 17 October 2006)
    • Peter Haggar, IBM (until 7 March 2007)
    • Paul Thorpe, OSS Nokalva, Inc. (until 11 Sept 2007)
    • Kimmo Raatikainen, Nokia (until 13 March 2008)
    • Daniel Vogelheim, Invited Expert (former co-chair then from Siemens AG) (until 15 July 2008)
    • Stephen Williams, High Performance Technologies, Inc. (until 8 Aug 2008)
    • Ed Day, Objective Systems, Inc. (until 23 Oct 2009)
    • Santiago Pericas-Geertsen, Sun Microsystems, Inc. (until 6 May 2010)
    • Paul Sandoz, Sun Microsystems, Inc. (until 6 May 2010)
    • Alan Hudson, Web3D Consortium (until 2 June 2011)
    • Sheldon Snyder, Web3D Consortium (until 2 June 2011)
    • John Schneider, AgileDelta, Inc. (until 19 July 2012)
    • Rich Rollman, AgileDelta, Inc. (until 19 July 2012)
    • Nan Ma, China Electronics Standardization Institute (until 19 July 2012)
    • Jaakko Kangasharju, University of Helsinki (until 19 July 2012)
    • Greg White, Stanford University (former co-chair) (until 19 July 2012)
    • David Lee, MarkLogic (until 6 September 2013)
    • Hideyuki Moribe, Fujitsu Laboratories of America, Inc. (until 14 January 2014)
    <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></div></div><script src="https://www.w3.org/scripts/TR/fixup.js"></script></body></html>
    View source
  • <xsd:schema targetNamespace="http://www.w3.org/2009/exi"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                elementFormDefault="qualified">
    
      <!-- 
         * This is a schema for the EXI options
         *
         * The schema is made available under the terms of the W3C software notice and license
         * at https://www.w3.org/Consortium/Legal/copyright-software-19980720
         *
        -->
    
      <xsd:element name="header">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="lesscommon" minOccurs="0">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="uncommon" minOccurs="0">
                    <xsd:complexType>
                      <xsd:sequence>
                        <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded"
                                 processContents="skip" />
                        <xsd:element name="alignment" minOccurs="0">
                          <xsd:complexType>
                            <xsd:choice>
                              <xsd:element name="byte">
                                <xsd:complexType />
                              </xsd:element>
                              <xsd:element name="pre-compress">
                                <xsd:complexType />
                              </xsd:element>
                            </xsd:choice>
                          </xsd:complexType>
                        </xsd:element>
                        <xsd:element name="selfContained" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                        <xsd:element name="valueMaxLength" minOccurs="0">
                          <xsd:simpleType>
                            <xsd:restriction base="xsd:unsignedInt" />
                          </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="valuePartitionCapacity" minOccurs="0">
                          <xsd:simpleType>
                            <xsd:restriction base="xsd:unsignedInt" />
                          </xsd:simpleType>
                        </xsd:element>
                        <xsd:element name="datatypeRepresentationMap"
                                     minOccurs="0" maxOccurs="unbounded">
                          <xsd:complexType>
                            <xsd:sequence>
                              <!-- schema datatype -->
                              <xsd:any namespace="##other" processContents="skip" />
                              <!-- datatype representation -->
                              <xsd:any processContents="skip" />
                            </xsd:sequence>
                          </xsd:complexType>
                        </xsd:element>
                      </xsd:sequence>
                    </xsd:complexType>
                  </xsd:element>
                  <xsd:element name="preserve" minOccurs="0">
                    <xsd:complexType>
                      <xsd:sequence>
                        <xsd:element name="dtd" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                        <xsd:element name="prefixes" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                        <xsd:element name="lexicalValues" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                        <xsd:element name="comments" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                        <xsd:element name="pis" minOccurs="0">
                          <xsd:complexType />
                        </xsd:element>
                      </xsd:sequence>
                    </xsd:complexType>
                  </xsd:element>
                  <xsd:element name="blockSize" minOccurs="0">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:unsignedInt">
                        <xsd:minInclusive value="1" />
                      </xsd:restriction>
                    </xsd:simpleType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
            <xsd:element name="common" minOccurs="0">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="compression" minOccurs="0">
                    <xsd:complexType />
                  </xsd:element>
                  <xsd:element name="fragment" minOccurs="0">
                    <xsd:complexType />
                  </xsd:element>
                  <xsd:element name="schemaId" minOccurs="0" nillable="true">
                    <xsd:simpleType>
                      <xsd:restriction base="xsd:string" />
                    </xsd:simpleType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
            <xsd:element name="strict" minOccurs="0">
              <xsd:complexType />
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    
      <!-- Built-in EXI Datatype IDs for use in datatype representation maps -->
      <xsd:simpleType name="base64Binary">
         <xsd:restriction base="xsd:base64Binary"/>
      </xsd:simpleType>
      <xsd:simpleType name="hexBinary" >
         <xsd:restriction base="xsd:hexBinary"/>
      </xsd:simpleType>
      <xsd:simpleType name="boolean" >
         <xsd:restriction base="xsd:boolean"/>
      </xsd:simpleType>
      <xsd:simpleType name="decimal" >
         <xsd:restriction base="xsd:decimal"/>
      </xsd:simpleType>
      <xsd:simpleType name="double" >
         <xsd:restriction base="xsd:double"/>
      </xsd:simpleType>
      <xsd:simpleType name="integer" >
         <xsd:restriction base="xsd:integer"/>
      </xsd:simpleType>
      <xsd:simpleType name="string" >
         <xsd:restriction base="xsd:string"/>
      </xsd:simpleType>
      <xsd:simpleType name="dateTime" >
         <xsd:restriction base="xsd:dateTime"/>
      </xsd:simpleType>
      <xsd:simpleType name="date" >
         <xsd:restriction base="xsd:date"/>
      </xsd:simpleType>
      <xsd:simpleType name="time" >
         <xsd:restriction base="xsd:time"/>
      </xsd:simpleType>
      <xsd:simpleType name="gYearMonth" >
         <xsd:restriction base="xsd:gYearMonth"/>
      </xsd:simpleType>
      <xsd:simpleType name="gMonthDay" >
         <xsd:restriction base="xsd:gMonthDay"/>
      </xsd:simpleType>
      <xsd:simpleType name="gYear" >
         <xsd:restriction base="xsd:gYear"/>
      </xsd:simpleType>
      <xsd:simpleType name="gMonth" >
         <xsd:restriction base="xsd:gMonth"/>
      </xsd:simpleType>
      <xsd:simpleType name="gDay" >
         <xsd:restriction base="xsd:gDay"/>
      </xsd:simpleType>
    
      <!-- Qnames reserved for future use in datatype representation maps -->
      <xsd:simpleType name="ieeeBinary32" >
         <xsd:restriction base="xsd:float"/>
      </xsd:simpleType>
      <xsd:simpleType name="ieeeBinary64" >
         <xsd:restriction base="xsd:double"/>
      </xsd:simpleType>
    </xsd:schema>
    
    View source