null,
href,
fDocLocation.getBaseSystemId(),
null);
XMLInputSource includedSource = null;
if (fEntityResolver != null) {
try {
includedSource =
fEntityResolver.resolveEntity(resourceIdentifier);
}
catch (IOException e) {
throw new XIncludeResourceError(
"XMLResourceError",
new Object[] { e.getMessage()});
}
}
if (includedSource == null) {
includedSource =
new XMLInputSource(null, href, fDocLocation.getBaseSystemId());
}
if (parse.equals(XINCLUDE_PARSE_XML)) {
// Instead of always creating a new configuration, the first one can be reused
if (fChildConfig == null) {
String parserName = XINCLUDE_DEFAULT_CONFIGURATION;
fChildConfig =
(XMLParserConfiguration)ObjectFactory.newInstance(
parserName,
ObjectFactory.findClassLoader(),
true);
// use the same error reporter
// REVISIT: see setErrorReporter()
fChildConfig.setProperty(ERROR_REPORTER, fErrorReporter);
// use the same namespace context
fChildConfig.setProperty(
Constants.XERCES_PROPERTY_PREFIX
+ Constants.NAMESPACE_CONTEXT_PROPERTY,
fNamespaceContext);
XIncludeHandler newHandler =
(XIncludeHandler)fChildConfig.getProperty(
Constants.XERCES_PROPERTY_PREFIX
+ Constants.XINCLUDE_HANDLER_PROPERTY);
newHandler.setParent(this);
newHandler.setDocumentHandler(this.getDocumentHandler());
}
// set all features on parserConfig to match this parser configuration
copyFeatures(fSettings, fChildConfig);
// we don't want a schema validator on the new pipeline,
// so we set it to false, regardless of what was copied above
fChildConfig.setFeature(
Constants.XERCES_FEATURE_PREFIX
+ Constants.SCHEMA_VALIDATION_FEATURE,
false);
try {
fNamespaceContext.pushScope();
fChildConfig.parse(includedSource);
}
catch (XIncludeFatalError e) {
reportFatalError(e.getKey(), e.getArgs());
}
catch (XNIException e) {
reportFatalError("XMLParseError");
}
catch (IOException e) {
throw new XIncludeResourceError(
"XMLResourceError",
new Object[] { e.getMessage()});
}
finally {
fNamespaceContext.popScope();
}
}
else if (parse.equals(XINCLUDE_PARSE_TEXT)) {
String encoding = attributes.getValue(XINCLUDE_ATTR_ENCODING);
includedSource.setEncoding(encoding);
XIncludeTextReader reader = null;
try {
reader = new XIncludeTextReader(includedSource, this);
reader.parse();