Browse Source

Validation added for five more FO's.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198470 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Glen Mazza 19 years ago
parent
commit
22ed7684d3

+ 3
- 1
src/java/org/apache/fop/fo/FONode.java View File

@@ -185,7 +185,9 @@ public abstract class FONode implements Cloneable {
}

/**
*
* 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

+ 31
- 1
src/java/org/apache/fop/fo/flow/BlockContainer.java View File

@@ -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 @@ import org.apache.fop.fo.properties.LengthRangeProperty;

/**
* 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 @@ public class BlockContainer extends FObj {
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
*/
@@ -101,10 +106,35 @@ public class BlockContainer extends FObj {
getFOEventHandler().startBlockContainer(this);
}

/**
* @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);
}


+ 32
- 1
src/java/org/apache/fop/fo/flow/InlineContainer.java View File

@@ -22,12 +22,15 @@ package org.apache.fop.fo.flow;
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 @@ import org.apache.fop.layoutmgr.LayoutManager;

/**
* 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 @@ public class InlineContainer extends FObj {
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
*/
@@ -106,6 +111,32 @@ public class InlineContainer extends FObj {
checkId(id);
}

/**
* @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.
*/

+ 1
- 4
src/java/org/apache/fop/fo/flow/ListItemBody.java View File

@@ -23,14 +23,13 @@ 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.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 @@ public class ListItemBody extends FObj {
}

/**
* 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 {

+ 27
- 0
src/java/org/apache/fop/fo/flow/ListItemLabel.java View File

@@ -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 @@ public class ListItemLabel extends FObj {
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
*/
@@ -60,10 +66,31 @@ public class ListItemLabel extends FObj {
getFOEventHandler().startListLabel();
}

/**
* @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();
}


+ 14
- 4
src/java/org/apache/fop/fo/flow/MultiToggle.java View File

@@ -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 @@ public class MultiToggle extends FObj {
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);
}
}


Loading…
Cancel
Save