syntax error using XQuery delete

This works:

declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
let $doc := (
for $z in (
for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
and $q/km_properties/document_type/details/detail=‘PCN’
return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
return $z)
for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
return $a



But this similar query produces a syntax error:

declare namespace tf = “http://namespaces.softwareag.com/tamino/TaminoFunction
declare namespace xs = “XML Schema
declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
let $doc := (
for $z in (
for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
and $q/km_properties/document_type/details/detail=‘PCN’
return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
return $z)
update for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
do delete $a/…


The only difference occurs in the last two lines. I want to delete these documents, which I can see using the first query. I believe $a returns me the root node, and for delete I need to go up one, thus the /…

(I am looking at Trevor Ford’s reply to
Delete XML Instance with XQuery, posted by Michelle in the Tamino API for Java forum.)

Thanks

Neil Keefe

Hi,

In order to get a valid update statement you just have to move the ?update? key word. The resulting update statement looks like this:

declare namespace tf = “http://namespaces.softwareag.com/tamino/TaminoFunction
declare namespace xs = “XML Schema
declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators

update
let $doc := (
for $z in (
for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
and $q/km_properties/document_type/details/detail=‘PCN’
return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
return $z)
for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
do delete $a/…


Best regards,

Thorsten Fiebig