<?xml version="1.0" encoding="UTF-8"?>
<!--  ================================================================================  -->
<!--  Errata applied:                                                                   -->
<!--    XQX.E4 - Editorial (Bugzilla Bug 5323)                                          -->
<!--    XQX.E6 - Editorial (Bugzilla Bug 6377)                                          -->
<!--  ================================================================================  -->
<!DOCTYPE spec SYSTEM "../schema/xsl-query.dtd" [
<!ENTITY date.day "10">
<!ENTITY date.DD "10">
<!ENTITY date.month "April">
<!ENTITY date.monthnum "04">
<!ENTITY date.year "2009">
<!ENTITY doc.date "&date.year;&date.monthnum;&date.DD;">
<!ENTITY doc.date.presentation "&date.DD; &date.month; &date.year;">

<!ENTITY w3c.tr "http://www.w3.org/TR">
<!ENTITY doc.shortname "xqueryx">
<!ENTITY doc.w3c-doctype "per">
<!ENTITY doc.w3c-designation "PER-&doc.shortname;">
<!ENTITY doc.w3c-prev-designation "REC-&doc.shortname;">
<!ENTITY doc.publoc "&w3c.tr;/&date.year;/&doc.w3c-designation;-&doc.date;">
<!ENTITY doc.latestloc "&w3c.tr;/&doc.shortname;">
<!ENTITY xqx-schema SYSTEM "included-files/xqueryx-CDATA.xsd.xml">
<!ENTITY xqx2xq-stylesheet SYSTEM "included-files/xqueryx-CDATA.xsl.xml">
<!ENTITY xq-grammarSnippet SYSTEM "included-files/xqueryx-grammar.xml.snippet-CDATA.xml">
<!ENTITY xqx-schemaSnippet SYSTEM "included-files/xqueryx.xsd.snippet-CDATA.xml">
<!ENTITY exmpl1xq SYSTEM "included-files/exmpl1-CDATA.xq.xml">
<!ENTITY exmpl2xq SYSTEM "included-files/exmpl2-CDATA.xq.xml">
<!ENTITY exmpl3xq SYSTEM "included-files/exmpl3-CDATA.xq.xml">
<!ENTITY exmpl1grammar SYSTEM "included-files/exmpl1-CDATA.grammar.xml">
<!ENTITY exmpl4xq SYSTEM "included-files/exmpl4-CDATA.xq.xml">
<!ENTITY exmpl1xqx SYSTEM "included-files/exmpl1-CDATA.xqx.xml">
<!ENTITY exmpl2xqx SYSTEM "included-files/exmpl2-CDATA.xqx.xml">
<!ENTITY exmpl3xqx SYSTEM "included-files/exmpl3-CDATA.xqx.xml">
<!ENTITY exmpl4xqx SYSTEM "included-files/exmpl4-CDATA.xqx.xml">
<!ENTITY exmpl1xqx2xq SYSTEM "included-files/exmpl1-CDATA.xqx2xq.xml">
<!ENTITY exmpl2xqx2xq SYSTEM "included-files/exmpl2-CDATA.xqx2xq.xml">
<!ENTITY exmpl3xqx2xq SYSTEM "included-files/exmpl3-CDATA.xqx2xq.xml">
<!ENTITY exmpl4xqx2xq SYSTEM "included-files/exmpl4-CDATA.xqx2xq.xml">
<!ENTITY mimetypeappendix SYSTEM "xqueryx-mime-type.xml">


<!ENTITY % status-entities SYSTEM "../etc/status-entities.dtd">
%status-entities;

<!ENTITY status-section-id "id-status">
<!ENTITY spec-devby    "&xqueryx-devby;">
<!ENTITY changelog-id  "&xqueryx-changelog-id;">
<!ENTITY changes-para  "&post.REC.changes;">
<!ENTITY implementation-report-location "&xquery-impl-report;">
<!ENTITY implementation-report-availability "&report-public;">
<!ENTITY implementation-para  "&implementation-report-exists;">
<!ENTITY disclosure.one    "&disclosure.xquery;"> 
<!ENTITY Bugzilla-key "&xqueryx-Bugzilla-key;">
<!ENTITY patent-policy-paragraph "&ppp-one;">

<!ENTITY status-section SYSTEM "../etc/status-2edREC.xml">
]>
<!-- <?xml-stylesheet type="text/xsl" href="xmlspec.xsl"?> -->

