Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to override xsi:schemaLocation for custom extensions schema #141

Merged
merged 6 commits into from
Sep 16, 2018

Conversation

ufranske
Copy link
Contributor

@ufranske ufranske commented Sep 10, 2018

Added the ability to set schemaLocation explicitly in a GPX object. This is done to support custom schemas for extensions when generating xml (for example, http://developer.garmin.com/downloads/connect-api/sample_file.gpx)

gpx = gpxpy.GPX()
gpx.schema_locations = [
    'http://www.topografix.com/GPX/1/1',
    'http://www.topografix.com/GPX/1/1/gpx.xsd',
    'http://www.garmin.com/xmlschemas/GpxExtensions/v3',
    'http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd',
]

@coveralls
Copy link

coveralls commented Sep 10, 2018

Coverage Status

Coverage increased (+0.2%) to 85.506% when pulling 97584f7 on ufranske:custom_schemaloc_support into 1f344e9 on tkrajina:master.

@Zverik
Copy link

Zverik commented Sep 10, 2018

Why schemaLocations is a space-separated string and not a list/tuple?

gpxpy/parser.py Outdated
@@ -102,7 +102,7 @@ def parse(self, version=None):
schema_loc = mod_re.search(r'\sxsi:schemaLocation="[^"]+"', self.xml)
if schema_loc:
_, _, value = schema_loc.group(0).partition('=')
self.gpx.schema_locations = value.strip('"')
self.gpx.schema_locations = value.strip('"').split(' ')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case there are multiple spaces, maybe use a simple no-argument split()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@tkrajina
Copy link
Owner

Good idea @ufranske and thanks @Zverik for your help. I'll probably merge this PR this weekend when I find a few minutes to go through it.

@tkrajina tkrajina merged commit 97584f7 into tkrajina:master Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants