public class EntityListResolver extends Object implements LSResourceResolver, EntityResolver, URIResolver
EntityListResolver resolver = new EntityListResolver();* URL xsd = new URL(<URL of an XSD>); resolver.addResolvedSystemID("http://location/refXSD.xsd", xsd); XMLSAXParser parser = new XMLSAXParser(); parser.setEntityListResolver(resolver);During the parsing of an XML file:
addDefaultResolvedEntities()
method allows to resolve the following entities:
Modifier and Type | Class and Description |
---|---|
static class |
EntityListResolver.URLLSInput
An LSInput implementation.
|
Modifier and Type | Field and Description |
---|---|
static String |
SCHEMA_RESOURCES |
static String |
XML_RESOURCES |
Constructor and Description |
---|
EntityListResolver() |
EntityListResolver(URL baseURL) |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultResolvedEntities()
Add default resolved entities.
|
void |
addResolvedEntity(String publicId,
URL entity)
Add an entity resolution to the resolver.
|
void |
addResolvedSystemID(String systemId,
URL entity)
Add an entity resolution to the resolver, for a specific systemID.
|
void |
addResolvedSystemIDs(List<String> systemIDs,
URL entity)
Add an entity resolution to the resolver, for a list of systemIDs.
|
void |
cacheSources(boolean cache)
Set if sources are cached.
|
Map<String,URL> |
getResolvedEntities()
Return the resolved entities in the resolver.
|
protected InputSource |
getSource(URL url,
String publicId,
String systemId)
Return an InputSource for a systemID and an URL.
|
boolean |
isCachingSources()
Return true if sources are cached.
|
boolean |
isResolvingEntities()
Return true if the resolver is resolving entities.
|
boolean |
isResolvingSystemEntities()
Return true if the resolver is resolving system entities.
|
boolean |
isResolvingSystemID(String systemId)
Return true if the resolver resolves a specified systemID.
|
void |
reset()
Clear the content of the resolver.
|
InputSource |
resolve(String publicId)
Resolve the entity for one publicID.
|
Source |
resolve(String href,
String base) |
InputSource |
resolveEntity(String publicId,
String systemId) |
LSInput |
resolveResource(String type,
String namespaceURI,
String publicId,
String systemId,
String baseURI)
Allow to resolve external resources for Schema validation.
|
InputSource |
resolveSystemID(String baseURI,
String systemId)
Resolve the entity for one systemID.
|
protected String |
resolveURI(String uriAsString)
Return a baseURI or a systemId as a String.
|
public static final String XML_RESOURCES
public static final String SCHEMA_RESOURCES
public EntityListResolver()
public EntityListResolver(URL baseURL)
public void addDefaultResolvedEntities()
public void reset()
public void cacheSources(boolean cache)
cache
- true if sources are cachedpublic boolean isCachingSources()
public void addResolvedSystemID(String systemId, URL entity)
systemId
- the system IDentity
- the URL to use for the entity resolutionpublic void addResolvedSystemIDs(List<String> systemIDs, URL entity)
systemIDs
- the list of systemIDsentity
- the URL to use for the entity resolutionpublic final void addResolvedEntity(String publicId, URL entity)
publicId
- the public IDentity
- the URL to use for the entity resolutionpublic Map<String,URL> getResolvedEntities()
public boolean isResolvingSystemID(String systemId)
systemId
- the system IDpublic boolean isResolvingSystemEntities()
public boolean isResolvingEntities()
protected InputSource getSource(URL url, String publicId, String systemId) throws IOException
url
- the URLpublicId
- the public IDsystemId
- the systemIDIOException
- if it is not posible to open the stream corresponding to the URLprotected String resolveURI(String uriAsString)
uriAsString
- the baseURI or systemIdpublic InputSource resolveSystemID(String baseURI, String systemId)
baseURI
- the base URIsystemId
- the systemIDpublic InputSource resolve(String publicId)
publicId
- the public IDpublic LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI)
getResolvedEntities()
Map (if a child resource is found because the baseURI was discovered, it will be added to the resolution Map).
getResolvedEntities()
http://www.my.site/mySchema.xsd
is resolved to the URL associated to D:/myDirectory/myXMLSchema.xsd
http://www.my.site/mySchema.xsd
LSInput
constructed with D:/myDirectory/myXMLSchema.xsd
http://www.my.site/mySchema.xsd
is resolved to the URL associated to D:/myDirectory/myXMLSchema.xsd
http://www.my.site/mySchema.xsd
and systemId = subSchema.xsd
LSInput
constructed with D:/myDirectory/subSchema.xsd
http://www.my.site/subSchema.xsd"
to D:/myDirectory/subSchema.xsd
resolveResource
in interface LSResourceResolver
type
- The type of the resource being resolved. For XML [XML 1.0] resources (i.e. entities), applications must use the value
"http://www.w3.org/TR/REC-xml". For XML Schema [XML Schema Part 1] , applications must use the value "http://www.w3.org/2001/XMLSchema"namespaceURI
- The namespace of the resource being resolved, e.g. the target namespace of the XML SchemapublicId
- The public identifier of the external entity being referenced, or null if no public identifier was supplied or if the resource
is not an entitysystemId
- The system identifier, a URI reference [IETF RFC 2396], of the external resource being referenced, or null if no system
identifier was suppliedbaseURI
- The absolute base URI of the resource being parsed, or null if there is no base URIpublic InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
resolveEntity
in interface EntityResolver
SAXException
IOException
public Source resolve(String href, String base) throws TransformerException
resolve
in interface URIResolver
TransformerException