-------------order.xml--------------
<orders>
<order>
<name>cola</name>
<price>3.0</price>
<factory>Number 1</factory>
</order>
<order>
<name>coffee</name>
<price>5.0</price>
<factory>Number 2</factory>
</order>
</orders>
--------------------------------------------
Now I want to update the price of the coffee to 6.0 with XQJ, so I got the following code:
String driverName = "org.basex.api.xqj.BXQDataSource";
Class<?> driverClass = Class.forName(driverName);
XQDataSource dataSource = (XQDataSource)driverClass.newInstance();
XQConnection xqc = dataSource.getConnection();
String updateString = "declare variable $node := doc('etc/xml/orders.xml')//order[name='coffee']; "+
"replace value of node $node/price with '5.0', " +
"return " +
"put(doc('etc/xml/orders.xml'), 'orders.xml')";
XQExpression xqu = xqc.createExpression();
xqu.executeQuery(updateString);
xqu.close();
unfortunately, it throws an exception. I tried many different ways and fails all the time. could any tell me the right "updateString"?
thanks a lot.
--
Xia Qu
Technology Center of Software Engineering,
Institute of Software,
Chinese Academy of Sciences
Beijing, 100190, China
Email (work):
quxia08@otcaix.iscas.ac.cnEmail (personal):
tsuxia@gmail.com
Mobile:(86) 1300-1010-069