You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2009/03/01 09:55:36 UTC

svn commit: r748981 - in /xmlgraphics/fop/trunk: ./ src/documentation/content/xdocs/trunk/ src/documentation/intermediate-format-ng/ src/java/org/apache/fop/afp/ src/java/org/apache/fop/area/ src/java/org/apache/fop/events/ src/java/org/apache/fop/fo/p...

Author: jeremias
Date: Sun Mar  1 08:55:35 2009
New Revision: 748981

URL: http://svn.apache.org/viewvc?rev=748981&view=rev
Log:
Added support for adding extension elements and foreign attributes on fo:page-sequence.
AFP: Added support for Invoke Medium Map (IMM).
AFP: Fixed a bug adding TLEs in DataStream (TLEs were added to the page group instead of to the page).

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
      - copied, changed from r748508, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java
Removed:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java
Modified:
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
    xmlgraphics/fop/trunk/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/DataStream.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageSequence.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFParser.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFSerializer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/afp-extension_1.xml

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/output.xml Sun Mar  1 08:55:35 2009
@@ -451,11 +451,35 @@
   </section>
   <section id="afp">
     <title>AFP</title>
-    <warning>The AFP Renderer is a new addition (27-Apr-2006) to the sandbox and as such not yet fully tested or feature complete.</warning>
     <p>
       The FOP AFP Renderer deals with creating documents conforming to the IBM AFP document architecture
       also refered to as MO:DCA (Mixed Object Document Content Architecture).
     </p>
+    <p>
+      The mapping of XSL-FO elements to the major MO:DCA structures is as follows:
+    </p>
+    <table>
+      <tr>
+        <th>XSL-FO element</th>
+        <th>MO:DCA-P object</th>
+      </tr>
+      <tr>
+        <td>fo:root</td>
+        <td>Document</td>
+      </tr>
+      <tr>
+        <td>fo:page-sequence</td>
+        <td>Page Group</td>
+      </tr>
+      <tr>
+        <td>fo:simple-page-master</td>
+        <td>Page</td>
+      </tr>
+    </table>
+    <p>
+      FOP creates exactly one Document per Printfile with an optional Resource Group at the
+      beginning. FOP does not create document indices.
+    </p>
     <section id="afp-references">
       <title>References</title>
       <ul>
@@ -687,7 +711,7 @@
                xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
 ]]></source>
       <section id="afp-page-overlay">