<spec id="spec-top" w3c-doctype="&doc.w3c-doctype;">
  <header id="spec-header">
    <title>XML Syntax for XQuery 1.0 (XQueryX)</title>
    <version> (Second Edition)</version>
    <w3c-designation>&doc.w3c-designation;</w3c-designation>
    <w3c-doctype>W3C Proposed Edited Recommendation</w3c-doctype>
    <pubdate>
      <day>&date.day;</day>
      <month>&date.month;</month>
      <year>&date.year;</year>
    </pubdate>
    <publoc>
      <loc href="&doc.publoc;">&doc.publoc;</loc>
    </publoc>
    <altlocs diff="chg" at="Updated for second edition">
      <loc href="&doc.publoc;/xqueryx-&doc.date;.xml">XML</loc>
      <loc href="&doc.publoc;/xqueryx-diff-from-REC20070123.html">Change markings relative to first edition</loc>
    </altlocs>
    <latestloc>
      <loc href="http://www.w3.org/TR/xqueryx">&doc.latestloc;</loc>
    </latestloc>
    <prevlocs diff="chg" at="Updated for second edition">
      <loc href="http://www.w3.org/TR/2007/REC-xqueryx-20070123">http://www.w3.org/TR/2007/REC-xqueryx-20070123</loc>
    </prevlocs>
    <authlist>
      <author>
        <name>Jim Melton</name>
        <affiliation>Oracle</affiliation>
        <email href="mailto:jim.melton@oracle.com">jim.melton@oracle.com</email>
      </author>
      <author>
        <name>Subramanian Muralidhar</name>
        <affiliation>Microsoft</affiliation>
<!--        <email href="mailto:smurali@microsoft.com">smurali@microsoft.com</email> -->
      </author>
    </authlist>

    <errataloc diff="chg" at="Updated for second edition"
               href="http://www.w3.org/XML/2009/qt-errata/xqueryx-errata2e.html" xlink:type="simple"/>

    <translationloc href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xqueryx"/>

    <abstract id="abstract">
      <p>This document defines an XML Syntax for <bibref ref="xquery"/>.</p>
    </abstract>

&status-section;

    <langusage>
      <language id="EN">English</language>
    </langusage>

    <revisiondesc>
      <p>This is the final Recommendation of this specification. 
         It is aligned with the XQuery grammar as published in <bibref ref="xquery"/>.</p>
    </revisiondesc>
  </header>

  <body>

    <div1 id="Introduction">
      <head>Introduction</head>

      <p>The <bibref ref="xquery-requirements"/> states that <quote>The XML Query Language MAY have
         more than one syntax binding. One query language syntax MUST be convenient for
         humans to read and write. One query language syntax MUST be expressed in XML in
         a way that reflects the underlying structure of the query.</quote></p>

      <p>XQueryX is an XML representation of an XQuery. It was created by mapping
         the productions of the XQuery grammar into XML productions.
         The result is not particularly convenient for humans to read and write, but it
         is easy for programs to parse, and because XQueryX is represented in XML, standard
         XML tools can be used to create, interpret, or modify queries.</p>

<!-- 2009-01-29 JM: Add paragraph clarifying that all Notes are non-normative per Bugzilla Bug #6377 and Erratum XQX.E6 -->
      <p diff="add" at="XQX.E6">In this document, examples and material labeled as <quote>Note</quote> are provided for
         explanatory purposes and are not normative. </p>

