I've just committed test case demonstrating usage.

http://svn.apache.org/repos/asf/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel

It looks like this (it works also with "tab type="xsd:anyType" ") :

commit b3a8521446f8385e3da197e3a3d3e2507f8c43cd
Author: Rafał Rusin <[email protected]>
Date:   Thu May 20 22:20:30 2010 -0700

    Table example

diff --git
a/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
b/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
index a61d30b..79c290a 100644
---
a/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
+++
b/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
@@ -41,6 +41,8 @@

     <variables>
         <variable name="myVar" messageType="test:HelloXQueryMessage"/>
+        <variable name="tab" element="xsd:any"/>
+        <variable name="tabel" type="xsd:string"/>
         <variable name="otherVar" type="xsd:string"/>
         <variable name="tempVar" element="test:content"/>
         <variable name="stringVar" type="xsd:string"/>
@@ -64,6 +66,22 @@
             operation="HelloXQuery"
             variable="myVar"
             createInstance="yes"/>
+
+        <bpws:assign>
+          <copy>
+
<from><literal><tns:tab><tns:a>1</tns:a><tns:a>2</tns:a></tns:tab></literal></from>
+            <to variable="tab"/>
+          </copy>
+          <copy>
+            <from>$tab/tns:a[2]</from>
+            <to variable="tabel"/>
+          </copy>
+        </bpws:assign>
+
+        <if>
+            <condition>$tabel != '2'</condition>
+            <throw faultName="error"/>
+        </if>

         <bpws:assign>
           <copy>
~


On 16 May 2010 08:18, Nowakowski, Mateusz <
[email protected]> wrote:
> Unfortunately it doesn't work.
>
> I've looked at the ASSIGN class and it is impossible to assign to a
> variable a sequence longer than 1:
>
> ASSIGN.java
> private Node evalRValue(OAssign.RValue from) throws FaultException,
> ExternalVariableModuleException {
> (...)
>
>        } else if (from instanceof OAssign.Expression) {
>            List<Node> l;
>            OExpression expr = ((OAssign.Expression) from).expression;
>            try {
>                l =
> getBpelRuntimeContext().getExpLangRuntime().evaluate(expr,
> getEvaluationContext());
>            } catch (EvaluationException e) {
>                String msg = __msgs.msgEvalException(from.toString(),
> e.getMessage());
>                if (__log.isDebugEnabled()) __log.debug(from + ": " +
> msg);
>                if (e.getCause() instanceof FaultException) throw
> (FaultException)e.getCause();
>                throw new
> FaultException(getOAsssign().getOwner().constants.qnSelectionFailure,
> msg);
>            }
>            if (l.size() == 0) {
>                String msg =
> __msgs.msgRValueNoNodesSelected(expr.toString());
>                if (__log.isDebugEnabled()) __log.debug(from + ": " +
> msg);
>                throw new
> FaultException(getOAsssign().getOwner().constants.qnSelectionFailure,
> msg, new Throwable("ignoreMissingFromData"));
>            } else if (l.size() > 1) {
>                String msg =
> __msgs.msgRValueMultipleNodesSelected(expr.toString());
>                if (__log.isDebugEnabled()) __log.debug(from + ": " +
> msg);
>                throw new
> FaultException(getOAsssign().getOwner().constants.qnSelectionFailure,
> msg);
>            }
>            retVal = (Node) l.get(0);
>        }
> (...)
> }
>
> So I had to solve the problem by using fn:string-join and fn:tokenize.
> If you have any other workaround please let me know
>
> --
> Regards,
> Mateusz Nowakowski
>
>> -----Original Message-----
>> From: David Carver [mailto:[email protected]]
>> Sent: Sunday, May 16, 2010 5:21 AM
>> To: [email protected]
>> Subject: Re: BPEL variable type for sequences of simple type
>>
>> Have you tried an xs:anyType?   If you are using XPath, that should
>> allow you to get Nodes stored into the variable.  You can't store
>> multiple nodes as a String value.
>>
>> http://www.w3.org/TR/xmlschema-0/#anyType
>>
>>
>>
>> On 05/15/2010 03:13 PM, Nowakowski, Mateusz wrote:
>> > Hi,
>> >
>> > What BPEL variable type should I use for a sequence of simple types?
>> >
>> > I have a situation where I'd like to save into variable a result of
>> > XPath $Request.body/xsd1:SomeElement/xsd1:ManyChildren/@Code which
> is
>> a
>> > sequence of several strings.
>> >
>> > When I specify a variable like this:
>> > <bpel:variable name="Codes" type="xs:string"/>
>> >
>> > I've got a selection failure:
>> > 2010-05-15 22:53:03,465 [pool-5-thread-44] DEBUG
>> > org.apache.ode.bpel.elang.xpath20.runtime.XPath20ExpressionRuntime -
>> > Expression {OXPath10Expression
>> > $Request.body/xsd1:SomeElement/xsd1:ManyChildren/@Code} generated
>> result
>> > net.sf.saxon.dom.domnodel...@1f81137 -
>> type=net.sf.saxon.dom.DOMNodeList
>> > 2010-05-15 22:53:03,465 [pool-5-thread-44] DEBUG
>> > org.apache.ode.bpel.elang.xpath20.runtime.XPath20ExpressionRuntime -
>> > Returned node list of size 2
>> > 2010-05-15 22:53:03,465 [pool-5-thread-44] DEBUG
>> > org.apache.ode.bpel.runtime.ASSIGN - {OXPath10Expression
>> > $Request.body/xsd1:SomeElement/xsd1:ManyChildren/@Code}: R-Value
>> > expression "{OXPath10Expression
>> > $Request.body/xsd1:SomeElement/xsd1:ManyChildren/@Code}" returned
>> > multiple nodes.
>> > 2010-05-15 22:53:03,465 [pool-5-thread-44] INFO
>> > org.apache.ode.bpel.runtime.ASSIGN - Assignment Fault:
>> > {http://docs.oasis-
>> open.org/wsbpel/2.0/process/executable}selectionFailu
>> > re,lineNo=1115,faultExplanation=R-Value expression
>> "{OXPath10Expression
>> > $Request.body/xsd1:SomeElement/xsd1:ManyChildren/@Code}" returned
>> > multiple nodes.
>> > 2010-05-15 22:53:03,465 [pool-5-thread-44] DEBUG
>> > org.apache.ode.bpel.runtime.SCOPE - ({OScope
>> > 'scope-implicit-scope-line-856'
>> > id=183},TerminationChannel#28,ParentScopeChannel#30): has a fault
>> > handler for
>> > {http://docs.oasis-
>> open.org/wsbpel/2.0/process/executable}selectionFailu
>> > re: {OCatch faultName=null, faultVariable=null}
>> >
>> >
>> >
>
>

-- 
Regards,
Rafał Rusin
http://rrusin.blogspot.com

Reply via email to