Roy
Roy

Reputation: 1225

How to use xpath xpression to check if data is present or not in wso2 ESB?

I have captured my input id in a property and now i want to validate if the property has data or not. How to do this? I have done something like this:

This is my property that i have set:

<property xmlns:cct="http://www.tempuri.org/" name="ID" expression="//cct:ID" scope="default" type="STRING"/>

This is my xpath xpression that should validate if property has data or not:

count(get-property(ID)[text()])>0

But this expression is wrong. How to solve this. Please help. Thanks in advance

Upvotes: 2

Views: 4452

Answers (2)

Chris
Chris

Reputation: 163

Change your property to this:

<property xmlns:cct="http://www.tempuri.org/" name="ID" expression="//cct:ID/text()" scope="default" type="STRING"/>

then test using

boolean(get-property('ID'))

Upvotes: 6

Rajeev Sampath
Rajeev Sampath

Reputation: 2747

It should be something like below,

count(/property[@name='ID']/text())

Note that the correct path (instead of /property/..) depends on your xml. you may also use /*/property/... if not sure about the path.

Upvotes: 0

Related Questions