<!-- 2005-10-05 JM: Add informative note clarifying that the
     XQueryX static/dynamic contexts are the same as the XQuery contexts -->
      <note>
        <p>Because the two syntaxes are merely different grammars that express the
           same query semantics, they share all aspects of an XQuery processing system
           except for the component that recognizes and translates the source representation
           of a query (that is, the parser). 
           The aspects that are shared include both the static context and
           the dynamic context that are defined in <bibref ref="xquery"/>. </p>
      </note>

      <p>There are several environments in which XQueryX may be useful:</p>

      <ulist>
        <item>
          <p><emph>Parser Reuse.</emph> In heterogeneous environments, a
             variety of systems may be used to execute a query. One parser can generate XQueryX
             for all of these systems.</p>
        </item>

        <item>
          <p><emph>Queries on Queries.</emph> Because XQueryX is represented in XML, queries
             can be queried and can be transformed into new queries. For instance, a query can
             be performed against a set of XQueryX queries to determine which queries use
             FLWOR expressions to range over a set of invoices.</p>
        </item>

        <item>
          <p><emph>Generating Queries.</emph> In some XML-oriented programming
             environments, it may be more convenient to build a query in its XQueryX
             representation than in the corresponding XQuery representation, since ordinary
             XML tools can be used.</p>
        </item>

        <item>
          <p><emph>Embedding Queries in XML.</emph> XQueryX can be embedded
             directly in an XML document.</p>
        </item>

      </ulist>

	  <p>The most recent versions of the XQueryX XML Schema and the XQueryX XSLT stylesheet
       are available at
       <loc href="http://www.w3.org/2005/XQueryX/xqueryx.xsd">http://www.w3.org/2005/XQueryX/xqueryx.xsd</loc>
       and
       <loc href="http://www.w3.org/2005/XQueryX/xqueryx.xsl">http://www.w3.org/2005/XQueryX/xqueryx.xsl</loc>, respectively. </p>

    </div1>


    <div1 id="Mapping">
      <head>Mapping the XQuery Syntax</head>

      <p>XQueryX is an XML representation of the abstract syntax found in
         Appendix A of <bibref ref="xquery"/>. The XQueryX syntax is defined by
         the XQueryX Schema, which is specified in <specref ref="Schema"/>. The XQueryX semantics are
         defined by a stylesheet that maps an instance of XQueryX to an instance of
         XQuery; see <specref ref="Stylesheet"/>.</p>

      <p>The main data structure in the XQueryX Schema is the set of types that describe
         expressions. We have chosen to model expressions using substitution groups,
         with an "expr" abstract base class and a number of intermediate abstract classes. </p>

      <p>Consider the following productions from the abstract syntax:</p>

      <!-- insert the grammar snippet here -->
      <eg>&xq-grammarSnippet;</eg>

      <p>The following XQueryX Schema definitions reflect the structure of those
         productions from that abstract syntax:</p>

      <!-- insert schema snippet here -->
      <eg>&xqx-schemaSnippet;</eg>

      <p>Since XQuery uses the expression production liberally to allow
         expressions to be flexibly combined, XQueryX uses the exprWrapper type
         in embedded contexts to allow all expression types to occur.</p>

    </div1>


    <div1 id="Examples">
      <head>Examples from the XML Query Use Cases in XML Syntax</head>

      <p>Three of following examples are based on the data and queries in the XMP
         (Experiences and Exemplars) use case in <bibref ref="xquery-use-cases"/>,
         while a fourth example is based on the data and queries in the
         NS (Queries Using Namespaces) use case. 
         For each example, we show the English description of the query,
         the XQuery solution given in <bibref ref="xquery-use-cases"/>,
         an XQueryX solution, and the XQuery that results from applying the XQueryX-to-XQuery transformation
         defined by the stylesheet in <specref ref="Stylesheet"/> to the XQueryX solution.
         That produced XQuery is presented only as a sanity-check &mdash;
         the intent of the stylesheet is not to create the identical
         XQuery expression given in <bibref ref="xquery-use-cases"/>, but to produce <emph>a</emph> valid
         XQuery expression with the same semantics. 
         The semantics of the XQueryX solution are determined by the semantics of the XQuery expression that
         results from that transformation.  The "correctness" of that transformation is determined by
         asking the following the question:
         Can some XQueryX processor QX process some XQueryX document D1 to produce results R1,
         after which the stylesheet is used to translate D1 into an XQuery expression E1 that,
         when processed by some XQuery processor Q, produces results R2 that are equivalent
         (under some meaningful definition of "equivalent") to results R1? </p>

      <p>Comparison of the results of the XQueryX-to-XQuery transformation given in this document
         with the XQuery solutions in the <bibref ref="xquery-use-cases"/> may be helpful in evaluating
         the correctness of the XQueryX solution in each example. </p>

      <p>The XQuery Use Cases solution given for each example is provided only to assist readers of this
         document in understanding the XQueryX solution.  There is no intent to imply that this
         document specifies a "compilation" or "transformation" of XQuery syntax into XQueryX syntax. </p>

      <p>In the following examples, note that path expressions are expanded to show their
         structure. Also, note that the prefix syntax for binary operators like "and" makes the
         precedence explicit. In general, humans find it easier to read an XML representation
         that does not expand path expressions, but it is less convenient for programmatic
         representation and manipulation.  XQueryX is designed as a language that is convenient
         for production and modification by software, and not as a convenient syntax for humans to
         read and write. </p>

      <p>Finally, please note that white space, including new lines, have been added to
         some of the XQueryX documents and XQuery expressions for readability. 
         That additional white space is not produced by the XQueryX-to-XQuery transformation. </p>

      <div2 id="Example1">
        <head>Example 1</head>

        <p>Here is Q1 from the <bibref ref="xquery-use-cases"/>, use case XMP
           (Experiences and Exemplars): "List books published by Addison-Wesley after 1991,
           including their year and title."</p>

        <div3 id="Example1-XQuery">
          <head>XQuery solution in XQuery Use Cases:</head>

          <eg>&exmpl1xq;</eg>

        </div3>

        <div3 id="Example1-XQueryX">
          <head>A Solution in XQueryX:</head>

          <eg>&exmpl1xqx;</eg>

        </div3>

        <div3 id="Example1-Transformation">
          <head>Transformation of XQueryX Solution into XQuery</head>

          <p>Application of the stylesheet in <specref ref="Stylesheet"/>
             to the XQueryX solution results in:</p>

          <eg>&exmpl1xqx2xq;</eg>

        </div3>

        <div3 id="Example1-Abstract">
          <head>Corresponding Grammar Abstract Parse Tree</head>

  <!-- replaced link to grammar applet per Bugzilla Bug #5323 -->
          <p>For comparison, here is the abstract parse tree corresponding to the
             XQuery for Example 1, as produced by the XQuery grammar applets found at
             <loc diff="chg" at="XQX.E4"
                  href="http://www.w3.org/2007/01/applets/">http://www.w3.org/2007/01/applets/</loc>. </p>

          <eg>&exmpl1grammar;</eg>

        </div3>

      </div2>

      <div2 id="Example2">
        <head>Example 2</head>

        <p>Here is Q4 from the <bibref ref="xquery-use-cases"/>, use case XMP
           (Experiences and Exemplars): "For each author in the bibliography, list the
           author's name and the titles of all books by that author, grouped inside a
           "result" element."</p>

        <div3 id="Example2-XQuery">
          <head>XQuery solution in XQuery Use Cases:</head>

          <eg>&exmpl2xq;</eg>

        </div3>

        <div3 id="Example2-XQueryX">
          <head>A solution in XQueryX:</head>

          <!-- insert exmpl2 here -->
          <eg>&exmpl2xqx;</eg>

        </div3>

        <div3 id="Example2-Transformation">
          <head>Transformation of XQueryX Solution into XQuery</head>

          <p>Application of the stylesheet in <specref ref="Stylesheet"/>
            to the XQueryX solution results in:</p>

          <eg>&exmpl2xqx2xq;</eg>

        </div3>

      </div2>

      <div2 id="Example3">
        <head>Example 3</head>

        <p>Here is Q7 from the <bibref ref="xquery-use-cases"/>, use case XMP
           (Experiences and Exemplars): "List the titles and years of all books published by
           Addison-Wesley after 1991, in alphabetic order."</p>
 
        <div3 id="Example3-XQuery">
          <head>XQuery solution in XQuery Use Cases:</head>
 
          <eg>&exmpl3xq;</eg>

        </div3>

        <div3 id="Example3-XQueryX">
          <head>A solution in XQueryX:</head>

          <!-- insert exmpl3 here -->
          <eg>&exmpl3xqx;</eg>

        </div3>

        <div3 id="Example3-Transformation">
          <head>Transformation of XQueryX Solution into XQuery</head>

          <p>Application of the stylesheet in <specref ref="Stylesheet"/> to the XQueryX solution
             results in:</p>

          <eg>&exmpl3xqx2xq;</eg>

        </div3>

      </div2>

      <div2 id="Example4">
        <head>Example 4</head>

        <p>Here is Q8 from the <bibref ref="xquery-use-cases"/>, use case NS
           (Queries Using Namespaces):
           "Select all traders (either seller or high bidder) without negative comments."</p>
 
        <div3 id="Example4-XQuery">
          <head>XQuery solution in XQuery Use Cases:</head>
 
          <eg>&exmpl4xq;</eg>

        </div3>

        <div3 id="Example4-XQueryX">
          <head>A solution in XQueryX:</head>

          <!-- insert exmpl4 here -->
          <eg>&exmpl4xqx;</eg>

        </div3>

        <div3 id="Example4-Transformation">
          <head>Transformation of XQueryX Solution into XQuery</head>

          <p>Application of the stylesheet in <specref ref="Stylesheet"/>
             to the XQueryX solution results in:</p>

          <eg>&exmpl4xqx2xq;</eg>

        </div3>

      </div2>

    </div1>


    <div1 id="Schema">
      <head>An XML Schema for the XQuery XML Syntax</head>

      <p>Here is the XML Schema against which XQueryX documents must be valid.</p>

      <eg>&xqx-schema;</eg>

    </div1>

