Package org.apache.solr.util
Class SystemIdResolver
- java.lang.Object
-
- org.apache.solr.util.SystemIdResolver
-
- All Implemented Interfaces:
EntityResolver,EntityResolver2
public final class SystemIdResolver extends Object implements EntityResolver, EntityResolver2
This is a helper class to support resolving of XIncludes or other hrefs inside XML files on top of aResourceLoader. Just plug this class on top of aResourceLoaderand pass it asEntityResolverto SAX parsers or via wrapper methods asURIResolverto XSL transformers orXMLResolverto STAX parsers. The resolver handles special SystemIds with an URI scheme ofsolrres:that point to resources. To produce such systemIds when you initially call the parser, usecreateSystemIdFromResourceName(java.lang.String)which produces a SystemId that can be included along the InputStream coming fromResourceLoader.openResource(java.lang.String).In general create the
InputSourceto 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 Modifier and Type Field Description static StringRESOURCE_LOADER_AUTHORITY_ABSOLUTEstatic StringRESOURCE_LOADER_URI_SCHEME
-
Constructor Summary
Constructors Constructor Description SystemIdResolver(org.apache.lucene.util.ResourceLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EntityResolverasEntityResolver()URIResolverasURIResolver()XMLResolverasXMLResolver()static StringcreateSystemIdFromResourceName(String name)InputSourcegetExternalSubset(String name, String baseURI)InputSourceresolveEntity(String publicId, String systemId)InputSourceresolveEntity(String name, String publicId, String baseURI, String systemId)
-
-
-
Field Detail
-
RESOURCE_LOADER_URI_SCHEME
public static final String RESOURCE_LOADER_URI_SCHEME
- See Also:
- Constant Field Values
-
RESOURCE_LOADER_AUTHORITY_ABSOLUTE
public static final String RESOURCE_LOADER_AUTHORITY_ABSOLUTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
asEntityResolver
public EntityResolver asEntityResolver()
-
asURIResolver
public URIResolver asURIResolver()
-
asXMLResolver
public XMLResolver asXMLResolver()
-
getExternalSubset
public InputSource getExternalSubset(String name, String baseURI)
- 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
public InputSource resolveEntity(String publicId, String systemId) throws IOException
- Specified by:
resolveEntityin interfaceEntityResolver- Throws:
IOException
-
-