Skip to content

Instantly share code, notes, and snippets.

@FiV0
Last active January 5, 2025 21:41
Show Gist options
  • Save FiV0/91098e483ab993a3ef2293c12bd60afc to your computer and use it in GitHub Desktop.
Save FiV0/91098e483ab993a3ef2293c12bd60afc to your computer and use it in GitHub Desktop.
Geotools XML parsing issue
org.xml.sax.SAXParseException; systemId: http://repository.gdi-de.org/schemas/adv/citygml/1.0/cityGMLBaseLoD1.xsd; lineNumber: 1; columnNumber: 1; Premature end of file.
java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: http://repository.gdi-de.org/schemas/adv/citygml/1.0/cityGMLBaseLoD1.xsd; lineNumber: 1; columnNumber: 1; Premature end of file.
at org.example.LibraryTest.parseXSDFile(LibraryTest.java:362)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
@Test
public void parsingGeoFileTest() {
Parser parser = new Parser(new XMLConfiguration());
File file = new File( "/path/to/above/test.xml");
try {
parser.parse(new FileInputStream(file));
} catch (IOException | SAXException | ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
@Test
public void parseXSDFile() {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "file,http");
String schemaDir = "schema-catalog";
schemaFactory.setResourceResolver(new CachingResourceResolver(Path.of(schemaDir)));
// Parse the schema
File file = new File(schemaDir, "buildingLoD1.xsd");
// Downloading the erroring schema via for example wget and parsing it works
// File file = new File(schemaDir, "cityGMLBaseLoD1.xsd");
schemaFactory.newSchema(file);
} catch (SAXException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<core:CityModel xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:bldg="http://www.opengis.net/citygml/building/1.0" xmlns:gml="http://www.opengis.net/gml" xmlns:core="http://www.opengis.net/citygml/1.0" xmlns:gen="http://www.opengis.net/citygml/generics/1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0 http://schemas.opengis.net/citygml/xAL/xAL.xsd http://www.opengis.net/citygml/building/1.0 http://repository.gdi-de.org/schemas/adv/citygml/building/1.0/buildingLoD1.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd http://www.opengis.net/citygml/1.0 http://repository.gdi-de.org/schemas/adv/citygml/1.0/cityGMLBaseLoD1.xsd http://www.opengis.net/citygml/generics/1.0 http://repository.gdi-de.org/schemas/adv/citygml/generics/1.0/genericsLoD1.xsd http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink.xsd">
<gml:name>LoD1_390_5820_1_BE</gml:name>
<gml:boundedBy>
<gml:Envelope srsName="urn:adv:crs:ETRS89_UTM33*DE_DHHN2016_NH">
<gml:lowerCorner srsDimension="3">390000.0 5820000.0 30.83</gml:lowerCorner>
<gml:upperCorner srsDimension="3">391000.0 5821000.0 119.039</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<core:cityObjectMember>
<bldg:Building gml:id="DEBE01YYK0001xAr">
<core:creationDate>2019-03-02</core:creationDate>
<core:externalReference>
<core:informationSystem>http://repository.gdi-de.org/schemas/adv/citygml/fdv/art.htm#_9100</core:informationSystem>
<core:externalObject>
<core:name>DEBE01YYK0001xAr</core:name>
</core:externalObject>
</core:externalReference>
<gen:stringAttribute name="Gemeindeschluessel">
<gen:value>11000001</gen:value>
</gen:stringAttribute>
<gen:stringAttribute name="DatenquelleDachhoehe">
<gen:value>1000</gen:value>
</gen:stringAttribute>
<gen:stringAttribute name="BezugspunktDach">
<gen:value>2200</gen:value>
</gen:stringAttribute>
<gen:stringAttribute name="DatenquelleLage">
<gen:value>1000</gen:value>
</gen:stringAttribute>
<gen:stringAttribute name="DatenquelleBodenhoehe">
<gen:value>1400</gen:value>
</gen:stringAttribute>
<bldg:function>51009_1610</bldg:function>
<bldg:measuredHeight uom="urn:adv:uom:m">0.778</bldg:measuredHeight>
<bldg:storeysAboveGround>0</bldg:storeysAboveGround>
<bldg:lod1Solid>
<gml:Solid>
<gml:exterior>
<gml:CompositeSurface>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390692.46 5820842.066 35.62 390692.768 5820841.385 35.62 390692.962 5820835.587 35.62 390694.656 5820835.718 35.62 390694.155 5820842.196 35.62 390692.46 5820842.066 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390692.46 5820842.066 34.842 390694.155 5820842.196 34.842 390694.656 5820835.718 34.842 390692.962 5820835.587 34.842 390692.768 5820841.385 34.842 390692.46 5820842.066 34.842</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390694.155 5820842.196 35.62 390694.155 5820842.196 34.842 390692.46 5820842.066 34.842 390692.46 5820842.066 35.62 390694.155 5820842.196 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390694.656 5820835.718 35.62 390694.656 5820835.718 34.842 390694.155 5820842.196 34.842 390694.155 5820842.196 35.62 390694.656 5820835.718 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390692.962 5820835.587 35.62 390692.962 5820835.587 34.842 390694.656 5820835.718 34.842 390694.656 5820835.718 35.62 390692.962 5820835.587 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390692.768 5820841.385 35.62 390692.768 5820841.385 34.842 390692.962 5820835.587 34.842 390692.962 5820835.587 35.62 390692.768 5820841.385 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="3">390692.46 5820842.066 35.62 390692.46 5820842.066 34.842 390692.768 5820841.385 34.842 390692.768 5820841.385 35.62 390692.46 5820842.066 35.62</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
</gml:CompositeSurface>
</gml:exterior>
</gml:Solid>
</bldg:lod1Solid>
</bldg:Building>
</core:cityObjectMember>
</core:CityModel>
INFO: http://repository.gdi-de.org/schemas/adv/citygml/building/1.0/buildingLoD1.xsd
Jan 05, 2025 10:29:52 PM org.geotools.xsd.impl.ParserHandler loadSchemas
WARNING: Error loading schema for namespace: http://www.opengis.net/citygml/building/1.0 at location: http://repository.gdi-de.org/schemas/adv/citygml/building/1.0/buildingLoD1.xsd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment