Я использую Eclipse Kepler с саксонским плагином. Используя следующий входной XML и следующий XSL. Любые идеи, что я делаю неправильно?Необходима помощь XSD
Мой Входной 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>
Мой 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>
Мой выход:
<?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>
Желаемая Выход:
<?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>
Я попробовал несколько вариантов, таких как:
<max:SUCCESS>
<xsl:value-of select="/GetCityWeatherByZIPResponse/GetCityWeatherByZIPResult/Success"/>
</max:SUCCESS>
И использование:
<?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>
номер 1 ошибка XSLT сообщил на этом форуме: вы игнорируете тот факт, что элементы находятся в пространстве имен. –