aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-02-23 22:04:01 +0000
committerJeremias Maerki <jeremias@apache.org>2005-02-23 22:04:01 +0000
commit8ada5c8257ff520a5869e2f6fccce3d5349a9305 (patch)
tree74f29a246da86d9e45e4eb6cb9dd4fc3ce75c1b2 /src
parentce6b0bd2e4f97178ea4f3677daa565d4ae12d8a3 (diff)
downloadxmlgraphics-fop-8ada5c8257ff520a5869e2f6fccce3d5349a9305.tar.gz
xmlgraphics-fop-8ada5c8257ff520a5869e2f6fccce3d5349a9305.zip
An empty table-body is illegal but we'll allow it to make things easier for stylesheet writers.
Empty table-body elements are removed from their parent so they can't cause any nasty effects in the LMs. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198457 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java10
-rw-r--r--src/java/org/apache/fop/fo/FObj.java7
-rw-r--r--src/java/org/apache/fop/fo/flow/TableBody.java9
3 files changed, 25 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index 4f9707c2d..ba7832858 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -198,6 +198,15 @@ public abstract class FONode implements Cloneable {
}
/**
+ * Removes a child node. Used by the child nodes to remove themselves, for
+ * example table-body if it has no children.
+ * @param child child node to be removed
+ */
+ public void removeChild(FONode child) {
+ //nop
+ }
+
+ /**
* @return the parent node of this node
*/
public FONode getParent() {
@@ -410,5 +419,6 @@ public abstract class FONode implements Cloneable {
public int getNameId() {
return Constants.FO_UNKNOWN_NODE;
}
+
}
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index 87dc3bb1e..b3982bfa5 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -170,6 +170,13 @@ public abstract class FObj extends FONode implements Constants {
}
}
+ /** @see org.apache.fop.fo.FONode#removeChild(org.apache.fop.fo.FONode) */
+ public void removeChild(FONode child) {
+ if (childNodes != null) {
+ childNodes.remove(child);
+ }
+ }
+
/**
* Find the nearest parent, grandparent, etc. FONode that is also an FObj
* @return FObj the nearest ancestor FONode that is an FObj
diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java
index 28c182424..fd3b42341 100644
--- a/src/java/org/apache/fop/fo/flow/TableBody.java
+++ b/src/java/org/apache/fop/fo/flow/TableBody.java
@@ -88,6 +88,11 @@ public class TableBody extends FObj {
*/
protected void endOfNode() throws FOPException {
getFOEventHandler().endBody(this);
+ if (childNodes == null || childNodes.size() == 0) {
+ getLogger().error("fo:table-body must not be empty. "
+ + "Expected: (table-row+|table-cell+)");
+ getParent().removeChild(this);
+ }
convertCellsToRows();
}
@@ -98,7 +103,9 @@ public class TableBody extends FObj {
*/
private void convertCellsToRows() throws FOPException {
try {
- if (childNodes.size() == 0 || childNodes.get(0) instanceof TableRow) {
+ if (childNodes == null
+ || childNodes.size() == 0
+ || childNodes.get(0) instanceof TableRow) {
return;
}
//getLogger().debug("Converting cells to rows...");