[jboss-jira] [JBoss JIRA] Commented: (BPEL-272) allow xpath expression/query to create more than one occurrence of an element
Alejandro Guizar (JIRA)
jira-events at lists.jboss.org
Wed Aug 8 17:17:49 EDT 2007
[ http://jira.jboss.com/jira/browse/BPEL-272?page=comments#action_12371547 ]
Alejandro Guizar commented on BPEL-272:
---------------------------------------
Thanks for the reference. However, as far as I can see, the extension function has no advantages over the "last plus one" predicate. Both compromise the portability of the process definition.
On the other hand, the extension function has one clear disadvantage. Consider the signature:
addChildNode(Element e, Node childNode)
To implement it, the element e must be cloned, the childNode appended to the clone, and the whole thing copied to the destination. In consequence, the function above has time and space requirements proportional to the size of the array. The "last plus one" predicate, while somewhat dirty, has constant performance.
An alternate,cleaner approach is to leverage the <bpel2:extensionAssignOperation> construct. Apart from the standard <bpel2:copy> we could offer a <jbpm:append> operation to perform this exact manipulation without abusing XPath syntax or introducing a function of linear performance.
Unfortunately there is no <extensionAssignOperation> construct in BPEL 1.1, which is what prevented me from proposing this approach in the first place. There is a workaround, though: <jbpm:append> elements can appear directly under the <bpel11:assign> element.
> allow xpath expression/query to create more than one occurrence of an element
> -----------------------------------------------------------------------------
>
> Key: BPEL-272
> URL: http://jira.jboss.com/jira/browse/BPEL-272
> Project: JBoss jBPM BPEL
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Components: Engine
> Affects Versions: jBPM BPEL 1.1 beta 3
> Reporter: Alejandro Guizar
> Assigned To: Alejandro Guizar
> Priority: Critical
> Fix For: jBPM BPEL 1.1 GA
>
>
> PROBLEM The current XPath sublanguage implementation automatically creates nodes missing from location paths during assignment. This facility has a number of conceptual limitations. One of them is the inability to append a child element to an existing element if the latter already has a child element with the same name. There is no XPath syntax to express that a new element is required!
> It is tempting to think of a numeric XPath predicate as an array index, leading to the next snippet:
> <copy>
> <from><literal>haha</literal></from>
> <to variable='laughter' xmlns:ex='http://jbpm.org/bpel/examples'>
> <query>ex:laugh[last() + 1]</query>
> </to>
> </copy>
> However, such an interpretation of a predicate is wrong. Consider the following extract from XPath 1.0 specification on predicates:
> "A PredicateExpr is evaluated by evaluating the Expr and converting the result to a boolean. If the result is a number, the result will be converted to true if the number is equal to the context position and will be converted to false otherwise."
> The description of the last() function reads:
> "The last function returns a number equal to the context size from the expression evaluation context."
> Noticed the problem? The context position is never greater than the context size. Therefore the predicate [last() + 1] does not represent the position "one past the context size" but the boolean value false. Unfortunately, no other predicate seems appropriate.
> PROPOSAL Introduce a minor deviation from the XPath 1.0 specification. Interpret the result of a numeric predicate that equals the context size plus one as a request to create a new occurrence of the node.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list