pbwest 2002/10/24 07:58:14 Modified: src/org/apache/fop/fo/pagination Tag: FOP_0-20-0_Alt-Design FoLayoutMasterSet.java FoPageSequenceMaster.java FoSimplePageMaster.java Log: Changed XMLEvent to FoXMLEvent throughout. Account for the fact that 'expect' methods returning FoXMLEvents return null on failure. Revision Changes Path No revision No revision 1.1.2.10 +13 -8 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoLayoutMasterSet.java Index: FoLayoutMasterSet.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoLayoutMasterSet.java,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- FoLayoutMasterSet.java 21 Oct 2002 16:12:53 -0000 1.1.2.9 +++ FoLayoutMasterSet.java 24 Oct 2002 14:58:14 -0000 1.1.2.10 @@ -12,10 +12,11 @@ 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; @@ -78,7 +79,7 @@ * 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, @@ -93,7 +94,7 @@ * @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; @@ -102,9 +103,10 @@ 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"); @@ -145,7 +147,8 @@ ("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); @@ -153,6 +156,8 @@ 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 1.1.2.10 +21 -15 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java Index: FoPageSequenceMaster.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoPageSequenceMaster.java,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- FoPageSequenceMaster.java 21 Oct 2002 16:12:54 -0000 1.1.2.9 +++ FoPageSequenceMaster.java 24 Oct 2002 14:58:14 -0000 1.1.2.10 @@ -15,6 +15,7 @@ // 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; @@ -68,7 +69,7 @@ //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, @@ -76,8 +77,9 @@ // 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"); @@ -103,8 +105,10 @@ ("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); } @@ -131,7 +135,7 @@ 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, @@ -152,7 +156,7 @@ 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, @@ -177,7 +181,7 @@ 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, @@ -186,17 +190,19 @@ // 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); } @@ -208,7 +214,7 @@ 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, 1.1.2.7 +5 -5 xml-fop/src/org/apache/fop/fo/pagination/Attic/FoSimplePageMaster.java Index: FoSimplePageMaster.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/pagination/Attic/FoSimplePageMaster.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- FoSimplePageMaster.java 6 Oct 2002 14:01:19 -0000 1.1.2.6 +++ FoSimplePageMaster.java 24 Oct 2002 14:58:14 -0000 1.1.2.7 @@ -12,7 +12,7 @@ // 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; @@ -37,13 +37,13 @@ * @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); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]