You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/12/27 11:51:12 UTC

svn commit: r607036 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java

Author: jeremias
Date: Thu Dec 27 02:51:11 2007
New Revision: 607036

URL: http://svn.apache.org/viewvc?rev=607036&view=rev
Log:
Don't just exit with no error message if the document contains no content. Pretty irritating if it does so.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=607036&r1=607035&r2=607036&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java Thu Dec 27 02:51:11 2007
@@ -21,25 +21,27 @@
 
 import java.io.OutputStream;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.fo.ElementMapping.Maker;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fo.pagination.Root;
 import org.apache.fop.image.ImageFactory;
 import org.apache.fop.util.ContentHandlerFactory;
-import org.apache.fop.util.ContentHandlerFactory.ObjectSource;
 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
+import org.apache.fop.util.ContentHandlerFactory.ObjectSource;
 
 /**
  * SAX Handler that passes parsed data to the various
@@ -79,6 +81,7 @@
     private FOUserAgent userAgent;
     
     private boolean used = false;
+    private boolean empty = true;
     
     private int depth;
     
@@ -145,6 +148,7 @@
                     + " Please instantiate a new instance.");
         }
         used = true;
+        empty = true;
         rootFObj = null;    // allows FOTreeBuilder to be reused
         if (log.isDebugEnabled()) {
             log.debug("Building formatting object tree");
@@ -160,6 +164,10 @@
      */
     public void endDocument() throws SAXException {
         this.delegate.endDocument();
+        if (this.rootFObj == null && empty) {
+            throw new ValidationException(
+                    "Document is empty (something might be wrong with your XSLT stylesheet).");
+        }
         rootFObj = null;
         if (log.isDebugEnabled()) {
             log.debug("Parsing of document complete");
@@ -280,6 +288,7 @@
 
             // Check to ensure first node encountered is an fo:root
             if (rootFObj == null) {
+                empty = false;
                 if (!namespaceURI.equals(FOElementMapping.URI) 
                     || !localName.equals("root")) {
                     throw new ValidationException(



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org