This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6288 - [UPDUseCase] Static Typing and Parts Q3 Solution 2
Summary: [UPDUseCase] Static Typing and Parts Q3 Solution 2
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Update Facility 1.0 Use Cases (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows XP
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-08 21:26 UTC by Andrew Eisenberg
Modified: 2009-02-17 16:08 UTC (History)
1 user (show)

See Also:


Attachments

Description Andrew Eisenberg 2008-12-08 21:26:29 UTC
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).
Comment 1 Jonathan Robie 2009-02-10 13:09:30 UTC
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