Methods Summary |
---|
private com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource | createXMLInputSource(org.xml.sax.InputSource source, java.lang.String baseURI)Creates an XMLInputSource from a SAX InputSource.
String publicId = source.getPublicId();
String systemId = source.getSystemId();
String baseSystemId = baseURI;
InputStream byteStream = source.getByteStream();
Reader charStream = source.getCharacterStream();
String encoding = source.getEncoding();
XMLInputSource xmlInputSource =
new XMLInputSource(publicId, systemId, baseSystemId);
xmlInputSource.setByteStream(byteStream);
xmlInputSource.setCharacterStream(charStream);
xmlInputSource.setEncoding(encoding);
return xmlInputSource;
|
public org.xml.sax.ext.EntityResolver2 | getEntityResolver()Returns the SAX entity resolver wrapped by this object.
return fEntityResolver;
|
public com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource | getExternalSubset(com.sun.org.apache.xerces.internal.xni.grammars.XMLDTDDescription grammarDescription)Locates an external subset for documents which do not explicitly
provide one. If no external subset is provided, this method should
return null .
if (fEntityResolver != null) {
String name = grammarDescription.getRootName();
String baseURI = grammarDescription.getBaseSystemId();
// Resolve using EntityResolver2
try {
InputSource inputSource = fEntityResolver.getExternalSubset(name, baseURI);
return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
}
// error resolving external subset
catch (SAXException e) {
Exception ex = e.getException();
if (ex == null) {
ex = e;
}
throw new XNIException(ex);
}
}
// unable to resolve external subset
return null;
|
public com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource | resolveEntity(com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier resourceIdentifier)Resolves an external parsed entity. If the entity cannot be
resolved, this method should return null.
if (fEntityResolver != null) {
String pubId = resourceIdentifier.getPublicId();
String sysId = resourceIdentifier.getExpandedSystemId();
String baseURI = resourceIdentifier.getBaseSystemId();
String name = null;
if (resourceIdentifier instanceof XMLDTDDescription) {
name = "[dtd]";
}
else if (resourceIdentifier instanceof XMLEntityDescription) {
name = ((XMLEntityDescription) resourceIdentifier).getEntityName();
}
// When all of the parameters are null, the user's entity resolver
// can do nothing about it. We'd better not bother calling it.
// This happens when the resourceIdentifier is a GrammarDescription,
// which describes a schema grammar of some namespace, but without
// any schema location hint. -Sg
if (pubId == null && sysId == null && baseURI == null && name == null) {
return null;
}
// Resolve using EntityResolver2
try {
InputSource inputSource =
fEntityResolver.resolveEntity(name, pubId, baseURI, sysId);
return (inputSource != null) ? createXMLInputSource(inputSource, baseURI) : null;
}
// error resolving entity
catch (SAXException e) {
Exception ex = e.getException();
if (ex == null) {
ex = e;
}
throw new XNIException(ex);
}
}
// unable to resolve entity
return null;
|
public void | setEntityResolver(org.xml.sax.ext.EntityResolver2 entityResolver)Sets the SAX entity resolver wrapped by this object.
fEntityResolver = entityResolver;
|