<!-- Trivial Embedding, an At Risk feature, was dropped by the Joint XML Query and XSL WG meeting
     on 2006-11-02

    <div1 id="TrivialEmbedding">
      <head>A Trivial Embedding of XQuery</head>
      <p>
        <specref ref="Introduction"/> observed that the
<bibref ref="xquery-requirements"/> says <quote>The XML Query Language MAY have
more than one syntax binding. One query language syntax MUST be convenient for
humans to read and write. One query language syntax MUST be expressed in XML in
a way that reflects the underlying structure of the query.</quote>
There are many possible ways to define an XML syntax for XQuery. 
This document specifies two XML Syntaxes for XQuery: 
the one in <specref ref="Schema"/> and the <quote>trivial embedding</quote>
defined in this section. 
Of course, XQueries could be expressed in XML Syntax in other ways.</p>

      <p>The trivial embedding specified here can be used when an
      XQuery is exchanged with other entities as XML or embedded
      in an XML document, and when it is not necessary to communicate
      the underlying structure of the query. 
      When this alternative is chosen, the XQuery expression is treated
      as though it were ordinary text. </p>

      <p>The trivial embedding defined in this specification requires that the
entire query be enclosed within an element named "xquery" in the XQueryX namespace
(the "xqx:" namespace prefix is used here only for the purposes of this example),
as illustrated here:</p>

      <eg>&lt;xqx:xquery&gt;for $i... let $j...where $x = $y...return...&lt;/xqx:xquery&gt;</eg>

