Page Created :
ODExSITE :
copy with insert attribute
copy with insert attribute has been created by Alex Boisvert (Jun 07, 2007). Content:<bpel:copy> with insert attribute
Consider a simple use case. A BPEL process collects quotes from a number of suppliers, to determine which one provides the best price, before submitting an order to that supplier. Typically this will be done using the <bpel:foreach> activity, collecting information from each quote into a variable, and later on extracting a specific node from that variable, e.g. using XPath predicate to select the supplier with the lowest price. BPEL does not support array variables, but we can use XML structures as collections. However, updating a collection to add a new element requires either using a different assignment mechanism ( e.g. XUpdate, not on the roadmap), or performing a copy-append-replace transformation, using XPath 2.0 or XSLT. But the later approach is complicated, obfuscated and fragile. Instead, we're opting for a simpler mechanism that allows BPEL assignments to both replace and insert content. We introduce an insert attribute on the <bpel:copy> element. If the attribute is absent, the assignment performs a replacement, as per the BPEL 2.0 specification. Syntax: <bpel:assign> <bpel:copy insert="..."?> <bpel:from> ... </bpel:from> <bpel:to> ... </bpel:to> </bpel:copy> </bpel:assign>
For first and last, <bpel:to> must return an EII or throw a selectionFailure. For before and after, <bpel:to> must return an EII or TII or throw a selectionFailure. In all four cases, <bpel:from> must select some value or a node, or throw a selectionFailure. Example: LastLet $foo be a complex element with value <foo> <bar1/> <bar2/> </foo> Performing this assignment, <bpel:copy insert="last"> <bpel:from> <bpel:literal> <bar3/> </bpel:literal> </bpel:from> <bpel:to> $foo </bpel:to> </bpel:copy> results in $foo <foo> <bar1/> <bar2/> <bar3/> <!-- INSERTED --> </foo> Example: FirstContinuing with the previous value of $foo, <bpel:copy insert="first"> <bpel:from> <bpel:literal> <bar0/> </bpel:literal> </bpel:from> <bpel:to> $foo </bpel:to> </bpel:copy> results in $foo <foo> <bar0/> <!-- INSERTED --> <bar1/> <bar2/> <bar3/> </foo> Example: BeforeContinuing with the previous value of $foo, <bpel:copy insert="before"> <bpel:from> <bpel:literal> <baz/> </bpel:literal> </bpel:from> <bpel:to> $foo/bar1 </bpel:to> <!-- Insert before "bar1" --> </bpel:copy> results in $foo <foo> <bar0/> <baz/> <!-- INSERTED --> <bar1/> <bar2/> <bar3/> </foo> Example: AfterContinuing with the previous value of $foo, <bpel:copy insert="before"> <bpel:from> <bpel:literal> <bam/> </bpel:literal> </bpel:from> <bpel:to> $foo/bar2 </bpel:to> <!-- Insert after "bar2" --> </bpel:copy> results in $foo <foo> <bar0/> <baz/> <bar1/> <bar2/> <bam/> <!-- INSERTED --> <bar3/> </foo> |
Unsubscribe or edit your notifications preferences