Skip to content
New issue

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

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

Already on GitHub? # to your account

xlmns handling bug #12

Closed
MaRaSu opened this issue Sep 19, 2023 · 3 comments
Closed

xlmns handling bug #12

MaRaSu opened this issue Sep 19, 2023 · 3 comments

Comments

@MaRaSu
Copy link

MaRaSu commented Sep 19, 2023

GPX that is created has a bug, which is not bothering all parsers but some (e.g. Garmin Connect) which are more strict and refuse to parse it. The bug is because xlmns attribute is handled incorrectly and depending on browser (esp. Firefox) results in invalid GPX string after XML-serialization: either xlmns attribute is missing in gpx element and / or there is an extra xlmns="" attribute in other elements.

Ref old Firefox bug report that helped to find the root cause & fix: Bugzilla: xlmns dropped

Fix (I can prepare PR later if desired):

//const gpx = doc.createElement('gpx');
const gpx = createElementWithNS('gpx');
//gpx.setAttribute('xmlns', 'http://www.topografix.com/GPX/1/1');

function createElementWithNS(tagName: string): Element {
	return doc.createElementNS('http://www.topografix.com/GPX/1/1', tagName);
}

and replace all other occurrences of doc.createElement() in the code with createElementWithNS().

@dwayneparton
Copy link
Owner

Good find. Thanks for letting me know and for the docs. Should be fixed with #13

@MaRaSu
Copy link
Author

MaRaSu commented Sep 19, 2023

That was a quick PR! Thanks for creating this 0 dep gpx export library! When I run into this bug I first considered just switching to another library, but all of them seem to come with quite some dep issues or have been created for nodejs rather than browser.

@dwayneparton
Copy link
Owner

Awesome, glad to help! I was running into the exact same thing with dep issues.
Thanks again for taking the time to report. :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants