This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The query in Parts Q3 Solution 2 is: declare updating function local:delete-subtree($p as element(part)) { for $child in doc("part-list.xml")//part where $p/@partid eq $child/@partof return ( delete nodes $child, local:delete-subtree($child) ) }; for $p in doc("part-list.xml")//part[@name="car"] return local:delete-subtree($p) In Bug #5826, Tom Brosens points out that the type of $p in the function declaration should be changed to element(part, xs:untyped).
I am fixing this by adding a note to the example: Solution 2 (using a recursive updating function): declare updating function local:delete-subtree($p as element(part)) { for $child in doc("part-list.xml")//part where $p/@partid eq $child/@partof return ( delete nodes $child, local:delete-subtree($child) ) }; for $p in doc("part-list.xml")//part[@name="car"] return local:delete-subtree($p) NOTE: Because this data is not covered by a schema, an implementation that supports static typing will raise an error for the comparison $p/@partid eq $child/@partof. This can be solved by creating a schema for the data and importing it into the query. Please let me know if this is not sufficient. Jonathan