On Thu, Jan 22, 2009 at 8:53 AM, Matthieu Riou <[email protected]> wrote: > On Thu, Jan 22, 2009 at 12:34 AM, ZHAO Wenfeng <[email protected]>wrote: > >> Hello Alexey, >> >> "[number(string($signer))]" :-) >> >> And in your case, it seems this problem doesn't occur in from-spec, >> and only occurs in to-spec, isn't it? >> >> So, there must be a bug here, I think. >> > > The bug is in XPath 1.0 (and somewhat in XPath 2.0 when you don't have a > typed engine). Variables aren't typed even though in some cases some types > are expected. In most cases the engine coerces but coercion doesn't always > work so you often have to use conversion function like number() to be safe.
>From what I understood of the spec, there's one algorithm for converting string to number, that one is exposed by the number() function, and applied whenever type conversion happens. If one conversion fails, so would the other. Assaf > > Matthieu > > >> >> >> Regards. >> Wenfeng >> >> >> ======= 2009-01-22 13:56:07 您在来信中写道:======= >> >> >Hello! >> >I also encountered this bug. This is very strange and unexpected bug. >> >After some debugging time I found a workaround, and I think this worth >> >reporting in JIRA. Here is piece of my process: >> > >> ><?xml version="1.0" encoding="UTF-8"?> >> ><bpws:forEach counterName="signer" name="ForEachSignerUserName" >> > parallel="no"> >> > <bpws:startCounterValue><![CDATA[1]]></bpws:startCounterValue> >> > >> >> ><bpws:finalCounterValue><![CDATA[count($processingData/pdata:signer)]]></bpws:finalCounterValue> >> > <bpws:scope name="CheckSignerRolesScope"> >> > <bpws:sequence name="CheckSignerRoles"> >> > <bpws:assign name="prepareGetSignerDbId" validate="no"> >> > <bpws:copy> >> ><!-- *this works fine!* --> >> > >> >> ><bpws:from><![CDATA[$processingData/pdata:signer[$signer]/@name]]></bpws:from> >> > >> ><bpws:to><![CDATA[$getUsers.parameters/ps:nameFilter]]></bpws:to> >> > </bpws:copy> >> > </bpws:assign> >> > <bpws:assign name="ExtractSignerInfo" validate="no"> >> > <bpws:copy> >> > >> ><bpws:from><![CDATA[$getUserMembershipsResponse.parameters]]></bpws:from> >> ><!-- *this don't work!* --> >> > >> >> ><bpws:to><![CDATA[$processingData/pdata:signer[$signer]/pdata:memberships/*[1]]]></bpws:to> >> > </bpws:copy> >> > </bpws:assign> >> > </bpws:sequence> >> > </bpws:scope> >> ></bpws:forEach> >> > >> >As I said after some tricks, I made it work without temporary variable >> >as Wenfeng mentioned. >> ><?xml version="1.0" encoding="UTF-8"?> >> ><bpws:forEach counterName="signer" name="ForEachSignerUserName" >> > parallel="no"> >> > <bpws:startCounterValue><![CDATA[1]]></bpws:startCounterValue> >> > >> >> ><bpws:finalCounterValue><![CDATA[count($processingData/pdata:signer)]]></bpws:finalCounterValue> >> > <bpws:scope name="CheckSignerRolesScope"> >> > <bpws:sequence name="CheckSignerRoles"> >> > <bpws:assign name="prepareGetSignerDbId" validate="no"> >> > <bpws:copy> >> ><!-- *this works fine!* --> >> > >> >> ><bpws:from><![CDATA[$processingData/pdata:signer[$signer]/@name]]></bpws:from> >> > >> ><bpws:to><![CDATA[$getUsers.parameters/ps:nameFilter]]></bpws:to> >> > </bpws:copy> >> > </bpws:assign> >> > <bpws:assign name="ExtractSignerInfo" validate="no"> >> > <bpws:copy> >> > >> ><bpws:from><![CDATA[$getUserMembershipsResponse.parameters]]></bpws:from> >> ><!-- *this works also* --> >> > >> >> ><bpws:to><![CDATA[$processingData/pdata:signer[number(string($signer))]/pdata:memberships/*[1]]]></bpws:to> >> > </bpws:copy> >> > </bpws:assign> >> > </bpws:sequence> >> > </bpws:scope> >> ></bpws:forEach> >> > >> >Regards, >> >Alexey Ousov >> > >> >> Hi Alex, >> >> >> >> Thanks. But I had checked the issues you mentioned. The problem >> must be in elsewhere. Notice that when I simply replace $i with a normal >> unsignedInt variable $_i1, turning the piece above into: >> >> <forEach counterName="i" parallel="no"> >> >> <startCounterValue>1</startCounterValue> >> >> <finalCounterValue>2</finalCounterValue> >> >> <scope> >> >> <assign> >> >> <copy> >> >> <from variable="i" /> >> >> <to variable="_i1"/> >> >> </copy> >> >> <copy> >> >> <from>$i</from> >> >> <to>$output0.body/xsd0:field1[position()=$_i1]</to> <!-- >> note this line --> >> >> </copy> >> >> </assign> >> >> </scope> >> >> </forEach> >> >> it works fine! >> >> >> >> The attachements is the process files and you can try it. My environment >> is: ODE 2.0 Build #87 (2009-1-8 2:25:04). >> >> >> >> Thanks&Regards. >> >> Wenfeng >> >> >> >> ======= 2009-01-21 23:36:47 您在来信中写道:======= >> >> >> >> >> >>> "No result for expression ... " does not mean "$i does not work in >> XPath >> >>> predicate expression". >> >>> >> >>> http://ode.apache.org/faq.html >> >>> >> >>> *Q.* *My process fails with a selectionFailure; What can I do?* >> >>> *A.* BPEL expects a *single* element to be selected when evaluating >> <to> and >> >>> <from> expressions, and a selectionFailure fault is thrown if zero or >> more >> >>> than one element are selected. >> >>> >> >>> If you get zero element, double-check your namespace prefix and >> bindings. >> >>> Also, remember that you must initialize your variables (most often with >> >>> <literal>'s) before assigning into them, unless your are reassigning >> the >> >>> whole variable (e.g. directly into $variable, or $variable.part). To >> debug >> >>> assignments, you can set the "org.apache.ode" logging category to DEBUG >> in >> >>> order to see the content of variables as the process executes. >> >>> >> >>> >> >>> 2009/1/21 ZHAO Wenfeng <[email protected]> >> >>> >> >>> >> >>>> Hi all, >> >>>> I found another BUG-like problem in ODE 2.0 Build #87 (2009-1-8 >> 2:25:04). >> >>>> That is: the counterName variable can't be used in the position >> expression >> >>>> of XPath as normal variables are. For example, the following BPEL >> piece >> >>>> <forEach counterName="i" parallel="no"> >> >>>> <startCounterValue>1</startCounterValue> >> >>>> <finalCounterValue>2</finalCounterValue> >> >>>> <scope> >> >>>> <assign> >> >>>> <copy> >> >>>> <from>$i</from> >> >>>> >> <to>$output0.body/xsd0:field1[position()=$i]</to> >> >>>> <!-- note this line --> >> >>>> </copy> >> >>>> </assign> >> >>>> </scope> >> >>>> </forEach> >> >>>> will incur such ERROR in ODE: >> >>>> >> >>>> ERROR - GeronimoLog.error(104) | Assignment Fault: { >> >>>> >> http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure,lineNo=149,faultExplanation={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure<http://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure,lineNo=149,faultExplanation=%7Bhttp://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure> >> < >> http://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure,lineNo=149,faultExplanation=%7Bhttp://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure >> >: >> >>>> No results for expression: {OXPath10Expression >> >>>> $output0.body/xsd0:field1[position()=$i]} >> >>>> 12:39:37,781 ERROR [ASSIGN] Assignment Fault: { >> >>>> >> http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure,lineNo=149,faultExplanation={http://docs.oasis-open.org/wsbpel/2.0/process/executable}selectionFailure<http://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure,lineNo=149,faultExplanation=%7Bhttp://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure> >> < >> http://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure,lineNo=149,faultExplanation=%7Bhttp://docs.oasis-open.org/wsbpel/2.0/process/executable%7DselectionFailure >> >: >> >>>> No results for expression: {OXPath10Expression >> >>>> $output0.body/xsd0:field1[position()=$i]} >> >>>> >> >>>> >> >>>> But when I simply replace $i with a normal unsignedInt variable $_i1, >> >>>> turning the piece above into: >> >>>> <forEach counterName="i" parallel="no"> >> >>>> <startCounterValue>1</startCounterValue> >> >>>> <finalCounterValue>2</finalCounterValue> >> >>>> <scope> >> >>>> <assign> >> >>>> <copy> >> >>>> <from variable="i" /> >> >>>> <to variable="_i1"/> >> >>>> </copy> >> >>>> <copy> >> >>>> <from>$i</from> >> >>>> >> <to>$output0.body/xsd0:field1[position()=$_i1]</to> >> >>>> <!-- note this line --> >> >>>> </copy> >> >>>> </assign> >> >>>> </scope> >> >>>> </forEach> >> >>>> it works fine! How strange! The expression language and query language >> used >> >>>> are both the default one, i.e. XPath 1.0. >> >>>> >> >>>> Need I commit a bug report to the developers of ODE? :-) >> >>>> >> >>>> Thanks & Regards. >> >>>> Wenfeng >> >>>> >> >>>> >> >>>> >> >>>> ZHAO Wenfeng >> >>>> [email protected] >> >>>> 2009-01-21 >> >>>> >> >>>> >> >> >> >> = = = = = = = = = = = = = = = = = = = = >> >> >> >> >> >> 致 >> >> 礼! >> >> >> >> >> >> ZHAO Wenfeng >> >> [email protected] >> >> 2009-01-22 >> >> >> >> >> > >> > >> >> = = = = = = = = = = = = = = = = = = = = >> >> >> 致 >> 礼! >> >> >> ZHAO Wenfeng >> [email protected] >> 2009-01-22 >> >> >
