Hi,
I'm using Xalan 2.2 and am able to perform transformations using XSLTC with
the TrAX api as long as my xsl stylesheet is provided via a StreamSource.
If I configure my stylesheet as a DOMSource instead, I get an error whenever
I try to create the template. If I use the default (i.e., non-xsltc)
transformer factory implementation, the same code works fine with DOMSource.
The following error occurs on the transFactory.newTemplates() method.
Could not compile stylesheet
ERROR: The input document is not a stylesheet (the XSL namespace is not
declared in the root element).
Here's the relevant code.
// convert xsl file to DOM document
DocumentBuilderFactory domFactory =
DocumentBuilderFactory.newInstance();
domFactory.setNamespaceAware(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document xsldoc = builder.parse(new
FileInputStream(FILE_NAME));
// try the test using standard implementation or xsltc
implementation
if (useXsltc) {
String value =
"org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
Properties props = System.getProperties();
props.put(PROP_NAME, value);
System.setProperties(props);
}
TransformerFactory transFactory =
TransformerFactory.newInstance();
DOMSource xslSource = new DOMSource(xsldoc);
xslSource.setSystemId(FILE_NAME);
Templates template = transFactory.newTemplates(xslSource);
For this test, I used the following identity stylesheet.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>