I have this well-formed XSLT file to convert XML files into slightly different XML files. My setup works when I run the tranformation in plain Java, but when I try to run my code on Google App Engine it crashes when I try to load the XSLT file, with the following error message:
ERROR: 'null'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
(Something goes wrong here)
InputStream is = context.getResourceAsStream("/xslt/add_spaces_and_ids.xslt");
if (is == null) {
throw new NullPointerException("File could not be found");
}
Source xsltSource = new StreamSource(is);
Transformer transformer = factory.newTransformer(xsltSource);
return transformer;
(Should be nothing special)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="kop">
<xsl:variable name="kopText">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:variable name="titelText">
<xsl:value-of select="titel"/>
</xsl:variable>
<!-- Add a space -->
<xsl:text> </xsl:text>
<xsl:copy>
<xsl:attribute name="id">
<xsl:value-of select="generate-id()" />
</xsl:attribute>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="node()">
<xsl:text> </xsl:text>
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
How can I fix this?
I had some conflicting libraries in my build path:
xercesImps.jar
, xml-apis.jar
, and serializer.jar
Removing these from the build path, while keeping saxon, resolved my issues.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.