Forum Discussion

Paultje's avatar
Paultje
New Contributor
12 years ago

Problem with multiple returns in XQuery Match assertion

Currently I'm trying to make an XQuery Match assertion on the GetWeatherInformation operation of the Weather service (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL) that returns the WeatherIDs and the Descriptions.

This is the XML response of the GetWeatherInformation operation:

<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>
<GetWeatherInformationResponse xmlns="http://ws.cdyne.com/WeatherWS/">
<GetWeatherInformationResult>
<WeatherDescription>
<WeatherID>1</WeatherID>
<Description>Thunder Storms</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/thunderstorms.gif</PictureURL>
</WeatherDescription>
<WeatherDescription>
<WeatherID>2</WeatherID>
<Description>Partly Cloudy</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif</PictureURL>
</WeatherDescription>
<WeatherDescription>
<WeatherID>3</WeatherID>
<Description>Mostly Cloudy</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/mostlycloudy.gif</PictureURL>
</WeatherDescription>
(...)
<WeatherDescription>
<WeatherID>35</WeatherID>
<Description>Snow, Blowing Snow, and Fog</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif</PictureURL>
</WeatherDescription>
<WeatherDescription>
<WeatherID>36</WeatherID>
<Description>Unknown Precipitation</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/na.gif</PictureURL>
</WeatherDescription>
<WeatherDescription>
<WeatherID>37</WeatherID>
<Description>AM CLOUDS</Description>
<PictureURL>http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif</PictureURL>
</WeatherDescription>
</GetWeatherInformationResult>
</GetWeatherInformationResponse>
</soap:Body>
</soap:Envelope>


This is the XQuery Match assertion I've made:

declare namespace test = 'http://ws.cdyne.com/WeatherWS/';
<Result>
{
for $z in //test:WeatherDescription
return (<WeatherID>{data($z/WeatherID)}</WeatherID>,<Description>{data($z/Description)}</Description>)
}
</Result>


And this is the result of that assertion (by clicking 'Select from current'):

<Result>
<WeatherID/>
<Description/>
<WeatherID/>
<Description/>
<WeatherID/>
<Description/>
(...)
<WeatherID/>
<Description/>
<WeatherID/>
<Description/>
<WeatherID/>
<Description/>
</Result>


Does anyone know what I've done wrong here?

Thanks for your help!

2 Replies

  • nmrao's avatar
    nmrao
    Community Hero
    Namespace have to be included.

    Check this out:

    declare namespace soap='http://schemas.xmlsoap.org/soap/envelope/';
    declare namespace ns1='http://ws.cdyne.com/WeatherWS/';
    <Result>
    {
    for $z in //ns1:WeatherDescription
    return (<WeatherID>{data($z/ns1:WeatherID/text())}</WeatherID>,<Description>{data($z/ns1:Description/text())}</Description>)
    }
    </Result>