0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creator="GPSMAP 64sx" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackStatsExtension/v1 http://www8.garmin.com/xmlschemas/TrackStatsExtension.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">
  <metadata>
    <link href="http://www.garmin.com">
      <text>Garmin International</text>
    </link>
  </metadata>
  <wpt lat="0.0000" lon="0.0000">
    <name>AST</name>
    <sym>Navaid, White</sym>
  </wpt>
</gpx>

I'm trying to use xsl transform on the gpx file, but it does not transform the xml unless I manually remove all the attributes in the gpx node. What I don't know is which attribute specifically is causing the problem. I would like to know why this problem is occurring and how to fix it. I'm pretty new to xsl transform. I would appreciate any help.

This is the xsl transform that I'm using. It does not do what I want at the moment, but the issue with the attributes is preventing me from testing the xsl transform at all. When the attributes are present, the xls transform does not work at all. After I remove the attributes, the transform gets rid of the metadata node, which is part of what I want.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
        <xsl:copy>
            <xsl:apply-templates select="gpx/wpt"/>
        </xsl:copy>
    </xsl:template>
  <xsl:template match="gpx/wpt/@*">
    <xsl:element name="{name()}">
      <xsl:value-of select="."/>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
PerfectFiasco
  • 127
  • 2
  • 7
  • 1
    Namespace declarations are not attributes. Specifically in your example, the declaration that is "causing the problem" is the one without a prefix, a.k.a. the default namespace. – michael.hor257k Jun 09 '23 at 06:50

0 Answers0