xslt - Processing a GPX file with xsl (probably a namespace issue) -
this question looks duplicate of xpath query gpx files namespaces?, must missing because can't seem simple style sheet work. have input:
<?xml version="1.0" encoding="utf-8"?> <gpx xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" version="1.0" creator="groundspeak pocket query" xsi:schemalocation="http://www.topografix.com/gpx/1/0 http://www.topografix.com/gpx/1/0/gpx.xsd http://www.groundspeak.com/cache/1/0 http://www.groundspeak.com/cache/1/0/cache.xsd" xmlns="http://www.topografix.com/gpx/1/0"> <name>ottawa pocket query</name> <wpt lat="45.348517" lon="-75.825933"> <name>gc3hxaz</name> <desc>craft maker box fishdetective, traditional cache (2/2.5)</desc> <url>http://www.geocaching.com/seek/cache_details.aspx?guid=e86ce3f5-9e75-48a6-b47e-9415101fc658</url> <groundspeak:cache id="2893138" available="true" archived="false" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0"> <groundspeak:name>craft maker box</groundspeak:name> <groundspeak:difficulty>2</groundspeak:difficulty> <groundspeak:terrain>2.5</groundspeak:terrain> </groundspeak:cache> </wpt> </gpx>
and stylesheet looks this:
<?xml version="1.0"?> <!-- --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0" > <xsl:output method="html"/> <xsl:template match="/"> cache names: <xsl:apply-templates select="//wpt"> </xsl:apply-templates> </xsl:template> <xsl:template match="wpt"> <li><xsl:value-of select="groundspeak:cache/groundspeak:name"/></li> </xsl:template> </xsl:stylesheet>
and expect list 1 element on it, "craft maker box", empty list.
what missing?
the default namespace http://www.topografix.com/gpx/1/0
. should add , use prefix match wpt
.
something this: (untested)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:groundspeak="http://www.groundspeak.com/cache/1/0" xmlns:gpx="http://www.topografix.com/gpx/1/0" > <xsl:output method="html"/> <xsl:template match="/"> cache names: <xsl:apply-templates select="//gpx:wpt"> </xsl:apply-templates> </xsl:template> <xsl:template match="gpx:wpt"> <li><xsl:value-of select="groundspeak:cache/groundspeak:name"/></li> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment