Forum: WHALER
  ContinuousWave
  Whaler
  Moderated Discussion Areas
  ContinuousWave: Small Boat Electrical
  Validating GPX file with XERCES

Post New Topic  Post Reply
search | FAQ | profile | register | author help

Author Topic:   Validating GPX file with XERCES
jimh posted 09-22-2014 07:09 PM ET (US)   Profile for jimh   Send Email to jimh  
Validating GPX files using Xerces

The GPX website suggests that GPX output can and should be validated for conformance to the GPX XML specification. The method suggested is to use the XML Parser XERCES. See

http://www.topografix.com/gpx_validation.asp

Installing XERCES for MacOS 10.6.8 required compiling a binary from the source distribution. This was greatly facilitated by a note from another user who found an important change that must be made in the process. See the instructions under the heading "1 Answer" at

http://stackoverflow.com/questions/17102409/ mac-osx-compatibility-version-of-xerces-c-dylib-10-5-10-8

I compiled XERCES from

/Users/jimh/xerces/xerces-c-3.1.1/

and then tested it by running the SAXcount utility against a sample file:


bigDog:xerces-c-3.1.1 jimh$ cd samples/data/
bigDog:data jimh$ SAXCount -v=always personal.xml
personal.xml: 1 ms (37 elems, 12 attrs, 134 spaces, 134 chars)

This output indicated a valid XML file. Then I tested a typical GPX file I had created from data on my chart plotter during a long cruise (to Isle Royale National Park in 2013):


bigDog:data jimh$ SAXCount -v=always -n -f IRNP2013TrackOnly.gpx

The output was very long and contained a list of errors. Here are some examples:


Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 2, char 90
Message: no declaration found for element 'gpx'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 2, char 90
Message: attribute 'xmlns' is not declared for element 'gpx'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 2, char 90
Message: attribute 'version' is not declared for element 'gpx'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 2, char 90
Message: attribute 'creator' is not declared for element 'gpx'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 3, char 15
Message: no declaration found for element 'metadata'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 4, char 15
Message: no declaration found for element 'time'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 5, char 21
Message: no declaration found for element 'depthunits'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 6, char 20
Message: no declaration found for element 'tempunits'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 7, char 19
Message: no declaration found for element 'sogunits'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 10, char 10
Message: no declaration found for element 'trk'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 11, char 15
Message: no declaration found for element 'name'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 12, char 17
Message: no declaration found for element 'trkseg'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 13, char 58
Message: no declaration found for element 'trkpt'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 13, char 58
Message: attribute 'lon' is not declared for element 'trkpt'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 13, char 58
Message: attribute 'lat' is not declared for element 'trkpt'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 14, char 23
Message: no declaration found for element 'time'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 15, char 28
Message: no declaration found for element 'watertemp'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 16, char 22
Message: no declaration found for element 'sog'

Error at file /Users/jimh/xerces/xerces-c-3.1.1/samples/data/IRNP2013TrackOnly.gpx, line 18, char 58
Message: no declaration found for element 'trkpt'

As you can see, something is very wrong. The parser complains about every line in the file. Any XML, XERCES, or GPX experts out there that can help?

acseatsri posted 09-22-2014 07:23 PM ET (US)     Profile for acseatsri  Send Email to acseatsri     
Not sure what you're trying to accomplish, but I convert Lowrance & Humminbird tracks and coordinates back and forth using GpsBabel without any fuss.
jimh posted 09-23-2014 12:43 AM ET (US)     Profile for jimh  Send Email to jimh     
acseatsri says:

quote:
Not sure what you are trying to accomplish...

I am trying to validate a GPX file I created. I use an XML parser called XERCES that I compiled from the source code on my MacOS 10.6.8 machine. The XERCES package compiled and installed without error, and the utility SAXcount runs fine on the sample XML file. When I run SAXcount against my GPX file, the parser finds hundreds of errors.

Complicating the testing of my installation: the sample GPX files on the GPX website are no longer available; they're all dead links.

I think the compiled package I installed is working. I am trying to figure out if if my GPX files are really not valid or if there is something awry with my XERCES installation.

acseatsri says:

quote:
...I convert Lowrance & Humminbird tracks and coordinates back and forth using GpsBabel without any fuss.

That is great, but it does not help me validate GPX files with XERCES. You ought to use GPX files. Then you would not need to bother will all the addition work of using GPSBABEL.

jimh posted 09-23-2014 01:12 AM ET (US)     Profile for jimh  Send Email to jimh     
By the way, I can only work on this problem first thing in the morning with a fresh cup of coffee. By 11 a.m. my brain is too mushy to work on Unix command line utilities.
jimh posted 09-23-2014 01:30 PM ET (US)     Profile for jimh  Send Email to jimh     
I think my problem is there is no DTD for GPX on my system. I will continue to work on this.

Post New Topic  Post Reply
Hop to:


Contact Us | RETURN to ContinuousWave Top Page

Powered by: Ultimate Bulletin Board, Freeware Version 2000
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.