App-Schema ---------- The app-schema module allows you to configure geotools to support a predefined application schema (as provided by a standards body). References: * `Geoserver docs `_ * `tut_RoadSegment `_ Configuration ^^^^^^^^^^^^^ Much of the provided documentation is expressed in terms of use from GeoServer; however the general approach of starting with a target XSD file and producing a mapping.xml document remains the same. 1. The following code example can be used to load a mapping.xml file:: // pending 2. One thing that is interesting is the requirement to have your features sources available in a Registry (for the mapping file to look them up and find them).:: // pending 3. In this case the source data is provided by a properties file:: _=the_geom:LineString,FID:String,NAME:String,fromNode:Point,toNode:Point RoadSegments.1=LINESTRING (-0.0042 -0.0006, -0.0032 -0.0003, -0.0026 -0.0001, -0.0014 0.0002, 0.0002 0.0007)|102|Route 5|POINT(-0.0042 -0.0006)|POINT(0.0002 0.0007) RoadSegments.2=LINESTRING (0.0002 0.0007, 0.0014 0.001, 0.0028 0.0014)|103|Route 5|POINT(0.0002 0.0007)|POINT(0.0028 0.0014) RoadSegments.3=LINESTRING (0.0028 0.0014, 0.003 0.0024)|104|Route 5|POINT(0.0028 0.0014)|POINT(0.003 0.0024) RoadSegments.4=LINESTRING (0.0002 0.0007, 0.0014 0.001, 0.0028 0.0014, 0.0042 0.0018)|105|Main Street|POINT(0.0002 0.0007)|POINT(0.0042 0.0018) RoadSegments.5=LINESTRING (-0.0014 -0.0024, -0.0014 0.0002)|106|Dirt Road by Green Forest|POINT(-0.0014 -0.0024)|POINT(-0.0014 0.0002) Target XSD '''''''''' As indicated you need to have a target XML schema in mind before starting your mapping.:: Mapping File '''''''''''' The mapping file goes through the steps of mapping types and attributes in the target XSD through to features sources provided at the geotools level. Here is an example mapping file:: tuthttp://example.org gmlhttp://www.opengis.net/gml directory1 directory file:./ RoadSegment.xsd directory1 tut_RoadSegment tut:RoadSegment RoadSegment getId() RoadSegment/gml:name codeSpace 'urn:x-test:classifierScheme:TestAuthority:SDI:transport:v1' FID RoadSegment/tut:name NAME RoadSegment/tut:fromToNodes FID RoadSegment/tut:fromToNodes/tut:fromNode fromNode RoadSegment/tut:fromToNodes/tut:toNode toNode RoadSegment/tut:the_geom the_geom App-Schema-Resolver ^^^^^^^^^^^^^^^^^^^ The app-schema resolver allows you to bundle schema files into jars (rather then have your application resort the the internet every time). The codebase also appears to support caching of schema information. References: * `App-Schema Geoserver Docs `_ Code Example '''''''''''' From test case:: Configuration configuration = new AppSchemaConfiguration("urn:cgi:xmlns:CGI:GeoSciML:2.0", "http://www.geosciml.org/geosciml/2.0/xsd/geosciml.xsd", new AppSchemaResolver()); SchemaIndex schemaIndex = Schemas.findSchemas(configuration); Assert.assertEquals(3, schemaIndex.getSchemas().length); String schemaLocation = schemaIndex.getSchemas()[0].getSchemaLocation(); Assert.assertTrue(schemaLocation.startsWith("jar:file:")); Assert.assertTrue(schemaLocation.endsWith("geosciml.xsd"));