XPath Update Facility
---------------------

                 Key: ODE-367
                 URL: https://issues.apache.org/jira/browse/ODE-367
             Project: ODE
          Issue Type: New Feature
          Components: BPEL Runtime
    Affects Versions: 1.2
         Environment: Platform-Independent
            Reporter: Karthick Sankarachary
             Fix For: 1.3


This is a description of a facility to make changes to instances of the XPath 
2.0 data model. This will come in handy in these types of scenarios: modifying 
XML messages, adding to existing XML documents, creating edited copies, etc. In 
particular, it will allow you to perform any or all of the following operations 
on an XDM instance:

* Insertion of a node
* Deletion of a node
* Renaming a node

The building blocks of our update facility are XPath functions, all of which 
take a context node, a copy of which is modified in some way and in turn 
returned. Below, we describe the update syntax in terms of XPath extension 
functions, and its semantics in terms of XQuery Update expressions. We wrote 
our (non-updating) functions along the lines of corresponding (updating) XQuery 
Update expressions, in such a way that the two are interchangeable (i.e., once 
we add support for the xquery expression language.) Note that, by default, 
XQuery Update modifies nodes in-place, whereas our XPath functions modify a 
copy.

Use Case: Insert Siblings Before Children Of Context Node
Description: A function to insert the node(s) specified by $siblings before the 
first node specified by $children, all of whose nodes must have $context as 
parent.
Signature: 
    ode:insert-before($context as node(), $children as node()*, $siblings as 
node()*) as node()
Example: 
    <assign>
      <copy>
        <from>ode:insert-before($parent, 
$parent/child::node[position()=last()], $siblings)</from>
         <to variable="parent"/>
      </copy>
    </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    insert nodes $siblings before $parent/child::node[position()=last()]

Use Case: Insert Siblings After Children Of Context Node
Description: A function to insert the node(s) specified by $siblings after the 
last node specified by $children, all of whose nodes must have $context as 
parent.
Signature: 
    ode:insert-after($context as node(), $children as node()*, $siblings as 
node()*) as node()
Example: 
    <assign>
      <copy>
        <from>ode:insert-after($parent, $parent/child::node(), $siblings)</from>
         <to variable="parent"/>
      </copy>
    </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    insert nodes $siblings after $parent/child::node()

Use Case: Insert As First Children Of Context Node
Description: A function to insert the node(s) specified by $children as the 
first child(ren) of $context.
Signature: 
    ode:insert-as-first-into($context as node(), $children as node()*) as node()
Example: 
    <assign>
      <copy>
        <from>ode:insert-as-first-into($parent, $children)</from>
        <to variable="parent"/>
      </copy>
    </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    insert nodes $children as first into $parent

Use Case: Insert As Last Children Of Context Node
Description: A function to insert the node(s) specified by $children as the 
last child(ren) of $context.
Signature: 
    ode:insert-as-last-into($context as node(), $children as node()*) as node()
Example: 
    <assign>
      <copy>
        <from>ode:insert-as-last-into($parent, $children)</from>
        <to variable="parent"/>
      </copy>
     </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    insert nodes $children as last into $parent

Use Case: Delete Children From Context Node
Description: A function to delete the node(s) specified by $children from its 
parent specified by $context.
Signature: 
    ode:delete($context as node(), $children as node()*) as node()
Example: 
    <assign>
      <copy>
        <from>ode:delete($parent, $children)</from>
        <to variable="parent"/>
      </copy>
    </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    delete nodes $children

Use Case: Rename Context Node:
Description: A function to rename the context node specified by $context as per 
the name specified by $item, which is either a QName, Element or String.
Signature: 
    ode:rename($context as node(), $name as item()) as node()
Example: 
    <assign>
      <copy>
        <from>ode:rename($person, fn:QName("http://www.example.com/example";, 
"manager"))</from>
        <to variable="person"/>
      </copy>
    </assign>
Semantic: The above snippet is equivalent to the XQuery expression: 
    rename $person as fn:QName("http://www.example.com/example";, "manager")

Unlike XQuery Update, we designed our functions to be non-updating in that they 
preserve the identity and properties of its arguments (i.e., they don't try to 
change the XML in-place). Instead, a modified copy of the context node is 
created, essentially giving it a new identity. Further, all of our functions 
return a single R-value item, as opposed to a sequence. This allows us to not 
only honor WS-BPEL's static analysis requirements, but also be friendly to the 
copy operation of WS-BPEL's assign activity. In particular, it ensures that:
(a) Our functions are safe to use in the from-spec of the copy operation (no 
in-place updates must occur here.)
(b) The burden of modifying XML messages remains with the copy operation (all 
updates are reflected only here.)
(c) The node replacement semantics of the copy operation is not impacted (the 
entire target node is replaced.)
(d) The modified copy of the context node can be moved to a new location 
(target need not be the context node.)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to