protected String name;
/**
- *
* @param parent the parent formatting object
*/
public XMLObj(FONode parent) {
super(parent);
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * here, blocks XSL FO's from having non-FO parents.
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FO_URI) {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+
/**
* @see org.apache.fop.fo.FONode#processNode
*/
+++ /dev/null
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.fo.pagination;
-
-// SAX
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXParseException;
-
-// FOP
-import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.FObj;
-
-/**
- * Base PageMasterReference class. Provides implementation for handling the
- * master-reference attribute and containment within a PageSequenceMaster
- */
-public abstract class PageMasterReference extends FObj
- implements SubSequenceSpecifier {
-
- private String masterName;
-
- /**
- * @see org.apache.fop.fo.FONode#FONode(FONode)
- */
- public PageMasterReference(FONode parent) {
- super(parent);
- }
-
- /**
- * @see org.apache.fop.fo.FObj#addProperties
- */
- protected void addProperties(Attributes attlist) throws SAXParseException {
- super.addProperties(attlist);
- if (getProperty(PR_MASTER_REFERENCE) != null) {
- this.masterName = getProperty(PR_MASTER_REFERENCE).getString();
- }
- validateParent(parent);
- }
-
-
- /**
- * Returns the "master-reference" attribute of this page master reference
- * @return the name of the page master
- */
- public String getMasterName() {
- return masterName;
- }
-
- /**
- * Checks that the parent is the right element. The default implementation
- * checks for fo:page-sequence-master.
- * @param parent parent node
- * @throws SAXParseException If the parent is invalid.
- */
- protected void validateParent(FONode parent) throws SAXParseException {
- if (parent.getName().equals("fo:page-sequence-master")) {
- PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
-
- if (getMasterName() == null) {
- getLogger().warn(getName()
- + " does not have a master-reference and so is being ignored");
- } else {
- pageSequenceMaster.addSubsequenceSpecifier(this);
- }
- } else {
- throw new SAXParseException(getName() + " must be"
- + "child of fo:page-sequence-master, not "
- + parent.getName(), locator);
- }
- }
-
- public String getName() {
- return "fo:page-master-reference";
- }
-}
// FOP
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
/**
* A repeatable-page-master-reference formatting object.
* This handles a reference with a specified number of repeating
* instances of the referenced page master (may have no limit).
*/
-public class RepeatablePageMasterReference extends PageMasterReference {
+public class RepeatablePageMasterReference extends FObj
+ implements SubSequenceSpecifier {
private static final int INFINITE = -1;
private PageSequenceMaster pageSequenceMaster;
-
private int maximumRepeats;
private int numberConsumed = 0;
super(parent);
}
- /**
- * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
- * XSL Content Model: empty
- */
- protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws SAXParseException {
- invalidChildError(loc, nsURI, localName);
- }
-
/**
* @see org.apache.fop.fo.FObj#addProperties
+ * @todo need to
*/
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
+
+ PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
+
+ if (getPropString(PR_MASTER_REFERENCE) == null) {
+ missingPropertyError("master-reference");
+ } else {
+ pageSequenceMaster.addSubsequenceSpecifier(this);
+ }
+
String mr = getPropString(PR_MAXIMUM_REPEATS);
+
if (mr.equals("no-limit")) {
this.maximumRepeats = INFINITE;
} else {
}
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: empty
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ invalidChildError(loc, nsURI, localName);
+ }
+
/**
* @see org.apache.fop.fo.pagination.SubSequenceSpecifier
*/
return null;
}
}
- return getMasterName();
+ return getPropString(PR_MASTER_REFERENCE);
}
/**
this.numberConsumed = 0;
}
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
public String getName() {
return "fo:repeatable-page-master-reference";
}
// FOP
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
/**
* A single-page-master-reference formatting object.
* This is a reference for a single page. It returns the
* master name only once until reset.
*/
-public class SinglePageMasterReference extends PageMasterReference {
+public class SinglePageMasterReference extends FObj
+ implements SubSequenceSpecifier {
private static final int FIRST = 0;
private static final int DONE = 1;
this.state = FIRST;
}
+ /**
+ * @see org.apache.fop.fo.FObj#addProperties
+ */
+ protected void addProperties(Attributes attlist) throws SAXParseException {
+ super.addProperties(attlist);
+
+ PageSequenceMaster pageSequenceMaster = (PageSequenceMaster) parent;
+ if (getPropString(PR_MASTER_REFERENCE) == null) {
+ missingPropertyError("master-reference");
+ } else {
+ pageSequenceMaster.addSubsequenceSpecifier(this);
+ }
+ }
+
/**
* @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
* XSL Content Model: empty
boolean isEmptyPage) {
if (this.state == FIRST) {
this.state = DONE;
- return getMasterName();
+ return getPropString(PR_MASTER_REFERENCE);
} else {
return null;
}