gmazza      2004/08/29 06:27:08

  Modified:    src/java/org/apache/fop/fo/flow MultiSwitch.java
                        TableAndCaption.java TableCaption.java
  Log:
  Three more validateChildNodes() added.
  
  Revision  Changes    Path
  1.15      +28 -1     xml-fop/src/java/org/apache/fop/fo/flow/MultiSwitch.java
  
  Index: MultiSwitch.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiSwitch.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- MultiSwitch.java  25 Aug 2004 05:03:06 -0000      1.14
  +++ MultiSwitch.java  29 Aug 2004 13:27:08 -0000      1.15
  @@ -18,13 +18,18 @@
   
   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.FObj;
   
   /**
    * Class modelling the fo:multi-switch object.
  - * @todo implement validateChildNode()
  + * @todo needs implementation
    */
   public class MultiSwitch extends FObj {
   
  @@ -39,6 +44,28 @@
           if (!notImplementedWarningGiven) {
               getLogger().warn("fo:multi-switch is not yet implemented.");
               notImplementedWarningGiven = true;
  +        }
  +    }
  +
  +    /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  +     * XSL Content Model: (multi-case+)
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  +        throws SAXParseException {
  +        if (!(nsURI == FO_URI && localName.equals("multi-case"))) {
  +            invalidChildError(loc, nsURI, localName);
  +        }
  +    }
  +
  +    /**
  +     * Make sure content model satisfied, if so then tell the
  +     * FOInputHandler that we are at the end of the flow.
  +     * @see org.apache.fop.fo.FONode#end
  +     */
  +    protected void endOfNode() throws SAXParseException {
  +        if (childNodes == null) {
  +            missingChildElementError("(multi-case+)");
           }
       }
   
  
  
  
  1.17      +53 -1     xml-fop/src/java/org/apache/fop/fo/flow/TableAndCaption.java
  
  Index: TableAndCaption.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableAndCaption.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TableAndCaption.java      25 Aug 2004 05:03:06 -0000      1.16
  +++ TableAndCaption.java      29 Aug 2004 13:27:08 -0000      1.17
  @@ -18,18 +18,27 @@
   
   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.FObj;
   
   /**
    * Class modelling the fo:table-and-caption property.
  - * @todo implement validateChildNode()
  + * @todo needs implementation
    */
   public class TableAndCaption extends FObj {
   
       static boolean notImplementedWarningGiven = false;
   
  +    /** used for FO validation */
  +    private boolean tableCaptionFound = false;
  +    private boolean tableFound = false;
  +
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -39,6 +48,49 @@
           if (!notImplementedWarningGiven) {
               getLogger().warn("fo:table-and-caption is not yet implemented.");
               notImplementedWarningGiven = true;
  +        }
  +    }
  +
  +    /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  +     * XSL Content Model: marker* table-caption? table
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  +        throws SAXParseException {
  +
  +            if (nsURI == FO_URI && localName.equals("marker")) {
  +                if (tableCaptionFound) {
  +                    nodesOutOfOrderError(loc, "fo:marker", "fo:table-caption");
  +                } else if (tableFound) {
  +                    nodesOutOfOrderError(loc, "fo:marker", "fo:table");
  +                }
  +            } else if (nsURI == FO_URI && localName.equals("table-caption")) {
  +                if (tableCaptionFound) {
  +                    tooManyNodesError(loc, "fo:table-caption");
  +                } else if (tableFound) {
  +                    nodesOutOfOrderError(loc, "fo:table-caption", "fo:table");
  +                } else {
  +                    tableCaptionFound = true;
  +                }
  +            } else if (nsURI == FO_URI && localName.equals("table")) {
  +                if (tableFound) {
  +                    tooManyNodesError(loc, "fo:table");
  +                } else {
  +                    tableFound = true;
  +                }
  +            } else {
  +                invalidChildError(loc, nsURI, localName);
  +            }
  +    }
  +
  +    /**
  +     * Make sure content model satisfied, if so then tell the
  +     * FOInputHandler that we are at the end of the flow.
  +     * @see org.apache.fop.fo.FONode#end
  +     */
  +    protected void endOfNode() throws SAXParseException {
  +        if (!tableFound) {
  +            missingChildElementError("marker* table-caption? table");
           }
       }
   
  
  
  
  1.17      +37 -1     xml-fop/src/java/org/apache/fop/fo/flow/TableCaption.java
  
  Index: TableCaption.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/TableCaption.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TableCaption.java 25 Aug 2004 05:03:06 -0000      1.16
  +++ TableCaption.java 29 Aug 2004 13:27:08 -0000      1.17
  @@ -18,16 +18,24 @@
   
   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.FObj;
   
   /**
    * Class modelling the fo:table-caption object.
  - * @todo implement validateChildNode()
  + * @todo needs implementation
    */
   public class TableCaption extends FObj {
   
  +    /** used for FO validation */
  +    private boolean blockItemFound = false;
  +
       static boolean notImplementedWarningGiven = false;
   
       /**
  @@ -39,6 +47,34 @@
           if (!notImplementedWarningGiven) {
               getLogger().warn("fo:table-caption is not yet implemented.");
               notImplementedWarningGiven = true;
  +        }
  +    }
  +
  +    /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
  +     * XSL Content Model: marker* (%block;)
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String localName) 
  +        throws SAXParseException {
  +        if (nsURI == FO_URI && localName.equals("marker")) {
  +            if (blockItemFound) {
  +               nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
  +            }
  +        } else if (!isBlockItem(nsURI, localName)) {
  +            invalidChildError(loc, nsURI, localName);
  +        } else {
  +            blockItemFound = true;
  +        }
  +    }
  +
  +    /**
  +     * Make sure content model satisfied, if so then tell the
  +     * FOInputHandler that we are at the end of the flow.
  +     * @see org.apache.fop.fo.FONode#end
  +     */
  +    protected void endOfNode() throws SAXParseException {
  +        if (childNodes == null) {
  +            missingChildElementError("marker* (%block;)");
           }
       }
   
  
  
  

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

Reply via email to