Package org.apache.solr.util
Class SystemIdResolver
java.lang.Object
org.apache.solr.util.SystemIdResolver
- All Implemented Interfaces:
EntityResolver,EntityResolver2
This is a helper class to support resolving of XIncludes or other hrefs inside XML files on top
of a
ResourceLoader. Just plug this class on top of a ResourceLoader and pass it
as EntityResolver to SAX parsers or via wrapper methods as URIResolver to XSL
transformers or XMLResolver to STAX parsers. The resolver handles special SystemIds with
an URI scheme of solrres: that point to resources. To produce such systemIds when you
initially call the parser, use createSystemIdFromResourceName(java.lang.String) which produces a SystemId
that can be included along the InputStream coming from ResourceLoader.openResource(java.lang.String).
In general create the InputSource to be passed to the parser like:
InputSource is = new InputSource(loader.openSchema(name)); is.setSystemId(SystemIdResolver.createSystemIdFromResourceName(name)); final DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); db.setEntityResolver(new SystemIdResolver(loader)); Document doc = db.parse(is);
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetExternalSubset(String name, String baseURI) resolveEntity(String publicId, String systemId) resolveEntity(String name, String publicId, String baseURI, String systemId)
-
Field Details
-
RESOURCE_LOADER_URI_SCHEME
- See Also:
-
RESOURCE_LOADER_AUTHORITY_ABSOLUTE
- See Also:
-
-
Constructor Details
-
SystemIdResolver
public SystemIdResolver(org.apache.lucene.util.ResourceLoader loader)
-
-
Method Details
-
asEntityResolver
-
asURIResolver
-
asXMLResolver
-
getExternalSubset
- Specified by:
getExternalSubsetin interfaceEntityResolver2
-
resolveEntity
public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws IOException - Specified by:
resolveEntityin interfaceEntityResolver2- Throws:
IOException
-
resolveEntity
- Specified by:
resolveEntityin interfaceEntityResolver- Throws:
IOException
-
createSystemIdFromResourceName
-