]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #43070
authorChris Bowditch <cbowditch@apache.org>
Fri, 5 Oct 2007 08:36:48 +0000 (08:36 +0000)
committerChris Bowditch <cbowditch@apache.org>
Fri, 5 Oct 2007 08:36:48 +0000 (08:36 +0000)
Postscript extension : comment before and after page
Submitted by Adrian Cumiskey <dev.at.cumiskey.com>

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@582124 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/render/ps/PSRenderer.java
src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSCommentAfter.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSCommentBefore.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java [new file with mode: 0644]
src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java
src/java/org/apache/fop/render/ps/extensions/PSExtensionHandler.java
test/layoutengine/standard-testcases/ps-extension_2.xml

index 5d823e86ea179d8498c705c28bc3caca3bf9707f..91769f6debb7b0096e5c2860cb4d385ca5df3261 100644 (file)
@@ -73,6 +73,8 @@ import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.ps.extensions.PSExtensionAttachment;
 import org.apache.fop.render.ps.extensions.PSSetPageDevice;
 import org.apache.fop.render.ps.extensions.PSSetupCode;
+import org.apache.fop.render.ps.extensions.PSCommentAfter;
+import org.apache.fop.render.ps.extensions.PSCommentBefore;
 import org.apache.fop.util.CharUtilities;
 
 import org.apache.xmlgraphics.ps.DSCConstants;
@@ -135,7 +137,6 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
     private boolean ioTrouble = false;
 
     private boolean inTextMode = false;
-    private boolean firstPageSequenceReceived = false;
 
     /** Used to temporarily store PSSetupCode instance until they can be written. */
     private List setupCodeList;
@@ -154,6 +155,11 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
     /** Whether or not Dublin Core Standard (dsc) compliant output is enforced */
     private boolean dscCompliant = true;
 
+    /** This is a collection holding all document header comments */
+    private Collection headerComments;
+
+    /** This is a collection holding all document footer comments */
+    private Collection footerComments;
     /**
      * {@inheritDoc}
      */
@@ -729,7 +735,9 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
         this.pageDeviceDictionary = new PSPageDeviceDictionary();
         pageDeviceDictionary.setFlushOnRetrieval(!this.dscCompliant);
         pageDeviceDictionary.put("/ImagingBBox", "null");
+    }
 
