Repository navigation
Merged GPX file fails validation #63
Copy link
Copy link
Closed
Description
Merging two files that are valid produces a resulting file that has the following errors:
S4s-elt-character: Non-whitespace Characters Are Not Allowed In Schema Elements Other Than 'xs:appinfo' And 'xs:documentation'. Saw 'Document Moved'., Line '1', Column '28'.
The Markup In The Document Following The Root Element Must Be Well-formed., Line '2', Column '2'.
The Markup In The Document Following The Root Element Must Be Well-formed.
I used this page for validation, as reccomended here.
File 1 contents
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="Colota" xmlns="http://www.topografix.com/GPX/1/1">
<metadata>
<name>Colota Location Export</name>
<time>2026-05-20T22:04:53.000Z</time>
</metadata>
<trk>
<name>Colota Track Export</name>
<trkseg>
<trkpt lat="62.424161" lon="6.274748">
<ele>78</ele>
<time>2026-05-20T10:14:42.000Z</time>
<extensions>
<accuracy>19.296001434326172</accuracy>
<speed>0</speed>
<battery>35</battery>
</extensions>
</trkpt>
<trkpt lat="62.423844" lon="6.275863">
<ele>87</ele>
<time>2026-05-20T20:06:47.000Z</time>
<extensions>
<accuracy>68.60800170898438</accuracy>
<speed>0.6600000262260437</speed>
<battery>12</battery>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
File 2 contents
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="Colota" xmlns="http://www.topografix.com/GPX/1/1">
<metadata>
<name>Colota Location Export</name>
<time>2026-05-20T12:27:43.000Z</time>
</metadata>
<trk>
<name>Colota Track Export</name>
<trkseg>
<trkpt lat="62.424161" lon="6.274748">
<ele>78</ele>
<time>2026-05-20T10:14:42.000Z</time>
<extensions>
<accuracy>19.296001434326172</accuracy>
<speed>0</speed>
<battery>35</battery>
</extensions>
</trkpt>
<trkpt lat="62.424104" lon="6.275333">
<ele>63</ele>
<time>2026-05-20T10:17:32.000Z</time>
<extensions>
<accuracy>254.0640106201172</accuracy>
<speed>0</speed>
<battery>34</battery>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
Merged file contents
<?xml version='1.0' encoding='utf-8'?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" creator="https://github.com/sgraaf/gpx">
<trk>
<name>Colota Track Export</name>
<trkseg>
<trkpt lat="62.424161" lon="6.274748">
<ele>78</ele>
<time>2026-05-20T10:14:42Z</time>
<extensions>
<accuracy>19.296001434326172</accuracy>
<speed>0</speed>
<battery>35</battery>
</extensions>
</trkpt>
<trkpt lat="62.423844" lon="6.275863">
<ele>87</ele>
<time>2026-05-20T20:06:47Z</time>
<extensions>
<accuracy>68.60800170898438</accuracy>
<speed>0.6600000262260437</speed>
<battery>12</battery>
</extensions>
</trkpt>
</trkseg>
</trk>
<trk>
<name>Colota Track Export</name>
<trkseg>
<trkpt lat="62.424161" lon="6.274748">
<ele>78</ele>
<time>2026-05-20T10:14:42Z</time>
<extensions>
<accuracy>19.296001434326172</accuracy>
<speed>0</speed>
<battery>35</battery>
</extensions>
</trkpt>
<trkpt lat="62.424104" lon="6.275333">
<ele>63</ele>
<time>2026-05-20T10:17:32Z</time>
<extensions>
<accuracy>254.0640106201172</accuracy>
<speed>0</speed>
<battery>34</battery>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
KronosTheLate commentedon May 30, 2026
Note that a file created with the gpxpy python package has exactly the same issues, so I also raised this issue over there
sgraaf commentedon Jun 1, 2026
Hi there!
Thank you for raising this issue. There are two different things going on here, I think:
http://www.topografix.com/GPX/1/1/gpx.xsdtohttps://www.topografix.com/GPX/1/1/gpx.xsdin thexsi:schemaLocationdirective of the rootgpxelement resolves the XML validation errors you report above, but does raise the errors of the two unmerged files mentioned above. In my opinion this is an issue with the XML validator you use, more so than with the output of this package.All told, I do think the merged GPX file produced by this package is valid, and that there is no "bug" to be fixed here. What I could do is raise a warning when a GPX file is read that contains invalid extensions elements as a UX improvement.
Curious to read your thoughts should you feel differently.
KronosTheLate commentedon Jun 3, 2026
Your comment is very educational, and I agree with all your sentiments. Also, big fan of the UX improvement you suggested!
sgraaf commentedon Jun 15, 2026
I just merged #66 that implements the UX improvement discussed:
KronosTheLate commentedon Jun 16, 2026
Amazing! Thanks for this 😸