user3719857
user3719857

Reputation: 1123

White spaces are required between publicId and systemId while parsing KML document

I get this error while I try to parse a KML document:

com.bmw.cockpitm.business.backend.spec.ImportException: Error parsing KML data
at com.bmw.cockpitm.data.importers.riskmanagement.SimpleKmlDataImporter.importData(SimpleKmlDataImporter.java:120)
at com.bmw.cockpitm.jobs.ImportRiskEventsJob.execute(ImportRiskEventsJob.java:105)
at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 50; White spaces are required between publicId and systemId.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at com.bmw.cockpitm.data.importers.riskmanagement.SimpleKmlDataImporter.loadEventsData(SimpleKmlDataImporter.java:261)
at com.bmw.cockpitm.data.importers.riskmanagement.SimpleKmlDataImporter.importData(SimpleKmlDataImporter.java:100)
... 3 more

The KML document can be found here .

Most probably there is some error in the formating of the kml file, but I don't know where and what it is. Any help is welcomed.

Part of the KML:

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<description>
    The Global Disaster Alert and Coordination System provides near real-time alerts about natural disasters around the world and tools to facilitate response coordination, including news, maps and V. OSOCC. GDACS is a joint initiative of the European Commission and the United Nations.
</description>
<name>Global Disaster Alert and Coordination system</name>
<Folder>
<name><![CDATA[ Tropical Cyclone HOWARD-16]]></name>
<Placemark id='TC_1000281'>
    <name>Green Alert for  Tropical Cyclone HOWARD-16 </name>
    <extendeddata>
        <data name="eventtype">
            <value>TC</value>
        </data>
        <data name = "eventid" >
            <value>1000281</value>
        </data >
        <data name="episodeid">
            <value>8</value>
        </data>
    </extendeddata>
    <snippet></snippet>

Upvotes: 0

Views: 1626

Answers (1)

CodeMonkey
CodeMonkey

Reputation: 23748

The sample KML document is not a valid KML document. It has numerous errors which can cause various parsing errors. However, it is a well-formed XML document in that the start and end tags match and attributes are quoted.

Three types of errors are described as follows:

1. Typos

First type of error is using a wrong element name. KML elements are case sensitive. Using the wrong element will often have those elements ignored in Google Earth. XML parsers may or may not ignore these errors.

Example: `<extendeddata>` element must be renamed with `<ExtendedData>`.

2. Out of order elements

Next type of errors result from out of order elements. KML 2.2 has a strict order of elements and elements should appear in the correct sequence. This is probably the most common error found in KML files.

Example:

   <Document>
    <description>The Global Disaster Alert...</description>
    <name>Global Disaster Alert and Coordination system</name>

The <name> field must be followed by the <description> element.

3. Missing altitudeMode but specifying an altitude

LineString for example has an altitude component (e.g. 30 meters) but the altitudeMode is missing so it is assumed clampToGround by default and altitude is ignored. If want the lines to appear off the ground then must specify altitudeMode with value of either absolute or relativeToGround.

<LineString>
     <extrude>0</extrude>
     <coordinates>
       123.5,16.483,30 123.5814,16.491,30 ...
     </coordinates>
</LineString>

Recommendations

Must first validate the KML document using validator such as KML Validator or Feed Validator. There is also a command-line XML Validator tool that can validate any size KML or KMZ file. Then fix the validation errors.

Alternatively, you may want to disable schema and/or validation checking in the SAX parser.

Upvotes: 1

Related Questions