user2128585
user2128585

Reputation: 47

bpel if condition xpath expression

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

Upvotes: 0

Views: 3702

Answers (1)

joergl
joergl

Reputation: 2866

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.

Upvotes: 0

Related Questions