Opened 16 years ago

Last modified 12 years ago

#2724 closed enhancement

Validate GPX — at Version 5

Reported by: hampelratte Owned by: team
Priority: minor Milestone:
Component: Core Version:
Keywords: gpx Cc: hampelratte

Description (last modified by Manu1400)

I have created a patch, which enables validation of GPX files, when they are imported. If an error occurs, a JOptionPane pops up with details from the parser (line, column and error msg).
This shall encourage developers of other software to make their software GPX compliant and inform JOSM users, that it's not JOSM fault, that a file can't be read.

Change History (6)

by hampelratte, 16 years ago

Attachment: validate_gpx.diff.gz added

comment:1 by stoecker, 16 years ago

Summary: [PATCH] Validate GPXValidate GPX

A serious problem of this patch is, that files previously opening fine now fail to load, e.g. this example form another bug report.

<?xml version='1.0' encoding='UTF-8'?>
<gpx version='1.1' creator='GPSMID' xmlns='http://www.topografix.com/GPX/1/1'>
<wpt lat='50.10123' lon='14.475168'>
<name>Waypoint 1</name>
<time>2009-05-26T05:09:28Z</time>
</wpt>
</gpx>

Whereas warning the user about defect files is a nice idea enforcing standards behaviour is not.

In its current form I will not apply this patch.

comment:2 by hampelratte, 16 years ago

Enabling another parser feature:

factory.setFeature("http://apache.org/xml/features/validation/dynamic", true);

enables the parsing only for files, which specify a grammar (schema or dtd).

comment:3 by stoecker, 16 years ago

This means removing that line fixes the problem?

comment:4 by hampelratte, 16 years ago

Not removing, but adding this line fixes the problem with the example you posted, because it doesn't specify a schema nor a dtd. So no validation will be done. Invalid files, which specify a dtd or a schema will still fail with an error message.

comment:5 by Manu1400, 12 years ago

Description: modified (diff)
Keywords: gpx added
Note: See TracTickets for help on using tickets.