HI,

It did work with both round method and initialing the array with elements.
Here is the working code. An interesting observation was, it only worked
after we started using the XPath version 2.0 as the query language for
assignments.


<bpel:assign validate="no" name="Assign">
<bpel:copy>
 <bpel:from>
<bpel:literal xml:space="preserve"><tns:ArrayBPELProcessResponse
 xmlns:tns="http://www.arraybpel.process"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
</tns:ArrayBPELProcessResponse></bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="output"></bpel:to>
 </bpel:copy>
<bpel:copy>
<bpel:from>
 <bpel:literal xml:space="preserve"><tns:ArrayBPELProcessResponse
xmlns:tns="http://www.arraybpel.process"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";>
<tns:result>value</tns:result>
</tns:ArrayBPELProcessResponse></bpel:literal>
</bpel:from>
<bpel:to part="payload" variable="tempVar"></bpel:to>
 </bpel:copy>
</bpel:assign>
<bpel:forEach parallel="no" counterName="Counter" name="ForEach">
 <bpel:startCounterValue>
                <![CDATA[1]]>
</bpel:startCounterValue>

<bpel:finalCounterValue><![CDATA[count($input.payload/tns:input)]]></bpel:finalCounterValue>
            <bpel:completionCondition></bpel:completionCondition>
            <bpel:scope>
<bpel:sequence>
<!-- <assign> <copy> <from>ode:insert-as-first-into($output,
$tempVar)</from>
 <to variable="output"/> </copy> </assign> -->
 <bpel:assign validate="no" name="Assign1">
<bpel:copy>
 <bpel:from><![CDATA[ode:insert-as-last-into($output.payload,
$tempVar.payload/tns:result)]]>
</bpel:from>
 <bpel:to part="payload" variable="output" />
</bpel:copy>
 <bpel:copy>
<bpel:from part="payload" variable="input">
 <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
                                    <![CDATA[tns:input[round($Counter)] ]]>
 </bpel:query>
</bpel:from>
<bpel:to part="payload" variable="output">
 <bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
                                    <![CDATA[tns:result[round($Counter)] ]]>
 </bpel:query>
</bpel:to>
</bpel:copy>
 </bpel:assign>
</bpel:sequence>
</bpel:scope>
 </bpel:forEach>

Thanks,
 - Chethiya


On Tue, Feb 28, 2012 at 12:41 PM, Denis Weerasiri <de...@wso2.com> wrote:

