gmazza      2004/08/01 09:46:46

  Modified:    src/java/org/apache/fop/fo FONode.java
               src/java/org/apache/fop/fo/flow InstreamForeignObject.java
  Log:
  Child element validation added to fo:instream-foreign-object.
  
  Revision  Changes    Path
  1.36      +14 -0     xml-fop/src/java/org/apache/fop/fo/FONode.java
  
  Index: FONode.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- FONode.java       1 Aug 2004 04:20:47 -0000       1.35
  +++ FONode.java       1 Aug 2004 16:46:46 -0000       1.36
  @@ -245,6 +245,20 @@
        * 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) 
  
  
  
  1.16      +35 -73    
xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
  
  Index: InstreamForeignObject.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- InstreamForeignObject.java        27 Jul 2004 23:57:12 -0000      1.15
  +++ InstreamForeignObject.java        1 Aug 2004 16:46:46 -0000       1.16
  @@ -18,7 +18,14 @@
   
   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 @@
    */
   public class InstreamForeignObject extends FObj {
   
  +    boolean hasNonXSLNamespaceElement = false;
  +
       /**
        * constructs an instream-foreign-object object (called by Maker).
        *
  @@ -38,6 +47,32 @@
           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();
  @@ -84,79 +119,6 @@
       public boolean generatesInlineAreas() {
           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
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to