-        <title>Page Overlay Extension</title>
+        <title>Page Overlay (IPO) Extension</title>
         <p>The include-page-overlay extension element allows to define on a per simple-page-master basis a page overlay resource. Example:</p>
       <source><![CDATA[
       <fo:layout-master-set>
@@ -701,7 +725,7 @@
         must be known in the AFP processing environment.</p>
       </section>
       <section id="afp-page-segment">
-        <title>Page Segment Extension</title>
+        <title>Page Segment (IPS) Extension</title>
         <p>The include-page-segment extension element allows to define resource substitution for fo:external-graphics elements. 
           Example:</p>
       <source><![CDATA[
@@ -724,7 +748,7 @@
         </p>
       </section>
       <section id="afp-tag-logical-element">
-        <title>Tag Logical Element Extension</title>
+        <title>Tag Logical Element (TLE) Extension</title>
         <p>The tag-logical-element extension element allows to injects TLEs into the AFP output stream. Example:</p>
       <source><![CDATA[
     <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
@@ -740,9 +764,14 @@
         Multiple tag-logical-element extension elements within a simple-page-master are allowed.
         The name and value attributes are mandatory.
         </p>
+        <note>
+          Currently, TLEs are only possible inside simple-page-master (i.e. on page leve).
+          At this time, it is not possible to add TLE's at page-group level (i.e. as direct child
+          of fo:page-sequence).
+        </note>
       </section>
       <section id="afp-no-operation">
-        <title>No Operation Extension</title>
+        <title>No Operation (NOP) Extension</title>
         <p>The no-operation extension provides the ability to carry up to 32K of comments or any other type
         of unarchitected data into the AFP output stream. Example:</p>
       <source><![CDATA[
@@ -759,6 +788,29 @@
         The name attribute is mandatory.
         </p>
       </section>
+      <section id="afp-invoke-medium-map">
+        <title>Invoke Medium Map (IMM) Extension</title>
+        <p>
+          The invoke-medium-map extension allows to generate IMM fields (Invoke Medium Map) in the
+          generated AFP output. Example:
+        </p>
+      <source><![CDATA[
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+     xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
+      [..]
+      <fo:page-sequence master-reference="normal">
+        <afp:invoke-medium-map name="MYMAP"/>
+        <fo:flow flow-name="xsl-region-body">
+          [..]
+]]></source>
+        <p>
+          The invoke-medium-map element is allowed as child of fo:page-sequence (page group
+          level). It is NOT supported on document level (fo:root), yet. FOP also doesn't support
+          specifying medium maps inside XML (using BMM/EMM). It can only reference an existing
+          medium map by name. The medium map has to be constructed through different means and
+          available on the target platform.
+        </p>
+      </section>
     </section>
     <section id="afp-foreign-attributes">
       <title>Foreign Attributes</title>

Modified: xmlgraphics/fop/trunk/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd (original)
+++ xmlgraphics/fop/trunk/src/documentation/intermediate-format-ng/fop-intermediate-format-ng.xsd Sun Mar  1 08:55:35 2009
@@ -55,6 +55,9 @@
   <xs:element name="page-sequence">
     <xs:complexType>
       <xs:sequence>
+        <xs:choice minOccurs="0" maxOccurs="unbounded">
+          <xs:any namespace="##other" processContents="lax"/>
+        </xs:choice>
         <xs:element ref="mf:page" minOccurs="1" maxOccurs="unbounded"/>
       </xs:sequence>
       <xs:attribute name="id" type="xs:ID"/>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/DataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/DataStream.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/DataStream.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/DataStream.java Sun Mar  1 08:55:35 2009
@@ -486,10 +486,10 @@
      *            The tag value
      */
     public void createTagLogicalElement(String name, String value) {
-        if (currentPageGroup != null) {
-            currentPageGroup.createTagLogicalElement(name, value);
-        } else {
+        if (currentPage != null) {
             currentPage.createTagLogicalElement(name, value, tleSequence++);
+        } else {
+            currentPageGroup.createTagLogicalElement(name, value);
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/AreaTreeParser.java Sun Mar  1 08:55:35 2009
@@ -356,6 +356,7 @@
                 pageSequence.setLanguage(lang);
                 String country = attributes.getValue("country");
                 pageSequence.setCountry(country);
+                transferForeignObjects(attributes, pageSequence);
                 areaStack.push(pageSequence);
             }
         }
@@ -970,7 +971,14 @@
                     this.currentPageViewport.addExtensionAttachment(attachment);
                 }
             } else {
-                log.warn("Don't know how to handle externally generated object: " + obj);
+                Object o = areaStack.peek();
+                if (o instanceof AreaTreeObject && obj instanceof ExtensionAttachment) {
+                    AreaTreeObject ato = (AreaTreeObject)o;
+                    ExtensionAttachment attachment = (ExtensionAttachment)obj;
+                    ato.addExtensionAttachment(attachment);
+                } else {
+                    log.warn("Don't know how to handle externally generated object: " + obj);
+                }
             }
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageSequence.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/PageSequence.java Sun Mar  1 08:55:35 2009
@@ -24,7 +24,7 @@
 /**
  * Represents a page sequence in the area tree.
  */
-public class PageSequence {
+public class PageSequence extends AreaTreeObject {
 
     private List pages = new java.util.ArrayList();
     private LineArea title;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml Sun Mar  1 08:55:35 2009
@@ -27,6 +27,7 @@
   <message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
   <message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
   <message key="rule.childOfInstreamForeignObjectorExternalGraphic">The element must be a child of fo:instream-foreign-object or fo:external-graphic.</message>
+  <message key="rule.childOfPageSequence">The element must be a child of fo:page-sequence.</message>
   <message key="rule.wrapperInvalidChildForParent">An fo:wrapper is only permitted to have children that would be permitted for its parent.</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/pagination/PageSequence.java Sun Mar  1 08:55:35 2009
@@ -170,7 +170,7 @@
             flowMap.put(((StaticContent)child).getFlowName(), child);
             break;
         default:
-            assert false;
+            super.addChildNode(child);
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Sun Mar  1 08:55:35 2009
@@ -26,7 +26,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
+import org.apache.fop.area.AreaTreeObject;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
@@ -266,8 +268,10 @@
             childLMs = new java.util.ArrayList(10);
         }
         childLMs.add(lm);
-        log.trace(this.getClass().getName()
-                  + ": Adding child LM " + lm.getClass().getName());
+        if (log.isTraceEnabled()) {
+            log.trace(this.getClass().getName()
+                    + ": Adding child LM " + lm.getClass().getName());
+        }
     }
 
     /**
@@ -300,6 +304,13 @@
         return pos;
     }
 
+    private void verifyNonNullPosition(Position pos) {
+        if (pos == null || pos.getIndex() < 0) {
+            throw new IllegalArgumentException(
+                    "Only non-null Positions with an index can be checked");
+        }
+    }
+
     /**
      * Indicates whether the given Position is the first area-generating Position of this LM.
      * @param pos the Position (must be one with a position index)
@@ -307,9 +318,7 @@
      */
     public boolean isFirst(Position pos) {
         //log.trace("isFirst() smallestPosNumberChecked=" + smallestPosNumberChecked + " " + pos);
-        if (pos == null || pos.getIndex() < 0) {
-            throw new IllegalArgumentException("Only non-null Positions with an index can be checked");
-        }
+        verifyNonNullPosition(pos);
         if (pos.getIndex() == this.smallestPosNumberChecked) {
             return true;
         } else if (pos.getIndex() < this.smallestPosNumberChecked) {
@@ -326,10 +335,7 @@
      * @return True if it is the last Position
      */
     public boolean isLast(Position pos) {
-        //log.trace("isLast() lastGenPos=" + lastGeneratedPosition + " " + pos);
-        if (pos == null || pos.getIndex() < 0) {
-            throw new IllegalArgumentException("Only non-null Positions with an index can be checked");
-        }
+        verifyNonNullPosition(pos);
         return (pos.getIndex() == this.lastGeneratedPosition
                 && isFinished());
     }
@@ -338,12 +344,32 @@
      * Transfers foreign attributes from the formatting object to the area.
      * @param targetArea the area to set the attributes on
      */
-    protected void transferForeignAttributes(Area targetArea) {
+    protected void transferForeignAttributes(AreaTreeObject targetArea) {
         Map atts = fobj.getForeignAttributes();
         targetArea.setForeignAttributes(atts);
     }
 
     /**
+     * Transfers extension attachments from the formatting object to the area.
+     * @param targetArea the area to set the extensions on
+     */
+    protected void transferExtensionAttachments(AreaTreeObject targetArea) {
+        if (fobj.hasExtensionAttachments()) {
+            targetArea.setExtensionAttachments(fobj.getExtensionAttachments());
+        }
+    }
+
+    /**
+     * Transfers extensions (foreign attributes and extension attachments) from
+     * the formatting object to the area.
+     * @param targetArea the area to set the extensions on
+     */
+    protected void transferExtensions(AreaTreeObject targetArea) {
+        transferForeignAttributes(targetArea);
+        transferExtensionAttachments(targetArea);
+    }
+
+    /**
      * Registers the FO's markers on the current PageViewport
      *
      * @param isStarting    boolean indicating whether the markers qualify as 'starting'

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java Sun Mar  1 08:55:35 2009
@@ -105,7 +105,9 @@
             Dimension intrinsicSize = info.getSize().getDimensionMpt();
             ImageLayout layout = new ImageLayout(getExternalDocument(), this, intrinsicSize);
 
-            areaTreeHandler.getAreaTreeModel().startPageSequence(new PageSequence(null));
+            PageSequence pageSequence = new PageSequence(null);
+            transferExtensions(pageSequence);
+            areaTreeHandler.getAreaTreeModel().startPageSequence(pageSequence);
             if (log.isDebugEnabled()) {
                 log.debug("Starting layout");
             }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java Sun Mar  1 08:55:35 2009
@@ -92,6 +92,7 @@
         AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
         org.apache.fop.area.PageSequence pageSequenceAreaObject
                 = new org.apache.fop.area.PageSequence(title);
+        transferExtensions(pageSequenceAreaObject);
         pageSequenceAreaObject.setLanguage(getPageSequence().getLanguage());
         pageSequenceAreaObject.setCountry(getPageSequence().getCountry());
         areaTreeModel.startPageSequence(pageSequenceAreaObject);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Sun Mar  1 08:55:35 2009
@@ -38,6 +38,7 @@
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontManager;
 import org.apache.fop.render.afp.extensions.AFPElementMapping;
+import org.apache.fop.render.afp.extensions.AFPInvokeMediumMap;
 import org.apache.fop.render.afp.extensions.AFPPageSetup;
 import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
 import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
@@ -69,7 +70,11 @@
     private Map/*<String,String>*/pageSegmentMap
         = new java.util.HashMap/*<String,String>*/();
 
-    private boolean inPageHeader;
+    private static final int LOC_ELSEWHERE = 0;
+    private static final int LOC_FOLLOWING_PAGE_SEQUENCE = 1;
+    private static final int LOC_IN_PAGE_HEADER = 2;
+
+    private int location = LOC_ELSEWHERE;
 
     /**
      * Default constructor.
@@ -158,6 +163,7 @@
         } catch (IOException ioe) {
             throw new IFException("I/O error in startPageSequence()", ioe);
         }
+        this.location = LOC_FOLLOWING_PAGE_SEQUENCE;
     }
 
     /** {@inheritDoc} */
@@ -180,6 +186,7 @@
     /** {@inheritDoc} */
     public void startPage(int index, String name, String pageMasterName, Dimension size)
                 throws IFException {
+        this.location = LOC_ELSEWHERE;
         paintingState.clear();
         pageSegmentMap.clear();
 
@@ -202,12 +209,12 @@
     /** {@inheritDoc} */
     public void startPageHeader() throws IFException {
         super.startPageHeader();
-        this.inPageHeader = true;
+        this.location = LOC_IN_PAGE_HEADER;
     }
 
     /** {@inheritDoc} */
     public void endPageHeader() throws IFException {
-        this.inPageHeader = false;
+        this.location = LOC_ELSEWHERE;
         super.endPageHeader();
     }
 
@@ -238,7 +245,7 @@
     public void handleExtensionObject(Object extension) throws IFException {
         if (extension instanceof AFPPageSetup) {
             AFPPageSetup aps = (AFPPageSetup)extension;
-            if (!inPageHeader) {
+            if (this.location != LOC_IN_PAGE_HEADER) {
                 throw new IFException(
                     "AFP page setup extension encountered outside the page header: " + aps, null);
             }
@@ -262,6 +269,17 @@
                     dataStream.createNoOperation(content);
                 }
             }
+        } else if (extension instanceof AFPInvokeMediumMap) {
+            if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE) {
+                throw new IFException(
+                    "AFP IMM extension must be between page-sequence and the first page: "
+                        + extension, null);
+            }
+            AFPInvokeMediumMap imm = (AFPInvokeMediumMap)extension;
+            String mediumMap = imm.getName();
+            if (mediumMap != null) {
+                dataStream.createInvokeMediumMap(mediumMap);
+            }
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java Sun Mar  1 08:55:35 2009
@@ -33,12 +33,6 @@
  */
 public class AFPElementMapping extends ElementMapping {
 
-    /** page element */
-    public static final String PAGE = "page";
-
-    /** page group element */
-//    public static final String PAGE_GROUP = "page-group";
-
     /** tag logical element */
     public static final String TAG_LOGICAL_ELEMENT = "tag-logical-element";
 
@@ -51,8 +45,8 @@
     /** NOP */
     public static final String NO_OPERATION = "no-operation";
 
-    /** resource information (name, level, dest) */
-//    public static final String RESOURCE_INFO = "resource-info";
+    /** IMM: Invoke Medium Map (on fo:page-sequence) */
+    public static final String INVOKE_MEDIUM_MAP = "invoke-medium-map";
 
     /**
      * The namespace used for AFP extensions
@@ -77,11 +71,6 @@
 
         if (foObjs == null) {
             super.foObjs = new java.util.HashMap();
-            foObjs.put(PAGE, new AFPPageSetupMaker());
-//            foObjs.put(
-//              PAGE_GROUP,
-//              new AFPPageGroupMaker()
-//            );
             foObjs.put(
                 TAG_LOGICAL_ELEMENT,
                 new AFPTagLogicalElementMaker());
@@ -94,51 +83,40 @@
             foObjs.put(
                 NO_OPERATION,
                 new AFPNoOperationMaker());
-//           foObjs.put(
-//               RESOURCE_INFO,
-//               new AFPResourceInfoMaker());
-        }
-    }
-
-    static class AFPPageSetupMaker extends ElementMapping.Maker {
-        public FONode make(FONode parent) {
-            return new AFPPageSetupElement(parent);
+            foObjs.put(
+                INVOKE_MEDIUM_MAP,
+                new AFPInvokeMediumMapMaker());
         }
     }
 
     static class AFPIncludePageOverlayMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
-            return new AFPElement(parent, INCLUDE_PAGE_OVERLAY);
+            return new AFPPageSetupElement(parent, INCLUDE_PAGE_OVERLAY);
         }
     }
 
     static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
-            return new AFPElement(parent, INCLUDE_PAGE_SEGMENT);
+            return new AFPPageSetupElement(parent, INCLUDE_PAGE_SEGMENT);
         }
     }
 
     static class AFPTagLogicalElementMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
-            return new AFPElement(parent, TAG_LOGICAL_ELEMENT);
+            return new AFPPageSetupElement(parent, TAG_LOGICAL_ELEMENT);
         }
     }
 
     static class AFPNoOperationMaker extends ElementMapping.Maker {
         public FONode make(FONode parent) {
-            return new AFPElement(parent, NO_OPERATION);
+            return new AFPPageSetupElement(parent, NO_OPERATION);
         }
     }
 
-//    static class AFPResourceInfoMaker extends ElementMapping.Maker {
-//        public FONode make(FONode parent) {
-//            return new AFPResourceInfoElement(parent);
-//        }
-//    }
+    static class AFPInvokeMediumMapMaker extends ElementMapping.Maker {
+        public FONode make(FONode parent) {
+            return new AFPInvokeMediumMapElement(parent);
+        }
+    }
 
-//    static class AFPPageGroupMaker extends ElementMapping.Maker {
-//        public FONode make(FONode parent) {
-//            return new AFPElement(parent, PAGE_GROUP);
-//        }
-//    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionAttachment.java Sun Mar  1 08:55:35 2009
@@ -5,9 +5,9 @@
  * 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.
@@ -21,45 +21,37 @@
 
 import java.io.Serializable;
 
-import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.xmlgraphics.util.XMLizable;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.fop.fo.extensions.ExtensionAttachment;
 
 /**
  * This is the pass-through value object for the AFP extension.
  */
 public abstract class AFPExtensionAttachment
     implements ExtensionAttachment, Serializable, XMLizable {
+
     private static final long serialVersionUID = 7190606822558332901L;
 
     /** The category URI for this extension attachment. */
     public static final String CATEGORY = "apache:fop:extensions:afp";
 
+    /** name attribute */
+    protected static final String ATT_NAME = "name";
+
     /**
      * the extension element name
      */
     protected String elementName;
 
     /**
-     * the extension content
-     */
-    protected String content;
-
-    /**
      * the extension name attribute
      */
     protected String name;
 
     /**
-     * the extension value attribute
-     */
-    protected String value;
-
-    /**
      * Default constructor.
-     * 
+     *
      * @param elementName the name of the afp extension attachment, may be null
      */
     public AFPExtensionAttachment(String elementName) {
@@ -91,65 +83,9 @@
         this.name = name;
     }
 
-    /**
-     * @return the value 
-     */
-    public String getValue() {
-        return value;
-    }
-
-    /**
-     * Sets the value
-     * @param source The value name to set.
-     */
-    public void setValue(String source) {
-        this.value = source;
-    }
-    
     /** {@inheritDoc} */
     public String getCategory() {
         return CATEGORY;
     }
 
-    /**
-     * @return the data
-     */
-    public String getContent() {
-        return content;
-    }
-
-    /**
-     * Sets the data
-     * @param content The byte data to set.
-     */
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    /**
-     * name attribute
-     */
-    protected static final String ATT_NAME = "name";
-
-    /**
-     * value attribute
-     */
-    protected static final String ATT_VALUE = "value";
-
-    /** {@inheritDoc} */
-    public void toSAX(ContentHandler handler) throws SAXException {
-        AttributesImpl atts = new AttributesImpl();
-        if (name != null && name.length() > 0) {
-            atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
-        }
-        if (value != null && value.length() > 0) {
-            atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value);
-        }
-        handler.startElement(CATEGORY, elementName, elementName, atts);
-        if (content != null && content.length() > 0) {
-            char[] chars = content.toCharArray();
-            handler.characters(chars, 0, chars.length);
-        }
-        handler.endElement(CATEGORY, elementName, elementName);
-    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Sun Mar  1 08:55:35 2009
@@ -19,13 +19,15 @@
 
 package org.apache.fop.render.afp.extensions;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * ContentHandler (parser) for restoring AFPExtension objects from XML.
@@ -53,8 +55,7 @@
                     || localName.equals(AFPElementMapping.TAG_LOGICAL_ELEMENT)
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
-                    || localName.equals(AFPElementMapping.PAGE)
-                    /*|| localName.equals(AFPElementMapping.PAGE_GROUP)*/) {
+                    || localName.equals(AFPElementMapping.INVOKE_MEDIUM_MAP)) {
                 //handled in endElement
             } else {
                 handled = false;

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java?rev=748981&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java Sun Mar  1 08:55:35 2009
@@ -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.afp.extensions;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+/**
+ * This is the pass-through value object for the AFP extension.
+ */
+public class AFPInvokeMediumMap extends AFPExtensionAttachment {
+
+    private static final long serialVersionUID = -7493160084509249309L;
+
+    /**
+     * Default constructor.
+     */
+    public AFPInvokeMediumMap() {
+        super(AFPElementMapping.INVOKE_MEDIUM_MAP);
+    }
+
+    /** {@inheritDoc} */
+    public void toSAX(ContentHandler handler) throws SAXException {
+        AttributesImpl atts = new AttributesImpl();
+        if (name != null && name.length() > 0) {
+            atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
+        }
+        handler.startElement(CATEGORY, elementName, elementName, atts);
+        handler.endElement(CATEGORY, elementName, elementName);
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "AFPInvokeMediumMap(name=" + getName() + ")";
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java?rev=748981&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java Sun Mar  1 08:55:35 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.afp.extensions;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
+
+/**
+ * This class represents an AFP-specific extension element to embed Invoke Medium Map (IMM)
+ * fields at the beginning of a page group. The element is optional and expected as a direct child
+ * of an fo:page-sequence.
+ */
+public class AFPInvokeMediumMapElement extends AbstractAFPExtensionObject {
+
+    /**
+     * Constructs the AFP extension object (called by Maker).
+     * @param parent the parent formatting object
+     */
+    public AFPInvokeMediumMapElement(FONode parent) {
+        super(parent, AFPElementMapping.INVOKE_MEDIUM_MAP);
+    }
+
+    /** {@inheritDoc} */
+    protected void startOfNode() throws FOPException {
+        super.startOfNode();
+        if (parent.getNameId() != Constants.FO_PAGE_SEQUENCE) {
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                "rule.childOfPageSequence");
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new AFPInvokeMediumMap();
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMapElement.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java Sun Mar  1 08:55:35 2009
@@ -19,11 +19,28 @@
 
 package org.apache.fop.render.afp.extensions;
 
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
 /**
  * This is the pass-through value object for the AFP extension.
  */
 public class AFPPageSetup extends AFPExtensionAttachment {
 
+    /** value attribute */
+    protected static final String ATT_VALUE = "value";
+
+    /**
+     * the extension content
+     */
+    protected String content;
+
+    /**
+     * the extension value attribute
+     */
+    protected String value;
+
     /**
      * Default constructor.
      *
@@ -36,8 +53,55 @@
     private static final long serialVersionUID = -549941295384013190L;
 
     /**
-     * {@inheritDoc}
+     * Returns the value of the extension.
+     * @return the value
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * Sets the value
+     * @param source The value name to set.
      */
+    public void setValue(String source) {
+        this.value = source;
+    }
+
+    /**
+     * Returns the content of the extension.
+     * @return the data
+     */
+    public String getContent() {
+        return content;
+    }
+
+    /**
+     * Sets the data
+     * @param content The byte data to set.
+     */
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    /** {@inheritDoc} */
+    public void toSAX(ContentHandler handler) throws SAXException {
+        AttributesImpl atts = new AttributesImpl();
+        if (name != null && name.length() > 0) {
+            atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
+        }
+        if (value != null && value.length() > 0) {
+            atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value);
+        }
+        handler.startElement(CATEGORY, elementName, elementName, atts);
+        if (content != null && content.length() > 0) {
+            char[] chars = content.toCharArray();
+            handler.characters(chars, 0, chars.length);
+        }
+        handler.endElement(CATEGORY, elementName, elementName);
+    }
+
+    /** {@inheritDoc} */
     public String toString() {
         return "AFPPageSetup(element-name=" + getElementName()
             + " name=" + getName() + " value=" + getValue() + ")";

Copied: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (from r748508, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?p2=xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java&r1=748508&r2=748981&rev=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Sun Mar  1 08:55:35 2009
@@ -19,10 +19,13 @@
 
 package org.apache.fop.render.afp.extensions;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 
 /**
@@ -31,7 +34,7 @@
  * the static list as defined in the AFPElementMapping implementation.
  * <p/>
  */
-public class AFPElement extends AbstractAFPExtensionObject {
+public class AFPPageSetupElement extends AbstractAFPExtensionObject {
 
     /**
      * Constructs an AFP object (called by Maker).
@@ -39,19 +42,59 @@
      * @param parent the parent formatting object
      * @param name the name of the afp element
      */
-    public AFPElement(FONode parent, String name) {
+    public AFPPageSetupElement(FONode parent, String name) {
         super(parent, name);
     }
 
+    private AFPPageSetup getPageSetupAttachment() {
+        return (AFPPageSetup)getExtensionAttachment();
+    }
+
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
         if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
-            throw new ValidationException(getName() + " must be a child of fo:simple-page-master.");
+            invalidChildError(getLocator(), parent.getName(), getNamespaceURI(), getName(),
+                "rule.childOfSPM");
+        }
+    }
+
+    /** {@inheritDoc} */
+    protected void characters(char[] data, int start, int length,
+                                 PropertyList pList, Locator locator) throws FOPException {
+        StringBuffer sb = new StringBuffer();
+        AFPPageSetup pageSetup = getPageSetupAttachment();
+        if (pageSetup.getContent() != null) {
+            sb.append(pageSetup.getContent());
+        }
+        sb.append(data, start, length);
+        pageSetup.setContent(sb.toString());
+    }
+
+    /** {@inheritDoc} */
+    public void processNode(String elementName, Locator locator,
+                            Attributes attlist, PropertyList propertyList)
+                                throws FOPException {
+        super.processNode(elementName, locator, attlist, propertyList);
+        AFPPageSetup pageSetup = getPageSetupAttachment();
+        if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) {
+            String attr = attlist.getValue("src");
+            if (attr != null && attr.length() > 0) {
+                pageSetup.setValue(attr);
+            } else {
+                throw new FOPException(elementName + " must have a src attribute.");
+            }
+        } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) {
+            String attr = attlist.getValue("value");
+            if (attr != null && attr.length() > 0) {
+                pageSetup.setValue(attr);
+            } else {
+                throw new FOPException(elementName + " must have a value attribute.");
+            }
         }
     }
 
-    /** {@inheritDoc} */    
+    /** {@inheritDoc} */
     protected ExtensionAttachment instantiateExtensionAttachment() {
         return new AFPPageSetup(getLocalName());
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java Sun Mar  1 08:55:35 2009
@@ -54,9 +54,7 @@
         this.name = name;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void validateChildNode(Locator loc, String nsURI, String localName)
                 throws ValidationException {
         if (FO_URI.equals(nsURI)) {
@@ -64,32 +62,17 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    protected void characters(char[] data, int start, int length,
-                                 PropertyList pList, Locator locator) throws FOPException {
-        ((AFPExtensionAttachment)getExtensionAttachment()).setContent(
-                new String(data, start, length));       
-    }
-
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getNamespaceURI() {
         return AFPElementMapping.NAMESPACE;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getNormalNamespacePrefix() {
         return AFPElementMapping.NAMESPACE_PREFIX;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void processNode(String elementName, Locator locator,
                             Attributes attlist, PropertyList propertyList)
                                 throws FOPException {
@@ -100,26 +83,9 @@
         } else {
             throw new FOPException(elementName + " must have a name attribute.");
         }
-        if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) {
-            attr = attlist.getValue("src");
-            if (attr != null && attr.length() > 0) {
-                extensionAttachment.setValue(attr);
-            } else {
-                throw new FOPException(elementName + " must have a src attribute.");
-            }
-        } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) {
-            attr = attlist.getValue("value");
-            if (attr != null && attr.length() > 0) {
-                extensionAttachment.setValue(attr);
-            } else {
-                throw new FOPException(elementName + " must have a value attribute.");
-            }
-        }
     }
-    
-    /**
-     * {@inheritDoc}
-     */
+
+    /** {@inheritDoc} */
     protected void endOfNode() throws FOPException {
         super.endOfNode();
     }
@@ -130,9 +96,7 @@
      */
     protected abstract ExtensionAttachment instantiateExtensionAttachment();
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public ExtensionAttachment getExtensionAttachment() {
         if (extensionAttachment == null) {
             this.extensionAttachment = (AFPExtensionAttachment)instantiateExtensionAttachment();
@@ -140,9 +104,7 @@
         return this.extensionAttachment;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getLocalName() {
         return name;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFParser.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFParser.java Sun Mar  1 08:55:35 2009
@@ -352,7 +352,10 @@
 
             public void startElement(Attributes attributes) throws IFException {
                 String id = attributes.getValue("id");
+                Map foreignAttributes = getForeignAttributes(lastAttributes);
+                establishForeignAttributes(foreignAttributes);
                 documentHandler.startPageSequence(id);
+                resetForeignAttributes();
             }
 
             public void endElement() throws IFException {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFRenderer.java Sun Mar  1 08:55:35 2009
@@ -53,6 +53,7 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Area;
+import org.apache.fop.area.AreaTreeObject;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.BookmarkData;
@@ -500,7 +501,10 @@
                 documentHandler.endDocumentHeader();
                 this.inPageSequence = true;
             }
+            establishForeignAttributes(pageSequence.getForeignAttributes());
             documentHandler.startPageSequence(null);
+            resetForeignAttributes();
+            processExtensionAttachments(pageSequence);
         } catch (IFException e) {
             handleIFException(e);
         }
@@ -557,13 +561,7 @@
             documentHandler.startPageHeader();
 
             //Add page attachments to page header
-            if (page.hasExtensionAttachments()) {
-                for (Iterator iter = page.getExtensionAttachments().iterator();
-                    iter.hasNext();) {
-                    ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
-                    this.documentHandler.handleExtensionObject(attachment);
-                }
-            }
+            processExtensionAttachments(page);
 
             documentHandler.endPageHeader();
             this.painter = documentHandler.startPageContent();
@@ -590,6 +588,16 @@
         }
     }
 
+    private void processExtensionAttachments(AreaTreeObject area) throws IFException {
+        if (area.hasExtensionAttachments()) {
+            for (Iterator iter = area.getExtensionAttachments().iterator();
+                iter.hasNext();) {
+                ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
+                this.documentHandler.handleExtensionObject(attachment);
+            }
+        }
+    }
+
     private void establishForeignAttributes(Map foreignAttributes) {
         documentHandler.getContext().setForeignAttributes(foreignAttributes);
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFSerializer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFSerializer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/intermediate/IFSerializer.java Sun Mar  1 08:55:35 2009
@@ -210,6 +210,7 @@
             if (id != null) {
                 atts.addAttribute(XML_NAMESPACE, "id", "xml:id", XMLUtil.CDATA, id);
             }
+            addForeignAttributes(atts);
             handler.startElement(EL_PAGE_SEQUENCE, atts);
         } catch (SAXException e) {
             throw new IFException("SAX error in startPageSequence()", e);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Sun Mar  1 08:55:35 2009
@@ -438,7 +438,9 @@
         if (pageSequence.getCountry() != null) {
             addAttribute("country", pageSequence.getCountry());
         }
+        transferForeignObjects(pageSequence);
         startElement("pageSequence", atts);
+        handleExtensionAttachments(pageSequence.getExtensionAttachments());
         LineArea seqTitle = pageSequence.getTitle();
         if (seqTitle != null) {
             startElement("title");

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Mar  1 08:55:35 2009
@@ -59,6 +59,9 @@
     -->
     <release version="FOP Trunk" date="TBD">
       <action context="Renderers" dev="JM" type="add">
+        AFP Output: Added support for Invoke Medium Map (IMM). 
+      </action>
+      <action context="Renderers" dev="JM" type="add">
         Introduced a new, additional intermediate format optimized for performance. Please see
         the intermediate format documentation for details.
       </action>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/afp-extension_1.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/afp-extension_1.xml?rev=748981&r1=748980&r2=748981&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/afp-extension_1.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/afp-extension_1.xml Sun Mar  1 08:55:35 2009
@@ -35,7 +35,8 @@
           <fo:region-body/>
         </fo:simple-page-master>
       </fo:layout-master-set>
-      <fo:page-sequence master-reference="normal">
+      <fo:page-sequence master-reference="normal" afp:test-ignore="this">
+        <afp:invoke-medium-map name="MYMAP"/>
         <fo:flow flow-name="xsl-region-body">
           <fo:block>Text on page <fo:page-number/>.</fo:block>
           <fo:block break-before="page">Text on page <fo:page-number/>.</fo:block>
@@ -43,7 +44,7 @@
       </fo:page-sequence>
     </fo:root>
   </fo>
-  <checks>
+  <checks xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
     <eval expected="4" xpath="count(/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*)"/>
     <eval expected="O1SAMP1 " xpath="/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*[1]/@name"/>
     <eval expected="S1ISLOGO" xpath="/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*[2]/@name"/>
@@ -52,5 +53,16 @@
     <eval expected="My NOP" xpath="/areaTree/pageSequence/pageViewport[@nr=1]/page/extension-attachments/child::*[4]/@name"/>
     
     <eval expected="4" xpath="count(/areaTree/pageSequence/pageViewport[@nr=2]/page/extension-attachments/child::*)"/>
+    
+    <eval expected="1" xpath="count(/areaTree/pageSequence/extension-attachments)"/>
+    <eval expected="MYMAP" xpath="/areaTree/pageSequence/extension-attachments/child::*[1]/@name"/>
+    
+    <!-- This just tests if extension attributes make it through to the PageSequence object. -->
+    <eval expected="this" xpath="/areaTree/pageSequence/@afp:test-ignore"/>
   </checks>
+  <if-checks xmlns:if="http://xmlgraphics.apache.org/fop/intermediate"
+        xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
+    <eval expected="this" xpath="//if:page-sequence/@afp:test-ignore"/>
+    <eval expected="MYMAP" xpath="//if:page-sequence/afp:invoke-medium-map/@name"/>
+  </if-checks>
 </testcase>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org