GPSBabel / gpsbabel

GPSBabel: convert, manipulate, and transfer data from GPS programs or GPS receivers. Open Source and supported on MacOS, Windows, Linux, and more. Pointy clicky GUI or a command line version...
https://www.gpsbabel.org
GNU General Public License v2.0
473 stars 126 forks source link

gpx writer can violate schema when extensions exist, gpx read and write versions differ, and passthrough is used. #1194

Open tsteven4 opened 10 months ago

tsteven4 commented 10 months ago
  1. reading 1.0, writing 1.1. gpsbabel -i gpx -f reference/gc/GCGCA8.gpx -o gpx,gpxver=1.1 -F gc11.gpx $ xmllint --noout --schema tools/schema/gpx/topografix/gpx11.xsd gc11.gpx gc11.gpx:20: element cache: Schemas validity error : Element '{http://www.groundspeak.com/cache/1/0}cache': This element is not expected. Expected is one of ( {http://www.topografix.com/GPX/1/1}fix, {http://www.topografix.com/GPX/1/1}sat, {http://www.topografix.com/GPX/1/1}hdop, {http://www.topografix.com/GPX/1/1}vdop, {http://www.topografix.com/GPX/1/1}pdop, {http://www.topografix.com/GPX/1/1}ageofdgpsdata, {http://www.topografix.com/GPX/1/1}dgpsid, {http://www.topografix.com/GPX/1/1}extensions ). gc11.gpx fails to validate element groundspeak:cache is written as a child of wpt, not as a child of extensions.
  2. reading 1.1, writing 1.0 gpsbabel -i gpx -f reference/basecamp.gpx -o gpx,gpxver=1.0 -F bc10.gpx $ xmllint --noout --schema tools/schema/gpx/topografix/gpx10.xsd bc10.gpx bc10.gpx:27: element extensions: Schemas validity error : Element '{http://www.topografix.com/GPX/1/0}extensions': This element is not expected. Expected is one of ( {http://www.topografix.com/GPX/1/0}type, {http://www.topografix.com/GPX/1/0}fix, {http://www.topografix.com/GPX/1/0}sat, {http://www.topografix.com/GPX/1/0}hdop, {http://www.topografix.com/GPX/1/0}vdop, {http://www.topografix.com/GPX/1/0}pdop, {http://www.topografix.com/GPX/1/0}ageofdgpsdata, {http://www.topografix.com/GPX/1/0}dgpsid, ##other{http://www.topografix.com/GPX/1/0}* ). bc10.gpx:41: element extensions: Schemas validity error : Element '{http://www.topografix.com/GPX/1/0}extensions': This element is not expected. Expected is one of ( {http://www.topografix.com/GPX/1/0}type, {http://www.topografix.com/GPX/1/0}fix, {http://www.topografix.com/GPX/1/0}sat, {http://www.topografix.com/GPX/1/0}hdop, {http://www.topografix.com/GPX/1/0}vdop, {http://www.topografix.com/GPX/1/0}pdop, {http://www.topografix.com/GPX/1/0}ageofdgpsdata, {http://www.topografix.com/GPX/1/0}dgpsid, ##other{http://www.topografix.com/GPX/1/0}* ). bc10.gpx fails to validate The extensions element doesn't exist in 1.0.
tsteven4 commented 10 months ago

A possible solution is to split kFsGpx into version dependent types, one for gpx 1.0, one for gpx 1.1. Then have the gpx writer only search for the data that was read from the same version we are writing, dropping any cross version data. gpx_namespace_attributes may need to be split as well (or replaced with version dependent gpx_namespaces).