} catch (IOException ioe) {
throw constructFromIOE(ioe);
}
if (cache) {
DTDSubset extSubset = findCachedSubset(dtdId, intSubset);
if (extSubset != null) {
return extSubset;
}
}
// No useful cached copy? Need to read it then.
/* For now, we do require system identifier; otherwise we don't
* know how to resolve DTDs by public id. In future should
* probably also have some simple catalog resolving facility?
*/
if (sysId == null) {
throwParseError("Can not resolve DTD with public id \"{0}\"; missing system identifier", mDtdPublicId, null);
}
WstxInputSource src = null;
try {
int xmlVersion = mDocXmlVersion;
// 05-Feb-2006, TSa: If xmlVersion not explicitly known, defaults to 1.0
if (xmlVersion == XmlConsts.XML_V_UNKNOWN) {
xmlVersion = XmlConsts.XML_V_10;
}
/* null -> no explicit path context, use parent's
* null -> not an entity expansion, no name.
* Note, too, that we can NOT just pass mEntityResolver, since
* that's the one used for general entities, whereas ext subset
* should be resolved by the param entity resolver.
*/
src = DefaultInputResolver.resolveEntity
(mInput, null, null, pubId, sysId, mConfig.getDtdResolver(),
mConfig, xmlVersion);
} catch (FileNotFoundException fex) {
/* Let's catch and rethrow this just so we get more meaningful
* description (with input source position etc)
*/
throwParseError("(was {0}) {1}", fex.getClass().getName(), fex.getMessage());
} catch (IOException ioe) {
throwFromIOE(ioe);
}
DTDSubset extSubset = FullDTDReader.readExternalSubset(src, mConfig, intSubset,
hasConfigFlags(CFG_VALIDATE_AGAINST_DTD),
mDocXmlVersion);
if (cache) {
/* Ok; can be cached, but only if it does NOT refer to
* parameter entities defined in the internal subset (if
* it does, there's no easy/efficient to check if it could
* be used later on, plus it's unlikely it could be)
*/
if (extSubset.isCachable()) {
mOwner.addCachedDTD(dtdId, extSubset);
}
}
return extSubset;