checkEmpty();
checkTopLevel((this instanceof XSLInclude ? "XT0170" : "XT0190"));
try {
XSLStylesheet thisSheet = (XSLStylesheet)getParentNode();
PreparedStylesheet pss = getPreparedStylesheet();
Configuration config = pss.getConfiguration();
// System.err.println("GeneralIncorporate: href=" + href + " base=" + getBaseURI());
Source source = config.getURIResolver().resolve(href, getBaseURI());
// if a user URI resolver returns null, try the standard one
// (Note, the standard URI resolver never returns null)
if (source==null) {
source = (new StandardURIResolver(config)).resolve(href, getBaseURI());
}
if (source instanceof NodeInfo) {
if (source instanceof Node) {
source = new DOMSource((Node)source);
} else {
throw new DynamicError("URIResolver must not return a " + source.getClass());
}
}
// check for recursion
XSLStylesheet anc = thisSheet;
if (source.getSystemId() != null) {
while(anc!=null) {
if (source.getSystemId().equals(anc.getSystemId())) {
compileError("A stylesheet cannot " + getLocalPart() + " itself",
(this instanceof XSLInclude ? "XT0180" : "XT0210"));
return null;
}
anc = anc.getImporter();
}
}
StyleNodeFactory snFactory = new StyleNodeFactory(getNamePool(),
config.isAllowExternalFunctions());
includedDoc = pss.loadStylesheetModule(source, config, getNamePool(), snFactory);
// allow the included document to use "Literal Result Element as Stylesheet" syntax
ElementImpl outermost = (ElementImpl)includedDoc.getDocumentElement();