org.geotools.xml
Class SchemaLocationResolver

Object
  extended by SchemaLocationResolver
All Implemented Interfaces:
XSDSchemaLocationResolver

public class SchemaLocationResolver
extends Object
implements XSDSchemaLocationResolver

Resolves a physical schema location from a namespace uri.

This class works from a XSD instance 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
protected  XSD xsd
          the xsd instance
 
Constructor Summary
SchemaLocationResolver(XSD xsd)
          Creates the new schema location resolver.
 
Method Summary
 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.
 String resolveSchemaLocation(XSDSchema schema, String uri, String location)
          Resolves location to a physical location.
 String toString()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xsd

protected XSD xsd
the xsd instance

Constructor Detail

SchemaLocationResolver

public SchemaLocationResolver(XSD xsd)
Creates the new schema location resolver.

Parameters:
xsd - The xsd to resolve filenames relative to.
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:
resolveSchemaLocation in interface XSDSchemaLocationResolver

toString

public String toString()
Overrides:
toString in class Object


Copyright © 1996-2009 Geotools. All Rights Reserved.