>
>
> On Tue, Feb 28, 2012 at 12:36 PM, Chethiya Abeysinghe 
> <cheth...@wso2.com>wrote:
>
>> Hi Waruna,
>>
>> I tried round($Counter) with no luck. When it's used with the round, it
>> logs a selection error even for a single element in the array which was not
>> the case in above code. It works for a single element.
>>
>> Isn't it the problem is not initializing the result array with the number
>> of elements in the input array?
>>
> +1, this will be useful to insert new elements
> http://ode.apache.org/xpath-extensions.html
>
>>
>> Thanks,
>>  - Chethiya
>>
>>
>> On Tue, Feb 28, 2012 at 12:22 PM, Waruna Ranasinghe <war...@wso2.com>wrote:
>>
>>> On Tue, Feb 28, 2012 at 12:01 PM, Chethiya Abeysinghe <cheth...@wso2.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > I'm trying to assign an array to another array in a BPEL process.
>>> Following
>>> > is the bpel code for that:
>>> >
>>> >  <bpel:forEach parallel="no" counterName="Counter" name="ForEach">
>>> >
>>> <bpel:startCounterValue><![CDATA[1]]></bpel:startCounterValue>
>>> >
>>> <bpel:finalCounterValue><![CDATA[count($input.payload/tns:arr)
>>> > ]]></bpel:finalCounterValue>
>>> >             <bpel:completionCondition></bpel:completionCondition>
>>> >             <bpel:scope>
>>> >                 <bpel:assign validate="no" name="Assign">
>>> >
>>> >                     <bpel:copy>
>>> >                         <bpel:from>
>>> >                             <bpel:literal
>>> > xml:space="preserve"><tns:ArrayBPELProcessResponse
>>> > xmlns:tns="http://www.arraybpel.process";
>>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>>> > <tns:result></tns:result>
>>> > </tns:ArrayBPELProcessResponse></bpel:literal>
>>> >                         </bpel:from>
>>> >                         <bpel:to variable="output"
>>> part="payload"></bpel:to>
>>> >                     </bpel:copy>
>>> >                     <bpel:copy>
>>> >                         <bpel:from part="payload" variable="input">
>>> >                             <bpel:query
>>> >
>>> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:arr[$Counter]]]></bpel:query>
>>> IIRC there is an issue when evaluating the $Counter variable. Can you
>>> try using tns:arr[round($Counter)]
>>>
>>> Thanks,
>>> Waruna
>>> >                         </bpel:from>
>>> >                         <bpel:to part="payload" variable="output">
>>> >                             <bpel:query
>>> >
>>> queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"><![CDATA[tns:result[$Counter]]]></bpel:query>
>>> >                         </bpel:to>
>>> >                     </bpel:copy>
>>> >                 </bpel:assign>
>>> >             </bpel:scope>
>>> >         </bpel:forEach>
>>> >
>>> >
>>> > When I try to send multiple elements in the array it gives an error
>>> though
>>> > it works for an array with a single element.
>>> >
>>> > SOAP message is:
>>> >
>>> > <body>
>>> >    <p:ArrayBPELProcessRequest xmlns:p="http://www.arraybpel.process";>
>>> >       <!--0 or more occurrences-->
>>> >       <arr xmlns="http://www.arraybpel.process";>value1</arr>
>>> >       <arr xmlns="http://www.arraybpel.process";>value2</arr>
>>> >    </p:ArrayBPELProcessRequest>
>>> > </body>
>>> >
>>> > And the error log is:
>>> >
>>> > [2012-02-28 11:45:12,148]  INFO - ASSIGN - Assignment Fault:
>>> > {http://docs.oasis-
>>> >
>>> open.org/wsbpel/2.0/process/executable}selectionFailure,lineNo=73,faultExplanati<http://open.org/wsbpel/2.0/process/executable%7DselectionFailure,lineNo=73,faultExplanati>
>>> > on={
>>> http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
>>> :
>>> > M
>>> > ultiple results for expression: 'tns:arr[$Counter]' against '<?xml
>>> > version="1.0"
>>> >  encoding="UTF-8"?>
>>> > <ArrayBPELProcessRequest xmlns="http://www.arraybpel.process";
>>> > xmlns:p="http://ww
>>> > w.arraybpel.process" xmlns:s="
>>> http://schemas.xmlsoap.org/soap/envelope/";
>>> > xmlns:w
>>> > sa="http://www.w3.org/2005/08/addressing";><arr
>>> > xmlns="http://www.arraybpel.proce
>>> > ss">value1</arr><arr
>>> > xmlns="http://www.arraybpel.process";>value2</arr></ArrayBPE
>>> > LProcessRequest>'
>>> > [2012-02-28 11:45:12,168]  WARN - BpelProcess - Instance 270 of
>>> > {http://www.arra
>>> > ybpel.process}ArrayBPELProcess-9 has completed with fault: FaultData:
>>> > [faultName
>>> > ={
>>> http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure
>>> ,
>>> > fau
>>> > lType=null
>>> > ({http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionF
>>> > ailure: Multiple results for expression: 'tns:arr[$Counter]' against
>>> '<?xml
>>> > vers
>>> > ion="1.0" encoding="UTF-8"?>
>>> > <ArrayBPELProcessRequest xmlns="http://www.arraybpel.process";
>>> > xmlns:p="http://ww
>>> > w.arraybpel.process" xmlns:s="
>>> http://schemas.xmlsoap.org/soap/envelope/";
>>> > xmlns:w
>>> > sa="http://www.w3.org/2005/08/addressing";><arr
>>> > xmlns="http://www.arraybpel.proce
>>> > ss">value1</arr><arr
>>> > xmlns="http://www.arraybpel.process";>value2</arr></ArrayBPE
>>> > LProcessRequest>')] @73
>>> >
>>> >
>>> > Could someone please comment what's going wrong in this?
>>> >
>>> > Thanks,
>>> >  - Chethiya
>>> >
>>> > _______________________________________________
>>> > Carbon-dev mailing list
>>> > Carbon-dev@wso2.org
>>> > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>> >
>>>
>>>
>>>
>>> --
>>> -------------------------------------------------------------------------
>>> Waruna Ranasinghe
>>> Senior Software Engineer, WSO2
>>>
>>> Mobile: +94 724 318285
>>> BLOG: http://warunapw.blogspot.com
>>>
>>> www.wso2.com - "Lean . Enterprise . Middleware"
>>> _______________________________________________
>>> Carbon-dev mailing list
>>> Carbon-dev@wso2.org
>>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>>
>>
>>
>>
>> --
>> Chethiya Abeysinghe
>> Software Engineer; WSO2, Inc.;  http://wso2.com/
>> email: cheth...@wso2.com     phone: +94 777334874
>> blog: chethiya3000.blogspot.com
>>
>>
>>
>> _______________________________________________
>> Carbon-dev mailing list
>> Carbon-dev@wso2.org
>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>
>>
>
>
> --
> Thanks,
> Denis
> ----------------------------------------------------------
> *Denis Weerasiri*
> Software Engineer
> Integration Technologies Team, WSO2 Inc.; http://wso2.com,
> *email: denis <http://goog_277208233/>** [AT] wso2.com <http://wso2.com/>*
> *phone: +94117639629
> *
> *site: 
> **https://sites.google.com/site/ddweerasiri/*<https://sites.google.com/site/ddweerasiri/>
> *blog: **http://ddweerasiri.blogspot.com*<http://ddweerasiri.blogspot.com/>
> *
> twitter: **http://twitter.com/ddweerasiri*<http://twitter.com/ddweerasiri>
> *
> linked-in: 
> **http://lk.linkedin.com/in/ddweerasiri*<http://lk.linkedin.com/in/ddweerasiri>
>
>
> _______________________________________________
> Carbon-dev mailing list
> Carbon-dev@wso2.org
> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>
>


-- 
Chethiya Abeysinghe
Software Engineer; WSO2, Inc.;  http://wso2.com/
email: cheth...@wso2.com     phone: +94 777334874
blog: chethiya3000.blogspot.com
_______________________________________________
Carbon-dev mailing list
Carbon-dev@wso2.org
http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to