Insert element into XML using XQuery and Java -


I have to insert a new element into an XML document using an expression of XQuery. I am using saxon as a Java API. I'm new to XQuery so I'm not sure about the exact structure of the inserted expression. Please help me. Please

My XML file looks like the following:

   & Lt; Food & gt; & Lt; Name & gt; Belgian waffles & lt; / Name & gt; & Lt; Price & gt; $ 5.95 & lt; / Pricing & gt; & Lt; Description & gt; Our famous Belgian Waffles with our original famous maple syrup & lt; Description & gt; & Lt; Calories & gt; 650 & lt; / Calories & gt; & Lt; / Food & gt; & Lt; / Breakfast_menu>   

And I have java code to insert

  enter the public zero () throws XQException {string queryString = // "$ doc declare variable $ As XS: String External; "+ Sep +" variable $ Store: = doc ("+" food.xml "+") / *; " + "Element value {\" brnj \ "}," + "element value {\" $ 20 \ "}," + "element details {\" whatever \ "}," + " "Element calories {300}," + "} in the $ store; "; XQPreparedExpression expr = conn.prepareExpression (queryString); Expr.bindObject (new QN (" store ")," food.xml ", tap); XQResultSequence RS = expr.executeQuery ();}    

Base X XQ The API supports the XQuery Update feature 1.0 and 3.0, which allows you to update the documents in the BaseX database.

You can use the Markagic XQJ API, Sedna XQ API and Even by updating the Exxus API, in-database documents can also be updated, though not through the exaggerated update feature, because this implementation does not support XXF (yet).

Finally and probably For the most important of your questions, you can find Ryan Grim's "In-Memory-Update" Library module very useful [1].

You

  • In a library with a XQuery processor + XQJ Dual you can use
  • update an update is no need to write in-memory XML document (disk).
  • Perform "multiple" update operations against a single document in a single XQuery
  • Posted in in-memory documents can be posted to XQResultSequence (great for you)

    In addition, to clarify something here, XQJ 1.0 Specification does not reject vendors with the support of the XQuery Update feature.

    Excerpt from an Excerpt:

    18.6 Support for Updates and Transactions

    Although the update functionality is not part of [XQuery], XQJ expects Some implementations will include some proprietary extensions to handle updates functionality. "

    [1]

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -