Hi! I tried a myriad of things similar to those you mentioned below to try to fix this and none of them worked. I guess I will have to write an xslt transform or something. -Doug.
-----Original Message----- From: ZHAO Wenfeng [mailto:[email protected]] Sent: Wednesday, February 04, 2009 7:22 PM To: [email protected] Subject: Re: xpath question Hi Douglas, Matthieu has given a solution in a message with title "Re: Re: Is it a bug? ..." on Jan 23rd: $array[number($index)] This is his interpretation: " 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. " In addition, if the $index is a forEach counter variable, the following workaround (found by Alexey) is needed: $array[number(string($index))] P.S. I also found the following works fine only in XPath 1.0 but not in XPath 2.0: $array[position()=$index] Regards Wenfeng ======= 2009-02-05 08:30:34 您在来信中写道:======= >Hi! >I am not sure if this is a bug or not, but when I have code similar to the >following: > > $p-response-msg.response-part/x:e-response/xfer:r-info[$r-number]/x:l-ticket[1] >or > > $p-response-msg.response-part/x:e-response/xfer:r-info[position()=$r-number]/x:l-ticket[1] >I get a null (see below). But when I replace the $r-number with a constant >'1' it works. The value of $r-number is 1 as shown in the debug output. >$r-number is declared as <variable name="r-number" type="xsd:int" /> >I am using a war file built from the trunk sometime last week. >I am using xpath 2.0 as query language and expression language. The BPEL 2.0 >spec talks about using multiple variable references in xpath expressions, so >it would seem alright. >Thanks! >-Doug. > > >BPEL: > > <from>dbg:debugString(ode:dom-to-string($p-response-msg.response-part/x:e-response), > 'e-response')</from> > <to>$debug-output</to> > </copy> > <copy> > <from>dbg:debugString(xsd:string($r-number), 'r-number')</from> > <to>$debug-output2</to> > </copy> > <!-- constants ... works --> > <copy> > > <from>dbg:debugString($p-response-msg.response-part/x:e-response/x:r-info[1]/x:l-ticket[1], > 'l-ticket')</from> > <to>$debug-output1</to> > </copy> > <!-- variable reference fails (with or without position()= --> > <copy> > > <from>dbg:debugString($p-response-msg.response-part/x:e-response/x:r-info[$r-number]/x:l-ticket[1], > 'l-ticket')</from> > <to>$debug-output3</to> > </copy> > >Log output: > >e-response -> <?xml version="1.0" encoding="UTF-8"?> ><e-response xmlns="http://xxx/yyy" xmlns:ns1="http://xxx/yyy"> > <r-info> > <r-id>111</r-id> > <e-ticket>1233792023564-69</e-ticket> > <l-ticket>1233792023564-70</l-ticket> > <l-ticket>1233792023564-70</l-ticket> > </r-info> ></e-response> >r-number -> 1 >l-ticket -> 1233792023564-70 >ERROR - GeronimoLog.error(104) | Assignment Fault: >{http://docs.oasis-open.org/wsbpel/2.0/process/executable}subLanguageExecutionFault,lineNo=1210,faultExplanation={http://docs.oasis-open.org/wsbpel/2.0/process/executable}subLanguageExecutionFault: > null >DEBUG - GeronimoLog.debug(66) | schedulingRunnable for process >{http://teamcenter.com/globalservices/process/bpel/webservice/2007-06}data-transfer-36: > org.apache.ode.bpel.engine.unreliablemyrolemessageexchangeimp...@7a547b >DEBUG - GeronimoLog.debug(66) | ProcessImpl completed with fault >'{http://docs.oasis-open.org/wsbpel/2.0/process/executable}subLanguageExecutionFault' = = = = = = = = = = = = = = = = = = = =
