<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>1307</bug_id>
          
          <creation_ts>2005-05-05 09:37:03 +0000</creation_ts>
          <short_desc>[XQuery] Line Endings</short_desc>
          <delta_ts>2005-09-29 10:45:41 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 1.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>grammar</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Scott Boag">scott_boag</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3538</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-05-05 09:37:03 +0000</bug_when>
    <thetext>[XQuery] Line Endings

There are two places in XQuery where line endings are normalized: (a) in the
content of direct element constructors, and (b) in string literals.

Within attribute content, the spec refers to the rules for attribute value
normalization in XML 3.3.3. These start with the rule &quot;All line breaks must have
been normalized on input to #xA as described in 2.11 End-of-Line Handling, so
the rest of this algorithm operates on text normalized in this way.&quot; This can be
read as implying that XQuery also normalizes line endings in attribute content
(which means that CRLF in attribute content is turned into a single space, not
into two spaces).

(Aside: The XML rules for attribute value normalization depend on the type of
the attribute. I think it would be helpful if we specify that the algorithm is
executed on the basis that the attribute type is CDATA. If it isn&apos;t, then schema
validation will take care of it.)

There are contexts in XQuery where line endings are *not* normalized. For
example, they are not normalized in a CDATA section, a direct comment
constructor, or a direct processing instruction constructor. Since the syntax of
each of these constructs is explicitly designed to mimic XML, it seems odd that
the handling of line endings here should differ from XML.

Further, XQuery doesn&apos;t normalize line endings appearing in the middle of an
ordinary expression (for example, between &quot;declare&quot; and &quot;function&quot;. This doesn&apos;t
matter unless XML 1.1-style line endings are used. Currently, if an XQuery
processor decides to follow the XML 1.1 profile, then it allows and normalizes a
NEL character appearing in element content or in a string literal; allows and
doesn&apos;t normalize it in a CDATA section, comment, or PI; and disallows it in the
middle of an expression.

I can&apos;t see any good reason why XQuery doesn&apos;t do the same as XML, and specify
that all line endings in the query are normalized according to the XML 1.0 or
1.1 rules irrespective of the syntactic context, before any lexical or syntactic
analysis of the query starts.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3169</commentid>
    <comment_count>1</comment_count>
    <who name="Scott Boag">scott_boag</who>
    <bug_when>2005-05-17 19:53:09 +0000</bug_when>
    <thetext>I can&apos;t see any technical issue with the grammar with doing uniform line ending
normalization, except the need for pre-processing of the VersionDecl in the case
of XQuery, which has to be done in any event.  One has to assume the encoding is
known for XPath, that that isn&apos;t an issue.

Since the normalization occurs essentially out-of-band to the syntax parsing
process, I don&apos;t think there has to be any effect to the rest of the document. 
Of course, a real world parser would not do two passes... it&apos;s just cleaner to
specify it this way.

I suggest a new section immediately above the section on whitespace, where we
pretty much do the same as the XML specifications.  I&apos;m not very happy with how
the XML 1.0 vs. XML 1.1 wording is done in the first paragraph... this would be
easier if we had a proper XML 1.1 named feature, or the like.  Any suggestions
on ways to better handle this would be much appreciated.

=========
A.2.2 End-of-Line Handling

The [XPath/XQuery] processor MUST behave as if it normalized all line breaks on
input, before parsing. The normalization should be done according to the choice
to support [XML 1.0], or [XML 1.1] lexical processing.

A.2.2.1 XML 1.0 End-of-Line Handling

For [XML 1.0] processing, all of the following MUST be translated to a single
#xA character:

   1.  the two-character sequence #xD #xA
   2.   any #xD character that is not immediately followed by #xA.

A.2.2.2 XML 1.1 End-of-Line Handling

For [XML 1.1] processing, all of the following MUST be translated to a single
#xA character:

   1.  the two-character sequence #xD #xA
   2.  the two-character sequence #xD #x85
   3.  the single character #x85
   4.   the single character #x2028
   5.   any #xD character that is not immediately followed by #xA or #x85.

(XQuery-only)The characters #x85 and #x2028 cannot be reliably recognized and
translated until the VersionDecl declaration (if present) has been read. 
===========</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2740</commentid>
    <comment_count>2</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-06-11 02:59:02 +0000</bug_when>
    <thetext>I have deleted references to line-ending normalization from XQuery Sections 
3.1.1 (Literals) and 3.7.1.3 (Dir. Elem. Constructor--Content, Rule 1a). Scott, 
after you have inserted the new section on global end-of-line handling into 
Appendix A, you can close this bug report.
--Don</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5177</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Boag">scott_boag</who>
    <bug_when>2005-07-22 20:47:40 +0000</bug_when>
    <thetext>This work has been completed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>