  | |  (BUG?) org.apache.xpath.compiler.XPathParser.initXPath() going in
to infinite | (BUG?) org.apache.xpath.compiler.XPathParser.initXPath() going in
to infinite 2003-03-13 - By Tim Cronin
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[@(protected)=Table Heading']/Datum[@(protected)='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; }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <TITLE>RE: small program on converting html/xhtml to xsl:fo needed</TITLE>
<META content="MSHTML 6.00.2800.1141" name=GENERATOR></HEAD> <BODY> <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003>I'm running a transformation against an xsl stylesheet</SPAN></FONT></DIV> <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003></SPAN></FONT> </DIV> <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003>I've</SPAN></FONT></DIV> <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003></SPAN></FONT> </DIV> <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003>I</SPAN></FONT><FONT face=Arial color=#0000ff size=2><SPAN class=657010818-13032003> get Stack overflow exception and it spins through the following</SPAN></FONT></DIV> <DIV><FONT face=Arial color=#0000ff size=2>org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:191)< /FONT></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2>I believe this section of code is the culprit (note the comment...)</FONT></SPAN></DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2> catch (org.apache.xpath.XPathProcessorException e)<BR> {<BR> if(CONTINUE_AFTER_FATAL_ERROR.equals(e.getMessage()))<BR> {<BR> // What I _want_ to do is null out this XPath.<BR> // I doubt this has the desired effect, but I'm not sure what else to do.<BR> // %REVIEW%!!!<BR> initXPath(compiler, "/..", namespaceContext);<BR> }<BR> else<BR> throw e;<BR> }</FONT></SPAN></DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2>heres the stylesheet (it's invalid I'm trying to catch the errors</FONT></SPAN></DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2><xsl:stylesheet version="1.0" xmlns:xsl="<A href="http://www.w3.org/1999/XSL/Transform">http://www.w3.org/1999/XSL /Transform</A>"><BR> <xsl:template match="/"><BR> <div><BR> <xsl:value-of select="/Properties/Group[@(protected)=Table Heading']/Datum[@(protected)='Title']"/><BR>hello world...<BR> </div><BR> </xsl:template><BR></xsl:stylesheet></FONT></SPAN></DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2>here 's my calling code (ValidationHandler implements javax.xml.transform.ErrorListener)</FONT></SPAN></DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2>  ; public static ValidationHandler validate(String xsl)<BR> {<BR> ValidationHandler vh = new ValidationHandler();</FONT></SPAN></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2> try<BR> {<BR> // NOTE: strong tie to org.apache.xalan.processor.TransformerFactoryImpl<BR> // if xsl processors change then Need to force this to be able to set line number attribs...<BR> TransformerFactory tf = (TransformerFactory) new org.apache.xalan.processor.TransformerFactoryImpl();</FONT></SPAN></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2> tf.setAttribute(org.apache.xalan.processor.TransformerFactoryImpl.FEATURE _SOURCE_LOCATION, Boolean.TRUE);<BR> tf.setErrorListener(vh);<BR> tf.setURIResolver (new Resolver());</FONT></SPAN></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2> XMLReader xr = XMLReaderFactory.createXMLReader();<BR> xr.setEntityResolver(new Resolver());</FONT></SPAN></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=657010818-13032003><FONT face=Arial color=#0000ff size=2> Transformer transformer = tf.newTransformer(new SAXSource(xr, new InputSource(new StringReader(xsl))));<BR> }<BR> catch (SAXException e)<BR> {<BR> DOMException de = new DOMException(DOMException.SYNTAX_ERR,<BR> "cannot validate Stylesheet");<BR> de.initCause(e);<BR> throw de;<BR> }<BR> catch (TransformerException e)<BR> {<BR> vh.error(e);<BR> }<BR> return vh;<BR> }<BR></FONT></SPAN></DIV></BODY></HTML>
|
|
 |