Hello, I am using FOP and FOP uses Xalan. I am facing an issue where FOP enters in an infinite loop. Upon further investigation I found out that FOP throws an exception before the code reaches the infinite loop but that exception is trapped by Xalan. The relevant Xalan code is this one, in org.apache.xalan.templates.ElemLiteralResult.execute():
catch (TransformerException te) { // thrown in finally to prevent original exception consumed by subsequent exceptions tException = te; } catch (SAXException se) { tException = new TransformerException(se); } try { /* we need to do this endElement() to balance the * successful startElement() call even if * there was an exception in the middle. * Otherwise an exception in the middle could cause a system to hang. */ if (transformer.getDebug()) { // flush any buffered pending processing before // the trace event. //rhandler.flushPending(); transformer.getTraceManager().fireTraceEndEvent(this); } rhandler.endElement(getNamespace(), getLocalName(), getRawName()); } The tExeption holds the exception thrown by FOP. But then Xalan goes and calls rhandler.endElement(getNamespace(), getLocalName(), getRawName()) and that ultimately triggers the infinite loop in FOP. I see the above comment that seems to indicate there is a good reason why Xalan needs to hold the exception before re-throwing it, but in this case the result is not nice since rhandler.endElement() never returns. Since FOP throws an exception that would have avoided the infinite loop I don't know whether to blame FOP of Xalan. Can you please give me an explanation why the above Xalan code is necessary? Why would the system potentially hang if the exception was not trapped above? Thanks, Luis