protected static String FO_URI = FOElementMapping.URI;
- /**
- * FOEventHandler that handles FO events occurring
- * during FO Tree processing.
- */
- protected static FOEventHandler foEventHandler = null;
-
/** Parent FO node */
protected FONode parent;
}
}
- /**
- * Sets the FOEventHandler that the FOTree processing fires events to
- * @param eventHandler the FOEventHandler subclass to send FO events to
- */
- public static void setFOEventHandler(FOEventHandler eventHandler) {
- FONode.foEventHandler = eventHandler;
- }
-
/**
* Recursively goes up the FOTree hierarchy until the fo:root is found,
* which returns the parent FOEventHandler.
* @return the FOEventHandler object that is the parent of the FO Tree
*/
public FOEventHandler getFOEventHandler() {
- return FONode.foEventHandler;
+ return parent.getFOEventHandler();
}
/**
*/
public void startDocument() throws SAXException {
rootFObj = null; // allows FOTreeBuilder to be reused
- FONode.setFOEventHandler(foEventHandler);
if (log.isDebugEnabled()) {
log.debug("Building formatting object tree");
}
if (rootFObj == null) {
rootFObj = (Root) foNode;
+ rootFObj.setFOEventHandler(foEventHandler);
} else {
currentFObj.addChildNode(foNode);
}
*/
public class InstreamForeignObject extends FObj {
- boolean hasNonXSLNamespaceElement = false;
-
/**
* constructs an instream-foreign-object object (called by Maker).
*
throws SAXParseException {
if (nsURI == FO_URI) {
invalidChildError(loc, nsURI, localName);
- } else if (hasNonXSLNamespaceElement) {
+ } else if (childNodes != null) {
tooManyNodesError(loc, "child element");
- } else {
- hasNonXSLNamespaceElement = true;
}
}
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
- if (!hasNonXSLNamespaceElement) {
+ if (childNodes == null) {
missingChildElementError("one (1) non-XSL namespace child");
}
}
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fo.extensions.Bookmarks;
private int runningPageNumberCounter = 0;
/**
+ * FOEventHandler object for this FO Tree
+ */
+ private FOEventHandler foEventHandler = null;
+
+ /**
* @see org.apache.fop.fo.FONode#FONode(FONode)
*/
public Root(FONode parent) {
}
/**
+ * Sets the FOEventHandler object that this Root is attached to
+ * @param foEventHandler the FOEventHandler object
+ */
+ public void setFOEventHandler(FOEventHandler foEventHandler) {
+ this.foEventHandler = foEventHandler;
+ }
+
+ /**
+ * This method overrides the FONode version. The FONode version calls the
+ * method by the same name for the parent object. Since Root is at the top
+ * of the tree, it returns the actual FOEventHandler object. Thus, any FONode
+ * can use this chain to find which FOEventHandler it is being built for.
+ * @return the FOEventHandler implementation that this Root is attached to
+ */
+ public FOEventHandler getFOEventHandler() {
+ return foEventHandler;
+ }
+
+ /**
* Returns the number of pages generated (over all PageSequence instances).
* @return the number of pages
*/