本文整理汇总了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);
}