How to insert a Node??

Hi,

I have read some documents about updating a node, but haven’t seen anything related to inserting a node. Somewhere it says that this feature is not yet supported and will be supported after Tamino v4. I wonder if it is possible to insert a node at a specific location with Java APIs. If possible can you provide me with a sample code.

Thanks.
P.S: I am using Tamino 4.4.1.

There is no such method available in Tamino Java API which will add a node at a particular location. But by using XQuery with Tamino Java API you can insert a node at desired location in the document.

I hope this helps, if you need more information please let me know.

I saw an example about inserting a node with XQuery here, but it did not work for me. Is it possible for you to show me a detailed example?

Thanks.

For inserting a node using XQuery, please refer to the Tamino Documentation available with every Tamino Installation.

The documentation for XQuery node insert can be normally, found at
C:\Program Files\Software AG\Tamino\Tamino 4.4.1.1\Documentation\en\xquery\xq-update.htm

Please revert back if you need more information on the same.

Thanks & Regards,
Srinu.

Here’s an example of a query that inserts a node:

declare namespace x="http://example.com/ns/x"
declare namespace xs="http://www.w3.org/2001/XMLSchema"

update for $mydoc in input()/x:mydoc
where $mydoc/@date = xs:date("2006-04-17")
do insert <x:comment>This node added to existing document</x:comment>
  preceding $mydoc/x:first-child