-4

My GPX tracks¹ start with

<?xml version="1.0"?>
<gpx xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" version="1.1" creator="http://www.delorme.com" xmlns="http://www.topografix.com/GPX/1/1">
  <trk>

and end with </trk> with no </gpx> anywhere.

I am pretty sure there are no practical drawbacks to this, but what might be the benefit of "fixing" it in thousands of files?

¹Several years of hiking and biking.

WGroleau
  • 448
  • 1
  • 9
  • 26
  • Just append `` to the end of each file? Takes one line of Bash. If that's too much trouble, and you're not having any practical problem, then just don't do it.... Please refine your question a little so as to make it actionable and describe the problem(s) you face, either with the files as they are or with the attempts to fix them. – Lightness Races in Orbit Aug 18 '19 at 16:03
  • The benefit would presumably be that your code would work. What am I missing? – peeebeee Aug 18 '19 at 16:06
  • 1
    Possible duplicate of [How to parse invalid (bad / not well-formed) XML?](https://stackoverflow.com/questions/44765194/how-to-parse-invalid-bad-not-well-formed-xml) – Progman Aug 18 '19 at 16:09
  • Not a duplicate and I realize the effort is trivial (far easier than it was to actually obtain the files). Nor do I currently have _any_ problems with them myself. There are no hidden meanings in the question as asked. Just curious. – WGroleau Aug 18 '19 at 16:16
  • 1
    Then I'm afraid it's not actionable. We can't fix a problem that hasn't occurred, nor can we predict what problems you might have in the future with the level of detail/context provided. Good luck! – Lightness Races in Orbit Aug 18 '19 at 16:17
  • Define “actionable”? – WGroleau Aug 18 '19 at 16:17
  • https://www.merriam-webster.com/dictionary/actionable – Lightness Races in Orbit Aug 18 '19 at 16:17
  • Is that relevant? It’s certainly answerable. I could answer “there is no possible benefit” but I don’t know whether that would be a correct answer. – WGroleau Aug 18 '19 at 16:19
  • I didn’t ask for a fix to a problem. I asked what benefit there might be to fixing what a purist might consider a problem. – WGroleau Aug 18 '19 at 16:21
  • This website is for fixing problems, and we cannot magically see into the future, so we're back to my original comment. I'll put it as an answer for you. Have a good day. – Lightness Races in Orbit Aug 18 '19 at 16:22

2 Answers2

1

The benefit would be that any program reading these files that failed to do so before due to their ill-formity, would now do so.

It is impossible for us to predict what software you might use in the future, or what level of compatibility with ill-formed files said software might have, so that is literally (and obviously) as detailed as we can be.

But, does it matter? It's one line of Bash to fix these files. If you're concerned about your future with these files, simply append </gpx> to each one then move on to real problems.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
1

The benefit to making your "XML" be well-formed is that then anyone wishing to process your data will be able to use standards-based XML tools to do so. Without your textual data being well-formed XML, it's a non-standard format, its resemblance to XML notwithstanding.

There are many editors, parsing libraries, schema validation processors, transformation languages, etc, which become available if you fix your "XML".

See also How to parse invalid (bad / not well-formed) XML?

kjhughes
  • 106,133
  • 27
  • 181
  • 240