< ! - -  Response to Bugzilla bug #2611 - - >
<p>
XQuery expressions are, for the purposes of this trivial embedding, treated 
as literal text. Therefore, if the XQuery contains characters that are 
prohibited in XML text (specifically &lt; and &amp;), they must be "escaped" as 
character entity references (&amp;lt; and &amp;amp;, respectively) or as numeric 
character references (for example, &amp;#x3C; and &amp;#x26;, respectively), or 
they must be enclosed in a CDATA section (for example, &lt;![CDATA[&lt;]] or 
&lt;![CDATA[&amp;]]).  Note that this includes the leading "&lt;" of a CDATA section 
that appears in the original XQuery expression.  In addition, because the 
sequence of characters "]]&gt;" is always prohibited within element content,
it is recommended that instances of &gt; in the original XQuery always be 
"escaped" (for example, as &amp;gt;, &amp;#x3E;, or &lt;![CDATA[&gt;]]).
</p>

      <eg>&lt;xqx:xquery&gt;for $i... let $j...where $x &amp;lt; $y...return...&lt;/xqx:xquery&gt;</eg>

      <p>or</p>

      <eg>&lt;xqx:xquery&gt;for $i... let $j...where $x &amp;x003C; $y...return...&lt;/xqx:xquery&gt;</eg>

      <p>This limitation may require that user agents scan the XQuery text, escaping such
prohibited characters, before transmitting or embedding the XQuery as XML. </p>

< ! - - Response to Bugzilla bug #2611 - - >
< ! - - Response to Bugzilla bug #3056 - - >
      <p>The following two more complete examples (which are equivalent to one another
      and to "<code>for $i in (1 to 5) let $j := 4 where $i &lt; $j return
  &lt;x&gt;&lt;i&gt;{$i}&lt;/i&gt;&lt;/x&gt;</code>") further illustrate the use of the
         XQueryX trivial embedding. </p>

      <eg>&lt;xqx:xquery&gt;for $i in (1 to 5) let $j := 4 where $i &amp;lt; $j return
  &lt;x&gt;&lt;i&gt;{$i}&lt;/i&gt;&lt;/x&gt;&lt;/xqx:xquery&gt;

&lt;xqx:xquery&gt;&lt;![CDATA[for $i in (1 to 5) let $j := 4 where $i &lt; $j
  return &lt;x&gt;&lt;i&gt;{$i}&lt;/i&gt;&lt;/x&gt;]]&gt;&lt;/xqx:xquery&gt;</eg>

    </div1>
-->

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

      <p>This section defines the conformance criteria for an XQueryX processor
         (see Figure 1, "Processing Model Overview", in <bibref ref="xquery"/>,
         <xspecref spec="XQ" ref="id-processing-model"/>. 
      </p>

      <p>In this section, the following terms are used to indicate the
         requirement levels defined in <bibref ref="RFC2119"/>. 
         [Definition: MUST means that the item is an absolute requirement of the specification.]
         [Definition: SHOULD means that there may exist valid reasons in particular
         circumstances to ignore a particular item, but the full implications
         must be understood and carefully weighed before choosing a different course.]
         [Definition: MAY means that an item is truly optional.] </p>

      <p>An XQueryX processor that claims to conform to this specification MUST
         implement the XQueryX syntax as defined in <specref ref="Schema"/> of this
         specification and include a claim of Minimal Conformance as defined in
         <bibref ref="xquery"/>, <xspecref spec="XQ" ref="id-minimal-conformance"/>. 
         In addition to a claim of Minimal Conformance, it MAY claim conformance to
         one or more optional features defined in
         <bibref ref="xquery"/>, <xspecref spec="XQ" ref="id-conform-optional-features"/>. </p>

    </div1>

  </body>


  <back>

    <div1 id="biblio">
      <head>References</head>

<!-- Checked 2004-12-28, Jim Melton; updated dates of XQuery and Formal Semantics -->
<!-- RFC refs changed per re-opened Bugzilla bug #1345 -->
      <blist>
        <bibl id="xquery-requirements" key="XML Query 1.0 Requirements"/>
        <bibl id="xquery" key="XQuery 1.0: An XML Query Language"/>
        <bibl id="xquery-use-cases" key="XML Query Use Cases"/>
        <bibl id="xquery-semantics" key="XQuery 1.0 Formal Semantics"/>
        <bibl id="RFC2119" key="RFC 2119">S. Bradner. 
          <emph>Key Words for use in RFCs to Indicate Requirement Levels.</emph> IETF RFC 2119. 
          See <loc href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</loc>.</bibl>
        <bibl id="RFC3023" key="RFC 3023">M. Murata, S. St. Laurent, and D. Kohn. 
          <emph>XML Media Types</emph> IETF RFC 3023 or its successors. 
          See <loc href="http://www.ietf.org/rfc/rfc3023.txt">http://www.ietf.org/rfc/rfc3023.txt</loc>.</bibl>
<!--        <bibl id="RFC3986" key="RFC 3986">T. Berners-Lee, R. Fielding, and L. Masinter. 
		  <emph>Uniform Resource Identifiers (URI): Generic Syntax</emph>. IETF RFC 3986. 
		  See <loc href="http://www.ietf.org/rfc/rfc3986.txt">http://www.ietf.org/rfc/rfc3986.txt</loc>.</bibl> -->
      </blist>

    </div1>


    <div1 id="Stylesheet">

      <head>Transforming XQueryX to XQuery</head>

      <p>The following stylesheet converts from XQueryX syntax to XML Query syntax. 
         Note the intent of the stylesheet is to produce <emph>a</emph> valid XQuery with the
         same semantics (see <bibref ref="xquery-semantics"/>) as the input XQueryX.</p>

      <eg>&xqx2xq-stylesheet;</eg>

    </div1>

<!-- Insert the appendix for the MIME type for XQueryX here -->
    &mimetypeappendix;

    <inform-div1 id="changelog">
      <head diff="chg" at="Renamed for second edition">Changes since the First Edition</head>

      <p diff="chg" at="Updated for second edition">The changes made to this document,
        other than trivial editorial changes, are described in detail in the 
        <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html">Errata</loc> to the first edition. 
        The rationale for each erratum is explained in the corresponding Bugzilla database entry. 
        The following table summarizes the errata that have been applied.</p>
         <table border="1" cellpadding="5" width="100%">
            <thead>
               <tr diff="add" at="Added for second edition">
                  <td>Erratum</td>
                  <td>Bugzilla</td>
                  <td>Category</td>
                  <td>Description</td>
               </tr>
            </thead>
            <tbody>
               <tr diff="add" at="XQX.E1">
                  <td>
                     Erratum <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E1">E1</loc>
                  </td>
                  <td>
                     <loc href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=4924">Arguably incorrect element definition in XQueryX's Schema.</loc>
                  </td>
                  <td>
                     Editorial. 
                  </td>
                  <td>
                     The published XQueryX 1.0 schema defined many elements using anonymous complex types. 
                     That made it infeasible to extend the content model of those elements in other
                     specifications that define XQueryX extensions corresponding perhaps to XQuery extensions. 
                     While conceptually simple, a number of changes were required to ensure that
                     all elements are defined using named complex types.  
                  </td>
               </tr>

               <tr diff="add" at="XQX.E2 and XQX.E3">
                  <td>
                     Errata <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E2">E2</loc> and <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E3">E3</loc>
                  </td>
                  <td>
                     <loc href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=4963">Removed element xqx:parenthesizedExpr used in example.</loc>
                  </td>
                  <td>
                     Editorial. 
                  </td>
                  <td>
                     The XQueryX solution to Example 4 incorrectly contained an &lt;xqx:parenthesizedExpr> element. 
                     That element was changed to an &lt;xqx:sequenceExpr> element.
                     The XSLT stylesheet in Appendix B contained a template for the transformation
                     of &lt;xqx:parenthesizedExpr> elements that was unnecessary and
                     confusing; that template was deleted. 
                  </td>
               </tr>

               <tr diff="add" at="XQX.E4">
                  <td>
                     Erratum <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E4">E4</loc>
                  </td>
                  <td>
                     <loc href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=5323">Bug in XQueryX applet</loc>
                  </td>
                  <td>
                     Editorial. 
                  </td>
                  <td>
                     The XQueryX 1.0 Recommendation linked to an obsolete version of the XQuery 1.0 grammar applet.  
                     The proper link has now been used. 
                  </td>
               </tr>

               <tr diff="add" at="XQX.E5">
                  <td>
                     Erratum <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E5">E5</loc>
                  </td>
                  <td>
                     <loc href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=5343">Problem with {{ and }} in a Namespace Declaration Attribute</loc>
                  </td>
                  <td>
                     Editorial. 
                  </td>
                  <td>
                     The XSLT stylsheet in Appendix B contained a template for the transformation of
                     &lt;xqx:namespaceDeclaration> elements that failed to correctly "escape"
                     curly braces in the same manner as does the template for the transformation of
                     &lt;xqx:attributeConstructor> elements.  That template has been corrected. 
                  </td>
               </tr>

               <tr diff="add" at="XQX.E6">
                  <td>
                     Erratum <loc href="http://www.w3.org/XML/2007/qt-errata/xqueryx-errata.html#E6">E6</loc>
                  </td>
                  <td>
                     <loc href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=6377">[XQX] non-normative notes</loc>
                  </td>
                  <td>
                     Editorial. 
                  </td>
                  <td>
                     Added text in <specref ref="Introduction"/> to clarify that Notes are non-normative. 
                  </td>
               </tr>

               <tr diff="add">
                 <td>(None)</td>
                 <td>(None)</td>
                 <td>Editorial</td>
                 <td>Corrected typographical error in MIME appendix ("XSLT" should have been "XQueryX").</td>
               </tr>
            </tbody>
         </table>

    </inform-div1>

  </back>

</spec>
