I usually write a quick utility function to handle deleting the document that a node belongs to:

declare function pages:remove-page($element as element()?) as empty() {
  if (exists($element)) then xmldb:remove(util:collection-name($element), util:document-name($element)) else ()

};

I have it so that the element passed doesn't have to exist, so that I won't be trying to remove what isn't there.  The collection name and document name are both gotten from the element itself, so I don't need to know them before hand.


util:collection-name returns and xs:string, but I've never had to type cast it to xs:anyURI manually.  This has worked with both 1.4 and 2.0 with no issues.


Hope this helps.


--
Michael Westbay
Writer/System Administrator
http://www.japanesebaseball.com/