diff options
-rw-r--r-- | src/java/org/apache/fop/fo/FOTreeBuilder.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 84d03db83..49694eebd 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -83,6 +83,7 @@ public class FOTreeBuilder extends DefaultHandler { private boolean empty = true; private int depth; + private boolean errorinstart; /** * <code>FOTreeBuilder</code> constructor @@ -172,20 +173,28 @@ public class FOTreeBuilder extends DefaultHandler { public void startElement(String namespaceURI, String localName, String rawName, Attributes attlist) throws SAXException { this.depth++; - delegate.startElement(namespaceURI, localName, rawName, attlist); + errorinstart = false; + try { + delegate.startElement(namespaceURI, localName, rawName, attlist); + } catch (SAXException e) { + errorinstart = true; + throw e; + } } /** {@inheritDoc} */ public void endElement(String uri, String localName, String rawName) throws SAXException { - this.delegate.endElement(uri, localName, rawName); - this.depth--; - if (depth == 0) { - if (delegate != mainFOHandler) { - //Return from sub-handler back to main handler - delegate.endDocument(); - delegate = mainFOHandler; - delegate.endElement(uri, localName, rawName); + if (!errorinstart) { + this.delegate.endElement(uri, localName, rawName); + this.depth--; + if (depth == 0) { + if (delegate != mainFOHandler) { + //Return from sub-handler back to main handler + delegate.endDocument(); + delegate = mainFOHandler; + delegate.endElement(uri, localName, rawName); + } } } } |