I'm using the Oxygen XML Editor to learn Xquery, and I've opened one of their sample files:
xquery version "3.1";
(:The Saxon EE processor must be set in the XQuery transformation scenario for this example. :)
declare base-uri 'file:/Applications/Oxygen%20XML%20Editor/samples/xquery/Update/';
(: How to insert a node in an XML document. :)
insert node
<product id="p7">
<name>papa</name>
<price>2100</price>
<stock>4</stock>
<country>China</country>
</product>
as last into doc("products.xml")/products
I would use this to transform the appropriate file, but the file doesn't pass validation. The validation error I get is
F [Saxon-EE XQuery 10.6] Unexpected token "insert nodes" at start of expression
I tried to modify the code to match other examples and I still get the same error. I added the xquery version and base-uri to the sample to eliminate them as possible problems. Why is this happening, how do I fix it.
In Oxygen, go to Preferences / XML / XSLT-XQuery / XQuery / Saxon HE/PE/EE, and tick the option "Enable XQuery Update". Also ensure that the transformation scenario for executing the query has "Saxon-EE" and "Enable XQuery Update" set.
You may need to restart Oxygen for the setting to take effect.