This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
[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: "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 <size> elements to have no preceding sibling elements." 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 -> attribute :) $e/size, (: elem -> attribute :) $e/@color, (: attribute -> elem :) $e/node() except $e/size ) (: elem -> elem :) return local:swizzle($c) }
Hans-Juergen, Good catch! Thanks for notifying the working group of these errors. The next version of the XQuery specification will include the "safe code" 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 "Fixed and Closed." Regards, Don Chamberlin (for the Query Working Group)