<?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>3787</bug_id>
          
          <creation_ts>2006-10-02 21:13:24 +0000</creation_ts>
          <short_desc>[XQuery] Code example I.4 with flaws</short_desc>
          <delta_ts>2006-10-11 22:38:09 +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="Hans-Juergen Rennau">hrennau</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>12245</commentid>
    <comment_count>0</comment_count>
    <who name="Hans-Juergen Rennau">hrennau</who>
    <bug_when>2006-10-02 21:13:24 +0000</bug_when>
    <thetext>[XQuery] The function local:swizzle as described by the appendix has two flaws:

a) text nodes are ignored, thus producing an output document without any text contents
b) no care is taken to ensure that within an element constructor all attribute nodes are written before any element nodes, thus inviting runtime errors 
   
(a) could be solved by replacing the line
         { for $c in $e/(* | @*) return local:swizzle($c) }
by the line
         { for $c in $e/(node() | @*) return local:swizzle($c) }
         
(b) could be taken care of by adding a textual remark, e.g. something of this sort: 

&quot;For the sake of simplicity, the sample code neglects to ensure that 
within an element constructor all attribute nodes are written before 
any element nodes. For example, it relies on &lt;size&gt; elements to have no preceding sibling elements.&quot;

However, maybe it would be better to present safe code by just replacing the line
         { for $c in $e/(* | @*) return local:swizzle($c) }
by
         { for $c in ( $e/@* except $e/@color,    (: attribute -&gt; attribute :)
                       $e/size,                   (: elem -&gt; attribute :)
                       $e/@color,                 (: attribute -&gt; elem :)
                       $e/node() except $e/size ) (: elem -&gt; elem :) 
           return local:swizzle($c) }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12399</commentid>
    <comment_count>1</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2006-10-11 22:37:54 +0000</bug_when>
    <thetext>Hans-Juergen,
Good catch! Thanks for notifying the working group of these errors. The next version of the XQuery specification will include the &quot;safe code&quot; corrections that you have proposed. Since the working group has accepted your suggestion in its entirety, I have changed the status of this bug to &quot;Fixed and Closed.&quot;
Regards,
Don Chamberlin (for the Query Working Group)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>