issues outputting xml value due to namespace
xml code
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="MyXmlTransformer.xsl"?>
<JMO_obsList xmlns="urn:metoc:jmcbl:jmibl">
<urn:JMO_obs urn:observationTime ="20110118150000" urn:platformID="A001" urn:reporTypeCode="AUTO"
urn:HorizontalDatum="WGE" urn:verticalDatum="MSL" urn:stationMode="0"
urn:networkType="PTDS" xmlns:urn="urn:metoc:jmcbl开发者_如何学Python:jmcbl:jmibl">
<JMO_surfaceObs urn:stationPressure ="998.308" urn:airTemperature="28.56"
urn:windDirection="320" urn:windSpeed="3.807"/>
<urn:JMO_precipitation urn:PrecipAmount="6.858" urn:observationPeriod="60"
urn:precipType="L" urn:occcurenceID="1"/>
</urn:JMO_obs>
</JMO_obsList>
xslt code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<body>
<b>METAR</b>
<br/>
<span style="color:blue">
<xsl:value-of select="JMO_obsList/JMO_surfaceObs/windSpeed"/>
</span><br/>
<span style="color:blue">
<xsl:value-of select="JMO_obsList/JMO_surfaceObs/stationPressure"/>
</span><br/>
<span style="color:blue">
<xsl:value-of select="JMO_obsList/JMO_Obs/observationTime"/>
</span><br/>
<span style="color:blue">
<xsl:value-of select="JMO_obsList/JMO_precipitation/PrecipAmount"/>
</span><br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
In your stylesheet you will have to define prefixes for the namespace "urn:metoc:jmcbl:jmibl" and urn:metoc:jmcbl:jmcbl:jmibl and use them to explicitly qualify the references to JMO_obsList and other elements. Furthermore, the references to windSpeed and other XML attributes need to be referenced with the attribute: axis
An example of a complete value-of declaration:
<span style="color:blue">
<xsl:value-of xmlns:ns1="urn:metoc:jmcbl:jmibl"
xmlns:ns2="urn:metoc:jmcbl:jmcbl:jmibl"
select="ns1:JMO_obsList/ns2:JMO_obs/ns1:JMO_surfaceObs/@ns2:stationPressure"/>
</span>
精彩评论