XQueryUpdateOperation document update in for loop

Post here questions and problems related to oXygen frameworks/document types.
steve.cuzner
Posts: 69

XQueryUpdateOperation document update in for loop

Mon Oct 24, 2016 7:10 pm

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: 5376

Re: XQueryUpdateOperation document update in for loop

Tue Oct 25, 2016 9:25 am

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: 69

Re: XQueryUpdateOperation document update in for loop

Tue Oct 25, 2016 4:51 pm

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/chrismre/papers/XQueryBang.pdf

Steve
Radu
Posts: 5376

Re: XQueryUpdateOperation document update in for loop

Wed Oct 26, 2016 7:52 am

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 1 guest