XQueryUpdateOperation document update in for loop

Post here questions and problems related to oXygen frameworks/document types.
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

XQueryUpdateOperation document update in for loop

Post by steve.cuzner »

I've got a custom action that implements XQueryUpdateOperation. The associated script is something like:

Code: Select all

for $node in  ( //*:section )
let $new_att_node := mwclib:augment($node)
return
insert node $new_att_node into $node
The problem is that the function mwclib:augment() depends on evaluating the entire document so after the first iteration the section element is modified to have the new attribute and on the second iteration the function needs to know about the data inserted in iteration one, but that doesn't seem to be happening. Is there a way to signal a document update between iterations?
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: XQueryUpdateOperation document update in for loop

Post by Radu »

Hi Steve,

I would suggest you ask this question on an XSLT users list or on the Saxon users list.
From what I suspect both XQuery and XSLT are side-effect free, not sure about XQuery update but it should also be side effect free, the original model on which the iteration is done is not the same with the changed nodes model which will be eventually be saved.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

Re: XQueryUpdateOperation document update in for loop

Post by steve.cuzner »

Radu,

You are correct about the side effect free implementation. You might want to consider this proposed extension for use in XQueryUpdateOperation as a possible enhancement:

http://www.cs.stanford.edu/people/chris ... ryBang.pdf

Steve
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: XQueryUpdateOperation document update in for loop

Post by Radu »

Hi Steve,

The XQueryUpdate operation uses the Saxon 9 XSLT processor engine so we do not control its implementation. Se if you want you can request this on the Saxon mailing list. In the meantime you can probably also use a Javascript operation which iterates directly over the AuthorNode implementations and uses the AuthorDocumentController to directly change the nodes.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply