Meine, at first glance your application schema looks like a complex feature schema (OGC SF-1 simple feature profile level 1, which we call complex features; our simple features are OGC SF-0). https://portal.opengeospatial.org/files/?artifact_id=42729
The first piece of evidence is the use of gml:CodeType, which is complex and not in the list of permitted property types for SF-0. You also have multivalued properties (also not permitted in SF-0) such as: <element maxOccurs="unbounded" minOccurs="0" name="naamNL" type="string"> You also have user-defined geometry types and I think a couple of complex property types, neither of which are permitted in SF-0. You will not be able to use a simple feature parser to parse instance documents conforming to this schema, nor represent these with a SimpleFeatureCollection. Your options are: (1) use a simple feature profile schema, that is, a new schema that, for example, uses separate properties for the typeFunctioneelGebied value and typeFunctioneelGebied_codeSpace, properties with cardinality 0 or 1, and no user-defined geometry or complex properties (2) use the complex parser used by gt-wfs-ng, which I have never used successfully. I think it still has problems parsing nested complex features: https://osgeo-org.atlassian.net/browse/GEOT-5246 https://github.com/geotools/geotools/wiki/ComplexFeature-Parsing-and-Building-Support So, the bad news is that, while GeoTools has excellent support for encoding all manner of complex GML application schemas, support for parsing complex feature instance documents is still poor and, as far as I am aware, unused by anyone. If you can get it working, please report back. Pull requests welcome. Kind regards, Ben. On 15/11/16 21:15, Meine Toonen wrote: > Hi List, > > I've been trying to parse some gml (3.2) files into a > SimpleFeatureCollection, but it fails (it returns a hashmap). I've got > the XSD's locally, but it can't seem to find the imported one (which is > the GML definition). My parser configuration: > > Hints.putSystemDefault(Hints.ENTITY_RESOLVER, NullEntityResolver.INSTANCE); > Hints.scanSystemProperties(); > > final String schemaLocation = > TOP250NLParser.class.getResource("top250nl_resolved.xsd").toString(); > Configuration topNLConfig = new > ApplicationSchemaConfiguration("http://register.geostandaarden.nl/gmlapplicatieschema/top250nl/1.2.0", > schemaLocation); > > parser = new Parser(topNLConfig); > parser.setEntityResolver( > GeoTools.getEntityResolver(GeoTools.getDefaultHints() ) ); > parser.setValidating(false); > parser.setStrict(false); > parser.setFailOnValidationError(false); > > > This local xsd > (https://github.com/mtoonen/topparser/blob/master/src/main/resources/org/geotools/xml/top250nl_resolved.xsd) > has several imports: > > <import > namespace="http://register.geostandaarden.nl/gmlapplicatieschema/brt-algemeen/1.2.0" > schemaLocation="brt-algemeen_resolved.xsd"/> > > <import namespace="http://www.opengis.net/gml/3.2" > schemaLocation="gml_resolved.xsd"/> > > > which are in the same directory > (https://github.com/mtoonen/topparser/tree/master/src/main/resources/org/geotools/xml) > as the top250nl_resolved.xsd, but it can't load them. > > The logs show: > > > org.geotools.xml TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - > startElement(http://register.geostandaarden.nl/gmlapplicatieschema/top250nl/1.2.0,FeatureCollectionT250NL,top250nl:FeatureCollectionT250NL > > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#finer:135) - No schemaLocation > found, using > 'http://register.geostandaarden.nl/gmlapplicatieschema/top250nl/1.2.0 > file:/home/meine/dev/topparser/target/classes/org/geotools/xml/top250nl_resolved.xsd > > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#fine:134) - building schema for > schema: > http://register.geostandaarden.nl/gmlapplicatieschema/top250nl/1.2.0 > > org.geotools.factory TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - ENTRY > (FilterFactory, FILTER_FACTORY) > > org.geotools.factory TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - CHECK > (FilterFactory, FILTER_FACTORY): user provided a Class. > > org.geotools.factory TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - CHECK > (FilterFactory, FILTER_FACTORY): consider hint[last] FilterFactory2. > > org.geotools.util TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - Rehash from 7 to 13 > > org.geotools.resources DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#finer:135) - Loaded resources > for English from bundle "org.geotools.resources.i18n". > > org.geotools.factory INFO 08:58:00 > (org.geotools.util.logging.CommonsLogger#config:133) - Factory > implementations for category FilterFactory: > > org.geotools.filter.FilterFactoryImpl > > org.geotools.factory TRACE 08:58:00 > (org.geotools.util.logging.CommonsLogger#finest:136) - RETURN > (FilterFactory, FILTER_FACTORY): found implementation FilterFactoryImpl. > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#fine:134) - Could not locate > schema for: gml_resolved.xsd. > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#fine:134) - building schema for > schema: http://www.w3.org/1999/xlink > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#fine:134) - Could not locate > schema for: brt-algemeen_resolved.xsd. > > org.geotools.xml DEBUG 08:58:00 > (org.geotools.util.logging.CommonsLogger#fine:134) - Could not locate > schema for: gml_resolved.xsd. > > > The xml which I'm trying to parse: > https://github.com/mtoonen/topparser/blob/master/src/test/resources/org/geotools/xml/FunctioneelGebied.xml > > > > Any ideas? I wound up debugging the locating/resolving of the xsd's, but > that was /somewhat/ complex and I wound up getting lost. > > Fun fact: when I used the org.geotools.gml3.v3_2.GMLConfiguration > configuration, it returned a SimpleFeatureCollection (because it could > find the shipped XSD for gml 3.2). But it doesn't know how to interpret > parts of the features (ie. things from my own schema). > > Any help would be greatly appreciated! > > Regards, > > Meine > > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > GeoTools-GT2-Users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- Ben Caradoc-Davies <[email protected]> Director Transient Software Limited <http://transient.nz/> New Zealand ------------------------------------------------------------------------------ _______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
