Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.java > #13241
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | WolfgangR <wrinnert@web.de> |
| Newsgroups | de.comp.lang.java |
| Subject | Re: Validierung GPX-Datei mit Xerces/SAX |
| Date | Mon, 22 Apr 2019 12:17:52 +0200 |
| Lines | 70 |
| Message-ID | <gi5imgF3e05U1@mid.individual.net> (permalink) |
| References | <gi5i7dF3aa6U1@mid.individual.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | individual.net TYt+hLJGhi9Z2/ed1WMVRAf93EnopMoMRxaPucds6PmVmvKmtv |
| Cancel-Lock | sha1:3Rx69nSozvqJvVsXXCbMWvDL6mY= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
| In-Reply-To | <gi5i7dF3aa6U1@mid.individual.net> |
| Content-Language | de-DE |
| Xref | csiph.com de.comp.lang.java:13241 |
Show key headers only | View raw
Hi Alle,
Beim Parsen (mit Validierung) einer gpx-Datei bekomme ich folgende
Fehlermeldung:
[Error] Current_2019.03.30.gpx:2:5: Document is invalid: no grammar found.
[Error] Current_2019.03.30.gpx:2:5: Document root element "gpx", must
match DOCTYPE root "null".
Der Anfang der gpx-Datei sieht so aus:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"
creator="eTrex 30" version="1.1"
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">
<metadata>
<link href="http://www.garmin.com">
<text>Garmin International</text>
</link>
<time>2019-03-30T09:28:09Z</time>
</metadata>
<trk>
...
</trk>
Umgebung:
Debian Testing
Openjdk 11
Der entsprechende Code lautet:
try
{
Writer out = new OutputStreamWriter( System.out );
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware( true );
SAXParser saxparser = factory.newSAXParser();
ContentHandler handler = new GarminGpxHandler( out );
XMLReader reader = saxparser.getXMLReader();
reader.setContentHandler( handler );
reader.setFeature("http://xml.org/sax/features/validation", true);
// Parse
InputSource inputSource = new InputSource( inputfile );
reader.parse(inputSource);
out.flush();
}
catch( IOException ioe ) {...}
catch( ParserConfigurationException e ) {...}
catch( SAXException e ) {...}
Meine Probleme / Fragen:
(1) Da der Garmin etrex30 einige unbenutzte und unbenutzbare
xmlns-Angaben in die Datei einfügt, musste ich sie manuell bearbeiten.
Vorher verweigerte Xerces die Arbeit.
Habe ich dabei etwas falsch gemacht?
(2) Um das Root-Element richtig zu verdauen, muss ich wohl noch eine
Änderung im Java-Code vornehmen.
Ich weiß aber nicht, wo ich eine Anleitung oder Dokumentation zur
Verarbeitung von Dokumenten finde,
deren Root-Element nicht "<xml ..." lautet.
Wolfgang R.
Back to de.comp.lang.java | Previous | Next — Previous in thread | Find similar
Validierung GPX-Datei mit Xerces/SAX WolfgangR <wrinnert@web.de> - 2019-04-22 12:09 +0200 Re: Validierung GPX-Datei mit Xerces/SAX WolfgangR <wrinnert@web.de> - 2019-04-22 12:17 +0200
csiph-web