stiley
12 years agoNew Contributor
XPath Assertions
Hello, I have the following response from a very simple WebService
I am asserting that the value in the <GetRandomResult> tag is numeric with the following XPath assertion (its working just fine)
This is quite a bit of typing so I would like to use this instead
Any thoughts would be appreciated
Sean
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetRandomResponse xmlns="http://seant/webservices/">
<GetRandomResult>15</GetRandomResult>
</GetRandomResponse>
</soap:Body>
</soap:Envelope>
I am asserting that the value in the <GetRandomResult> tag is numeric with the following XPath assertion (its working just fine)
declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
declare namespace ns1='http://seant/webservices/';
matches(/soap:Envelope/soap:Body/*[namespace-uri()='http://seant/webservices/' and local-name()='GetRandomResponse']/*[namespace-uri()='http://seant/webservices/' and local-name()='GetRandomResult']/text(),'^\d{1,2}$')
This is quite a bit of typing so I would like to use this instead
matches(//GetRandomResult/text(),'^\d{1,2}$') but it keeps failing and I am not sure why. I have validated this expression in other editors and its fine, just not sure what is going on.Any thoughts would be appreciated
Sean