Class XercesResolver
- All Implemented Interfaces:
URIResolver
,org.apache.xerces.xni.parser.XMLEntityResolver
,LSResourceResolver
,EntityResolver
,EntityResolver2
,NamespaceResolver
Resolver
that implements Xerces XMLEntityResolver
.
This is a separate class so that the depenency on Xerces can remain optional. You must have
Xerces on your classpath to load this class, obviously. You must also explicitly configure
the underlying XMLReader
to use this resolver:
xmlReader.setProperty("http://apache.org/xml/properties/internal/entity-resolver", resolver);
This API relies on the input to the resolveEntity(XMLEntityDescription)
method to
work out what to resolve. If this API is in use, Xerces doesn't use any of the other resolver APIs.
-
Field Summary
Fields inherited from class org.xmlresolver.Resolver
config, NATURE_RELAX_NG, NATURE_XML_SCHEMA, NATURE_XML_SCHEMA_1_1, PURPOSE_SCHEMA_VALIDATION, resolver
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new XercesResolver.XercesResolver
(CatalogResolver resolver) Create a new XercesResolver with a particular catalog resolver.Create a new XercesResolver with a particular configuration. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.xerces.xni.parser.XMLInputSource
resolveEntity
(org.apache.xerces.xni.XMLResourceIdentifier resId) Resolve an entity.Methods inherited from class org.xmlresolver.Resolver
getCatalogResolver, getConfiguration, getExternalSubset, openConnection, openConnection, resolve, resolveEntity, resolveEntity, resolveNamespace, resolveResource, version
-
Constructor Details
-
XercesResolver
public XercesResolver()Create a new XercesResolver. -
XercesResolver
Create a new XercesResolver with a particular configuration.- Parameters:
config
- the configuration
-
XercesResolver
Create a new XercesResolver with a particular catalog resolver.- Parameters:
resolver
- the catalog resolver
-
-
Method Details
-
resolveEntity
public org.apache.xerces.xni.parser.XMLInputSource resolveEntity(org.apache.xerces.xni.XMLResourceIdentifier resId) Resolve an entity.How the resolver functions depends on what subclass of
XMLResourceIdentifier
is passed in:XMLDTDDescription
- Identifies an attept to load a DTD.
XMLEntityDescription
- Identifies an attept to load an entity (a parameter or general entity in the internal or external subset).
XSDDescription
- Identifies an attept to load an XML Schema.
If some other class is passed in, the method does its best. But if there are other possibilities, the code should really be extended to handle them explicitly.
For Schema lookup, it's worth noting that the behavior is slightly different depending on whether or not a "system identifier" is provided for the schema. This can occur in two different ways: if the document author provides a schema location hint, that is provided as the system identifier for the schema. If the schema being resolved is being included or imported into another schema, then the href of the xs:import or xs:include is the "system identifier".
If a schema location is provided, the method attempt to resolve it as a URI. In this case, it will not lookup the schema with its namespace. This is to prevent the case where an included or imported module is 404. If that fell back to using the namespace, you would create a loop.
If the schema location is not provided, the namespace resolver API is used to find the schema.
- Specified by:
resolveEntity
in interfaceorg.apache.xerces.xni.parser.XMLEntityResolver
- Parameters:
resId
- the resource identifier- Returns:
- a resolved source, or null if none was found
-