You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Tim Cronin <ti...@13-colonies.com> on 2003/03/13 19:19:48 UTC
RE: (BUG?) org.apache.xpath.compiler.XPathParser.initXPath() goin
g in to infinite loop
this comment was right above the code...
// Patch for Christine's gripe. She wants her errorHandler to return from
// a fatal error and continue trying to parse, rather than throwing an
exception.
// Without the patch, that put us into an endless loop.
//
// %REVIEW% Is there a better way of doing this?
// %REVIEW% Are there any other cases which need the safety net?
// (and if so do we care right now, or should we rewrite the XPath
// grammar engine and can fix it at that time?)
with
org.apache.xalan.xsltc.trax.TransformerFactoryImpl
you catch all the errors but it still throws the exception.
-----Original Message-----
From: Tim Cronin [mailto:tim@13-colonies.com]
Sent: Thursday, March 13, 2003 12:13 PM
To: xalan-j-users@xml.apache.org
Subject: (BUG?) org.apache.xpath.compiler.XPathParser.initXPath() going in
to infinite loop
I'm running a transformation against an xsl stylesheet
I've
I get Stack overflow exception and it spins through the following
org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:191)
I believe this section of code is the culprit (note the comment...)
catch (org.apache.xpath.XPathProcessorException e)
{
if(CONTINUE_AFTER_FATAL_ERROR.equals(e.getMessage()))
{
// What I _want_ to do is null out this XPath.
// I doubt this has the desired effect, but I'm not sure what else to do.
// %REVIEW%!!!
initXPath(compiler, "/..", namespaceContext);
}
else
throw e;
}
heres the stylesheet (it's invalid I'm trying to catch the errors
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform <http://www.w3.org/1999/XSL/Transform>
">
<xsl:template match="/">
<div>
<xsl:value-of select="/Properties/Group[@Name=Table
Heading']/Datum[@Name='Title']"/>
hello world...
</div>
</xsl:template>
</xsl:stylesheet>
here's my calling code (ValidationHandler implements
javax.xml.transform.ErrorListener)
public static ValidationHandler validate(String xsl)
{
ValidationHandler vh = new ValidationHandler();
try
{
// NOTE: strong tie to
org.apache.xalan.processor.TransformerFactoryImpl
// if xsl processors change then Need to force this to be able to set
line number attribs...
TransformerFactory tf = (TransformerFactory) new
org.apache.xalan.processor.TransformerFactoryImpl();
tf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE_SO
URCE_LOCATION, Boolean.TRUE);
tf.setErrorListener(vh);
tf.setURIResolver(new Resolver());
XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setEntityResolver(new Resolver());
Transformer transformer = tf.newTransformer(new SAXSource(xr, new
InputSource(new StringReader(xsl))));
}
catch (SAXException e)
{
DOMException de = new DOMException(DOMException.SYNTAX_ERR,
"cannot validate Stylesheet");
de.initCause(e);
throw de;
}
catch (TransformerException e)
{
vh.error(e);
}
return vh;
}