Frage

I'm attempting to delete an XML node through XQuery using the in-build XQuery compiler in Altova XMLSpy.

xquery version "1.0" encoding "UTF-8";
for $customer in doc("Customers.xml")/dataroot/Customers
where $customer/CustomerID = "ALFKI"
return delete node $customer;

The issue is the compiler doesn't see 'delete node' as valid syntax, whereas it's defined here: http://www.w3.org/TR/xquery-update-10/

It complains with an error "Unexpected token node $customer".

Any ideas?

War es hilfreich?

Lösung 2

Remove the missplaced semicolon after $customer.

xquery version "1.0" encoding "UTF-8";
for $customer in doc("Customers.xml")/dataroot/Customers
where $customer/CustomerID = "ALFKI"
return delete node $customer (: here was the semicolon :)

Otherwise, your XQuery is valid.

Andere Tipps

the fact is that XMLSpy don't support XQuery Update Facility, hence the delete keyword is not valid

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top