Q:Does update insert work as designed?

I do have a question about XQuery update insert. Does it work as designed? That is when I try to insert a node after a sibbling then the insertion fails (i.e. nothing happens) if the reference node is missing.

This is really horrible if you do have a document with a lot of optional nodes.

I was hoping that “update insert” would act more intelligently than its W3C DOM counterpart (which is a real nightmare. I’m glad that an object can be (de)serialized to/from XML using XmlSerialize, like its JAXB counterpart).

Kind regards,
Rudolf de Grijs

Personally I find xquery update insert unworkable. At the moment I’m working at the Customer’s site with Tamino API for .NET.

Here we work with complex data with a lot of optional nodes and choices.

Now I was hoping that xquery update would do a wonderfull job but I find myself writing a lot of unneccessary complex code just in order to determine which ancestor sibbling is present. Who sets the standard for xquery update? Ever thought about it to really use it in the field?

Now I have chosen to abondon xquery update in favor of the _process command.

The recipy is:
Deserialize (or is it dehydrate?) the result into an object presentation (take Tamino schema and generate an object using xsd.exe), modify the object and _process the result (). Real simple and very efficient.

A pitfall to watch out for: do not duplicate elements inline, but define these on the global level. xsd has some trouble with these kind of schema’s.

) I find it a shame that I have to turn the serialized data into XmlDocument for the purpose to store it in the database (via TaminoDocument wrapper). Can’t you support more types of input sources, like Stream and XmlReader.

I do hope that xquery update insert will become more user friendly in the (near) future…

Kind regards,
Rudolf de Grijs

If you are working with .NET XML Serialization similar implementations to the one described in the “Processing Node List” chapter of the user documentations might also be an option.

See also the samples source code QuerySamples\ProcessNodeList*.

I haven’t fully understood what your problems with XQuery update are. Do you have an example query with which you have problems?

Best Regards,

If I want to insert into the following document

and if we assume that all elements from elm1 until elm10 are optional, then I must determine which element I have to use as context element in order to insert . The following xquery update will fail

update insert following input()/doc[@code=“3”]/elm4

since is missing.

as will

update insert into input()/doc[@code=“3”]

since it will append elm5 after elm10

as will

update insert preceding input()/doc[@code=“3”]/elm6

since is missing.

So in order to insert elm5 if have to determine which existing element precedes (or follows) element 5. That is not what I call user friendly. And this can only be done by retrieving the document!


BTW only in the case of update insert … into I receive the following (correct) error message

<ino:messagetext ino:code=“INOXDE7730”>(cvc-model-group.1):invalid end of sequence</ino:messagetext>

In the other described scenario’s I don’t see a thing!


I would suspect that this isn’t really a problem with XQuery but a problem with the document schema? Having so many optional elements one after the other is going to make it hard for updates to be specified.

You might want to try the W3C XQuery Tamino forum.

Hi all,

Even i am facing the same problem in inserting a node. But the documentation (Performing Update Operations) says that the insert operation will insert the node in the order that is prescribed by the schema, which is not happening :confused:

Error thrown is :invalid end of sequence.

Could any one pls help me in this regard.


The following information would be quite helpful in looking at the problem:

Tamino version
schema + a little relevant data
XQuery operation attempted