简体   繁体   English

Soapui中的XQuery表达式

[英]XQuery Expression in Soapui

I am trying to write an XQuery in SOAPUI to validate an XML response. 我正在尝试在SOAPUI中编写XQuery来验证XML响应。 What I want to do is use a "where" to see if something equals something else with a wildcard. 我想做的是使用“ where”来查看是否有通配符等于其他内容。 Basically like this. 基本上是这样的。

<Result>
{
for $x in //ns3:Building
where $x/ns3:BuildingNumber/text()='JJJ*'     <--- This is my problem
return <Value>{$x/ns3:BuildingNumber/text()}</Value>
}
</Result>

I have taken out the namespaces for simplicity but I'm sure all of it works. 为了简单起见,我已经删除了命名空间,但是我确信所有这些都可以使用。

When I replace the where with something literal like the following, it works: 当我用类似以下内容的文字替换where时,它可以工作:

where $x/ns3:BuildingNumber/text()=JJJ1245

I need some kind of wildcard though but I'm not sure how or if it's done in this instance. 虽然我需要某种通配符,但是我不确定在这种情况下是如何完成的。 All missions that start with JJJ. 以JJJ开头的所有任务。 I have tried Regex and others like this but none work: 我已经尝试过Regex和其他类似的东西,但是没有用:

'JJJ*' '^JJJ.' 'JJJ *''^ JJJ。' 'JJJ.*' 'JJJ。*'

Use matches() for regex: matches()用于正则表达式:

where matches($x/ns3:BuildingNumber, '^JJJ.*')

Also, be careful with text() - usually you want string() . 另外,请注意text() -通常您需要string() This article offers a very good explanation. 本文提供了很好的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM