开发者

Xpath or xquery and test the order

开发者 https://www.devze.com 2022-12-29 15:28 出处:网络
Using SoapUI (great tool for WS by the way), I have the following xml result : <code>c</code>

Using SoapUI (great tool for WS by the way), I have the following xml result :

<code>c</code>
<code>b</code>
<code>a</code>

For this sample above, i would like to test the code value are order asc. Of course, 开发者_运维知识库for this sample the test will fail like excepted.

Any solution with xquery or xpath (i can use groovy inside the test if necessary)

Thanks in advance.


Use (XQuery or XPath 2.0):

not(code[. > following-sibling::code])


Two other ways:

empty(
  for $x at $p in code
  where ($x > code[$p + 1])
  return $x
)

and

deep-equal(for $x in code order by $x return $x/data(.), code/data(.))

But Dimitre's answer seems the cleanest.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号