public interface XSDSchemaLocationResolver
schema locations
.
When the schema location of an schema directive needs to be resolved,
each containing schema
will be inspected
for an adapter that implements this interface.
As such, you can register an adapter factory like this to tailor the algorithm used to resolve a schema location:
ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getAdapterFactories().add (new AdapterFactoryImpl() { class Resolver extends AdapterImpl implements XSDSchemaLocationResolver { public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI) { return XSDConstants.resolveSchemaLocation(xsdSchema.getSchemaLocation(), namespaceURI, schemaLocationURI); } public boolean isAdapterForType(Object type) { return type == XSDSchemaLocationResolver.class; } } protected Resolver resolver = new Resolver(); public boolean isFactoryForType(Object type) { return type == XSDSchemaLocationResolver.class; } public Adapter adaptNew(Notifier target, Object type) { return resolver; } });
Modifier and Type | Method and Description |
---|---|
java.lang.String |
resolveSchemaLocation(XSDSchema xsdSchema,
java.lang.String namespaceURI,
java.lang.String schemaLocationURI)
Resolve the namespace and schema location relative to the given base schema's location.
|
java.lang.String resolveSchemaLocation(XSDSchema xsdSchema, java.lang.String namespaceURI, java.lang.String schemaLocationURI)
resolveSchemaLocation (xsdSchema, // xsdSchema.getSchemaLocation() == "http://www.example.com/A/a.xsd" "http://www.example.com/B", "../B/b.xsd");would normally yield
"http://www.example.com/B/b.xsd"When no namespace schema location is provided, the namespace itself will be used.
xsdSchema
- the schema containing the referencenamespaceURI
- the namespace being resolved, i.e., XSDImport.getNamespace()
.schemaLocationURI
- the suggested location of the namespace being resolved, i.e., XSDSchemaDirective.getSchemaLocation()
.XSDConstants.resolveSchemaLocation(String,String,String)