Repository navigation
Conversation
Strip the topografix GPX namespace from element tags after building the element tree, so documents like <ns2:gpx> parse the same as documents using the default namespace. Elements in other namespaces (extensions) keep their qualified names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #242.
gpxpy/parser.pynow removes the GPX 1.0 and GPX 1.1 namespaces from element tags after it builds the element tree. A document that bindshttp://www.topografix.com/GPX/1/1to a prefix then parses like a document that uses it as the default namespace. Polar Access Manager writes files like this:Before this change, a prefixed root failed with
GPXException: Document must have a `gpx` root node.. Prefixed children under an unprefixed root parsed with no tracks, becausefind('trk')does not match{http://www.topografix.com/GPX/1/1}trk.Elements in other namespaces (extensions) keep their qualified names, so
nsmapand theto_xml()round trip do not change.notok.gpxfrom the issue zip now parses with its track, points, metadata and heart-rate extension.ok.gpxgives the same result as before.test.pyaddstest_with_prefixed_gpx_namespace(prefixed root and children, with an extension and ato_xml()round trip) andtest_with_prefixed_gpx_elements(unprefixed root, prefixed children). Both fail without the change and pass with it.One judgement call: Topografix-namespaced elements inside
<extensions>also become unqualified. They are GPX elements, andto_xml()writes them under the GPX default namespace. If you prefer to keep extension content as it is, I can limit the change to elements outside<extensions>.