Class XQueryUpdateOperation

  • All Implemented Interfaces:
    AuthorOperation, Extension

    @API(type=INTERNAL,
         src=PUBLIC)
    public class XQueryUpdateOperation
    extends java.lang.Object
    implements AuthorOperation
    An implementation of an operation that applies an XQuery Update script. The changes are performed directly over the Author nodes model. The script will be executed in the context of the caret node. If the XQuery script declares the selection variable (see the following code snippet), it will also receive the selected nodes (assuming that the selection consists entirely of nodes). THe following code snippet converts the selected paragraphs in a list.
     declare namespace oxyxq = "http://www.oxygenxml.com/ns/xqu";
    (: This variable will be linked to the selected nodes assuming that there are 
    actually fully selected nodes. For example this selection will return null: 
    

    {SEL_START}text{SEL_END} in para

    but this will give two "p" elements: {SEL_END}

    text

    text2

    {SEL_END} If a multiple selection exists it will also be processed and forwarded. Again, only fully selected nodes will be passed. :) declare variable $oxyxq:selection external; (: We will process either the selection or the context node :) let $toProcess := if (empty($oxyxq:selection)) then (.) else ($oxyxq:selection) return if (not(empty($toProcess))) then ( (: Create the list :) let $ul := <ul> { for $sel in $toProcess return <li>{$sel}</li> } </ul> return ( (: Delete the processed nodes :) for $sel in $toProcess return delete node $sel, (: Inserts the constructed list :) insert node $ul before $toProcess[1] ) ) else ()