Reputation: 3
I am using Eclipse Kepler with the Saxon plug-in. Using the following Input XML and the following XSL. Any Ideas what I am doing incorrectly?
My Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="weathertbos.xsl" ?>
<GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/">
<GetCityWeatherByZIPResult>
<Success>true</Success>
<ResponseText>City Found</ResponseText>
<State>FL</State>
<City>Clearwater</City>
<WeatherStationCity>Clearwater</WeatherStationCity>
<WeatherID>14</WeatherID>
<Description>Cloudy</Description>
<Temperature>73</Temperature>
<RelativeHumidity>90</RelativeHumidity>
<Wind>NE10</Wind>
<Pressure>30.07R</Pressure>
<Visibility />
<WindChill />
<Remarks />
</GetCityWeatherByZIPResult>
</GetCityWeatherByZIPResponse>
My XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:max="http://www.ibm.com/maximo" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:weat="http://ws.cdyne.com/WeatherWS/" exclude-result-prefixes="soapenv max">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<max:SyncWEATHERRSPOS xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS>
<xsl:value-of select="Success" />
</max:SUCCESS>
<max:RESPONSETEXT>
<xsl:value-of select="ResponseText" />
</max:RESPONSETEXT>
<max:STATE>
<xsl:value-of select="State" />
</max:STATE>
<max:CITY>
<xsl:value-of select="City" />
</max:CITY>
<max:WEATHERSTATIONCITY>
<xsl:value-of select="WeatherStationCity" />
</max:WEATHERSTATIONCITY>
<max:WEATHERID>
<xsl:value-of select="WeatherID" />
</max:WEATHERID>
<max:DESCRIPTION>
<xsl:value-of select="Description" />
</max:DESCRIPTION>
<max:TEMPERATURE>
<xsl:value-of select="Temperature" />
</max:TEMPERATURE>
<max:RELATIVEHUMIDITY>
<xsl:value-of select="RelativeHumidity" />
</max:RELATIVEHUMIDITY>
<max:WIND>
<xsl:value-of select="Wind" />
</max:WIND>
<max:PRESSURE>
<xsl:value-of select="Pressure" />
</max:PRESSURE>
<max:VISIBILITY>
<xsl:value-of select="Visibility" />
</max:VISIBILITY>
<max:WINDCHILL>
<xsl:value-of select="WindChill" />
</max:WINDCHILL>
<max:REMARKS>
<xsl:value-of select="Remarks" />
</max:REMARKS>
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
</xsl:template>
</xsl:stylesheet>
My Output:
<?xml version="1.0" encoding="UTF-8"?>
<max:SyncWEATHERRSPOS xmlns:weat="http://ws.cdyne.com/WeatherWS/" xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS />
<max:RESPONSETEXT />
<max:STATE />
<max:CITY />
<max:WEATHERSTATIONCITY />
<max:WEATHERID />
<max:DESCRIPTION />
<max:TEMPERATURE />
<max:RELATIVEHUMIDITY />
<max:WIND />
<max:PRESSURE />
<max:VISIBILITY />
<max:WINDCHILL />
<max:REMARKS />
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
Desired Output:
<?xml version="1.0" encoding="UTF-8"?>
<max:SyncWEATHERRSPOS xmlns:weat="http://ws.cdyne.com/WeatherWS/" xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS>true</max:SUCCESS>
<max:RESPONSETEXT>City Found</max:RESPONSETEXT>
<max:STATE>FL</max:STATE>
<max:CITY>Clearwater</max:CITY>
<max:WEATHERSTATIONCITY>Clearwater</max:WEATHERSTATIONCITY>
<max:WEATHERID>14</max:WEATHERID>
<max:DESCRIPTION>Cloudy</max:DESCRIPTION>
<max:TEMPERATURE>73</max:TEMPERATURE>
<max:RELATIVEHUMIDITY>90</max:RELATIVEHUMIDITY>
<max:WIND>NE10</max:WIND>
<max:PRESSURE>30.07R</max:PRESSURE>
<max:VISIBILITY />
<max:WINDCHILL />
<max:REMARKS />
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
I have tried several options such as:
<max:SUCCESS>
<xsl:value-of select="/GetCityWeatherByZIPResponse/GetCityWeatherByZIPResult/Success"/>
</max:SUCCESS>
And using :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:max="http://www.ibm.com/maximo" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:weat="http://ws.cdyne.com/WeatherWS/" exclude-result-prefixes="soapenv max">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="GetCityWeatherByZIPResponse">
<xsl:apply-templates select="GetCityWeatherByZIPResult" />
</xsl:template>
<xsl:template match="GetCityWeatherByZIPResult">
<max:SyncWEATHERRSPOS xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS>
<xsl:value-of select="Success" />
</max:SUCCESS>
<max:RESPONSETEXT>
<xsl:value-of select="ResponseText" />
</max:RESPONSETEXT>
<max:STATE>
<xsl:value-of select="State" />
</max:STATE>
<max:CITY>
<xsl:value-of select="City" />
</max:CITY>
<max:WEATHERSTATIONCITY>
<xsl:value-of select="WeatherStationCity" />
</max:WEATHERSTATIONCITY>
<max:WEATHERID>
<xsl:value-of select="WeatherID" />
</max:WEATHERID>
<max:DESCRIPTION>
<xsl:value-of select="Description" />
</max:DESCRIPTION>
<max:TEMPERATURE>
<xsl:value-of select="Temperature" />
</max:TEMPERATURE>
<max:RELATIVEHUMIDITY>
<xsl:value-of select="RelativeHumidity" />
</max:RELATIVEHUMIDITY>
<max:WIND>
<xsl:value-of select="Wind" />
</max:WIND>
<max:PRESSURE>
<xsl:value-of select="Pressure" />
</max:PRESSURE>
<max:VISIBILITY>
<xsl:value-of select="Visibility" />
</max:VISIBILITY>
<max:WINDCHILL>
<xsl:value-of select="WindChill" />
</max:WINDCHILL>
<max:REMARKS>
<xsl:value-of select="Remarks" />
</max:REMARKS>
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Views: 45
Reputation: 7905
It is a namespace issue; the tag GetCityWeatherByZIPResponse
is assigned the namespace uri http://ws.cdyne.com/WeatherWS/, you need to match your tags with the prefix weat
that has been declared on the root of your stylesheet.
You need to modify your stylesheet that wa, if I take the last attempt you posted (please note your stylesheet has been abridged to keep the answer as brief as possible, full XSL is here):
<xsl:template match="weat:GetCityWeatherByZIPResponse">
<xsl:apply-templates select="weat:GetCityWeatherByZIPResult" />
</xsl:template>
<xsl:template match="weat:GetCityWeatherByZIPResult">
<max:SyncWEATHERRSPOS xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS>
<xsl:value-of select="weat:Success" />
</max:SUCCESS>
<max:RESPONSETEXT>
<xsl:value-of select="weat:ResponseText" />
</max:RESPONSETEXT>
<!-- and so on ... -->
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
</xsl:template>
This is my output XML:
<?xml version="1.0" encoding="UTF-8"?>
<max:SyncWEATHERRSPOS xmlns:weat="http://ws.cdyne.com/WeatherWS/"
xmlns:max="http://www.ibm.com/maximo">
<max:WEATHERRSPOSSet>
<max:WEATHER action="AddChange">
<max:SUCCESS>true</max:SUCCESS>
<max:RESPONSETEXT>City Found</max:RESPONSETEXT>
<max:STATE>FL</max:STATE>
<max:CITY>Clearwater</max:CITY>
<max:WEATHERSTATIONCITY>Clearwater</max:WEATHERSTATIONCITY>
<max:WEATHERID>14</max:WEATHERID>
<max:DESCRIPTION>Cloudy</max:DESCRIPTION>
<max:TEMPERATURE>73</max:TEMPERATURE>
<max:RELATIVEHUMIDITY>90</max:RELATIVEHUMIDITY>
<max:WIND>NE10</max:WIND>
<max:PRESSURE>30.07R</max:PRESSURE>
<max:VISIBILITY/>
<max:WINDCHILL/>
<max:REMARKS/>
</max:WEATHER>
</max:WEATHERRSPOSSet>
</max:SyncWEATHERRSPOS>
Upvotes: 1