+    private void writeHeader() throws IOException {
         //PostScript Header
         writeln(DSCConstants.PS_ADOBE_30);
         gen.writeDSCComment(DSCConstants.CREATOR, new String[] {userAgent.getProducer()});
@@ -738,6 +746,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
         gen.writeDSCComment(DSCConstants.PAGES, new Object[] {DSCConstants.ATEND});
         gen.writeDSCComment(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES, 
                 new Object[] {DSCConstants.ATEND});
+        if (headerComments != null) {
+            for (Iterator iter = headerComments.iterator(); iter.hasNext();) {
+                PSExtensionAttachment comment = (PSExtensionAttachment)iter.next();
+                gen.writeln("%" + comment.getContent());
+            }
+        }
         gen.writeDSCComment(DSCConstants.END_COMMENTS);
 
         //Defaults
@@ -745,6 +759,22 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
         gen.writeDSCComment(DSCConstants.END_DEFAULTS);
 
         //Prolog and Setup written right before the first page-sequence, see startPageSequence()
+        //Do this only once, as soon as we have all the content for the Setup section!
+        //Prolog
+        gen.writeDSCComment(DSCConstants.BEGIN_PROLOG);
+        PSProcSets.writeStdProcSet(gen);
+        PSProcSets.writeEPSProcSet(gen);
+        gen.writeDSCComment(DSCConstants.END_PROLOG);
+
+        //Setup
+        gen.writeDSCComment(DSCConstants.BEGIN_SETUP);
+        writeSetupCodeList(setupCodeList, "SetupCode");
+        if (!twoPassGeneration) {
+            this.fontResources = PSFontUtils.writeFontDict(gen, fontInfo);
+        } else {
+            gen.commentln("%FOPFontSetup");
+        }
+        gen.writeDSCComment(DSCConstants.END_SETUP);
     }
 
     /**
@@ -763,6 +793,12 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
         
         //Write trailer
         gen.writeDSCComment(DSCConstants.TRAILER);
+        if (footerComments != null) {
+            for (Iterator iter = footerComments.iterator(); iter.hasNext();) {
+                PSExtensionAttachment comment = (PSExtensionAttachment)iter.next();
+                gen.commentln("%" + comment.getContent());
+            }
+        }
         gen.writeDSCComment(DSCConstants.PAGES, new Integer(this.currentPageNumber));
         gen.getResourceTracker().writeResources(false, gen);
         gen.writeDSCComment(DSCConstants.EOF);
@@ -840,7 +876,17 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
                                         + e.getMessage() + ", content = '" + content + "'");
                             }
                         }
-                    }        
+                    } else if (attachment instanceof PSCommentBefore) {
+                        if (headerComments == null) {
+                            headerComments = new java.util.TreeSet();
+                        }
+                        headerComments.add(attachment);
+                    } else if (attachment instanceof PSCommentAfter) {
+                        if (footerComments == null) {
+                            footerComments = new java.util.TreeSet();
+                        }
+                        footerComments.add(attachment);
+                    }
                 }
             }
         }
@@ -850,30 +896,6 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
     /** {@inheritDoc} */
     public void startPageSequence(LineArea seqTitle) {
         super.startPageSequence(seqTitle);
-        if (!firstPageSequenceReceived) {
-            //Do this only once, as soon as we have all the content for the Setup section!
-            try {
-                //Prolog
-                gen.writeDSCComment(DSCConstants.BEGIN_PROLOG);
-                PSProcSets.writeStdProcSet(gen);
-                PSProcSets.writeEPSProcSet(gen);
-                gen.writeDSCComment(DSCConstants.END_PROLOG);
-
-                //Setup
-                gen.writeDSCComment(DSCConstants.BEGIN_SETUP);
-                writeSetupCodeList(setupCodeList, "SetupCode");
-                if (!twoPassGeneration) {
-                    this.fontResources = PSFontUtils.writeFontDict(gen, fontInfo);
-                } else {
-                    gen.commentln("%FOPFontSetup");
-                }
-                gen.writeDSCComment(DSCConstants.END_SETUP);
-            } catch (IOException ioe) {
-                handleIOTrouble(ioe);
-            }
-            
-            firstPageSequenceReceived = true;
-        }
     }
     
     /**
@@ -911,6 +933,10 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
             throws IOException, FOPException {
         log.debug("renderPage(): " + page);
 
+        if (this.currentPageNumber == 0) {
+            writeHeader();
+        }
+        
         this.currentPageNumber++;
         
         gen.getResourceTracker().notifyStartNewPage();
@@ -994,6 +1020,17 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
 
         gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
 
+        if (page.hasExtensionAttachments()) {
+            List extensionAttachments = page.getExtensionAttachments();
+            for (int i = 0; i < extensionAttachments.size(); i++) {
+                PSExtensionAttachment attachment
+                    = (PSExtensionAttachment)extensionAttachments.get(i);
+                if (attachment instanceof PSCommentBefore) {
+                    gen.commentln("%" + attachment.getContent());
+                }
+            }
+        }
+
         // Write any unwritten changes to page device dictionary
         if (!pageDeviceDictionary.isEmpty()) {
             String content = pageDeviceDictionary.getContent();
@@ -1019,7 +1056,16 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
         //Show page
         writeln("showpage");
         gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
-                
+        if (page.hasExtensionAttachments()) {
+            List extensionAttachments = page.getExtensionAttachments();
+            for (int i = 0; i < extensionAttachments.size(); i++) {
+                PSExtensionAttachment attachment;
+                attachment = (PSExtensionAttachment)extensionAttachments.get(i);
+                if (attachment instanceof PSCommentAfter) {
+                    gen.commentln("%" + attachment.getContent());
+                }
+            }
+        }
         gen.getResourceTracker().writeResources(true, gen);
     }
 
@@ -1385,7 +1431,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
             iter.remove();
         }
     }
-
+    
     /**
      * Sets whether or not the safe set page device macro should be used
      * (as opposed to directly invoking setpagedevice) when setting the
@@ -1416,5 +1462,5 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
      */
     public void setDSCCompliant(boolean dscCompliant) {
         this.dscCompliant = dscCompliant;        
-    }
+    }    
 }
