/** Name of the node */
protected String name;
+ /** Marks input file containing this object **/
+ public String systemId;
+
+ /** Marks line number of this object in the input file **/
+ public int line;
+
+ /** Marks column number of this object in the input file **/
+ public int column;
+
/**
* Main constructor.
* @param parent parent of this node
this.parent = parent;
}
+ /**
+ * Set the location information for this element
+ * @param locator the org.xml.sax.Locator object
+ */
+ public void setLocation(Locator locator) {
+ if (locator != null) {
+ line = locator.getLineNumber();
+ column = locator.getColumnNumber();
+ systemId = locator.getSystemId();
+ }
+ }
+
/**
* Returns the user agent for the node.
* @return FOUserAgent
* @throws FOPException for errors or inconsistencies in the attributes
*/
public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException {
+ System.out.println("name = " + elementName);
this.name = elementName;
}
/**
* 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 offendingNode incoming node that would cause a duplication.
*/
protected void tooManyNodesError(Locator loc, String offendingNode) {
/**
* Helper function to standardize "out of order" exceptions
* (e.g., fo:layout-master-set appearing after fo:page-sequence)
+ * @param loc org.xml.sax.Locator object of the error (*not* parent node)
* @param tooLateNode string name of node that should be earlier in document
* @param tooEarlyNode string name of node that should be later in document
*/
/**
* Helper function to return "invalid child" exceptions
* (e.g., fo:block appearing immediately under 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 invalidChildError(Locator loc, String nsURI, String lName) {
throw new IllegalArgumentException(
errorText(loc) + getNodeString(nsURI, lName) +
- " is not valid child element of " + getName() + ".");
+ " is not a valid child element of " + getName() + ".");
}
+ /**
+ * Helper function to return missing child element errors
+ * (e.g., fo:layout-master-set not having any page-master child element)
+ * @param contentModel The XSL Content Model for the fo: object.
+ * or a similar description indicating child elements needed.
+ */
+ protected void missingChildElementError(String contentModel) {
+ throw new IllegalArgumentException(
+ errorText(line, column) + getName() + " is missing child elements. \n" +
+ "Required Content Model: " + contentModel);
+ }
+
/**
* Helper function to return "Error (line#/column#)" string for
* above exception messages
* @param loc org.xml.sax.Locator object
+ * @return String opening error text
*/
protected static String errorText(Locator loc) {
return "Error(" + loc.getLineNumber() + "/" + loc.getColumnNumber() + "): ";
}
+
+ /**
+ * Helper function to return "Error (line#/column#)" string for
+ * above exception messages
+ * @param lineNumber - line number of node with error
+ * @param columnNumber - column number of node with error
+ * @return String opening error text
+ */
+ protected static String errorText(int lineNumber, int columnNumber) {
+ return "Error(" + lineNumber + "/" + columnNumber + "): ";
+ }
}
*/
public void endElement(String uri, String localName, String rawName)
throws SAXException {
- currentFObj.end();
+ try {
+ currentFObj.end();
+ } catch (IllegalArgumentException e) {
+ throw new SAXException(e);
+ }
+
currentFObj = currentFObj.getParent();
}
/** Dynamic layout dimension. Used to resolve relative lengths. */
protected Map layoutDimension = null;
- /** Marks input file containing this object **/
- public String systemId;
-
- /** Marks line number of this object in the input file **/
- public int line;
-
- /** Marks column number of this object in the input file **/
- public int column;
-
/**
* Create a new formatting object.
* All formatting object classes extend this class.
name = "fo:" + str;
}
- /**
- * Set the location information for this element
- * @param locator the org.xml.sax.Locator object
- */
- public void setLocation(Locator locator) {
- if (locator != null) {
- line = locator.getLineNumber();
- column = locator.getColumnNumber();
- systemId = locator.getSystemId();
- }
- }
-
/**
* Set properties for this FO based on node attributes
* @param attlist Collection of attributes passed to us from the parser.
parentPL = parentFO.getPropertiesForNamespace(FOElementMapping.URI);
}
- propertyList = new PropertyList(this, parentPL, FOElementMapping.URI, name);
+ propertyList = new PropertyList(this, parentPL, FOElementMapping.URI);
propertyList.addAttributesToList(attlist);
propMgr = new PropertyManager(propertyList);
setWritingMode();
return getName() + " at line " + line + ":" + column;
}
*/
+
+ public String getName() {
+ return null;
+ }
+
}
private PropertyList parentPropertyList = null;
private String namespace = "";
- private String elementName = "";
private FObj fobj = null;
/**
* @param parentPropertyList the PropertyList belonging to the new objects
* parent
* @param space name of namespace
- * @param elementName name of element
*/
public PropertyList(FObj fObjToAttach, PropertyList parentPropertyList,
- String space, String elementName) {
+ String space) {
this.fobj = fObjToAttach;
this.parentPropertyList = parentPropertyList;
this.namespace = space;
- this.elementName = elementName;
}
/**
return namespace;
}
- /**
- * @return element name for this
- */
- public String getElement() {
- return elementName;
- }
-
/**
* Return the value explicitly specified on this FO.
* @param propertyName The name of the property whose value is desired.
* @see org.apache.fop.fo.FONode#processNode
*/
public void processNode(String elementName, Locator locator, Attributes attlist) throws FOPException {
+ setLocation(locator);
name = elementName;
attr = attlist;
}
throw new PropertyException("Non numeric operand to "
+ "proportional-column-width function");
}
- if (!pInfo.getPropertyList().getElement().equals("fo:table-column")) {
+ if (!pInfo.getPropertyList().getFObj().getName().equals("fo:table-column")) {
throw new PropertyException("proportional-column-width function "
+ "may only be used on table-column FO");
}
package org.apache.fop.fo.extensions;
+// Java
+import java.util.ArrayList;
+
+// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.pagination.Root;
-import java.util.ArrayList;
-
/**
* Bookmarks data is the top level element of the pdf bookmark extension.
* This handles the adding of outlines. When the element is ended it
* the bookmark data from the child elements and add
* the extension to the area tree.
*/
- public void end() {
+ protected void end() {
((Root) parent).setBookmarks(this);
}
/**
* @see org.apache.fop.fo.FONode#end
*/
- public void end() {
+ protected void end() {
super.end();
getFOInputHandler().endLink();
}
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
/**
* @see org.apache.fop.fo.FONode#end
*/
- public void end() {
+ protected void end() {
handleWhiteSpace();
getFOInputHandler().endBlock(this);
}
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
import org.xml.sax.Attributes;
// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.CharIterator;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
-import org.apache.fop.apps.FOPException;
/**
* Class modelling the fo:inline object. See Sec. 6.6.7 of the XSL-FO Standard.
/**
* @see org.apache.fop.fo.FONode#end
*/
- public void end() {
+ protected void end() {
getFOInputHandler().endInline(this);
}
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.apps.FOPException;
import java.net.URL;
import java.io.IOException;
import java.io.InputStream;
+
+// XML
import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
// FOP
import org.apache.fop.datatypes.ColorType;
}
/**
- * @see org.apache.fop.fo.FONode#validateChildNode(String, String)
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
XSL 1.0/FOP: EMPTY (no child nodes permitted)
*/
protected void validateChildNode(Locator loc, String nsURI, String localName) {
* Extract instance variables from the collection of properties for this
* object.
*/
- public void end() {
+ protected void end() {
src = this.propertyList.get(PR_SRC).getString();
profileName = this.propertyList.get(PR_COLOR_PROFILE_NAME).getString();
intent = this.propertyList.get(PR_RENDERING_INTENT).getEnum();
import java.util.Map;
import java.util.Iterator;
+// XML
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
// FOP
import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.fo.XMLObj;
-import org.xml.sax.Locator;
/**
}
/**
- * @see org.apache.fop.fo.FONode#validateChildNode(String, String)
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
XSL 1.0: (color-profile)+ (and non-XSL NS nodes)
FOP/XSL 1.1: (color-profile)* (and non-XSL NS nodes)
*/
* At the end of this element sort out the child into
* a hashmap of color profiles and a list of external xml.
*/
- public void end() {
+ protected void end() {
if (children != null) {
for (Iterator iter = children.iterator(); iter.hasNext();) {
FONode node = (FONode)iter.next();
/**
* Tell the StructureRenderer that we are at the end of the flow.
*/
- public void end() {
+ protected void end() {
getFOInputHandler().endFlow(this);
}
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.apps.FOPException;
+import org.xml.sax.Locator;
/**
* The layout-master-set formatting object.
super(parent);
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ XSL/FOP: (simple-page-master|page-sequence-master)+
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName) {
+ if (nsURI == FOElementMapping.URI) {
+ if (!localName.equals("simple-page-master")
+ && !localName.equals("page-sequence-master")) {
+ invalidChildError(loc, nsURI, localName);
+ }
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+
+ protected void end() {
+ if (children == null) {
+ missingChildElementError("(simple-page-master|page-sequence-master)+");
+ }
+ }
+
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
package org.apache.fop.fo.pagination;
+// Java
+import java.util.HashMap;
+
+// XML
+import org.xml.sax.Attributes;
+
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.FOTreeVisitor;
import org.apache.fop.apps.FOPException;
-// Java
-import java.util.HashMap;
-
-import org.xml.sax.Attributes;
-
/**
* This provides pagination of flows onto pages. Much of the
* logic for paginating flows is contained in this class.
* This passes the end page sequence to the structure handler
* so it can act upon that.
*/
- public void end() {
+ protected void end() {
try {
getFOInputHandler().endPageSequence(this);
} catch (FOPException fopex) {
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
+
/**
* Abstract base class for fo:region-before and fo:region-after.
*/
/**
* @see org.apache.fop.fo.FONode#end()
*/
- public void end() {
+ protected void end() {
super.end();
bPrecedence =
(this.propertyList.get(PR_PRECEDENCE).getEnum() == Precedence.TRUE);
package org.apache.fop.fo.pagination;
+// XML
+import org.xml.sax.SAXException;
+
// FOP
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FOTreeVisitor;
+
/**
* Base class for Before, After, Start and End regions (BASE).
*/
/**
* @see org.apache.fop.fo.FONode#end()
*/
- public void end() {
+ protected void end() {
// The problem with this is that it might not be known yet....
// Supposing extent is calculated in terms of percentage
this.extent = this.propertyList.get(PR_EXTENT).getLength().getValue();
}
/**
- * @see org.apache.fop.fo.FONode#validateChildNode(String, String)
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
XSL 1.0 Spec: (layout-master-set,declarations?,page-sequence+)
FOP: (layout-master-set, declarations?, fox:bookmarks?, page-sequence+)
*/