Hi David,
> […]
> try {attribute id { "new-id" }} catch * {()},
> […]
>
> but it doesn't trap the error (in any XQuery 3 processor I've checked). The
> try/catch will work only if put around the entire element constructor.
The reason for this is that the attribute constructor itself is
correct. The error occurs when trying to add the newly created
attribute to the element.
The following query should work:
let $element := <el att1="one" att2="two" id="old-id">text</el>
return element new {
$element/attribute(),
if($element/@id) then () else attribute id { "new-id" },
$element/node()
}
Hope this helps,
Christian
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk