import org.apache.fop.fo.FONode;
import org.apache.fop.fo.expr.PropertyException;
import org.apache.fop.fo.pagination.FoLayoutMasterSet;
+import org.apache.fop.xml.FoXMLEvent;
import org.apache.fop.xml.XMLEvent;
import org.apache.fop.xml.XMLNamespaces;
-import org.apache.fop.xml.SyncedXmlEventsBuffer;
+import org.apache.fop.xml.SyncedFoXmlEventsBuffer;
import org.xml.sax.Attributes;
/**
* @param foTree the FO tree being built
- * @param event the <tt>XMLEvent</tt> that triggered the creation of this
+ * @param event the <tt>FoXMLEvent</tt> that triggered the creation of this
* node
*/
public FoRoot
- (FOTree foTree, XMLEvent event)
+ (FOTree foTree, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
// This is the root node of the tree; hence the null argument
* in the page-sequence-sequence.
*/
public void buildFoTree() throws FOPException{
- XMLEvent ev;
+ FoXMLEvent ev;
System.out.println("buildFoTree: " + event);
// Look for layout-master-set
try {
(XMLNamespaces.XSLNSpaceIndex, "layout-master-set",
XMLEvent.DISCARD_W_SPACE);
} catch (NoSuchElementException e) {
- throw new FOPException(e);
+ throw new FOPException("buildFoTree: Unexpected EOF in layout-master-set.");
}
// Process the layout-master-set
try {
}
// Look for optional declarations
try {
- xmlevents.expectStartElement
+ ev = xmlevents.expectStartElement
(XMLNamespaces.XSLNSpaceIndex, "declarations",
XMLEvent.DISCARD_W_SPACE);
- // process the declarations
- xmlevents.getEndElement
- (XMLNamespaces.XSLNSpaceIndex, "declarations");
+ if (ev != null) {
+ // process the declarations
+ xmlevents.getEndElement
+ (XMLNamespaces.XSLNSpaceIndex, "declarations");
+ }
} catch (NoSuchElementException e) {
- // Take no notice - declarations is optional
+ throw new FOPException
+ ("Unexpected EOF while processing declarations.");
}
-
+
}
}
import org.apache.fop.fo.FOTree;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.xml.FoXMLEvent;
import org.apache.fop.xml.XMLEvent;
import org.apache.fop.xml.UriLocalName;
import org.apache.fop.xml.XMLNamespaces;
-import org.apache.fop.xml.SyncedXmlEventsBuffer;
+import org.apache.fop.xml.SyncedFoXmlEventsBuffer;
import org.apache.fop.datastructs.Tree;
import org.apache.fop.fo.pagination.FoPageSequenceMaster;
import org.apache.fop.fo.pagination.PageSequenceMaster;
* this node
*/
public FoLayoutMasterSet
- (FOTree foTree, FONode parent, XMLEvent event)
+ (FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.LAYOUT_MASTER_SET, parent, event,
* @param event - the layout page-master-set STARTELEMENT event.
* @throws <tt>FOPException</tt>.
*/
- public void setupPageMasters(XMLEvent event)
+ public void setupPageMasters(FoXMLEvent event)
throws FOPException, PropertyException
{
FoSimplePageMaster simple;
FoPageSequenceMaster foPageSeq;
try {
do {
- XMLEvent ev =
+ FoXMLEvent ev =
xmlevents.expectStartElement
(simpleOrSequenceMaster, XMLEvent.DISCARD_W_SPACE);
+ if (ev == null) break; // No instance of these elements found
localName = ev.getLocalName();
if (localName.equals("simple-page-master")) {
//System.out.println("Found simple-page-master");
("Aargh! expectStartElement(events, list)");
} while (true);
} catch (NoSuchElementException e) {
- // Masters exhausted
+ // Unexpected end of file
+ throw new FOPException("layout-master-set: unexpected EOF.");
}
catch (PropertyException e) {
throw new FOPException(e);
catch (Tree.TreeException e) {
throw new FOPException(e);
}
+ if (pageMasters.size() == 0)
+ throw new FOPException("No pageg masters defined in layout-master-set.");
// Create the master set structures.
// Scan the page-sequence-masters
// N.B. Processing of the page-sequence-masters must be deferred until
// FOP
import org.apache.fop.fo.FOAttributes;
+import org.apache.fop.xml.FoXMLEvent;
import org.apache.fop.xml.XMLEvent;
import org.apache.fop.xml.XMLNamespaces;
import org.apache.fop.xml.UriLocalName;
//private ArrayList subSequenceList = new ArrayList(1);
- public FoPageSequenceMaster(FOTree foTree, FONode parent, XMLEvent event)
+ public FoPageSequenceMaster(FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.PAGE_SEQUENCE_MASTER, parent, event,
// Process sequence members here
try {
do {
- XMLEvent ev = xmlevents.expectStartElement
+ FoXMLEvent ev = xmlevents.expectStartElement
(singleOrRepeatableMasterRefs, XMLEvent.DISCARD_W_SPACE);
+ if (ev == null) break; // page-sequence-masters exhausted
String localName = ev.getLocalName();
if (localName.equals("single-page-master-reference")) {
//System.out.println("Found single-page-master-reference");
("Aargh! expectStartElement(events, list)");
} while (true);
} catch (NoSuchElementException e) {
- // sub-sequence specifiers exhausted
+ throw new FOPException("Unexpected EOF in page-sequence-master.");
}
+ if (this.numChildren() == 0)
+ throw new FOPException("No children of page-sequence-master.");
XMLEvent ev = xmlevents.getEndElement(event);
}
public class FoSinglePageMasterReference extends FONode {
public FoSinglePageMasterReference
- (FOTree foTree, FONode parent, XMLEvent event)
+ (FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.SINGLE_PAGE_MASTER_REFERENCE, parent,
public class FoRepeatablePageMasterReference extends FONode {
public FoRepeatablePageMasterReference
- (FOTree foTree, FONode parent, XMLEvent event)
+ (FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.REPEATABLE_PAGE_MASTER_REFERENCE,
public class FoRepeatablePageMasterAlternatives extends FONode {
public FoRepeatablePageMasterAlternatives
- (FOTree foTree, FONode parent, XMLEvent event)
+ (FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.REPEATABLE_PAGE_MASTER_ALTERNATIVES,
// Process conditional-page-master-references here
try {
do {
- XMLEvent ev = this.xmlevents.expectStartElement
+ FoXMLEvent ev = this.xmlevents.expectStartElement
(conditionalPageMasterRef.uriIndex,
conditionalPageMasterRef.localName,
XMLEvent.DISCARD_W_SPACE);
- //System.out.println
- // ("Found conditional-page-master-reference");
- new FoConditionalPageMasterReference(foTree, this, ev);
- this.xmlevents.getEndElement(ev);
+ if (ev == null) break; // Sun-sequences exhausted
+ //System.out.println
+ // ("Found conditional-page-master-reference");
+ new FoConditionalPageMasterReference(foTree, this, ev);
+ this.xmlevents.getEndElement(ev);
} while (true);
} catch (NoSuchElementException e) {
- // sub-sequence specifiers exhausted
+ // Enf of file reached
+ throw new FOPException("EOF in repeatable-page-masters.");
}
XMLEvent ev = this.xmlevents.getEndElement(event);
}
public class FoConditionalPageMasterReference extends FONode {
public FoConditionalPageMasterReference
- (FOTree foTree, FONode parent, XMLEvent event)
+ (FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException, PropertyException
{
super(foTree, FObjectNames.CONDITIONAL_PAGE_MASTER_REFERENCE,
// FOP
import org.apache.fop.fo.FOAttributes;
import org.apache.fop.fo.PropNames;
-import org.apache.fop.xml.XMLEvent;
+import org.apache.fop.xml.FoXMLEvent;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.FOPropertySets;
import org.apache.fop.fo.FObjectNames;
* @param event the <tt>XMLEvent</tt> that triggered the creation of
* this node
*/
- public FoSimplePageMaster(FOTree foTree, FONode parent, XMLEvent event)
+ public FoSimplePageMaster(FOTree foTree, FONode parent, FoXMLEvent event)
throws Tree.TreeException, FOPException
{
super(foTree, FObjectNames.SIMPLE_PAGE_MASTER, parent, event,
FOPropertySets.LAYOUT_SET);
// Process regions here
- XMLEvent ev = xmlevents.getEndElement(event);
+ FoXMLEvent ev = xmlevents.getEndElement(event);
}
/**