Package org.geotools.xsd
Class SchemaLocationResolver
- Object
-
- SchemaLocationResolver
-
- All Implemented Interfaces:
XSDSchemaLocationResolver
- Direct Known Subclasses:
AppSchemaLocationResolver
public class SchemaLocationResolver extends Object implements XSDSchemaLocationResolver
Resolves a physical schema location from a namespace uri.This class works from a
XSDinstance from which it resolves location on disk relative to.Example usage:
XSD xsd = ... String namespaceURI = xsd.getNamesapceURI(); SchemaLocationResolver resolver = new SchemaLocationResolver( xsd ); String schemaLocation = locator.resolveSchemaLocation( null, namespaceURI, "mySchema.xsd" );- Author:
- Justin Deoliveira, The Open Planning Project
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]lookupDirectoriesA list of locations to use as prefixes when looking up schema files.protected XSDxsdthe xsd instance
-
Constructor Summary
Constructors Constructor Description SchemaLocationResolver(XSD xsd)Creates the new schema location resolver.SchemaLocationResolver(XSD xsd, String... lookupDirectories)Creates the new schema location resolver specifying additional directories to locate schema files in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanHandle(XSDSchema schema, String uri, String location)Determines if the locator can resolve the schema location for a particular namespace uri and schema location.StringresolveSchemaLocation(XSDSchema schema, String uri, String location)Resolves location to a physical location.StringtoString()
-
-
-
Constructor Detail
-
SchemaLocationResolver
public SchemaLocationResolver(XSD xsd)
Creates the new schema location resolver.- Parameters:
xsd- The xsd to resolve filenames relative to.
-
SchemaLocationResolver
public SchemaLocationResolver(XSD xsd, String... lookupDirectories)
Creates the new schema location resolver specifying additional directories to locate schema files in.The lookupDirectories parameter should be used in cases where a main schema imports or includes files from sub directories. Consider the following schema file structure:
main.xsd dir1/ include1.xsd dir2/ include2.xsdThe constructor would be called with:new SchemaLocationResolver(this,"include1","include2");
- Parameters:
xsd- The xsd to resolve files relative to.lookupDirectories- Additional lookup directories relative to the xsd to lookup files in.
-
-
Method Detail
-
canHandle
public boolean canHandle(XSDSchema schema, String uri, String location)Determines if the locator can resolve the schema location for a particular namespace uri and schema location.- Returns:
- true if it can handle, otherwise false.
-
resolveSchemaLocation
public String resolveSchemaLocation(XSDSchema schema, String uri, String location)
Resolves location to a physical location.Resolution is performed by stripping the filename off of location and looking up a resource located in the same package as the xsd.
- Specified by:
resolveSchemaLocationin interfaceXSDSchemaLocationResolver
-
-