]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
PR:
authorGlen Mazza <gmazza@apache.org>
Sun, 1 Aug 2004 16:46:46 +0000 (16:46 +0000)
committerGlen Mazza <gmazza@apache.org>
Sun, 1 Aug 2004 16:46:46 +0000 (16:46 +0000)
Obtained from:
Submitted by:
Reviewed by:
Child element validation added to fo:instream-foreign-object.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197849 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/FONode.java
src/java/org/apache/fop/fo/flow/InstreamForeignObject.java

index acea124dc27ffa4493e94e23bfc92ba71c7ab1a4..c7b125e76bfa8787220a9f136b7095640d3240dc 100644 (file)
@@ -245,6 +245,20 @@ public abstract class FONode {
      * Helper function to standardize "too many" error exceptions
      * (e.g., two fo:declarations within fo:root)
      * @param loc org.xml.sax.Locator object of the error (*not* parent node)
+     * @param nsURI namespace URI of incoming invalid node
+     * @param lName local name (i.e., no prefix) of incoming node 
+     */
+    protected void tooManyNodesError(Locator loc, String nsURI, String lName) 
+        throws SAXParseException {
+        throw new SAXParseException (errorText(loc) + getName() + ", only one " 
+            + getNodeString(nsURI, lName) + " may be declared.", loc);
+    }
+
+    /**
+     * Helper function to standardize "too many" error exceptions
+     * (e.g., two fo:declarations within fo:root)
+     * This overrloaded method helps make the caller code better self-documenting
+     * @param loc org.xml.sax.Locator object of the error (*not* parent node)
      * @param offendingNode incoming node that would cause a duplication.
      */
     protected void tooManyNodesError(Locator loc, String offendingNode) 
index f2677268c5c4b4fc7b568ef3ebd75e762d67db41..afbeff95e9676d56cf0792d939c980dc7b41ee17 100644 (file)
 
 package org.apache.fop.fo.flow;
 
+// XML
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXParseException;
+
+// FOP
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOElementMapping;
 import org.apache.fop.layoutmgr.AddLMVisitor;
 import org.apache.fop.fo.FObj;
 
@@ -29,6 +36,8 @@ import org.apache.fop.fo.FObj;
  */
 public class InstreamForeignObject extends FObj {
 
+    boolean hasNonXSLNamespaceElement = false;
+
     /**
      * constructs an instream-foreign-object object (called by Maker).
      *
@@ -38,6 +47,32 @@ public class InstreamForeignObject extends FObj {
         super(parent);
     }
 
+    /**
+     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+     * XSL Content Model: one (1) non-XSL namespace child
+     */
+    protected void validateChildNode(Locator loc, String nsURI, String localName) 
+        throws SAXParseException {
+        if (nsURI == FOElementMapping.URI) {
+            invalidChildError(loc, nsURI, localName);
+        } else if (hasNonXSLNamespaceElement) {
+            tooManyNodesError(loc, "child element");
+        } else {
+            hasNonXSLNamespaceElement = true;
+        }
+    }
+
+    /**
+     * Make sure content model satisfied, if so then tell the
+     * StructureRenderer that we are at the end of the flow.
+     * @see org.apache.fop.fo.FONode#end
+     */
+    protected void endOfNode() throws SAXParseException {
+        if (!hasNonXSLNamespaceElement) {
+            missingChildElementError("one (1) non-XSL namespace child");
+        }
+    }
+
     public int computeXOffset (int ipd, int cwidth) {
         int xoffset = 0;
         int ta = propertyList.get(PR_TEXT_ALIGN).getEnum();
@@ -85,79 +120,6 @@ public class InstreamForeignObject extends FObj {
         return true;
     }
 
-    /*
-
-            // Common Accessibility Properties
-            AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
-
-            // Common Aural Properties
-            AuralProps mAurProps = propMgr.getAuralProps();
-
-            // Common Border, Padding, and Background Properties
-            BorderAndPadding bap = propMgr.getBorderAndPadding();
-            BackgroundProps bProps = propMgr.getBackgroundProps();
-
-            // Common Margin Properties-Inline
-            MarginInlineProps mProps = propMgr.getMarginInlineProps();
-
-            // Common Relative Position Properties
-            RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
-
-            // this.propertyList.get("alignment-adjust");
-            // this.propertyList.get("alignment-baseline");
-            // this.propertyList.get("baseline-shift");
-            // this.propertyList.get("block-progression-dimension");
-            // this.propertyList.get("content-height");
-            // this.propertyList.get("content-type");
-            // this.propertyList.get("content-width");
-            // this.propertyList.get("display-align");
-            // this.propertyList.get("dominant-baseline");
-            // this.propertyList.get("height");
-            setupID();
-            // this.propertyList.get("inline-progression-dimension");
-            // this.propertyList.get("keep-with-next");
-            // this.propertyList.get("keep-with-previous");
-            // this.propertyList.get("line-height");
-            // this.propertyList.get("line-height-shift-adjustment");
-            // this.propertyList.get("overflow");
-            // this.propertyList.get("scaling");
-            // this.propertyList.get("scaling-method");
-            // this.propertyList.get("text-align");
-            // this.propertyList.get("width");
-
-            /* retrieve properties *
-            int align = this.propertyList.get("text-align").getEnum();
-            int valign = this.propertyList.get("vertical-align").getEnum();
-            int overflow = this.propertyList.get("overflow").getEnum();
-
-            this.breakBefore = this.propertyList.get("break-before").getEnum();
-            this.breakAfter = this.propertyList.get("break-after").getEnum();
-            this.width = this.propertyList.get("width").getLength().mvalue();
-            this.height = this.propertyList.get("height").getLength().mvalue();
-            this.contwidth =
-                this.propertyList.get("content-width").getLength().mvalue();
-            this.contheight =
-                this.propertyList.get("content-height").getLength().mvalue();
-            this.wauto = this.propertyList.get("width").getLength().isAuto();
-            this.hauto = this.propertyList.get("height").getLength().isAuto();
-            this.cwauto =
-                this.propertyList.get("content-width").getLength().isAuto();
-            this.chauto =
-                this.propertyList.get("content-height").getLength().isAuto();
-
-            this.startIndent =
-                this.propertyList.get("start-indent").getLength().mvalue();
-            this.endIndent =
-                this.propertyList.get("end-indent").getLength().mvalue();
-            this.spaceBefore =
-                this.propertyList.get("space-before.optimum").getLength().mvalue();
-            this.spaceAfter =
-                this.propertyList.get("space-after.optimum").getLength().mvalue();
-
-            this.scaling = this.propertyList.get("scaling").getEnum();
-
-*/
-
     /**
      * This is a hook for the AddLMVisitor class to be able to access
      * this object.