- From: <bugzilla@wiggum.w3.org>
- Date: Mon, 02 Oct 2006 21:13:24 +0000
- To: public-qt-comments@w3.org
- CC:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=3787
Summary: [XQuery] Code example I.4 with flaws
Product: XPath / XQuery / XSLT
Version: Candidate Recommendation
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: XQuery
AssignedTo: chamberl@almaden.ibm.com
ReportedBy: hrennau@yahoo.de
QAContact: public-qt-comments@w3.org
[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) }
Received on Monday, 2 October 2006 21:13:35 UTC