From: Glen Mazza Date: Sat, 12 Jun 2004 18:52:08 +0000 (+0000) Subject: More solid checking to ensure first node encountered is an fo:root FO. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~719 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e389e54a568773a3ea1599718d28a014ee86b227;p=xmlgraphics-fop.git More solid checking to ensure first node encountered is an fo:root FO. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197702 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 59a16095a..f49439a41 100644 --- a/src/java/org/apache/fop/fo/FOTreeBuilder.java +++ b/src/java/org/apache/fop/fo/FOTreeBuilder.java @@ -224,7 +224,14 @@ public class FOTreeBuilder extends DefaultHandler { /* the node found in the FO document */ FONode foNode; - /* the maker for the formatting object started */ + // Check to ensure first node encountered is an fo:root + if (rootFObj == null) { + if (!namespaceURI.equals(FObj.FO_URI) || !localName.equals("root")) { + throw new SAXException(new FOPException("Error: Root element" + + " must be fo:root formatting object")); + } + } + ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName); // System.out.println("found a " + fobjMaker.toString()); @@ -237,11 +244,6 @@ public class FOTreeBuilder extends DefaultHandler { } if (rootFObj == null) { - if (!foNode.getName().equals("fo:root")) { - throw new SAXException(new FOPException("Root element must" - + " be fo:root, not " - + foNode.getName())); - } rootFObj = (Root) foNode; rootFObj.setFOTreeControl(foTreeControl); } else { diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 3f17965cf..1ecfc1aa7 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -36,7 +36,7 @@ import org.xml.sax.Locator; * Base class for representation of formatting objects and their processing. */ public class FObj extends FONode implements Constants { - private static final String FO_URI = "http://www.w3.org/1999/XSL/Format"; + public static final String FO_URI = "http://www.w3.org/1999/XSL/Format"; public static PropertyMaker[] propertyListTable = null;