diff --git a/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java b/src/java/org/apache/fop/render/ps/extensions/AbstractPSCommentElement.java
new file mode 100644 (file)
index 0000000..a6e77fb
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.render.ps.extensions;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.ValidationException;
+
+/**
+ * Base postscript commment element class
+ */
+public abstract class AbstractPSCommentElement extends AbstractPSExtensionElement {
+
+    /**
+     * Default constructor
+     * 
+     * @param parent parent of this node
+     * @see org.apache.fop.fo.FONode#FONode(FONode)
+     */
+    public AbstractPSCommentElement(FONode parent) {
+        super(parent);
+    }    
+    
+    /**
+     * @throws FOPException if there's a problem during processing
+     * @see org.apache.fop.fo.FONode#startOfNode() 
+     */
+    protected void startOfNode() throws FOPException {
+        if (parent.getNameId() != Constants.FO_DECLARATIONS
+                && parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
+          throw new ValidationException(getName()
+          + " must be a child of fo:declarations or fo:simple-page-master.");            
+        }
+    }
+
+}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfter.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfter.java
new file mode 100644 (file)
index 0000000..60c47b2
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.render.ps.extensions;
+
+/**
+ * Custom postscript comment after class
+ */
+public class PSCommentAfter extends PSExtensionAttachment {
+
+    /**
+     * Element name
+     */
+    protected static final String ELEMENT = "ps-comment-after";
+
+    /**
+     * Default constructor
+     */
+    public PSCommentAfter() {
+        super();
+    }
+
+    /**
+     * Constructor
+     * @param content comment
+     */
+    public PSCommentAfter(String content) {
+        super(content);
+    }
+
+    /**
+     * @return the element name
+     */
+    protected String getElement() {
+        return ELEMENT;
+    }
+}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
new file mode 100644 (file)
index 0000000..2dbbf1f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.render.ps.extensions;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * Comment after element
+ */
+public class PSCommentAfterElement extends AbstractPSCommentElement {
+
+    /**
+     * Main constructor
+     * @param parent node
+     */
+    public PSCommentAfterElement(FONode parent) {
+        super(parent);
+    }
+
+    /**
+     * @return local name 
+     * @see org.apache.fop.fo.FONode#getLocalName()
+     */
+    public String getLocalName() {
+        return "ps-comment-after";
+    }
+
+    /**
+     * @return instance of its extension attachment object
+     * @see org.apache.fop.render.ps.extensions.AbstractPSExtensionElement
+     * #instantiateExtensionAttachment()
+     */
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new PSCommentAfter();
+    }
+}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentBefore.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentBefore.java
new file mode 100644 (file)
index 0000000..60b6f2e
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.render.ps.extensions;
+
+/**
+ * Custom postscript comment before class
+ */
+public class PSCommentBefore extends PSExtensionAttachment {
+
+    /**
+     * Element name
+     */
+    protected static final String ELEMENT = "ps-comment-before";
+
+    /**
+     * Default constructor
+     * @param content the actual comment
+     */
+    public PSCommentBefore(String content) {
+        super(content);
+    }
+
+    /**
+     * Constructor
+     */
+    public PSCommentBefore() {
+        super();
+    }
+
+    /**
+     * @return element name
+     */
+    protected String getElement() {
+        return ELEMENT;
+    }
+}
diff --git a/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java b/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
new file mode 100644 (file)
index 0000000..7abb670
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.render.ps.extensions;
+
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * Comment before element
+ */
+public class PSCommentBeforeElement extends AbstractPSCommentElement {
+
+    /**
+     * Main constructor
+     * @param parent parent node
+     */
+    public PSCommentBeforeElement(FONode parent) {
+        super(parent);
+    }
+
+    /**
+     * @return local name
+     * @see org.apache.fop.fo.FONode#getLocalName()
+     */
+    public String getLocalName() {
+        return "ps-comment-before";
+    }
+
+    /**
+     * @return instance of its extension attachment object
+     */
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new PSCommentBefore();
+    }    
+}
index a90af2a9cdb6e4f7248f997853acb23136feb607..bfb402d29960a52ce36ba707c8d689d19f12a16e 100644 (file)
@@ -42,6 +42,8 @@ public class PSExtensionElementMapping extends ElementMapping {
             foObjs.put("ps-setup-code", new PSSetupCodeMaker());
             foObjs.put("ps-page-setup-code", new PSPageSetupCodeMaker());
             foObjs.put("ps-setpagedevice", new PSSetPageDeviceMaker());
+            foObjs.put("ps-comment-before", new PSCommentBeforeMaker());
+            foObjs.put("ps-comment-after", new PSCommentAfterMaker());
         }
     }
 
@@ -62,4 +64,16 @@ public class PSExtensionElementMapping extends ElementMapping {
             return new PSSetPageDeviceElement(parent);
         }
     }
+    
+    static class PSCommentBeforeMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new PSCommentBeforeElement(parent);
+        }
+    }
+
+    static class PSCommentAfterMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new PSCommentAfterElement(parent);
+        }
+    }
 }
index 6cc41f8ccece30b1f0d0e1448aadfaf902f2dc01..72f665a0f070c49fe5e3f13b812865e48122779e 100644 (file)
@@ -50,7 +50,9 @@ public class PSExtensionHandler extends DefaultHandler
             lastAttributes = attributes;
             handled = false;
             if (localName.equals(PSSetupCode.ELEMENT)
-                    || localName.equals(PSSetPageDevice.ELEMENT)) {
+                    || localName.equals(PSSetPageDevice.ELEMENT)
+                    || localName.equals(PSCommentBefore.ELEMENT)
+                    || localName.equals(PSCommentAfter.ELEMENT)) {
                 //handled in endElement
                 handled = true;
             }
