I am trying to create a simple XML database (inside BaseX or Exist-DB), but believe me How to modify values in the document:
The content is simple to test:
& Lt; / Id & gt; & Lt; / Pl & gt; & Lt; / P & gt; I am trying to create something that is & lt; Pl & gt; if the element does not exist or if it exists, but XQuery is causing me problems: When I simultaneously interact with it Try to:
if (exists (/ p / pl [id = 6] / name) = false) then node and lieutenant; Name & gt; Then the name & lt; / Name & gt; I get an error error: [/ p> XUDY0027] Replace the goal should not be empty I am clearly confused, why both sides are evaluated, thus error when I empty any other part: if (exists (/ p / pl [id = 6] / name) = true) then node and lieutenant; Name & gt; The name & lt; / Name & gt; In / p / pl [id = 6] second & lt; Dummy /> Then I get the error: [XUST0001] If the expression: no expression is allowed . When I try to update the function, it also reports the error:
declare name testa = 'test'; Function testa Update announcement: bid ($ a, $ b) {if (exists (/ p / pl [id = 6] / name) = true) then node & lt; Name & gt; The name & lt; / Name & gt; In / p / pl [id = 6] second & lt; Dummy /> }; Testa: bid (0,0) Error: [XUST0001] If expression: No permission to allow an expression is permitted. I have found these errors from the Basic 6.5.1 package.
So it is possible how can I modify values in a simple fashion? If I call directly , , then there can be many elements of the same value. If I call replaced , then it will fail when the node is not present if I delete the nodes before inserting / replacing then I delete the sub-nodes I can not do what I do not want. In most SQL databases, this is a simple task (such as MYSQL ' Replace ' command).
@Qiqi: @eljeendro is correct if your expression is wrong XQuery syntax : if (present (/ p / pl [id = 6] / name)) then node & lt; Name & gt; Insert thenname & lt; / Name & gt; Note that eXist-db's XQuery update functionality There is currently an EXECસ્ટ-specific implementation, therefore, in EXEC (currently) 1.4.x and 1.5dev, you would like:
if (present (/ p / pl [id = 6] / Name)) then insert & lt; Name & gt; The name & lt; / Name & gt; This is the exact document on the XQuery Update syntax, in / p / pl [id = 6] with other updated values / p / pl [id = 6] / name 'ellename' . The development of this syntax had reached its present position before the W3C XQuery Update spec. The Exist team is planning to complain completely with the W3C device soon, but in the meantime, the above documents should help you achieve it if you use XX.
Note that in your example code the typo valid XML version will be inside PL and ID elements:
Comments
Post a Comment