对于以下数据,
<Document xmlns="http://www.mycompany.net/xyz/2.2">
<Placemark>
<ExtendedData>
<Data name="Value">
<value>6.5</value>
</Data>
<Data name="Direction">
<value>77</value>
</Data>
</ExtendedData>
<Point>
<coordinates>0,-25.2</coordinates>
</Point>
</Placemark>
<Placemark>
<ExtendedData>
<Data name="Value">
<value>7.0</value>
</Data>
<Data name="Direction">
<value>101</value>
</Data>
</ExtendedData>
<Point>
<coordinates>3.6,-25.2</coordinates>
</Point>
</Placemark>
</Document>
我正在尝试验证XML中有数字的坐标。我尝试使用Regex,但它仍然无法通过
When def xmld = read('classpath:rough/GriddedElementResponse.xml')
* match $xmld/Document/Placemark[*]/Point/coordinates == "#[] #string"
# Above gets passed as the numbers are inside quotes
* match $xmld/Document/Placemark[*]/Point/coordinates == "#regex [\d \. \, \-]"
在空手道中由于以下错误而失败,但在此处通过。
org.opentest4j.AssertionFailedError:
match failed: EQUALS
$ | not a string (LIST:STRING)
["0,-25.2","3.6,-25.2"]
'#regex [d . , -]'
您有一个由2个字符串组成的列表,请注意错误消息。
试试这个:
* match each $xmld/Document/Placemark[*]/Point/coordinates == '#regex \d+(\.\d+)?,-?\d+(\.\d+)'