Datastore factory for gml datastore.
Usage
When creating an instance of the datastore, the
GMLDataStoreFactory.LOCATION parameter must
be specified.
GMLDataStoreFactory factory = new GMLDataStoreFactory();
Map params = new HashMap();
params.put( GMLDataStoreFactory.LOCATION, "instanceDocument.xml" );
GMLDataStore dataStore = factory.createDataStore( params );
Creating a datastore with only the location parameter causes the datastore to deduce
all the information about the schema from the instance document directly. Which means
the schemaLocation must be properly specifed in the instance document. As this is not
always the case, there are ways to specify information about the schema to the datastore.
- Specifying the targetNamespace and schemaLocation directly.
- Specifying a
org.geotools.xml.Configuration
Target namespace and Schema Location
GMLDataStoreFactory factory = new GMLDataStoreFactory();
Map params = new HashMap();
params.put( GMLDataStoreFactory.LOCATION, "instanceDocument.xml" );
params.put( GMLDataStoreFactory.NAMESPACE, "http://myApplicationSchemaNamespaceUri" );
params.put( GMLDataStoreFactory.SCHEMALOCATION, "/path/to/applicationSchema.xsd" );
GMLDataStore dataStore = factory.createDataStore( params );
Configuration
A
org.geotools.xml.Configuration is used to specify information about a schema and
configure the xml parser to parse instances of the schema. The
org.geotools.gml3.ApplicationSchemaConfiguration is a subclass that can be extented
in order to create a configuration specific to an application schema:
class MyApplictionSchemaConfiguration extends ApplicationSchemaConfiguration {
public MyApplicationSchema() {
super( "http://myApplicationSchemaNamespaceUri", "/path/to/applicationSchema.xsd" );
}
}
The class of the application schema can then be supplied with the
GMLDataStoreFactory.CONFIGURATION paramter:
GMLDataStoreFactory factory = new GMLDataStoreFactory();
Map params = new HashMap();
params.put( GMLDataStoreFactory.LOCATION, "instanceDocument.xml" );
params.put( GMLDataStoreFactory.CONFIGURATION, MyApplicationSchemaConfiguration.class );
GMLDataStore dataStore = factory.createDataStore( params );
It is important to note that when using the CONFIGURATION parameter the configuration class
must have a no-argument constructor.
TODO: document support for application schema defined types
author: Justin Deoliveira, The Open Planning Project |