本文整理匯總了Java中org.xml.sax.EntityResolver.resolveEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityResolver.resolveEntity方法的具體用法?Java EntityResolver.resolveEntity怎麽用?Java EntityResolver.resolveEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xml.sax.EntityResolver
的用法示例。
在下文中一共展示了EntityResolver.resolveEntity方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: resolveEntity
import org.xml.sax.EntityResolver; //導入方法依賴的package包/類
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
boolean trace = log.isTraceEnabled();
for (Map.Entry<EntityResolver, String> entry : resolvers.entrySet()) {
EntityResolver entityResolver = entry.getKey();
if (trace)
log.trace("Trying to resolve entity [" + publicId + "|" + systemId + "] through resolver "
+ entry.getValue());
InputSource entity = entityResolver.resolveEntity(publicId, systemId);
String resolvedMsg = (entity != null ? "" : "not ");
if (trace)
log.trace("Entity [" + publicId + "|" + systemId + "] was " + resolvedMsg
+ "resolved through entity resolver " + entry.getValue());
if (entity != null) {
return entity;
}
}
return null;
}
示例2: getModelSource
import org.xml.sax.EntityResolver; //導入方法依賴的package包/類
public ModelSource getModelSource(URI locationURI,
ModelSource modelSourceOfSourceDocument) throws CatalogModelException {
InputStream inputStream = null;
try {
UserCatalog cat = UserCatalog.getDefault();
// mainly for unit tests
if (cat == null) {
return null;
}
EntityResolver resolver = cat.getEntityResolver();
InputSource src = resolver.resolveEntity(null, locationURI.toString());
if(src != null) {
inputStream = new URL(src.getSystemId()).openStream();
} else {
javax.xml.transform.Source isrc = ((javax.xml.transform.URIResolver)resolver).
resolve(locationURI.toString(), null);
if(isrc != null)
inputStream = new URL(isrc.getSystemId()).openStream();
}
if(inputStream != null)
return createModelSource(inputStream);
} catch (Exception ex) {
throw new CatalogModelException(ex);
}
return null;
}
示例3: getInputSource
import org.xml.sax.EntityResolver; //導入方法依賴的package包/類
public InputSource getInputSource(EntityResolver r)
throws IOException, SAXException {
InputSource retval;
retval = r.resolveEntity(publicId, systemId);
// SAX sez if null is returned, use the URI directly
if (retval == null)
retval = Resolver.createInputSource(new URL(systemId), false);
return retval;
}
示例4: makeInputSource
import org.xml.sax.EntityResolver; //導入方法依賴的package包/類
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
EntityResolver er = xr.getEntityResolver();
if (er != null) {
InputSource inputSource = er.resolveEntity(null, systemId);
if (inputSource != null)
return inputSource;
}
return new InputSource(systemId);
}