gmazza      2005/03/04 20:52:06

  Modified:    src/java/org/apache/fop/fo FONode.java
               src/java/org/apache/fop/fo/flow BlockContainer.java
                        InlineContainer.java ListItemBody.java
                        ListItemLabel.java MultiToggle.java
  Log:
  Validation added for five more FO's.
  
  Revision  Changes    Path
  1.56      +3 -1      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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- FONode.java       5 Mar 2005 00:32:25 -0000       1.55
  +++ FONode.java       5 Mar 2005 04:52:06 -0000       1.56
  @@ -185,7 +185,9 @@
      }
   
       /**
  -     *
  +     *  Primarily used for making final content model validation checks
  +     *  and/or informing the FOEventHandler that the end of this FO
  +     *  has been reached.
        */
       protected void endOfNode() throws FOPException {
           // do nothing by default
  
  
  
  1.36      +31 -1     
xml-fop/src/java/org/apache/fop/fo/flow/BlockContainer.java
  
  Index: BlockContainer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/BlockContainer.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- BlockContainer.java       17 Jan 2005 21:47:05 -0000      1.35
  +++ BlockContainer.java       5 Mar 2005 04:52:06 -0000       1.36
  @@ -18,12 +18,15 @@
   
   package org.apache.fop.fo.flow;
   
  +import org.xml.sax.Locator;
  +
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.datatypes.Length;
   import org.apache.fop.datatypes.Numeric;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.properties.CommonAbsolutePosition;
   import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
   import org.apache.fop.fo.properties.CommonMarginBlock;
  @@ -32,7 +35,6 @@
   
   /**
    * Class modelling the fo:block-container object.
  - * @todo implement validateChildNode()
    */
   public class BlockContainer extends FObj {
       // The value of properties relevant for fo:block-container.
  @@ -59,6 +61,9 @@
       private Numeric zIndex;
       // End of property values
   
  +    /** used for FO validation */
  +    private boolean blockItemFound = false;
  +
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -102,9 +107,34 @@
       }
   
       /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, 
String)
  +     * XSL Content Model: marker* (%block;)+
  +     * But: "In addition an fo:block-container that does not generate an 
  +     * absolutely positioned area may have a sequence of zero or more 
  +     * fo:markers as its initial children."
  +     * @todo - implement above restriction if possible
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String 
localName) 
  +        throws ValidationException {
  +        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;
  +        }
  +    }
  +
  +    /**
        * @see org.apache.fop.fo.FONode#endOfNode
        */
       protected void endOfNode() throws FOPException {
  +        if (!blockItemFound) {
  +            missingChildElementError("marker* (%block;)+");
  +        }
  +
           getFOEventHandler().endBlockContainer(this);
       }
   
  
  
  
  1.26      +32 -1     
