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 3474 - [XQueryX] constructing attribute values with the less than character
Summary: [XQueryX] constructing attribute values with the less than character
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQueryX 1.0 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jim Melton
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-17 22:09 UTC by Andrew Eisenberg
Modified: 2007-02-25 23:55 UTC (History)
0 users

See Also:


Attachments

Description Andrew Eisenberg 2006-07-17 22:09:26 UTC
I might want to construct an XQueryX instance that is equivalent to the
following XQuery:

<elem attr="&amp;&lt;&gt;"></elem>

I can try to do this with the following:

<?xml version="1.0"?>
<xqx:module xmlns:xqx="http://www.w3.org/2005/XQueryX"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.w3.org/2005/XQueryX
                                http://www.w3.org/2005/XQueryX/xqueryx.xsd">
  <xqx:mainModule>
    <xqx:queryBody>
      <xqx:elementConstructor>
        <xqx:tagName>elem</xqx:tagName>
        <xqx:attributeList>
          <xqx:attributeConstructor>
            <xqx:attributeName>attr</xqx:attributeName>
            <xqx:attributeValue>&amp;&lt;&gt;</xqx:attributeValue>
          </xqx:attributeConstructor>
        </xqx:attributeList>
      </xqx:elementConstructor>
    </xqx:queryBody>
  </xqx:mainModule>
</xqx:module>

The XQueryX stylesheet turns this into the following:

<elem attr="&amp;<>"></elem>

This is not well-formed XML. Either attr="&amp;&lt;>" or attr="&amp;&lt;&gt;" should be produced.
Comment 1 Michael Kay 2006-07-18 01:02:19 UTC
I think you're right that this is a bug, but to raise a technicality, the issue isn't whether <elem attr="&amp;<>"></elem> is well-formed XML, it's whether it is well formed XQuery. As it happens it is neither.

Michael Kay
Comment 2 David Carlisle 2006-07-18 10:32:11 UTC
to fix this one and bug #3446 the stylesheet will need to quote <, #9, #10, #13, in addition to & and { that are already handled. In xslt1 that's a deeply nested set of calls to the replace template. If xslt2 isn't an option (which could do this all with a single regexp-replace) another possiblity would be to 
translate

 <xqx:attributeValue>&amp;&lt;&gt;</xqx:attributeValue>

to

<elem attr="{"&amp;<>"}"></elem>
            ^^        ^^

the extra {"..."} mean that you only need to take care of string-quoting rather than attribute constructor quoting (which I think the stylesheet already gets right) and the XQuery serialiser will then take care of the attribute value quoting rules for < and white space.
Comment 3 Jim Melton 2006-08-01 01:14:51 UTC
Thanks for your comment. 

I agree with the comment and have modified the stylesheet to properly escape "<" characters, in addition to the several others identified by bug #3446.

I have marked this bug FIXED and encourage you to test the solution and, if you find it satisfactory, mark this bug CLOSED.  (I will post the revised stylesheet shortly.)
Comment 4 Jim Melton 2007-02-25 23:55:46 UTC
Closing bug because commenter has not objected to the resolution posted and more than two weeks have passed.