@@ -75,6 +77,10 @@ public class PSExtensionHandler extends DefaultHandler
             } else if (PSSetPageDevice.ELEMENT.equals(localName)) {
                 String name = lastAttributes.getValue("name");
                 this.returnedObject = new PSSetPageDevice(name, content.toString());                
+            } else if (PSCommentBefore.ELEMENT.equals(localName)) {
+                this.returnedObject = new PSCommentBefore(content.toString());          
+            } else if (PSCommentAfter.ELEMENT.equals(localName)) {
+                this.returnedObject = new PSCommentAfter(content.toString());
             }
         }    
         content.setLength(0); //Reset text buffer (see characters())
index d0c18a97770d86e5206fff4a0e41107fb41f0fe1..6429b789edfde7c5b9f89f8649825f7e198f2ff9 100644 (file)
       <fo:layout-master-set>\r
         <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">\r
           <ps:ps-setpagedevice name="lower tray"><![CDATA[ << /MediaPosition /4 >> ]]></ps:ps-setpagedevice>\r
+          <ps:ps-comment-before>A4 before page</ps:ps-comment-before>\r
+          <ps:ps-comment-after>A4 after page</ps:ps-comment-after>\r
           <fo:region-body/>\r
         </fo:simple-page-master>\r
         <fo:simple-page-master master-name="A4a" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">\r
           <ps:ps-setpagedevice name="upper tray"><![CDATA[ << /MediaPosition /1 >> ]]></ps:ps-setpagedevice>\r
+          <ps:ps-comment-before>A4a before page</ps:ps-comment-before>\r
+          <ps:ps-comment-after>A4a after page</ps:ps-comment-after>\r
           <fo:region-body background-color="orange"/>\r
         </fo:simple-page-master>\r
         <fo:page-sequence-master master-name="complex">\r
@@ -42,6 +46,8 @@
       </fo:layout-master-set>\r
       <fo:declarations>\r
         <ps:ps-setpagedevice name="autofeed"><![CDATA[ << /ManualFeed false >> ]]></ps:ps-setpagedevice>\r
+        <ps:ps-comment-before>header comment</ps:ps-comment-before>\r
+        <ps:ps-comment-after>footer comment</ps:ps-comment-after>\r
       </fo:declarations>\r
       <fo:page-sequence master-reference="complex">\r
         <fo:flow flow-name="xsl-region-body">\r
   </fo:root>\r
   </fo>\r
   <checks>\r
-    <eval expected="1" xpath="count(/areaTree/child::extension-attachments/child::*)"/>\r
+    <eval expected="2" xpath="count(/areaTree/child::*)"/>\r
+    <eval expected="1" xpath="count(/areaTree/child::pageSequence)"/>\r
+    <eval expected="1" xpath="count(/areaTree/child::extension-attachments)"/>\r
+    <eval expected="3" xpath="count(/areaTree/child::extension-attachments/child::*)"/>\r
     <eval expected="autofeed"       xpath="/areaTree/extension-attachments/child::*[1]/@name"/>\r
+    <eval expected="header comment" xpath="/areaTree/extension-attachments/child::*[2]/text()"/>\r
+    <eval expected="footer comment" xpath="/areaTree/extension-attachments/child::*[3]/text()"/>\r
 \r
-    <eval expected="1" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*)"/>\r
+    <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*)"/>\r
     <eval expected="lower tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[1]/@name"/>\r
+    <eval expected="A4 before page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[2]"/>\r
+    <eval expected="A4 after page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=1]/page/extension-attachments/child::*[3]"/>\r
 \r
-    <eval expected="1" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*)"/>\r
+    <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*)"/>\r
     <eval expected="upper tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[1]/@name"/>\r
+    <eval expected="A4a before page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[2]"/>\r
+    <eval expected="A4a after page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4a' and @nr=2]/page/extension-attachments/child::*[3]"/>\r
 \r
-    <eval expected="1" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*)"/>\r
+    <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*)"/>\r
     <eval expected="lower tray" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*[1]/@name"/>\r
+    <eval expected="A4 before page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*[2]"/>\r
+    <eval expected="A4 after page" xpath="/areaTree/pageSequence/pageViewport[@simple-page-master-name='A4' and @nr=3]/page/extension-attachments/child::*[3]"/>\r
   </checks>\r
 </testcase>\r