<?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>2710</bug_id>
          
          <creation_ts>2006-01-13 11:46:18 +0000</creation_ts>
          <short_desc>[xqueryx and xquery] extra white space in pragma content</short_desc>
          <delta_ts>2006-06-13 12:21:27 +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>Candidate Recommendation</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></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Carlisle">davidc</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>7816</commentid>
    <comment_count>0</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2006-01-13 11:46:21 +0000</bug_when>
    <thetext>The stylesheet has
 &lt;xsl:variable name=&quot;PRAGMA_BEGIN&quot; select=&quot;&apos;(# &apos;&quot;/&gt;
 &lt;xsl:variable name=&quot;PRAGMA_END&quot; select=&quot;&apos; #)&apos;&quot;/&gt;
which means that a space is inserted at the beginging and end of each pragma.
The stylesheet also inserts a space between the name and pragmacontents.

so the xqueryx
&lt;xqx:pragma&gt;
  &lt;xqx:pragmaName&gt;a&lt;/xqx:pragmaName&gt;
  &lt;xqx:pragmaContents&gt;b&lt;/xqx:pragmaContents&gt;
&lt;/xqx:pragma&gt;

is defined to mean the same as the xquery
(# a b #)

The EBNF for this expression is
[66]    	Pragma 	   ::=    	&quot;(#&quot; S? QName PragmaContents &quot;#)&quot;
so the first space has no effect but both of the second two spaces end up being
parsed as pragmacontent. Since the semantics of this are implementation defined,
this may or may not have an effect. However whether or not a sytem treats them
differently here is no XqueryX expression corresponding to xquery expressions
which do not have space in pragmacontent, such as
(#a+b#}{1}
which is a valid Xquery with pragma with name a and content +b

The final space is easy to fix, $PRAGMA_END should just be &apos;#)&apos;

However the middle space is harder, I think that the best fix would be for the
stylesheet to continue to insert a space between the name and content but the
XQuery EBNF modified to
[66]    	Pragma 	   ::=    	&quot;(#&quot; S? QName (S PragmaContents)? &quot;#)&quot;
so that if you have any contents, they have to be separated by white space from
the name (which would make my (#a+b#} example above a syntax error)

David</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7965</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-01-25 04:41:23 +0000</bug_when>
    <thetext>I agree that this is something that may or may not (and, IMHO, probably not)
make a difference, but there is a possibility that some implementation may
ascribe importance to a space at the end of pragmaContents.  Based on that
possibility, I have removed the space that is the first character of PRAGMA_END
as you have suggested. 

The XML Query WG will consider the second part of your suggestion -- the
modification of the EBNF for Pragma to require whitespace to precede any
PragmaContents -- at its earliest opportunity. 

Until the XML Query WG has considered that proposal, I am leaving this bug
unresolved. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7966</commentid>
    <comment_count>2</comment_count>
    <who name="David Carlisle">davidc</who>
    <bug_when>2006-01-25 10:03:31 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; I agree that this is something that may or may not (and, IMHO, probably not)
&gt; make a difference, but there is a possibility that some implementation may
&gt; ascribe importance to a space at the end of pragmaContents.  Based on that
&gt; possibility, I have removed the space that is the first character of PRAGMA_END
&gt; as you have suggested. 
&gt;
Thanks, In a sense I already have an application for which this made a
difference (which is how I came to spot it:-)

As a general sanity check I have tests that try to round trip expressions
between xquery and xqueryx and these spaces meant that I couldn&apos;t get back to
where I started. I agree that it&apos;s unlikely that any sane application that&apos;s
actually executing code is likely to treat these spaces as significant, but (as
I&apos;m sure you know even better than me) the job of the specification is as much
to specify what insane applications can or cannot attempt as it is to say what
the normal process should be.

If you do consider the EBNF change I think it would need to be a little
different from what I suggested as in that form it is an ambiguous grammar, If
there are multiple spaces at the start of pragma content the later ones could
either be parsed as part of the S that I added or as the start of pragma
content. I think you&apos;d need the regexp for pragma content to explictly exclude
the possibility of initial space. (Unless you can appeal to some global
&quot;longest match&quot; rule that would force any space in that position to be parsed by
the &quot;S&quot;, not sure of the exact semantics you are using there)

David</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8387</commentid>
    <comment_count>3</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-02-22 21:45:40 +0000</bug_when>
    <thetext>Thank you very much for your comments on this subject.  After considerable
discussion, the XML Query WG determined that the solution with the fewest
problems was to simply require white space between the pragma name and the
pragma contents. The principle consequences of this decision are 1)No pragma
contents can actually start with white space (because it would be
indistinguishable from the separating white space), 2)Some otherwise acceptible
pragma text (e.g., (# A-name=&quot;A value&quot;#) is invalid, and 3)It is possible to
represent something in XQueryX that is not representable in XQuery.  It is our
conclusion that problem 1) will very likely not affect any existing XQuery
implementations or users, that problem 2) will affect a small number of
implementations or users, and that problem 3) is moot because XQueryX syntax
that does not transform into correct XQuery syntax has no meaning and is thus
incorrect. 

Based on your most recent comment (#2), we believe that we have completely
resolved this comment and have marked it CLOSED.  If you disagree, you are
welcome to reopen the bug. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9459</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2006-04-26 16:54:23 +0000</bug_when>
    <thetext>I am reopening this to ask for clarification on an issued raised by test extexpr-26: (bug #3151) http://www.w3.org/Bugs/Public/show_bug.cgi?id=3151

If the pragmaContents is empty, should the whitespace still be required after the QName?

My interpretation of the resolution was that whitespace was needed only to separate the QName from the pragmaContents. The writer of this test seems to have interpreted it as meaning that the space is needed after the QName regardless what follows.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9494</commentid>
    <comment_count>5</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-04-27 14:54:29 +0000</bug_when>
    <thetext>My memory of the discussions, and my interpretation of the wording in reply #3 below (which I wrote), is that the white space is required only to separate a pragma name from pragma contents, not that a pragma name is always to be followed by white space.  Thus, I believe that (# Pname#) satisfies the intended syntax for pragmas as discussed and recorded in response #3. 

Of course, I do not believe that any harm is done when a space is used, based on my interpretation that whitespace immediately following a pragma name is not part of a pragma contents.  Thus the pragma (# Pname#) and the pragma (# Pname #) are, IMHO, identical in semantics. 

As a consequence, I do not believe that this is actually an XQueryX bug, nor will a change to XQueryX have any effect on this issue.  I am therefore transferring ownership of this bug to our grammar expert and editor. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9507</commentid>
    <comment_count>6</comment_count>
    <who name="Andrew Eisenberg">andrew.eisenberg</who>
    <bug_when>2006-04-27 20:21:51 +0000</bug_when>
    <thetext>Scott, when you answer this, please show us the new grammar productions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9931</commentid>
    <comment_count>7</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2006-06-05 05:22:01 +0000</bug_when>
    <thetext>I transferred this bug from XQueryX to XQuery on the grounds that any change to address it must apply to the XQuery grammar, and leaving it in XQueryX has not gotten it any attention.  (Sorry, Don!)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9966</commentid>
    <comment_count>8</comment_count>
    <who name="Scott Boag">scott_boag</who>
    <bug_when>2006-06-12 14:39:02 +0000</bug_when>
    <thetext>(In reply to comment #7)
I&apos;ve tried to research the history of this.  In the April 2006 telcon, http://lists.w3.org/Archives/Member/w3c-xsl-query/2006Feb/0030, the request was made to change the grammar to:
[66] Pragma ::= &quot;(#&quot; S? QName (S PragmaContents)? &quot;#)&quot;

Which I did.  Mike Kay&apos;s comment (http://www.w3.org/Bugs/Public/show_bug.cgi?id=2710#c4) and subsequent comments seem to have been made after this grammar change, which is confusing to me since the grammar now clearly allows for there being no whitespace after the QName.

extexpr-26 of XQTS 0.9.0 has:
(# ns1:you-do-not-know-me-as-index#){fn:count((1,2,3))}

The XQTSCatalog lists this as being a &quot;runtime-error&quot; (erronious in any case for a syntax issue!), and the test contains the comment &quot;Negative for extension expression for new sytax (missing space after pragma name)&quot;.  I think this is a bad test... the test clearly parses under the current grammar.

So the answer to Mike&apos;s question &quot;If the pragmaContents is empty, should the whitespace still be required after the QName?&quot; is &quot;no&quot;, whitespace is not required.  I don&apos;t think any further clarification is needed in the spec.

Perhaps this bug should be transfered as a bug on extexpr-26?

Will wait for ratification of the WGs to close the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9967</commentid>
    <comment_count>9</comment_count>
    <who name="Carmelo Montanez">carmelo</who>
    <bug_when>2006-06-12 14:51:41 +0000</bug_when>
    <thetext>All:

extexpr-26, was changed to reflect this change and no longer is out
of sync with the proposed Recs.  I think this bug can be safely closed
by David/Michael.  I can close it as well.  I am marking this as &quot;fixed&quot;

Greetings,
Carmelo</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>