return this.name;
}
+ /**
+ * Checks to make sure, during SAX processing of input document, that the
+ * incoming node is valid for the this (parent) node (e.g., checking to
+ * see that fo:table is not an immediate child of fo:root)
+ * called within FObj constructor
+ * @param namespaceURI namespace of incoming node
+ * @param localName (e.g. "table" for "fo:table")
+ * @throws IllegalArgumentException if incoming node not valid for parent
+ */
+ protected void validateChildNode(String namespaceURI, String localName) {}
+
/**
* Adds characters (does nothing here)
* @param data text
// Check to ensure first node encountered is an fo:root
if (rootFObj == null) {
if (!namespaceURI.equals(FObj.FO_URI) || !localName.equals("root")) {
- throw new SAXException(new FOPException("Error: Root element" +
- " must be fo:root formatting object"));
+ throw new SAXException(new IllegalArgumentException(
+ "Error: First element must be fo:root formatting object"));
+ }
+ } else { // check that incoming node is valid for currentFObj
+ try {
+ currentFObj.validateChildNode(namespaceURI, localName);
+ } catch (IllegalArgumentException e) {
+ throw new SAXException(e);
}
}
ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName);
-
// System.out.println("found a " + fobjMaker.toString());
try {
foNode = fobjMaker.make(currentFObj);
foNode.processNode(localName, locator, attlist);
+ } catch (IllegalArgumentException e) {
+ throw new SAXException(e);
} catch (FOPException e) {
throw new SAXException(e);
}
* @param localName name of the Element
* @return the ElementMapping.Maker that can create an FO object for this element
*/
- public Maker findFOMaker(String namespaceURI, String localName) {
+ private Maker findFOMaker(String namespaceURI, String localName) {
Map table = (Map)fobjTable.get(namespaceURI);
Maker fobjMaker = null;
if (table != null) {
*/
public void processNode(String elementName, Locator locator,
Attributes attlist) throws FOPException {
- setName(elementName);
setLocation(locator);
addProperties(attlist);
}
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveLabel(this);
}
+
+ public String getName() {
+ return "(http://xml.apache.org/fop/extensions) label";
+ }
}
return outlines;
}
+ public String getName() {
+ return "(http://xml.apache.org/fop/extensions) outline";
+ }
}
getFOTreeControl().getFOInputHandler().endLink();
}
+
+ public String getName() {
+ return "fo:basic-link";
+ }
}
fotv.serveBidiOverride(this);
}
+ public String getName() {
+ return "fo:bidi-override";
+ }
}
fotv.serveBlock(this);
}
+ public String getName() {
+ return "fo:block";
+ }
+
}
fotv.serveBlockContainer(this);
}
+ public String getName() {
+ return "fo:block-container";
+ }
}
fotv.serveCharacter(this);
}
+ public String getName() {
+ return "fo:character";
+ }
}
return placement;
}
+ public String getName() {
+ return "fo:external-graphic";
+ }
+
}
fotv.serveFloat(this);
}
+ public String getName() {
+ return "fo:float";
+ }
}
super.end();
getFOTreeControl().getFOInputHandler().endFootnote(this);
}
+
+ public String getName() {
+ return "fo:footnote";
+ }
}
getFOTreeControl().getFOInputHandler().endFootnoteBody(this);
}
+
+ public String getName() {
+ return "fo:footnote-body";
+ }
}
fotv.serveInitialPropertySet(this);
}
+ public String getName() {
+ return "fo:initial-property-set";
+ }
}
getFOTreeControl().getFOInputHandler().endInline(this);
}
+ public String getName() {
+ return "fo:inline";
+ }
}
fotv.serveInlineContainer(this);
}
+ public String getName() {
+ return "fo:inline-container";
+ }
}
fotv.serveInstreamForeignObject(this);
}
+ public String getName() {
+ return "fo:instream-foreign-object";
+ }
}
fotv.serveLeader(this);
}
+ public String getName() {
+ return "fo:leader";
+ }
}
getFOTreeControl().getFOInputHandler().endList(this);
}
+
+ public String getName() {
+ return "fo:list-block";
+ }
}
super.end();
getFOTreeControl().getFOInputHandler().endListItem(this);
}
+
+ public String getName() {
+ return "fo:list-item";
+ }
}
fotv.serveListItemBody(this);
}
+ public String getName() {
+ return "fo:list-item-body";
+ }
}
getFOTreeControl().getFOInputHandler().endListLabel();
}
+
+ public String getName() {
+ return "fo:list-item-label";
+ }
}
fotv.serveMarker(this);
}
+ public String getName() {
+ return "fo:marker";
+ }
}
fotv.serveMultiCase(this);
}
+ public String getName() {
+ return "fo:multi-case";
+ }
}
fotv.serveMultiProperties(this);
}
+ public String getName() {
+ return "fo:multi-properties";
+ }
}
fotv.serveMultiPropertySet(this);
}
+ public String getName() {
+ return "fo:multi-property-set";
+ }
}
fotv.serveMultiSwitch(this);
}
+ public String getName() {
+ return "fo:multi-switch";
+ }
}
fotv.serveMultiToggle(this);
}
+ public String getName() {
+ return "fo:multi-toggle";
+ }
}
protected void end() {
getFOTreeControl().getFOInputHandler().endPageNumber(this);
}
+
+ public String getName() {
+ return "fo:page-number";
+ }
}
return fontState;
}
+ public String getName() {
+ return "fo:page-number-citation";
+ }
}
fotv.serveRetrieveMarker(this);
}
+ public String getName() {
+ return "fo:retrieve-marker";
+ }
}
getFOTreeControl().getFOInputHandler().endTable(this);
}
+ public String getName() {
+ return "fo:table";
+ }
}
fotv.serveTableAndCaption(this);
}
+ public String getName() {
+ return "fo:table-and-caption";
+ }
+
}
getFOTreeControl().getFOInputHandler().endBody(this);
}
+ public String getName() {
+ return "fo:table-body";
+ }
}
fotv.serveTableCaption(this);
}
+ public String getName() {
+ return "fo:table-caption";
+ }
}
protected void end() {
getFOTreeControl().getFOInputHandler().endCell(this);
}
+
+ public String getName() {
+ return "fo:table-cell";
+ }
+
}
protected void end() {
getFOTreeControl().getFOInputHandler().endColumn(this);
}
+
+ public String getName() {
+ return "fo:table-column";
+ }
}
fotv.serveTableFooter(this);
}
+ public String getName() {
+ return "fo:table-footer";
+ }
}
fotv.serveTableHeader(this);
}
+ public String getName() {
+ return "fo:table-header";
+ }
}
protected void end() {
getFOTreeControl().getFOInputHandler().endRow(this);
}
+
+ public String getName() {
+ return "fo:table-row";
+ }
}
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveWrapper(this);
}
+
+ public String getName() {
+ return "fo:wrapper";
+ }
}
fotv.serveColorProfile(this);
}
+ public String getName() {
+ return "fo:color-profile";
+ }
}
fotv.serveConditionalPageMasterReference(this);
}
+ public String getName() {
+ return "fo:conditional-page-master-reference";
+ }
}
fotv.serveDeclarations(this);
}
+ public String getName() {
+ return "fo:declarations";
+ }
}
public void acceptVisitor(FOTreeVisitor fotv) {
fotv.serveFlow(this);
}
+
+ public String getName() {
+ return "fo:flow";
+ }
}
if (parent.getName().equals("fo:root")) {
Root root = (Root)parent;
- if (root.getLayoutMasterSet() != null) {
- throw new FOPException("Multiple fo:layout-master-sets " +
- "found; only one allowed per document");
- }
root.setLayoutMasterSet(this);
} else {
throw new FOPException("fo:layout-master-set must be child of fo:root, not "
fotv.serveLayoutMasterSet(this);
}
+ public String getName() {
+ return "fo:layout-master-set";
+ }
}
fotv.servePageMasterReference(this);
}
+ public String getName() {
+ return "fo:page-master-reference";
+ }
}
return alphaNumber.reverse().toString();
}
+ public String getName() {
+ return "fo:page-number-generator";
+ }
+
}
*/
protected void addProperties(Attributes attlist) throws FOPException {
super.addProperties(attlist);
- if (parent.getName().equals("fo:root")) {
- this.root = (Root)parent;
- // this.root.addPageSequence(this);
- } else {
- throw new FOPException("Error: page-sequence must be child of root, not "
- + parent.getName());
- }
+ this.root = (Root) parent;
+// this.root.addPageSequence(this);
layoutMasterSet = root.getLayoutMasterSet();
- if (layoutMasterSet == null) {
- throw new FOPException("Error: fo:layout-master-set undefined for this document");
- }
-
// best time to run some checks on LayoutMasterSet
layoutMasterSet.checkRegionNames();
}
}
-
String masterName = this.propertyList.get(PR_MASTER_REFERENCE).getString();
this.simplePageMaster =
this.layoutMasterSet.getSimplePageMaster(masterName);
return root;
}
+ public String getName() {
+ return "fo:page-sequence";
+ }
}
fotv.servePageSequenceMaster(this);
}
+ public String getName() {
+ return "fo:page-sequence-master";
+ }
}
fotv.serveRegionAfter(this);
}
+ public String getName() {
+ return "fo:region-after";
+ }
}
fotv.serveRegionBefore(this);
}
+ public String getName() {
+ return "fo:region-before";
+ }
}
fotv.serveRegionBody(this);
}
+ public String getName() {
+ return "fo:region-body";
+ }
}
fotv.serveRegionEnd(this);
}
+ public String getName() {
+ return "fo:region-end";
+ }
}
fotv.serveRegionStart(this);
}
+ public String getName() {
+ return "fo:region-start";
+ }
}
fotv.serveRepeatablePageMasterAlternatives(this);
}
+ public String getName() {
+ return "fo:repeatable-page-master-alternatives";
+ }
}
fotv.serveRepeatablePageMasterReference(this);
}
+ public String getName() {
+ return "fo:repeatable-page-master-reference";
+ }
}
*/
public class Root extends FObj {
private LayoutMasterSet layoutMasterSet;
+ private Declarations declarations;
private List pageSequences;
/**
}
}
+ /**
+ * @see org.apache.fop.fo.FONode#validateChildNode(String, String)
+ */
+ protected void validateChildNode(String namespaceURI, String localName) {
+ if (namespaceURI == FObj.FO_URI) {
+ if (localName.equals("layout-master-set")) {
+ if (layoutMasterSet != null) { // only one fo:declarations
+ throw new IllegalArgumentException("Error: Only one" +
+ " fo:layout-master-set may be defined per fo:root");
+ }
+ } else if (localName.equals("declarations")) {
+ if (layoutMasterSet == null) { // must already have a l-m-s
+ throw new IllegalArgumentException("Error:" +
+ " fo:layout-master-set must be first child of" +
+ " fo:root");
+ } else if (declarations != null) { // only one fo:declarations
+ throw new IllegalArgumentException("Error: Only one" +
+ " fo:declarations may be defined per fo:root");
+ } else if (!pageSequences.isEmpty()) { // no page-seqs yet
+ throw new IllegalArgumentException("Error: fo:declarations" +
+ " must be defined before fo:page-sequence declarations");
+ }
+ } else if (localName.equals("page-sequence")) {
+ if (layoutMasterSet == null) { // must already have a l-m-s
+ throw new IllegalArgumentException("Error:" +
+ " fo:layout-master-set must be first child of fo:root");
+ }
+ } else
+ throw new IllegalArgumentException("Error: Invalid child" +
+ " node \"fo:" + localName + "\" of fo:root");
+ } else {
+ throw new IllegalArgumentException("Error: Invalid child node ("
+ + namespaceURI + ") \"" + localName + "\" of fo:root");
+ }
+ }
+
/**
* Returns the number of pages generated (over all PageSequence instances).
* @return the number of pages
fotv.serveRoot(this);
}
+ public String getName() {
+ return "fo:root";
+ }
}
fotv.serveSimplePageMaster(this);
}
+ public String getName() {
+ return "fo:simple-page-master";
+ }
}
fotv.serveSinglePageMasterReference(this);
}
+ public String getName() {
+ return "fo:single-page-master-reference";
+ }
}
fotv.serveStaticContent(this);
}
+ public String getName() {
+ return "fo:static-content";
+ }
}
fotv.serveTitle(this);
}
+ public String getName() {
+ return "fo:title";
+ }
}