Closed lorenh closed 4 years ago
Not at the top level; the only place where you have an opportunity to inject custom stuff like that is when we go to write out the children of <extensions>
elements.
Essentially, you'd make a subclass of GpxExtensionWriter
, override what you need, and provide an instance of it for your GpxWriterSettings.ExtensionWriter
. The namespaces of your XElement
instances should get written out correctly if necessary, though I think it will wind up writing out the same xmlns:foo
declaration on every single place where it's used, and I'm not 100% sure off the top of my head if it's going to pick the namespace prefix you want it to.
OK, that's what I thought. Technically speaking the XML namespace declaration should be interpreted by the XML parser the same whether it's at the top or duplicated on each element. I was just trying to match a spec given to me. Now I know I can't do it quite the way they want. Hopefully this will be sufficient. But keep it in mind if you are ever in there tinkering with this area in case some way to customize things like this pops into your head.
I wouldn't mind adding the option to accept a list of namespace / prefix pairs in GpxWriterSettings
, if for no other reason than to shrink the output for these cases.
OK, I guess I'd like that feature added when you get around to it.
I created a pull request with one way you could achieve this, I'm sure you can improve on it.
https://github.com/NetTopologySuite/NetTopologySuite.IO.GPX/pull/37
Still curious if this is on a roadmap for a future release? I'd love to abandon using the custom package I built.
Yes -- I'm focusing most of my free time on the NTS v2 upgrades, so this is going to be a while.
I updated the PR for this to merge cleanly into 1.0 branch in case you ever get around to it. Again, I'd love to abandon using my custom package.
Resolved by #37, but I'm going to see if I can make it any better before releasing a 1.1.0 that includes it.
1.1.0 is on NuGet with the most important fix for this. I'll open a new issue to track parsing out existing namespaces on read for the sake of a better round-trip.
Is injecting a custom namespace similar to the following possible when writing a GPX with this library?