0

The request xml is :

<ABC>
 <ServiceCharacteristic>
     <Code>AAA</Code>
     <CharacteristicValue>
       <CharacteristicValue>2222</CharacteristicValue>
     </CharacteristicValue>
 </ServiceCharacteristic>

 <ServiceCharacteristic>
     <Code>BBB</Code>
     <CharacteristicValue>
       <CharacteristicValue>2223</CharacteristicValue>
     </CharacteristicValue>
 </ServiceCharacteristic>

 <ServiceCharacteristic>
     <Code>CCC</Code>
     <CharacteristicValue>
       <CharacteristicValue>2224</CharacteristicValue>
     </CharacteristicValue>
   </ServiceCharacteristic>
 <Account>
 --------
 </Account>

</ABC>


Need to put a BPEL if condition to check if there is ServiceCharacteristic with code   "CCC"

tried something like below but no luck (Error(703): The LocationPath expression "self::node()/child::*[(local-name() = "Code")]" is not allowed in as there is no implicit context node present) :

**count($variable name/'*asterisk'[local-name()='ServiceCharacteristic' and     ./'*asterisk'[local-name()='Code']='CCC'] ) > 0**

Any inputs please ..thanks

user2128585
  • 47
  • 2
  • 10
  • command is : count($variable name/*[local-name()='ServiceCharacteristic' and ./*[local-name()='Code']='CCC'] ) > 0 – user2128585 Apr 04 '14 at 02:43
  • this part is not valid XPath : `./*[local-name()='Code']='CCC'`? If you mean to select element with local name equals 'Code' and value equals 'CCC', try this way instead : `./*[local-name()='Code' and .='CCC']` – har07 Apr 04 '14 at 04:23
  • Thanks for that but after i altered the condition as : Count($variablename/*[local-name()='ServiceCharacteristic' and ./*[local-name()='Code' and .='CCC']]) > 0 Compiler shows me error again: Error(704): The LocationPath expression "self::node()/child::*[((local-name() = "Code") and (self::node() = "CCC"))]" is not allowed in as there is no implicit context node present. – user2128585 Apr 04 '14 at 05:11
  • try replacing `./*[local-name()='Code' and .='CCC']]` with `child::*[local-name()='Code' and .='CCC']]` – Joel M. Lamsen Apr 04 '14 at 05:50
  • Thanks but the same error again. – user2128585 Apr 04 '14 at 06:00

1 Answers1

0

I pasted your XML script as presented in the question into an XPath evaluator and the following expresssion returns true for me:

count(/*[local-name() = 'ABC']/*[local-name() = 'ServiceCharacteristic']/*[local-name() = 'Code' and text() = 'CCC'])>0

Using that in a BPEL if could look like this:

 <if>
    <condition>count($Variable.ABCpart/*[local-name() = 'ABC']/*[local-name() = 'ServiceCharacteristic']/*[local-name() = 'Code' and text() = 'CCC'])>0</condition>
    <!-- remaining activities-->
 </if>

This assumes that you store your the XML in a variable called Variable and a messagePart called ABCpart. You have to adjust this to your setting for the expression to work.

joergl
  • 2,850
  • 4
  • 36
  • 42
  • Thanks for that but no luck again ... just to check if i am not going wrong anywhere my condition is like: count($ExecuteRequest.parameter/ns8:CustomerOrder/ns8:CustomerOrderItem/ns8:Business//ns8:Product/ns8:CustomerFacingService/*[local-name()='ServiceCharacteristic']/*[local-name()='Code' and text()='PortID']) > 0 There is already '//' used for abstraction in the xpath is that a reason why bpel raises the below error : Error(702): The LocationPath expression "child::text()" is not allowed in as there is no implicit context node present. – user2128585 Apr 06 '14 at 02:51
  • No, the error doesn't make sense at all, since there is no explicit `child::text()` present in the expression. Are you really really sure that the error is raised by exactly this expression and not be some other part of the process? Moreover, this is no BPEL fault, so perhaps its a bug in the engine you use? Maybe you should ask on the mailing list of the engine developers, they could know more. – joergl Apr 07 '14 at 08:02