From: Jeremias Maerki Date: Tue, 4 Oct 2005 13:07:43 +0000 (+0000) Subject: Bugzilla #36871: X-Git-Tag: fop-0_90-alpha1~165 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dd5611116e9c430499bce387b2168c019005ad61;p=xmlgraphics-fop.git Bugzilla #36871: Better error messages when invalid XSL-FO is sent to FOP. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@293596 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java index 58942036f..595dc0566 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -247,8 +247,10 @@ public class FOTreeBuilder extends DefaultHandler { if (rootFObj == null) { if (!namespaceURI.equals(FOElementMapping.URI) || !localName.equals("root")) { - throw new SAXException(new IllegalArgumentException( - "Error: First element must be fo:root formatting object")); + throw new SAXException(new ValidationException( + "Error: First element must be the fo:root formatting object. Found " + + FONode.getNodeString(namespaceURI, localName) + " instead." + + " Please make sure you're producing a valid XSL-FO document.")); } } else { // check that incoming node is valid for currentFObj if (namespaceURI.equals(FOElementMapping.URI)) { @@ -293,6 +295,10 @@ public class FOTreeBuilder extends DefaultHandler { */ public void endElement(String uri, String localName, String rawName) throws FOPException { + if (currentFObj == null) { + throw new FOPException("No current FO is available. The input document may not be " + + "a valid XSL-FO document."); + } currentFObj.endOfNode(); if (currentPropertyList.getFObj() == currentFObj) {