*/
protected void setStylesheetDocument(DocumentImpl doc, StyleNodeFactory snFactory)
throws XPathException {
DocumentImpl styleDoc = doc;
nodeFactory = snFactory;
// If top-level node is a literal result element, stitch it into a skeleton stylesheet
StyleElement topnode = (StyleElement)styleDoc.getDocumentElement();
if (topnode instanceof LiteralResultElement) {
styleDoc = ((LiteralResultElement)topnode).makeStylesheet(this, snFactory);
}
if (!(styleDoc.getDocumentElement() instanceof XSLStylesheet)) {
throw new XPathException(
"Outermost element of stylesheet is not xsl:stylesheet or xsl:transform or literal result element");
}
XSLStylesheet top = (XSLStylesheet)styleDoc.getDocumentElement();
if (config.isVersionWarning() && top.getVersion().equals(BigDecimal.valueOf(1))) {
try {
TransformerException w = new TransformerException(
"Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor");
w.setLocator(topnode);