xquery-update

Insert element into XML using XQuery and Java

馋奶兔 提交于 2020-01-05 10:40:06
问题 I need to insert a new element into an XML document using XQuery insert expression. I am using saxon as a java api. I am new to XQuery so I am not sure about the exact structure of the insert expression. Can anyone help me in this please. My XML file looks like the following: <?xml version="1.0" encoding="ISO-8859-1"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup<description> <calories

Insert element into XML using XQuery and Java

蹲街弑〆低调 提交于 2020-01-05 10:39:23
问题 I need to insert a new element into an XML document using XQuery insert expression. I am using saxon as a java api. I am new to XQuery so I am not sure about the exact structure of the insert expression. Can anyone help me in this please. My XML file looks like the following: <?xml version="1.0" encoding="ISO-8859-1"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup<description> <calories

Insertion of an data in an XML using Basex

我的梦境 提交于 2020-01-02 03:40:08
问题 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

How to return results together with update operations in BaseX?

血红的双手。 提交于 2019-12-20 03:52:07
问题 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")? 回答1: XQuery Update statements do not return anything -- that's how they are defined. But you're not the only one who does

Can I make XQuery evaluate { $expression } within variables bound with XQJ?

主宰稳场 提交于 2019-12-13 02:19:20
问题 To mimic an auto-increment value in XQuery Update, the following works fine, assuming <root count="0"/> when running this for the first time: let $count := /root/@count return ( insert node <node id='{ $count }'/> into /root, replace value of node $count with $count + 1 ) ...nicely yielding: <root count="1"> <node id="0"> </root> However, I'd like to define the node in my Java code, and then bind that as an org.w3c.dom.Node or Document , or even String . Like: String expr = " declare variable

No updating expression allowed Basex

六月ゝ 毕业季﹏ 提交于 2019-12-11 14:31:07
问题 I am using BaseX version 8.6.6 i am getting the error while updating database expression must all be updating or return empty sequence below is the code: declare %private %updating function local:ingest-job() { let $contentpath := 'D:\2019\bloomsbury-ingest-content\TEI.zip' let $archive := file:read-binary($contentpath) for $entry in archive:entries($archive)[fn:ends-with(., '.xml')] let $rootNode := fn:name(fn:parse-xml(archive:extract-text($archive, $entry))/*) return let $docId := fn:parse

How to convert text inside a node into child node using xquery update?

孤街醉人 提交于 2019-12-10 15:46:49
问题 I have a xml document like <root> <first> First Level <second> second level <third> Third Level </third> </second> <second2> another second level </second2> </first> </root> How to convert this document with all nodes, that means if a node contains text and child node convert text into a child node (let's say childtext ) using xquery-update <root> <first> <childtext>First Level</childtext> <second> <childtext>second level</childtext> <third> Third Level </third> </second> <second2> another

Auto increment with XQuery Update?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 01:24:20
问题 Does XQuery Update support auto increment attributes, just like auto increment fields in SQL ? I'm using BaseX as my database. 回答1: 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