1

I am trying to update some XML data using XMLspy.

Here is the data I have...

<Orders>
    <Order_x0020_ID>30</Order_x0020_ID>
    <Employee_x0020_ID>9</Employee_x0020_ID>
    <Customer_x0020_ID>27</Customer_x0020_ID>
    <Order_x0020_Date>2006-01-15T00:00:00</Order_x0020_Date>
    <Shipped_x0020_Date>2006-01-22T00:00:00</Shipped_x0020_Date>
    <Shipper_x0020_ID>2</Shipper_x0020_ID>
    <Ship_x0020_Name>Karen Toh</Ship_x0020_Name>
    <Ship_x0020_Address>789 27th Street</Ship_x0020_Address>
    <Ship_x0020_City>Las Vegas</Ship_x0020_City>
    <Ship_x0020_State_x002F_Province>NV</Ship_x0020_State_x002F_Province>
    <Ship_x0020_ZIP_x002F_Postal_x0020_Code>99999</Ship_x0020_ZIP_x002F_Postal_x0020_Code> 
    <Ship_x0020_Country_x002F_Region>USA</Ship_x0020_Country_x002F_Region>
    <Shipping_x0020_Fee>200</Shipping_x0020_Fee>
    <Taxes>0</Taxes>
    <Payment_x0020_Type>Check</Payment_x0020_Type>
    <Paid_x0020_Date>2006-01-15T00:00:00</Paid_x0020_Date>
    <Tax_x0020_Rate>0</Tax_x0020_Rate>
    <Status_x0020_ID>3</Status_x0020_ID>
</Orders>

I'm using this XQuery:

xquery version "1.0";
insert nodes 
  <Orders>
    <Order_x0020_ID>999</Order_x0020_ID>
  </Orders>
into doc("Orders.xml")

This should create another order in the Orders.xml file. However, when trying to run it, it does not. This is the error I get:

Unexpected token 'nodes'

XPST0003: The expression around '"1.0"; insert nodes <Orders>' is not a  valid instance of the XQuery grammar

I wish the output data to be:

<Orders>
    <Order_x0020_ID>999</Order_x0020>
</Orders>

Any help would be greatly appreciated, thanks!

Nicholas Mordecai
  • 859
  • 2
  • 12
  • 33
  • your query seems grammatically correct. The only thing that is wrong with it is that its currently producing two document elements. You should use into doc("Orders.xml")/Orders instead. But from the error you're getting it seems the processor that you're using doesn't (fully?) support xquery update. I'm not an expert on the capabilities of xmlspy though. – Ewout Graswinckel Mar 10 '15 at 11:32

1 Answers1

0

You don't need the xquery version "1.0"; declaration since XQuery update is a separate extension. If you're going through the XMLSPY GUI, you just need to set the processor and version you're using:

enter image description here

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40