Re: [Gpsbabel-code] gpx writer
Brought to you by:
robertl
From: Robert L. <rob...@gp...> - 2013-03-11 01:58:29
|
On Sun, Mar 10, 2013 at 11:06 AM, tsteven4 <tst...@gm...> wrote: > Hi Robert, > > Hope the foot is coming along. > Thanx. It's not been very awesome so far, but that's kind of the rule of surgery - you take a beating for a while in the hope that it'll ultimately make things better. > // Our Pre-Qt XML writer would write >> // <trkpt lat=X lon=Y> >> // </trkpt> >> // even thogh <trkpt lat=X lon=Y /> is more compact and legal (assuming >> there >> // are no child tags, of course. This is to bridge our exsiting test >> suite >> > I am happy with this validation for our reference files, but if users want > to do comparison with the old and new output the will be on their own. In > my opinion it is better to move forward and clean up the gpx formatting by > not forcing things with QXmlStreamWriter. > I'd hoped that xmllint would do convert to self-closing tags, but I can't seem to make that work out. It's a little self-referential, but another option to RegEx toture is to just make our own "pretty printer" using Qt. The one below reads argv[1] and writes argv[2] for safety, but that's easy to change either in the code or with a shell wrapper. This has the moral problem that we'd be tuning our reference to match Qt's serializer but since it should all be things like whitespace changes, excess trailing zeros, and changing to self-closing tags that are trivially inspectable with diff (or whatever) before applying, that might not be too bad. c++ -I/usr/include -framework QtCore -framework QtXml pp3.cc -o pp3 Press ENTER or type command to continue #include <QtCore/QCoreApplication> #include <QtCore/QFile> #include <QtCore/QStringList> #include <QtCore/QTextStream> #include <QtXml/QDomDocument> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QString xmlIn(QCoreApplication::arguments().at(1)); QString xmlOut(QCoreApplication::arguments().at(2)); QFile inFile(xmlIn); QFile outFile(xmlOut); inFile.open(inFile.Text | inFile.ReadOnly); outFile.open(outFile.Text | outFile.WriteOnly); QDomDocument input; input.setContent(&inFile); QDomDocument output(input); QTextStream stream(&outFile); output.save(stream, 2); } Just let me know which part of this you're tackling so we don't run into each other. |