question

elainej avatar image
elainej asked Philip.Joung edited

XPath Query Count not returning an integer

Hi,

I have a query that is a count here is my example.

NumberOfDownThings: count(mapped/Tabular/dLpAp/table/row[osiOper="dis" or osiUage !="active" or ipAddr="0.0.0.0"])

I would expect that this would return an integer I could compare but it doesn't seem to.

What happens when I try to use this in a query as shown below

analyze

query NumberOfDownThings()

asset $value > 0

Is that I get an error in the form:

0.0 > 0

Why is my query returning a string and not a number that I can use?

I have tried using expr in from of it e.g.

assert [expr $value] > 0

but doesn't totally solve my problem.

Any suggestions how my count query can return a number to compare against 0???

Regards,

Elaine.

iTestxpath
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KumarS avatar image
KumarS answered KumarS posted

It is alll working properly. Itest will automatically do a numeric comparison in this case. It will convert 0.0 to 0 and then compare. It just so happens that 0.0 is zero and therefore not greater than zero. When creating an execution issue, ITest simply prints the values as they were so that it is easy for the user to see what could possibly be wrong with the expression.

 

 

 

 

 

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.