Hi Johnathan,
I have a patch that could potentially resolve your issue. If you don't mind,
can you apply the attached patch and let me know how it goes?
Regards,
Karthick
On 4/16/09, Karthick Sankarachary <[email protected]> wrote:
>
> Hi Johnathan,
>
> This sounds like a bug to me. I'll take a look see at that function when I
> get a chance.
>
> Regards,
> Karthick
>
> On 4/16/09, Jonathan Coogan <[email protected]> wrote:
>>
>> Hi. I have a question about the "insert-as-first-into" and
>> "insert-as-last-into" Xpath extensions.
>>
>> I get a selectionFailure if I try to insert a child into a parent that
>> does not yet contain other children. I'm wondering if this was done on
>> purpose for some reason, or if this is a bug.
>>
>> As an example, say I have the following elements/types:
>>
>> <element name="RecordSet" type="tns:RecordSetType"/>
>> <complexType name="RecordSetType">
>> <sequence>
>> <element maxOccurs="unbounded" minOccurs="0"
>> ref="tns:Record"/>
>> </sequence>
>> </complexType>
>>
>> <element name="Record" type="tns:RecordType"/>
>> <complexType name="RecordType">
>> <sequence>
>> <element maxOccurs="1" minOccurs="1" name="SomeValue"
>> type="string"/>
>> <element maxOccurs="1" minOccurs="1" name="AnotherValue"
>> type="string"/>
>> </sequence>
>> </complexType>
>>
>> So RecordSet can contain 0 or more Records. If I try to insert a Record
>> into an empty RecordSet (0 Records) I get a selectionFailure. I have to
>> initialize the RecordSet variable with at least one dummy Record before
>> it will work.
>>
>> Comments?
>>
>> Thanks.
>> -Jon
>>
>
--
Best Regards,
Karthick Sankarachary
Index: bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
===================================================================
--- bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java (revision 764942)
+++ bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java (working copy)
@@ -793,7 +793,12 @@
Node refChild = clonedElmt.getFirstChild();
Document clonedDocument = clonedElmt.getOwnerDocument();
for (int i = 0; i < siblingNodes.size(); i++) {
- clonedElmt.insertBefore(clonedDocument.importNode((Node) siblingNodes.get(i), true), refChild);
+ Node newChild = clonedDocument.importNode((Node) siblingNodes.get(i), true);
+ if (refChild != null) {
+ clonedElmt.insertBefore(newChild, refChild);
+ } else {
+ clonedElmt.appendChild(newChild);
+ }
}
return clonedElmt;
}