<?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>17173</bug_id>
          
          <creation_ts>2012-05-24 21:21:56 +0000</creation_ts>
          <short_desc>Inconsistent is-id behavior for updated attributes</short_desc>
          <delta_ts>2013-07-15 10:05:34 +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>Update Facility</component>
          <version>Recommendation</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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="Josh Spiegel">josh.spiegel</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>josh.spiegel</cc>
          
          <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>68087</commentid>
    <comment_count>0</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2012-05-24 21:21:56 +0000</bug_when>
    <thetext>Whenever an XDM attribute is brought into the world, the XQuery and XDM specifications ensure that if its name is xml:id:
  (a) the is-id property is set to true and 
  (b) the attribute value has undergone xml:id processing.

Example 1: XDM Attribute Conversion
http://www.w3.org/TR/xpath-datamodel/#const-infoset-attribute
is-id &quot;If the attribute is named xml:id and its [attribute type] property does not have the value ID, then [xml:id] processing is performed. This will assure that the value does have the type ID and that it is properly normalized&quot;

Example 2: Attribute construction
http://www.w3.org/TR/xquery/#id-attributes (bullet 5)
&quot;If the attribute name is xml:id, then xml:id processing is performed as defined in [XML ID]. This ensures that the attribute has the type xs:ID and that its value is properly normalized. &quot;

It looks like the XQuery Update Facility also tries to maintain this policy. 

Example 3:
http://www.w3.org/TR/xquery-update-10/#id-upd-rename (bullet 2. c.)
&quot;If $newName is xml:id, the is-id property of $target is set to true.&quot;

Example 4:
http://www.w3.org/TR/xquery-update-10/#id-upd-set-to-untyped (bullet 2. d.)
&quot;is-id is set to false if the attribute name is not xml:id.&quot;

But, I think there might be some holes in the XQUF specification with respect to this.

Problem 1:  It is possible to cause an attribute named xml:id to have is-id set to false. 
----------------------------------------

    copy $doc := document { &lt;e xml:id=&quot;bar&quot;/&gt; }
    modify replace value of node $doc/e/@xml:id with &quot;foo&quot;
    return fn:id(&quot;foo&quot;, $doc)

I think that the result of this query should be &lt;e xml:id=&quot;foo&quot;/&gt; but according to the spec the answer should be ().  The replace expression will create a upd:replaceValue primitive which in turn will use upd:removeType on the attribute node.  upd:removeType will set is-id to false, creating an attribute named xml:id with is-id false. 

Problem 2:  It is possible to produce an attribute named xml:id with is-id set to true where the value has not undergone xml:id processing
----------------------------------------

    copy $e := &lt;e a=&quot;foo     bar&quot;/&gt; 
    modify rename node $e/@a as xs:QName(&quot;xml:id&quot;)
    return $e

Possibly the result of this query should be &lt;e xml:id=&quot;foo bar&quot;/&gt; but currently I think it would be &lt;e xml:id=&quot;foo     bar&quot;/&gt;.  That is, the XQUF does not specify that xml:id processing should be performed on the value.  

And you can also combine problem 1 and problem 2 (an attribute named xml:id with is-id set to false and no xml:id normalization):

    copy $e := &lt;e xml:id=&quot;x&quot;/&gt; 
    modify replace value of node $e/@xml:id with &quot;foo    bar&quot;
    return $e</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>