<?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>4997</bug_id>
          
          <creation_ts>2007-08-30 12:33:15 +0000</creation_ts>
          <short_desc>[UPD] Replace of attribute nodes can be ambiguous</short_desc>
          <delta_ts>2007-10-15 22:57:21 +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>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</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>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="John Snelson">john.snelson</reporter>
          <assigned_to name="Don Chamberlin">chamberl</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>16336</commentid>
    <comment_count>0</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2007-08-30 12:33:15 +0000</bug_when>
    <thetext>I believe the following update query is ambiguous:

copy $in := &lt;employee name=&quot;Rhys Evans&quot; gender=&quot;male&quot;/&gt;
modify (
do replace $in/@name with attribute {&quot;salary&quot;} {&quot;10&quot;},
do replace $in/@gender with attribute {&quot;name&quot;} {&quot;Blodwyn Jones&quot;}
)
return $in

In this case, should the result be err:XUDY0021 because the second replace adds an attribute that already exists? Or should the transform succeed because the first replace removes the attribute that the second replace clashes with?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16601</commentid>
    <comment_count>1</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2007-09-14 17:18:36 +0000</bug_when>
    <thetext>Hi John,
I believe that the suggested transform expression will succeed. I see nothing in the update spec to suggest that an error will be raised. Each of the replace expressions will generate a upd:replaceNode() primitive on the Pending Update List. Finally upd:applyUpdates() will make these primitives effective, in either order. The Data Model instance will go through a temporarily invalid state but the final result is valid and unambiguous. The check for validity of the XDM takes place in Step 6 of upd:applyUpdates(), at which time the XDM is valid. 

In fact, you could even change your example to the following one, in which two attributes are &quot;swapped&quot;:

copy $in := &lt;employee name=&quot;Rhys Evans&quot; gender=&quot;male&quot;/&gt;
modify (
replace node $in/@name with $in/@gender,
replace node $in/@gender with $in/@name
)
return $in

This strange and entirely unmotivated expression is not an error. It returns an &lt;employee&gt; node that is effectively the same as the constructed one, since order of attributes is not significant.

Regards,
Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16611</commentid>
    <comment_count>2</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2007-09-17 14:37:42 +0000</bug_when>
    <thetext>On looking at this further, I agree with your assessment of this.

If there isn&apos;t one already, can I ask that a note is added to the specification to state that the data model may be transitionally invalid during the application of the update primitives?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16672</commentid>
    <comment_count>3</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2007-09-18 17:41:34 +0000</bug_when>
    <thetext>In the semantic specification for upd:applyUpdates (Section 3.2.2), Steps 1 through 5 describe how pending updates are applied. Then Step 6 calls for a check of data model constraints. Since checking of data model constraints is explicitly called for in Step 6 and not in any previous step, I think it is clear that these constraints may be transiently violated during the process of applying individual updates.
Regards,
--Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16673</commentid>
    <comment_count>4</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2007-09-18 18:22:57 +0000</bug_when>
    <thetext>I disagree that it is as clear as you say it is, because at least one person has already misread this. I think a note would aid reading of the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17224</commentid>
    <comment_count>5</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2007-10-15 22:57:04 +0000</bug_when>
    <thetext>As instructed by the working group, I have added the following Note to Step 6 of upd:applyUpdates:
&quot;During processing of a pending update list, an XDM instance may temporarily violate a data model constraint. An error is raised only if a constraint remains unsatisfied at the conclusion of upd:applyUpdates.&quot;
Regards,
Don Chamberlin (for the Query Working Group)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>