bpel如果条件xpath表达式

时间:2014-04-04 02:41:51

标签: xpath soa bpel bpelxexec

请求xml是:

<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"

试过类似下面但没有运气(错误(703):LocationPath表达式“self :: node()/ child :: * [(local-name()=”Code“)]”“不是允许,因为没有隐含的上下文节点):

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

请输入任何信息<谢谢

1 个答案:

答案 0 :(得分:0)

我将问题中提供的XML脚本粘贴到XPath评估程序中,以下表达式为我返回true

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

在BPEL if中使用它可能如下所示:

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

这假设您将XML存储在名为Variable的变量和名为messagePart的{​​{1}}中。您必须将此调整为您的设置才能使表达式生效。