Insert a node with the "following"-expression

Hi all,
due to my schema definition, I have this requirement:

A node called “Application” can have a sequence of the following nodes:
1.) Remark (minOccurs=0 maxOccurs=unbounded)
2.) PersonRole (minOccurs=0 maxOccurs=unbounded)
3.) DFVRef (minOccurs=1 maxOccurs=unbounded)

I tried to insert a new Remark, using this XQuery:
update insert

following input()/DataRoot/Application[@id=12348766]/PersonRole

But Tamino inserts this person after each “PeronRole”-node in “Application”.

Is there any “distinct” exression to tell Tamino to insert the nodes appropriate to the order specified in the schema definition?

I also expect some troubles if no PersonRole or
Remark exists and a new nodes should be inserted in the right order.

Thanks a lot in advance,

Hi Hoscha,

I do not understand completely, you are inserting a PersonRole.
Anyway, if the expression after the ‘following’ keyword evaluates
to a sequence, insertion occurs after every node in this sequence.
If you want to insert after a specific node, say the first, use
an index, i.e.
Use index [last()] to insert after the last node of a specific kind.
No, the schema is only considered afterwards, if some update results
in a non-valid document, it is attempted and the update gets backed
out when trying to write back to the database.
If ‘Application’ has no children, use ‘insert into’.