Jump to content


Photo

Validating GPX


  • Please log in to reply
7 replies to this topic

#1 Jose Lozano

Jose Lozano

    Member

  • Members
  • PipPip
  • 3 posts

Posted 15 April 2008 - 07:50 AM

Hi everybody,
I've been working with GPX for a month so far and I manage to validate my GPX files against the schema. However, as you probably now, this schema has the <extensions> tag to extend the funcionality. Well, what I need is to validate that part against my own schema. I'm using Java. I thought already about forming another xml document pasting all those parts inside the "extensions" tags together, but I'm sure there must be a better way.
Thanks in advance!

#2 Dan Foster

Dan Foster

    Author of ExpertGPS and EasyGPS

  • TopoGrafix
  • PipPipPip
  • 2,684 posts
  • Gender:Male
  • Location:Stow, MA, USA
  • Interests:Writing GPS Software!
  • geocaching.com username:topografix

Posted 15 April 2008 - 09:44 AM

http://www.topografi..._validation.asp

#3 Jose Lozano

Jose Lozano

    Member

  • Members
  • PipPip
  • 3 posts

Posted 15 April 2008 - 10:51 AM

http://www.topografi..._validation.asp



Yep, I know that site. As I said, I managed to validate against the GPX schema. What I need now is to validate the fragments inside the <extensions> </extensions> tags against a different schema. I was asking just in case anyone knows any java library to do this, or has sample code.

Thanks!

#4 Dan Foster

Dan Foster

    Author of ExpertGPS and EasyGPS

  • TopoGrafix
  • PipPipPip
  • 2,684 posts
  • Gender:Male
  • Location:Stow, MA, USA
  • Interests:Writing GPS Software!
  • geocaching.com username:topografix

Posted 15 April 2008 - 03:23 PM

If you use another schema inside <extensions>, you need to declare that schema and namespace in the top of the GPX file. The SAXCount validation described in the link above will then validate your GPX document against both the GPX 1.1 schema and your extension schema.

I don't know of a Java way to do this, but the MSXML parser has an option to validate on open.

#5 Jose Lozano

Jose Lozano

    Member

  • Members
  • PipPip
  • 3 posts

Posted 16 April 2008 - 04:25 AM

If you use another schema inside <extensions>, you need to declare that schema and namespace in the top of the GPX file. The SAXCount validation described in the link above will then validate your GPX document against both the GPX 1.1 schema and your extension schema.

I don't know of a Java way to do this, but the MSXML parser has an option to validate on open.




I've tried that already. That command-line tool validates only against the GPX schema. If I deliberately change tags inside <extensions> it says it's correct; meaning it is not validating that part against the second schema.

Anyway, I'm just taking those fragments away and pasting them into another document, a pity cause I think it's a quite bad solution, but still... at least it works hehe.

Thanks a lot Dan for your answers.

#6 Dan Foster

Dan Foster

    Author of ExpertGPS and EasyGPS

  • TopoGrafix
  • PipPipPip
  • 2,684 posts
  • Gender:Male
  • Location:Stow, MA, USA
  • Interests:Writing GPS Software!
  • geocaching.com username:topografix

Posted 16 April 2008 - 08:47 AM

Then you are doing something wrong, because I use SAXCount to validate GPX against three different included schemas, and I've caught many errors in <extensions> this way. Sorry I can't be more helpful, but this method DOES work if your schemas are all declared correctly at the top of the GPX file.

#7 Jason S

Jason S

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 18 April 2008 - 08:40 AM

I've tried that already. That command-line tool validates only against the GPX schema. If I deliberately change tags inside <extensions> it says it's correct; meaning it is not validating that part against the second schema.

Hmm. Let me try something (if I have time :unsure: ); MSXML is useable through COM/ActiveX and I've used it successfully though not yet with multiple namespaces.

#8 Jason S

Jason S

    Advanced Member

  • Members
  • PipPipPip
  • 87 posts

Posted 04 December 2008 - 08:24 PM

did you find a way to do this? i've been doing some java xml development recently & the o'reilly book on the subject mentions the "xmllint" program available at http://xmlsoft.org/downloads.html




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users