This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 18838 - [Applet30] encoding becomes version in version declaration
Summary: [Applet30] encoding becomes version in version declaration
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Grammar Test Applets (show other bugs)
Version: Last Call drafts
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Michael Dyck
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-11 20:40 UTC by Andrew Eisenberg
Modified: 2012-12-18 13:50 UTC (History)
1 user (show)

See Also:


Attachments

Description Andrew Eisenberg 2012-09-11 20:40:59 UTC
Test case version_declaration-023-v3 led me to look at 3 queries:

1)  xquery encoding "utf-8"; 1 eq 1

|         VersionDecl [1:0 - 1:24]
|            StringLiteral "utf-8" [2:17 - 1:23]
|            Separator [2:17 - 1:24]

  <xqx:versionDecl>
    <xqx:version>utf-8</xqx:version>
    <!-- encoding: null -->
  </xqx:versionDecl>

2)  xquery version "utf-8"; 1 eq 1

|         VersionDecl [1:0 - 1:23]
|            StringLiteral "utf-8" [2:16 - 1:22]
|            Separator [2:16 - 1:23]

  <xqx:versionDecl>
    <xqx:version>utf-8</xqx:version>
    <!-- encoding: null -->
  </xqx:versionDecl>

3) xquery version "utf-8" encoding "utf-9"; 1 eq 1

|         VersionDecl [1:0 - 1:40]
|            StringLiteral "utf-8" [2:16 - 1:22]
|            StringLiteral "utf-9" [2:33 - 1:39]
|            Separator [2:33 - 1:40]

  <xqx:versionDecl>
    <xqx:version>utf-8</xqx:version>
    <!-- encoding: "utf-9" -->
  </xqx:versionDecl>


The first of these is turning an encoding into a version. Our parser needs to generate a parse tree that distinguishes the string literal that represents an encoding from a string literal that represents a version.
Comment 1 Michael Dyck 2012-09-12 17:17:25 UTC
Thanks for spotting this. I've now fixed it.
Comment 2 Andrew Eisenberg 2012-09-14 19:40:10 UTC
I believe that some further work is needed here. The first of these queries:

xquery encoding "utf-8"; 1 eq 1

now generates:

  <xqx:versionDecl>
    <!-- encoding: "utf-8" -->
  </xqx:versionDecl>

which transforms into:

xquery ;
(1 eq 1)

which is invalid.


Possible solutions:

1) our applet should be generate:

  <xqx:versionDecl>
    <xqx:encoding>utf-8</xqx:encoding>
  </xqx:versionDecl>


2) our applet should generate no versionDecl element at all

3) XQueryX should transform this versionDecl element into ""
Comment 3 Michael Dyck 2012-09-18 01:42:36 UTC
Note that an empty <xqx:versionDecl> is schema-valid, so the question of how the (normative) XQueryX-to-XQuery stylesheet handles such a thing is independent of whether the (non-normative) XQuery-to-XQueryX converter generates such a thing.

-----------------------------------
re the XQuery-to-XQueryX converter:

The code doesn't say why it generates:

  <xqx:versionDecl>
    <!-- encoding: "utf-8" -->
  </xqx:versionDecl>

instead of:

  <xqx:versionDecl>
    <xqx:encoding>utf-8</xqx:encoding>
  </xqx:versionDecl>

(It's been doing so since the earliest version of the converter that I can find, dated 2005-10-16.) I suspect it's because the encoding of the original XQuery query isn't (or shouldn't be?) pertinent to the encoding of the resulting XQueryX query. Of course, we don't require that the declared encoding be correct ("since the encoding of a query may change as the query moves from one environment to another"), so it wouldn't be wrong to include the <xqx:encoding>.

Personally, I think I'd prefer an <xqx:encoding> over a comment (or no <xqx:versionDecl>), because the test suite has certain tests whose point is to elicit XQST0087 (malformed encoding string), and the corresponding XQueryX tests (generated by the converter) currently don't do so, because the offending encoding string is in a comment.

------------------------------------
re the XQueryX-to-XQuery stylesheet:

The XQueryX spec doesn't guarantee that the stylesheet will transform every schema-valid XQueryX query into a valid XQuery query, so producing
    xquery ;
    (1 eq 1)
is not technically wrong. However, it is undesirable. Probably the stylesheet should transform an empty <xqx:versionDecl> into the empty string, as you suggest.
Comment 4 Michael Dyck 2012-09-18 15:48:58 UTC
At its meeting today, the WG made the following determinations:

re the XQuery-to-XQueryX converter:
-- The 1.0 converter code can generate at most a comment for the encoding because the XQueryX 1.0 schema doesn't have an <xqx:encoding> element.
-- The 3.0 converter code should generate an <xqx:encoding> element. (Given that, it will never generate an empty <xqx:versionDecl>.)

re the XQueryX-to-XQuery stylesheet:
-- The schema will be changed to outlaw an empty <xqx:versionDecl> (i.e., it will require at least one of an <xqx:version> or an <xqx:encoding>, to parallel the XQuery syntax). Given that, the stylesheet doesn't need to change.
Comment 5 Michael Dyck 2012-12-18 06:45:40 UTC
(In reply to comment #4)
>
> re the XQuery-to-XQueryX converter:
> -- The 3.0 converter code should generate an <xqx:encoding> element. (Given
> that, it will never generate an empty <xqx:versionDecl>.)

I made this change on 2012-09-21.

> re the XQueryX-to-XQuery stylesheet:
> -- The schema will be changed to outlaw an empty <xqx:versionDecl> (i.e., it
> will require at least one of an <xqx:version> or an <xqx:encoding>, to
> parallel the XQuery syntax).

Jim Melton made this change on 2012-09-24.

Therefore, I'm marking this bug Resolved-fixed.
Andrew, if you agree with the resolution, please mark the bug Closed.