For some reason the Sun engineers decided it would be a good idea to base the XSLT engine of JDK 1.5 on Apache Xalan XSLTC. I'm not familiar enough with Xalan-J development to know whether XSLTC seemed to be stable back then or whether it would be a good choice today, but I do know that the specific version used is buggy. Too buggy to use in any environment.
We've had out share of XSLTC related bug reports in Ant (like this one) and it completely breaks XPath assertions in XMLUnit prior to 1.1 because it chokes on this trivial stylesheet:
<xsl:stylesheet ...> <xsl:preserve-space elements="*"/> <xsl:output method="xml" version="1.0" encoding="UTF-8"/> <xsl:template match="/"> <xpathResult> <xsl:apply-templates select="XPATH_EXPRESSION" mode="result"/> </xpathResult> </xsl:template> <xsl:template match="*" mode="result"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet>
which is used by SimpleXPathEngine
to get the result
of selecting XPATH_EXPRESSION
from a
document.
And now it strikes again in XMLUnit see this bug report or current Gump builds until I get around fixing it. XMLUnit uses an even simpler stylesheet to get rid of element content whitespace if you ask it to:
<xsl:stylesheet ...> <xsl:output method="xml" version="1.0" indent="no"/> <xsl:strip-space elements="*"/> <xsl:template match="/"><xsl:copy-of select="."/></xsl:template> </xsl:stylesheet>
This fails to strip element content whitespace if you use XML namespaces in your documents.
A bug in XSLTC that has been fixed in December 2005 and has been reported to Sun in April 2006 is still alive - at least in Update 11 of Java 5 which is what you get on Ubuntu, I haven't checked update 12, yet.
Back to thinking about a workaround for this issue, other than telling people to use Xalan-J or GNU JAXP or any other working implementation instead.
Of course it works for any version of JDK 1.4 or 1.6.
path: /en/oss/XMLUnit | #