aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorGlen Mazza <gmazza@apache.org>2005-03-05 04:52:06 +0000
committerGlen Mazza <gmazza@apache.org>2005-03-05 04:52:06 +0000
commit22ed7684d345f0504de4547f6735069a07d2eb1d (patch)
treefa56c88127105b097eee985ffbc4d6569a200951 /src/java/org/apache/fop
parente7450b91fbd4ba6eba950faab0c27e2c17a58d85 (diff)
downloadxmlgraphics-fop-22ed7684d345f0504de4547f6735069a07d2eb1d.tar.gz
xmlgraphics-fop-22ed7684d345f0504de4547f6735069a07d2eb1d.zip
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
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java4
-rw-r--r--src/java/org/apache/fop/fo/flow/BlockContainer.java32
-rw-r--r--src/java/org/apache/fop/fo/flow/InlineContainer.java33
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItemBody.java5
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItemLabel.java27
-rw-r--r--src/java/org/apache/fop/fo/flow/MultiToggle.java18
6 files changed, 108 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index c0f3a2c92..37e2b8222 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -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
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index 2195d7702..d18c7fbfd 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -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
*/
@@ -102,9 +107,34 @@ public class BlockContainer extends FObj {
}
/**
+ * @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);
}
diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java
index 6f7d18f01..985e6c508 100644
--- a/src/java/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java
@@ -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
*/
@@ -107,6 +112,32 @@ public class InlineContainer extends FObj {
}
/**
+ * @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() {
diff --git a/src/java/org/apache/fop/fo/flow/ListItemBody.java b/src/java/org/apache/fop/fo/flow/ListItemBody.java
index 8a79dc988..a3f7e776a 100644
--- a/src/java/org/apache/fop/fo/flow/ListItemBody.java
+++ b/src/java/org/apache/fop/fo/flow/ListItemBody.java
@@ -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 {
diff --git a/src/java/org/apache/fop/fo/flow/ListItemLabel.java b/src/java/org/apache/fop/fo/flow/ListItemLabel.java
index e6413e2a3..86a44d121 100644
--- a/src/java/org/apache/fop/fo/flow/ListItemLabel.java
+++ b/src/java/org/apache/fop/fo/flow/ListItemLabel.java
@@ -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
*/
@@ -61,9 +67,30 @@ public class ListItemLabel extends FObj {
}
/**
+ * @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();
}
diff --git a/src/java/org/apache/fop/fo/flow/MultiToggle.java b/src/java/org/apache/fop/fo/flow/MultiToggle.java
index 7c0111cde..1a9f6c05f 100644
--- a/src/java/org/apache/fop/fo/flow/MultiToggle.java
+++ b/src/java/org/apache/fop/fo/flow/MultiToggle.java
@@ -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);
}
}