cvs commit: xml-fop/src/java/org/apache/fop/fo/flow InstreamForeignObject.java

2004-09-13 Thread gmazza
gmazza  2004/09/13 05:39:24

  Modified:src/java/org/apache/fop/fo/flow InstreamForeignObject.java
  Log:
  Fixed validation bug.
  
  Revision  ChangesPath
  1.27  +1 -1  
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- InstreamForeignObject.java13 Sep 2004 03:46:04 -  1.26
  +++ InstreamForeignObject.java13 Sep 2004 12:39:24 -  1.27
  @@ -65,7 +65,7 @@
* @see org.apache.fop.fo.FONode#end
*/
   protected void endOfNode() throws SAXParseException {
  -if (childNodes == null) {
  +if (childNodes.size() != 1) {
   missingChildElementError("one (1) non-XSL namespace child");
   }
   }
  
  
  

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



cvs commit: xml-fop/src/java/org/apache/fop/fo/flow InstreamForeignObject.java

2004-08-01 Thread gmazza
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  ChangesPath
  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 -   1.35
  +++ FONode.java   1 Aug 2004 16:46:46 -   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.java27 Jul 2004 23:57:12 -  1.15
  +++ InstreamForeignObject.java1 Aug 2004 16:46:46 -   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();