xquery-update

Auto increment with XQuery Update?

久未见 提交于 2019-12-06 10:03:56
Does XQuery Update support auto increment attributes, just like auto increment fields in SQL ? I'm using BaseX as my database. Arjan Given an answer from Christian Grün on the BaseX mailing list , this is doable when the node one is adding is defined in the XQuery Update statement, and hence can be enhanced using an {enclosed expression} before inserting it: You might specify the attribute counter within your XML file/database and increment it every time when you insert an element. A simple example: input.xml: <root count="0"/> insert.xq: let $root := doc('input.xml')/root let $count := $root/

Insertion of an data in an XML using Basex

安稳与你 提交于 2019-12-05 07:19:10
I am storing two XML documents, namely hospital and office, in BaseX. The following is the office xml: <Staff> <Employee Name="Brian"> <Personal> <SSN> 666-66-6666 </SSN> </Personal> <StaffInfo> <Position> Doctor </Position> <AccountableTo> David </AccountableTo> </StaffInfo> </Employee> <Employee Name="David"> <Personal> <SSN> 555-55-5555 </SSN> </Personal> <StaffInfo> <Position> Doctor </Position> <AccountableTo /> </StaffInfo> </Employee> </Staff> In this XML I want to add one or more employees. How can I add elements using BaseX? XQuery has an update facility, an official W3C

How to return results together with update operations in BaseX?

醉酒当歌 提交于 2019-12-02 00:56:10
I recognized that ( insert / delete )-XQueries executed with the BaseX client always returning an empty string. I find this very confusing or unintuitive. Is there a way to find out if the query was "successful" without querying the database again (and using potentially buggy "transitive" logic like "if I deleted a node, there must be 'oldNodeCount-1' nodes in the XML")? Jens Erat XQuery Update statements do not return anything -- that's how they are defined. But you're not the only one who does not like those restrictions, and BaseX added two ways around this limitation : Returning Results By