Resolves an external parsed entity. If the entity cannot be
resolved, this method should return null.
// resolve entity using DOM entity resolver
if (fEntityResolver != null) {
// For entity resolution the type of the resource would be XML TYPE
// DOM L3 LS spec mention only the XML 1.0 recommendation right now
LSInput inputSource =
resourceIdentifier == null
? fEntityResolver.resolveResource(
null,
null,
null,
null,
null)
: fEntityResolver.resolveResource(
getType(resourceIdentifier),
resourceIdentifier.getNamespace(),
resourceIdentifier.getPublicId(),
resourceIdentifier.getLiteralSystemId(),
resourceIdentifier.getBaseSystemId());
if (inputSource != null) {
String publicId = inputSource.getPublicId();
String systemId = inputSource.getSystemId();
String baseSystemId = inputSource.getBaseURI();
InputStream byteStream = inputSource.getByteStream();
Reader charStream = inputSource.getCharacterStream();
String encoding = inputSource.getEncoding();
String data = inputSource.getStringData();
/**
* An LSParser looks at inputs specified in LSInput in
* the following order: characterStream, byteStream,
* stringData, systemId, publicId.
*/
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId);
if (charStream != null) {
xmlInputSource.setCharacterStream(charStream);
}
else if (byteStream != null) {
xmlInputSource.setByteStream((InputStream) byteStream);
}
else if (data != null && data.length() != 0) {
xmlInputSource.setCharacterStream(new StringReader(data));
}
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
}
}
// unable to resolve entity
return null;