aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2007-12-27 10:51:11 +0000
committerJeremias Maerki <jeremias@apache.org>2007-12-27 10:51:11 +0000
commit2ddc94a5b97c9a7a66bb2fee45ea6e46b86030bf (patch)
treeef9d3216ac5cef1130adae40065663de9ad37f7d
parent0c87214d3a98d0836083d191b36aa7abf944d0dc (diff)
downloadxmlgraphics-fop-2ddc94a5b97c9a7a66bb2fee45ea6e46b86030bf.tar.gz
xmlgraphics-fop-2ddc94a5b97c9a7a66bb2fee45ea6e46b86030bf.zip
Don't just exit with no error message if the document contains no content. Pretty irritating if it does so.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@607036 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/FOTreeBuilder.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/fo/FOTreeBuilder.java b/src/java/org/apache/fop/fo/FOTreeBuilder.java
index c4ab4fdc8..980404ffd 100644
--- a/src/java/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java
@@ -21,25 +21,27 @@ package org.apache.fop.fo;
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 @@ public class FOTreeBuilder extends DefaultHandler {
private FOUserAgent userAgent;
private boolean used = false;
+ private boolean empty = true;
private int depth;
@@ -145,6 +148,7 @@ public class FOTreeBuilder extends DefaultHandler {
+ " 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 class FOTreeBuilder extends DefaultHandler {
*/
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 @@ public class FOTreeBuilder extends DefaultHandler {
// 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(