xml-fop/src/java/org/apache/fop/fo/flow/InlineContainer.java
  
  Index: InlineContainer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/InlineContainer.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- InlineContainer.java      24 Dec 2004 12:06:26 -0000      1.25
  +++ InlineContainer.java      5 Mar 2005 04:52:06 -0000       1.26
  @@ -22,12 +22,15 @@
   import java.util.ArrayList;
   import java.util.List;
   
  +import org.xml.sax.Locator;
  +
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.datatypes.Length;
   import org.apache.fop.datatypes.Numeric;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
   import org.apache.fop.fo.properties.CommonMarginInline;
   import org.apache.fop.fo.properties.CommonRelativePosition;
  @@ -38,7 +41,6 @@
   
   /**
    * Class modelling the fo:inline-container object.
  - * @todo implement validateChildNode()
    */
   public class InlineContainer extends FObj {
       // The value of properties relevant for fo:inline-container.
  @@ -65,6 +67,9 @@
       private int writingMode;
       // End of property values
   
  +    /** used for FO validation */
  +    private boolean blockItemFound = false;
  +
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -107,6 +112,32 @@
       }
   
       /**
  +     * @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 ValidationException {
  +        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;
  +        }
  +    }
  +
  +    /**
  +     * @see org.apache.fop.fo.FONode#endOfNode
  +     */
  +    protected void endOfNode() throws FOPException {
  +        if (!blockItemFound) {
  +            missingChildElementError("marker* (%block;)+");
  +        }
  +    }
  +
  +    /**
        * Return the "id" property.
        */
       public String getId() {
  
  
  
  1.23      +1 -4      xml-fop/src/java/org/apache/fop/fo/flow/ListItemBody.java
  
  Index: ListItemBody.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListItemBody.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ListItemBody.java 5 Mar 2005 04:10:36 -0000       1.22
  +++ ListItemBody.java 5 Mar 2005 04:52:06 -0000       1.23
  @@ -23,14 +23,13 @@
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
  -import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.KeepProperty;
   
   /**
    * Class modelling the fo:list-item-body object.
  - * @todo implement validateChildNode()
    */
   public class ListItemBody extends FObj {
       // The value of properties relevant for fo:list-item-body.
  @@ -84,8 +83,6 @@
       }
   
       /**
  -     * Make sure content model satisfied, if so then tell the
  -     * FOEventHandler that we are at the end of the flow.
        * @see org.apache.fop.fo.FONode#endOfNode
        */
       protected void endOfNode() throws FOPException {
  
  
  
  1.31      +27 -0     
xml-fop/src/java/org/apache/fop/fo/flow/ListItemLabel.java
  
  Index: ListItemLabel.java
  ===================================================================
  RCS file: 
/home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/ListItemLabel.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- ListItemLabel.java        28 Oct 2004 10:00:21 -0000      1.30
  +++ ListItemLabel.java        5 Mar 2005 04:52:06 -0000       1.31
  @@ -18,10 +18,13 @@
   
   package org.apache.fop.fo.flow;
   
  +import org.xml.sax.Locator;
  +
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.properties.CommonAccessibility;
   import org.apache.fop.fo.properties.KeepProperty;
   
  @@ -36,6 +39,9 @@
       private KeepProperty keepTogether;
       // End of property values
   
  +    /** used for FO validation */
  +    private boolean blockItemFound = false;
  +
       /**
        * @param parent FONode that is the parent of this object
        */
  @@ -61,9 +67,30 @@
       }
   
       /**
  +     * @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 ValidationException {
  +        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;
  +        }
  +    }
  +
  +    /**
        * @see org.apache.fop.fo.FONode#endOfNode
        */
       protected void endOfNode() throws FOPException {
  +        if (!blockItemFound) {
  +            missingChildElementError("marker* (%block;)+");
  +        }
  +
           getFOEventHandler().endListLabel();
       }
   
  
  
  
  1.17      +14 -4     xml-fop/src/java/org/apache/fop/fo/flow/MultiToggle.java
  
  Index: MultiToggle.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/MultiToggle.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- MultiToggle.java  28 Oct 2004 10:00:21 -0000      1.16
  +++ MultiToggle.java  5 Mar 2005 04:52:06 -0000       1.17
  @@ -19,15 +19,18 @@
   package org.apache.fop.fo.flow;
   
   // FOP
  +import org.xml.sax.Locator;
  +
   import org.apache.fop.apps.FOPException;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.PropertyList;
  +import org.apache.fop.fo.ValidationException;
   import org.apache.fop.fo.properties.CommonAccessibility;
   
  +
   /**
    * Class modelling the fo:multi-toggle property.
  - * @todo implement validateChildNode()
    */
   public class MultiToggle extends FObj {
       // The value of properties relevant for fo:multi-toggle.
  @@ -56,9 +59,16 @@
           commonAccessibility = pList.getAccessibilityProps();
           // prSwitchTo = pList.get(PR_SWITCH_TO);
   
  -        if (!notImplementedWarningGiven) {
  -            getLogger().warn("fo:multi-toggle is not yet implemented.");
  -            notImplementedWarningGiven = true;
  +    }
  +
  +    /**
  +     * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, 
String)
  +     * XSL Content Model: (#PCDATA|%inline;|%block;)*
  +     */
  +    protected void validateChildNode(Locator loc, String nsURI, String 
localName) 
  +        throws ValidationException {
  +        if (!isBlockOrInlineItem(nsURI, localName)) {
  +            invalidChildError(loc, nsURI, localName);
           }
       }
   
  
  
  

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

Reply via email to