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 2006/01/17 12:08:04 UTC

svn commit: r369753 [2/2] - in /xmlgraphics/fop/trunk: ./ examples/embedding/java/embedding/intermediate/ examples/mathml/src/org/apache/fop/mathml/ examples/plan/src/org/apache/fop/plan/ src/java/org/apache/fop/area/ src/java/org/apache/fop/area/inlin...

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,11 @@
 
 import java.util.HashMap;
 
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.DOMImplementation;
+
 /**
  * Abstract base class for Element Mappings (including FO Element Mappings)
  * which provide the framework of valid elements and attibutes for a given
@@ -55,14 +60,50 @@
     public String getNamespaceURI() {
         return namespaceURI;
     }
+    
+    /**
+     * Returns the DOMImplementation used by this ElementMapping. The value returned may be null
+     * for cases where no DOM is used to represent the element tree (XSL-FO, for example). This
+     * method is used by the intermediate format to instantiate the right kind of DOM document
+     * for foreign objects. For example, SVG handled through Apache Batik has to use a special
+     * DOMImplementation.
+     * @return the DOMImplementation used by this ElementMapping, may be null
+     */
+    public DOMImplementation getDOMImplementation() {
+        return null; //For namespaces not used in foreign objects
+    }
 
     /**
+     * @return the default DOMImplementation when no specialized DOM is necessary.
+     */
+    protected DOMImplementation getDefaultDOMImplementation() {
+        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
+        fact.setNamespaceAware(true);
+        fact.setValidating(false);
+        try {
+            return fact.newDocumentBuilder().getDOMImplementation();
+        } catch (ParserConfigurationException e) {
+            throw new RuntimeException(
+                    "Cannot return default DOM implementation: " + e.getMessage());
+        }
+    }
+    
+    /**
      * Initializes the set of maker objects associated with this ElementMapping
      */
     protected abstract void initialize();
 
+    /**
+     * Base class for all Makers. It is responsible to return the right kind of FONode for a
+     * particular element.
+     */
     public static class Maker {
 
+        /**
+         * Creates a new FONode (or rather a specialized subclass of it).
+         * @param parent the parent FONode
+         * @return the newly created FONode instance
+         */
         public FONode make(FONode parent) {
             return null;
         }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.fo;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.ElementMapping.Maker;
+import org.apache.fop.util.Service;
+import org.w3c.dom.DOMImplementation;
+import org.xml.sax.Locator;
+
+/**
+ * This class keeps track of all configured ElementMapping implementations which are responsible
+ * for properly handling all kinds of different XML namespaces.
+ */
+public class ElementMappingRegistry {
+
+    /** logging instance */
+    protected Log log = LogFactory.getLog(ElementMappingRegistry.class);
+    
+    /**
+     * Table mapping element names to the makers of objects
+     * representing formatting objects.
+     */
+    protected Map fobjTable = new java.util.HashMap();
+
+    /**
+     * Map of mapped namespaces and their associated ElementMapping instances.
+     */
+    protected Map namespaces = new java.util.HashMap();
+
+    /**
+     * Main constructor. Adds all default element mapping as well as detects ElementMapping
+     * through the Service discovery.
+     * @param userAgent the user agent
+     */
+    public ElementMappingRegistry(FOUserAgent userAgent) {
+        // Add standard element mappings
+        setupDefaultMappings();
+
+        // add additional ElementMappings defined within FOUserAgent
+        List addlEMs = userAgent.getAdditionalElementMappings();
+
+        if (addlEMs != null) {
+            for (int i = 0; i < addlEMs.size(); i++) {
+                addElementMapping((ElementMapping) addlEMs.get(i));
+            }
+        }
+    }
+    
+    /**
+     * Sets all the element and property list mappings to their default values.
+     */
+    private void setupDefaultMappings() {
+        addElementMapping("org.apache.fop.fo.FOElementMapping");
+        addElementMapping("org.apache.fop.fo.extensions.svg.SVGElementMapping");
+        addElementMapping("org.apache.fop.fo.extensions.svg.BatikExtensionElementMapping");
+        addElementMapping("org.apache.fop.fo.extensions.ExtensionElementMapping");
+        addElementMapping("org.apache.fop.render.ps.extensions.PSExtensionElementMapping");
+
+        // add mappings from available services
+        Iterator providers = Service.providers(ElementMapping.class);
+        if (providers != null) {
+            while (providers.hasNext()) {
+                String str = (String)providers.next();
+                try {
+                    addElementMapping(str);
+                } catch (IllegalArgumentException e) {
+                    log.warn("Error while adding element mapping", e);
+                }
+
+            }
+        }
+    }
+
+    /**
+     * Add the element mapping with the given class name.
+     * @param mappingClassName the class name representing the element mapping.
+     * @throws IllegalArgumentException if there was not such element mapping.
+     */
+    public void addElementMapping(String mappingClassName)
+                throws IllegalArgumentException {
+
+        try {
+            ElementMapping mapping
+                = (ElementMapping)Class.forName(mappingClassName).newInstance();
+            addElementMapping(mapping);
+        } catch (ClassNotFoundException e) {
+            throw new IllegalArgumentException("Could not find "
+                                               + mappingClassName);
+        } catch (InstantiationException e) {
+            throw new IllegalArgumentException("Could not instantiate "
+                                               + mappingClassName);
+        } catch (IllegalAccessException e) {
+            throw new IllegalArgumentException("Could not access "
+                                               + mappingClassName);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(mappingClassName
+                                               + " is not an ElementMapping");
+        }
+    }
+
+    private void addElementMapping(ElementMapping mapping) {
+        this.fobjTable.put(mapping.getNamespaceURI(), mapping.getTable());
+        this.namespaces.put(mapping.getNamespaceURI().intern(), mapping);
+    }
+
+    /**
+     * Finds the Maker used to create node objects of a particular type
+     * @param namespaceURI URI for the namespace of the element
+     * @param localName name of the Element
+     * @param locator the Locator instance for context information
+     * @return the ElementMapping.Maker that can create an FO object for this element
+     * @throws FOPException if a Maker could not be found for a bound namespace.
+     */
+    public Maker findFOMaker(String namespaceURI, String localName, Locator locator) 
+                throws FOPException {
+        Map table = (Map)fobjTable.get(namespaceURI);
+        Maker fobjMaker = null;
+        if (table != null) {
+            fobjMaker = (ElementMapping.Maker)table.get(localName);
+            // try default
+            if (fobjMaker == null) {
+                fobjMaker = (ElementMapping.Maker)table.get(ElementMapping.DEFAULT);
+            }
+        }
+
+        if (fobjMaker == null) {
+            if (namespaces.containsKey(namespaceURI.intern())) {
+                  throw new FOPException(FONode.errorText(locator) 
+                      + "No element mapping definition found for "
+                      + FONode.getNodeString(namespaceURI, localName), locator);
+            } else {
+                log.warn("Unknown formatting object " + namespaceURI + "^" + localName);
+                fobjMaker = new UnknownXMLObj.Maker(namespaceURI);
+            }
+        }
+        return fobjMaker;
+    }
+
+    /**
+     * Tries to determine the DOMImplementation that is used to handled a particular namespace.
+     * The method may return null for namespaces that don't result in a DOM. It is mostly used
+     * in namespaces occurring in foreign objects. 
+     * @param namespaceURI the namespace URI
+     * @return the handling DOMImplementation, or null if not applicable
+     */
+    public DOMImplementation getDOMImplementationForNamespace(String namespaceURI) {
+        ElementMapping mapping = (ElementMapping)this.namespaces.get(namespaceURI);
+        return mapping.getDOMImplementation();
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMappingRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOTreeBuilder.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,10 +19,6 @@
 package org.apache.fop.fo;
 
 import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -30,7 +26,6 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.area.AreaTreeHandler;
-import org.apache.fop.util.Service;
 import org.apache.fop.fo.ElementMapping.Maker;
 import org.apache.fop.fo.pagination.Root;
 import org.apache.fop.image.ImageFactory;
@@ -48,22 +43,12 @@
  */
 public class FOTreeBuilder extends DefaultHandler {
 
-    /**
-     * Table mapping element names to the makers of objects
-     * representing formatting objects.
-     */
-    protected Map fobjTable = new java.util.HashMap();
-
-    /**
-     * logging instance
-     */
+    /** logging instance */
     protected Log log = LogFactory.getLog(FOTreeBuilder.class);
 
-    /**
-     * Set of mapped namespaces.
-     */
-    protected Set namespaces = new java.util.HashSet();
-
+    /** The registry for ElementMapping instances */
+    protected ElementMappingRegistry elementMappingRegistry;
+    
     /**
      * The root of the formatting object tree
      */
@@ -113,75 +98,7 @@
             }
         });
 
-        // Add standard element mappings
-        setupDefaultMappings();
-
-        // add additional ElementMappings defined within FOUserAgent
-        List addlEMs = foUserAgent.getAdditionalElementMappings();
-
-        if (addlEMs != null) {
-            for (int i = 0; i < addlEMs.size(); i++) {
-                addElementMapping((ElementMapping) addlEMs.get(i));
-            }
-        }
-    }
-
-    /**
-     * Sets all the element and property list mappings to their default values.
-     *
-     */
-    private void setupDefaultMappings() {
-        addElementMapping("org.apache.fop.fo.FOElementMapping");
-        addElementMapping("org.apache.fop.fo.extensions.svg.SVGElementMapping");
-        addElementMapping("org.apache.fop.fo.extensions.svg.BatikExtensionElementMapping");
-        addElementMapping("org.apache.fop.fo.extensions.ExtensionElementMapping");
-        addElementMapping("org.apache.fop.render.ps.extensions.PSExtensionElementMapping");
-
-        // add mappings from available services
-        Iterator providers = Service.providers(ElementMapping.class);
-        if (providers != null) {
-            while (providers.hasNext()) {
-                String str = (String)providers.next();
-                try {
-                    addElementMapping(str);
-                } catch (IllegalArgumentException e) {
-                    log.warn("Error while adding element mapping", e);
-                }
-
-            }
-        }
-    }
-
-    /**
-     * Add the element mapping with the given class name.
-     * @param mappingClassName the class name representing the element mapping.
-     * @throws IllegalArgumentException if there was not such element mapping.
-     */
-    public void addElementMapping(String mappingClassName)
-                throws IllegalArgumentException {
-
-        try {
-            ElementMapping mapping
-                = (ElementMapping)Class.forName(mappingClassName).newInstance();
-            addElementMapping(mapping);
-        } catch (ClassNotFoundException e) {
-            throw new IllegalArgumentException("Could not find "
-                                               + mappingClassName);
-        } catch (InstantiationException e) {
-            throw new IllegalArgumentException("Could not instantiate "
-                                               + mappingClassName);
-        } catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Could not access "
-                                               + mappingClassName);
-        } catch (ClassCastException e) {
-            throw new IllegalArgumentException(mappingClassName
-                                               + " is not an ElementMapping");
-        }
-    }
-
-    private void addElementMapping(ElementMapping mapping) {
-        this.fobjTable.put(mapping.getNamespaceURI(), mapping.getTable());
-        this.namespaces.add(mapping.getNamespaceURI().intern());
+        this.elementMappingRegistry = new ElementMappingRegistry(foUserAgent);
     }
 
     /**
@@ -340,27 +257,7 @@
      * @throws FOPException if a Maker could not be found for a bound namespace.
      */
     private Maker findFOMaker(String namespaceURI, String localName) throws FOPException {
-      Map table = (Map)fobjTable.get(namespaceURI);
-      Maker fobjMaker = null;
-      if (table != null) {
-          fobjMaker = (ElementMapping.Maker)table.get(localName);
-          // try default
-          if (fobjMaker == null) {
-              fobjMaker = (ElementMapping.Maker)table.get(ElementMapping.DEFAULT);
-          }
-      }
-
-      if (fobjMaker == null) {
-          if (namespaces.contains(namespaceURI.intern())) {
-                throw new FOPException(FONode.errorText(locator) 
-                    + "No element mapping definition found for "
-                    + FONode.getNodeString(namespaceURI, localName), locator);
-          } else {
-              log.warn("Unknown formatting object " + namespaceURI + "^" + localName);
-              fobjMaker = new UnknownXMLObj.Maker(namespaceURI);
-          }
-      }
-      return fobjMaker;
+        return elementMappingRegistry.findFOMaker(namespaceURI, localName, locator);
     }
 
     /** @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException) */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,19 +24,29 @@
 import org.apache.batik.util.XMLResourceDescriptor;
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FONode;
+import org.w3c.dom.DOMImplementation;
 
 /**
  * This Element Mapping is for Batik SVG Extension elements
  * of the http://xml.apache.org/batik/ext namespace.
  */
 public class BatikExtensionElementMapping extends ElementMapping {
-    public static String URI = "http://xml.apache.org/batik/ext";
+    
+    /** Namespace URI for Batik extension elements */
+    public static final String URI = "http://xml.apache.org/batik/ext";
+    
     private boolean batikAvail = true;
 
+    /** Main constructor. */
     public BatikExtensionElementMapping() {
         namespaceURI = URI;
     }
 
+    /** @see org.apache.fop.fo.ElementMapping#getDOMImplementation() */
+    public DOMImplementation getDOMImplementation() {
+        return null; //no DOMImplementation necessary here
+    }
+
     /**
      * Returns the fully qualified classname of an XML parser for
      * Batik classes that apparently need it (error messages, perhaps)
@@ -83,4 +93,5 @@
             return new SVGElement(parent);
         }
     }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 
 import org.apache.batik.util.XMLResourceDescriptor;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.w3c.dom.DOMImplementation;
 
 /**
  * Setup the SVG element mapping.
@@ -33,19 +34,28 @@
  * that create the SVG Document.
  */
 public class SVGElementMapping extends ElementMapping {
-    public static String URI = SVGDOMImplementation.SVG_NAMESPACE_URI;
-    private boolean batik = true;
+    
+    /** the SVG namespace */
+    public static final String URI = SVGDOMImplementation.SVG_NAMESPACE_URI;
+    
+    private boolean batikAvailable = true;
 
+    /** Main constructor. */
     public SVGElementMapping() {
         namespaceURI = URI;
     }
 
+    /** @see org.apache.fop.fo.ElementMapping#getDOMImplementation() */
+    public DOMImplementation getDOMImplementation() {
+        return SVGDOMImplementation.getDOMImplementation();
+    }
+
     /**
      * Returns the fully qualified classname of an XML parser for
      * Batik classes that apparently need it (error messages, perhaps)
      * @return an XML parser classname
      */
-    private final String getAParserClassName() {
+    private String getAParserClassName() {
         try {
             SAXParserFactory factory = SAXParserFactory.newInstance();
             return factory.newSAXParser().getXMLReader().getClass().getName();
@@ -54,8 +64,9 @@
         }
     }
 
+    /** @see org.apache.fop.fo.ElementMapping#initialize() */
     protected void initialize() {
-        if (foObjs == null && batik == true) {
+        if (foObjs == null && batikAvailable) {
             // this sets the parser that will be used
             // by default (SVGBrokenLinkProvider)
             // normally the user agent value is used
@@ -69,7 +80,7 @@
             } catch (Throwable t) {
                 // if the classes are not available
                 // the DISPLAY is not checked
-                batik = false;
+                batikAvailable = false;
             }
         }
     }
@@ -85,4 +96,5 @@
             return new SVGElement(parent);
         }
     }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/LazyFont.java Tue Jan 17 03:07:10 2006
@@ -165,6 +165,7 @@
      * @see org.apache.fop.fonts.Typeface#isMultiByte()
      */
     public boolean isMultiByte() {
+        load(true);
         return realFont.isMultiByte();
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/XMLHandlerRegistry.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -117,9 +117,16 @@
         XMLHandler handler;
 
         List lst = (List)handlers.get(ns);
-        if (lst == null) {
+        handler = getXMLHandler(renderer, lst);
+        if (handler == null) {
             lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
+            handler = getXMLHandler(renderer, lst);
         }
+        return handler;
+    }
+
+    private XMLHandler getXMLHandler(Renderer renderer, List lst) {
+        XMLHandler handler;
         if (lst != null) {
             for (int i = 0, c = lst.size(); i < c; i++) {
                 //TODO Maybe add priorities later
@@ -131,7 +138,6 @@
         }
         return null; //No handler found
     }
-    
     
     /**
      * Discovers XMLHandler implementations through the classpath and dynamically

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=369753&r1=369752&r2=369753&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 Tue Jan 17 03:07:10 2006
@@ -40,6 +40,7 @@
 
 // FOP
 import org.apache.fop.render.PrintRenderer;
+import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.XMLHandler;
 import org.apache.fop.apps.FOUserAgent;
@@ -60,6 +61,7 @@
 import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.Span;
 import org.apache.fop.area.Trait;
+import org.apache.fop.area.Trait.Background;
 import org.apache.fop.area.inline.Container;
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Image;
@@ -72,6 +74,8 @@
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.WordArea;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.FontTriplet;
 
@@ -99,6 +103,9 @@
     private boolean startedSequence = false;
     private RendererContext context;
 
+    /** If not null, the XMLRenderer will mimic another renderer by using its font setup. */
+    protected Renderer mimic;
+    
     /** TransformerHandler that the generated XML is written to */
     protected TransformerHandler handler;
     
@@ -137,10 +144,26 @@
     public void setUserAgent(FOUserAgent agent) {
         super.setUserAgent(agent);
 
-        //
-        //userAgent.addExtensionHandler();
-        XMLHandler handler = new XMLXMLHandler();
-        userAgent.getXMLHandlerRegistry().addXMLHandler(handler);
+        XMLHandler xmlHandler = new XMLXMLHandler();
+        userAgent.getXMLHandlerRegistry().addXMLHandler(xmlHandler);
+    }
+
+    /**
+     * Call this method to make the XMLRenderer mimic a different renderer by using its font
+     * setup. This is useful when working with the intermediate format parser.
+     * @param renderer the renderer to mimic
+     */
+    public void mimicRenderer(Renderer renderer) {
+        this.mimic = renderer;
+    }
+    
+    /** @see org.apache.fop.render.PrintRenderer#setupFontInfo(org.apache.fop.fonts.FontInfo) */
+    public void setupFontInfo(FontInfo inFontInfo) {
+        if (mimic != null) {
+            mimic.setupFontInfo(inFontInfo);
+        } else {
+            super.setupFontInfo(inFontInfo);
+        }
     }
 
     /**
@@ -280,6 +303,7 @@
             while (iter.hasNext()) {
                 Map.Entry traitEntry = (Map.Entry) iter.next();
                 String name = Trait.getTraitName(traitEntry.getKey());
+                Class clazz = Trait.getTraitClass(traitEntry.getKey());
                 if ("break-before".equals(name) || "break-after".equals(name)) {
                     continue;
                 }
@@ -289,6 +313,38 @@
                     addAttribute("font-name", triplet.getName());
                     addAttribute("font-style", triplet.getStyle());
                     addAttribute("font-weight", triplet.getWeight());
+                } else if (clazz.equals(Background.class)) {
+                    Background bkg = (Background)value;
+                    //TODO Remove the following line (makes changes in the test checks necessary)
+                    addAttribute(name, bkg.toString());
+                    if (bkg.getColor() != null) {
+                        addAttribute("bkg-color", bkg.getColor().toString());
+                    }
+                    if (bkg.getURL() != null) {
+                        addAttribute("bkg-img", bkg.getURL());
+                        String repString;
+                        int repeat = bkg.getRepeat();
+                        switch (repeat) {
+                        case Constants.EN_REPEAT:
+                            repString = "repeat";
+                            break;
+                        case Constants.EN_REPEATX:
+                            repString = "repeat-x";
+                            break;
+                        case Constants.EN_REPEATY:
+                            repString = "repeat-y";
+                            break;
+                        case Constants.EN_NOREPEAT:
+                            repString = "no-repeat";
+                            break;
+                        default:
+                            throw new IllegalStateException(
+                                    "Illegal value for repeat encountered: " + repeat);
+                        }
+                        addAttribute("bkg-repeat", repString);
+                        addAttribute("bkg-horz-offset", bkg.getHoriz());
+                        addAttribute("bkg-vert-offset", bkg.getVertical());
+                    }
                 } else {
                     addAttribute(name, value.toString());
                 }
@@ -404,6 +460,7 @@
             atts.clear();
             addAreaAttributes(region);
             addTraitAttributes(region);
+            addAttribute("name", region.getRegionName());
             addAttribute("ctm", region.getCTM().toString());
             if (region.getRegionClass() == FO_REGION_BEFORE) {
                 startElement("regionBefore", atts);
@@ -414,8 +471,13 @@
                 renderRegion(region);
                 endElement("regionStart");
             } else if (region.getRegionClass() == FO_REGION_BODY) {
+                BodyRegion body = (BodyRegion)region;
+                if (body.getColumnCount() != 1) {
+                    addAttribute("columnGap", body.getColumnGap());
+                    addAttribute("columnCount", body.getColumnCount());
+                }
                 startElement("regionBody", atts);
-                renderBodyRegion((BodyRegion) region);
+                renderBodyRegion(body);
                 endElement("regionBody");
             } else if (region.getRegionClass() == FO_REGION_END) {
                 startElement("regionEnd", atts);
@@ -465,7 +527,9 @@
         atts.clear();
         addAreaAttributes(mr);
         addTraitAttributes(mr);
-        addAttribute("columnGap", mr.getColumnGap());
+        if (mr.getColumnCount() != 1) {
+            addAttribute("columnGap", mr.getColumnGap());
+        }
         startElement("mainReference", atts);
 
         Span span = null;
@@ -473,6 +537,9 @@
         for (int count = 0; count < spans.size(); count++) {
             span = (Span) spans.get(count);
             atts.clear();
+            if (span.getColumnCount() != 1) {
+                addAttribute("columnCount", span.getColumnCount());
+            }
             addAreaAttributes(span);
             addTraitAttributes(span);
             startElement("span", atts);
@@ -506,14 +573,12 @@
         atts.clear();
         addAreaAttributes(block);
         addTraitAttributes(block);
+        int positioning = block.getPositioning();
         if (block instanceof BlockViewport) {
             BlockViewport bvp = (BlockViewport)block;
             boolean abspos = false;
-            if (bvp.getPositioning() == Block.ABSOLUTE) {
-                addAttribute("positioning", "absolute");
-                abspos = true;
-            } else if (bvp.getPositioning() == Block.FIXED) {
-                addAttribute("positioning", "fixed");
+            if (bvp.getPositioning() == Block.ABSOLUTE 
+                    || bvp.getPositioning() == Block.FIXED) {
                 abspos = true;
             }
             if (abspos) {
@@ -525,9 +590,6 @@
                 addAttribute("clipped", "true");
             }
         } else {
-            if (block.getPositioning() == Block.RELATIVE) {
-                addAttribute("positioning", "relative");
-            }
             if (block.getXOffset() != 0) {
                 addAttribute("left-offset", block.getXOffset());
             }
@@ -535,6 +597,18 @@
                 addAttribute("top-offset", block.getYOffset());
             }
         }
+        switch (positioning) {
+        case Block.RELATIVE:
+            addAttribute("positioning", "relative");
+            break;
+        case Block.ABSOLUTE:
+            addAttribute("positioning", "absolute");
+            break;
+        case Block.FIXED:
+            addAttribute("positioning", "fixed");
+            break;
+        default: //nop
+        }
         startElement("block", atts);
         super.renderBlock(block);
         endElement("block");
@@ -563,6 +637,10 @@
         addAreaAttributes(viewport);
         addTraitAttributes(viewport);
         addAttribute("offset", viewport.getOffset());
+        addAttribute("pos", viewport.getContentPosition());
+        if (viewport.getClip()) {
+            addAttribute("clip", Boolean.toString(viewport.getClip()));
+        }
         startElement("viewport", atts);
         super.renderViewport(viewport);
         endElement("viewport");
@@ -576,7 +654,7 @@
         addAreaAttributes(image);
         addTraitAttributes(image);
         addAttribute("url", image.getURL());
-        addAttribute("pos", pos);
+        //addAttribute("pos", pos);
         startElement("image", atts);
         endElement("image");
     }
@@ -600,10 +678,10 @@
         atts.clear();
         addAreaAttributes(fo);
         addTraitAttributes(fo);
-        addAttribute("pos", pos);
+        String ns = fo.getNameSpace();
+        addAttribute("ns", ns);
         startElement("foreignObject", atts);
         Document doc = fo.getDocument();
-        String ns = fo.getNameSpace();
         context.setProperty(XMLXMLHandler.HANDLER, handler);
         renderXML(context, doc, ns);
         endElement("foreignObject");
@@ -709,36 +787,11 @@
      * @see org.apache.fop.render.AbstractRenderer#renderLeader(Leader)
      */
     protected void renderLeader(Leader area) {
-        String style = "solid";
-        switch (area.getRuleStyle()) {
-            case EN_DOTTED:
-                style = "dotted";
-                break;
-            case EN_DASHED:
-                style = "dashed";
-                break;
-            case EN_SOLID:
-                break;
-            case EN_DOUBLE:
-                style = "double";
-                break;
-            case EN_GROOVE:
-                style = "groove";
-                break;
-            case EN_RIDGE:
-                style = "ridge";
-                break;
-            case EN_NONE:
-                style = "none";
-                break;
-            default:
-                style = "--NYI--";
-        }
         atts.clear();
         addAreaAttributes(area);
         addTraitAttributes(area);
         addAttribute("offset", area.getOffset());
-        addAttribute("ruleStyle", style);
+        addAttribute("ruleStyle", area.getRuleStyleAsString());
         addAttribute("ruleThickness", area.getRuleThickness());
         startElement("leader", atts);
         endElement("leader");

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/traits/BorderProps.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,10 @@
 import org.apache.fop.area.Trait;
 import org.apache.fop.datatypes.ColorType;
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fonts.FontTriplet;
 
 import java.io.Serializable;
+import java.util.StringTokenizer;
 
 /**
  * Border properties.
@@ -61,6 +63,17 @@
     }
 
     /**
+     * Constructs a new BorderProps instance.
+     * @param style border style (one of the XSL enum values for border style)
+     * @param width border width
+     * @param color border color
+     * @param mode border mode ((one of SEPARATE, COLLAPSE_INNER and COLLAPSE_OUTER)
+     */
+    public BorderProps(String style, int width, ColorType color, int mode) {
+        this(getConstantForStyle(style), width, color, mode);
+    }
+
+    /**
      * @param bp the border properties or null
      * @return the effective width of the clipped part of the border
      */
@@ -88,6 +101,83 @@
         }
     }
     
+    private static int getConstantForStyle(String style) {
+        if ("none".equalsIgnoreCase(style)) {
+            return Constants.EN_NONE;
+        } else if ("hidden".equalsIgnoreCase(style)) {
+            return Constants.EN_HIDDEN;
+        } else if ("dotted".equalsIgnoreCase(style)) {
+            return Constants.EN_DOTTED;
+        } else if ("dashed".equalsIgnoreCase(style)) {
+            return Constants.EN_DASHED;
+        } else if ("solid".equalsIgnoreCase(style)) {
+            return Constants.EN_SOLID;
+        } else if ("double".equalsIgnoreCase(style)) {
+            return Constants.EN_DOUBLE;
+        } else if ("groove".equalsIgnoreCase(style)) {
+            return Constants.EN_GROOVE;
+        } else if ("ridge".equalsIgnoreCase(style)) {
+            return Constants.EN_RIDGE;
+        } else if ("inset".equalsIgnoreCase(style)) {
+            return Constants.EN_INSET;
+        } else if ("outset".equalsIgnoreCase(style)) {
+            return Constants.EN_OUTSET;
+        } else {
+            throw new IllegalStateException("Illegal border style: " + style);
+        }
+    }
+    
+    /** @see java.lang.Object#hashCode() */
+    public int hashCode() {
+        return toString().hashCode();
+    }
+
+    /** @see java.lang.Object#equals(java.lang.Object) */
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        } else if (obj == this) {
+            return true;
+        } else {
+            if (obj instanceof BorderProps) {
+                BorderProps other = (BorderProps)obj;
+                return (style == other.style)
+                        && color.equals(other.color) 
+                        && width == other.width
+                        && mode == other.mode;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Returns a BorderProps represtation of a string of the format as written by 
+     * BorderProps.toString().
+     * @param s the string
+     * @return a BorderProps instance
+     */
+    public static BorderProps valueOf(String s) {
+        if (s.startsWith("(") && s.endsWith(")")) {
+            s = s.substring(1, s.length() - 1);
+            StringTokenizer st = new StringTokenizer(s, ",");
+            String style = st.nextToken();
+            String color = st.nextToken();
+            int width = Integer.parseInt(st.nextToken());
+            int mode = SEPARATE;
+            if (st.hasMoreTokens()) {
+                String ms = st.nextToken();
+                if ("collapse-inner".equalsIgnoreCase(ms)) {
+                    mode = COLLAPSE_INNER;
+                } else if ("collapse-outer".equalsIgnoreCase(ms)) {
+                    mode = COLLAPSE_OUTER;
+                }
+            }
+            return new BorderProps(style, width, Trait.Color.valueOf(color), mode);
+        } else {
+            throw new IllegalArgumentException("BorderProps must be surrounded by parentheses");
+        }
+    }
+
     /** @see java.lang.Object#toString() */
     public String toString() {
         StringBuffer sbuf = new StringBuffer();
@@ -108,4 +198,5 @@
         sbuf.append(')');
         return sbuf.toString();
     }
+
 }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DefaultErrorListener.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DefaultErrorListener.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DefaultErrorListener.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DefaultErrorListener.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.util;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.TransformerException;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Standard ErrorListener implementation for in-FOP use. Some Xalan-J versions don't properly
+ * re-throw exceptions.
+ */
+public class DefaultErrorListener implements ErrorListener {
+
+    private Log log;
+    
+    /**
+     * Main constructor
+     * @param log the log instance to send log events to
+     */
+    public DefaultErrorListener(Log log) {
+        this.log = log;
+    }
+    
+    /**
+     * @see javax.xml.transform.ErrorListener#warning(javax.xml.transform.TransformerException)
+     */
+    public void warning(TransformerException exc) {
+        log.warn(exc.toString());
+    }
+
+    /**
+     * @see javax.xml.transform.ErrorListener#error(javax.xml.transform.TransformerException)
+     */
+    public void error(TransformerException exc) throws TransformerException {
+        throw exc;
+    }
+
+    /**
+     * @see javax.xml.transform.ErrorListener#fatalError(javax.xml.transform.TransformerException)
+     */
+    public void fatalError(TransformerException exc)
+            throws TransformerException {
+        throw exc;
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DefaultErrorListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/status.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Jan 17 03:07:10 2006
@@ -27,6 +27,12 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add">
+        New feature: "Intermediate format" (IF). The IF is basically the XML dialect
+        written by the area tree renderer (XMLRenderer). A new parser for this format
+        allows reparsing a serialized and possibly modified area tree and rendering it
+        to the final target format.
+      </action>
       <action context="Code" dev="JM" type="fix">
         Bugfix: Floating point numbers were not properly formatted in the PDF renderer
         which could lead to error messages while opening a PDF in Acrobat Reader.

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/UtilityCodeTestSuite.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
  
 package org.apache.fop;
 
+import org.apache.fop.traits.BorderPropsTestCase;
+import org.apache.fop.traits.TraitColorTestCase;
 import org.apache.fop.util.ASCII85InputStreamTestCase;
 import org.apache.fop.util.ASCII85OutputStreamTestCase;
 import org.apache.fop.util.PDFNumberTestCase;
@@ -41,6 +43,8 @@
         suite.addTest(new TestSuite(ASCII85OutputStreamTestCase.class));
         suite.addTest(new TestSuite(ASCII85InputStreamTestCase.class));
         suite.addTest(new TestSuite(PDFNumberTestCase.class));
+        suite.addTest(new TestSuite(TraitColorTestCase.class));
+        suite.addTest(new TestSuite(BorderPropsTestCase.class));
         //$JUnit-END$
         return suite;
     }

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.intermediate;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.area.AreaTreeModel;
+import org.apache.fop.area.AreaTreeParser;
+import org.apache.fop.area.RenderPagesModel;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.render.xml.XMLRenderer;
+
+//XML Unit 1.0: See http://xmlunit.sourceforge.net (BSD-style License)
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.w3c.dom.Document;
+
+/**
+ * Tests the area tree parser.
+ */
+public class AreaTreeParserTestCase extends XMLTestCase {
+
+    private static SAXTransformerFactory tFactory 
+            = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
+    private static Templates stylesheet = null;
+    
+    private File mainDir = new File("test/layoutengine");
+    private File testDir = new File(mainDir, "standard-testcases");
+    
+    private String name;
+    private File testFile;
+
+    private File outputDir;
+    private Document intermediate;
+    
+    /** @see junit.framework.TestCase#TestCase(String) */
+    public AreaTreeParserTestCase(String name) {
+        super(name);
+    }
+    
+    /**
+     * Constructor for the test suite that is used for each test file.
+     * @param testFile the test file to run
+     */
+    public AreaTreeParserTestCase(File testFile) {
+        super(testFile.getName());
+        this.testFile = testFile;
+    }
+ 
+    private Templates getStylesheet() throws TransformerConfigurationException {
+        if (stylesheet == null) {
+            File xsltFile = new File(mainDir, "testcase2fo.xsl");
+            stylesheet = tFactory.newTemplates(new StreamSource(xsltFile));
+        }
+        return stylesheet;
+    }
+    
+    /** @see junit.framework.TestCase#setUp() */
+    protected void setUp() throws Exception {
+        super.setUp();
+        String s = System.getProperty("fop.intermediate.outdir");
+        if (s != null && s.length() > 0) {
+            outputDir = new File(s);
+            outputDir.mkdirs();
+        }
+        File srcFile;
+        if (testFile != null) {
+            srcFile = testFile;
+        } else {
+            srcFile = new File(testDir, "block_font-style.xml");
+        }
+        this.name = srcFile.getName();
+        intermediate = buildAreaTreeXML(new StreamSource(srcFile), getStylesheet());
+        if (outputDir != null) {
+            saveDOM(intermediate, new File(outputDir, name + ".at1.xml"));
+        }
+    }
+
+
+    /**
+     * Tests the area tree parser by running the parsed area tree again through the area tree
+     * renderer. The source and result documents are compared to each other.
+     * @throws Exception if the test fails
+     */
+    public void testParserToAT() throws Exception {
+                
+        Source src = new DOMSource(intermediate);
+        Document doc = parseAndRenderToAreaTree(src);
+        if (outputDir != null) {
+            File tgtFile = new File(outputDir, name + ".at2.xml");
+            saveDOM(doc, tgtFile);
+        }
+        
+        assertXMLEqual(intermediate, doc);
+    }
+    
+    private void saveDOM(Document doc, File tgtFile) throws Exception {
+        Transformer transformer = tFactory.newTransformer();
+        Source src = new DOMSource(doc);
+        Result res = new StreamResult(tgtFile);
+        transformer.transform(src, res);
+    }
+
+    /**
+     * Tests the area tree parser by sending the parsed area tree to the PDF Renderer. Some
+     * errors might be caught by the PDFRenderer.
+     * @throws Exception if the test fails
+     */
+    public void testParserToPDF() throws Exception {
+        OutputStream out;
+        if (outputDir != null) {
+            File tgtFile = new File(outputDir, name + ".pdf");
+            out = new FileOutputStream(tgtFile);
+            out = new BufferedOutputStream(out);
+        } else {
+            out = new ByteArrayOutputStream();
+        }
+        try {
+            Source src = new DOMSource(intermediate);
+            parseAndRender(src, out, MimeConstants.MIME_PDF);
+        } finally {
+            IOUtils.closeQuietly(out);
+        }
+    }
+    
+    private FOUserAgent createUserAgent() {
+        FOUserAgent userAgent = new FOUserAgent();
+        try {
+            userAgent.setBaseURL(testDir.toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            //ignore, won't happen
+        }
+        return userAgent;
+    }
+
+    private Document buildAreaTreeXML(Source src, Templates stylesheet) throws Exception {
+        Transformer transformer;
+        if (stylesheet != null) {
+            transformer = stylesheet.newTransformer();
+        } else {
+            transformer = tFactory.newTransformer();
+        }
+
+        //Set up XMLRenderer to render to a DOM
+        TransformerHandler handler = tFactory.newTransformerHandler();
+        DOMResult domResult = new DOMResult();
+        handler.setResult(domResult);
+        
+        FOUserAgent userAgent = createUserAgent();
+
+        //Create an instance of the target renderer so the XMLRenderer can use its font setup
+        Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
+                userAgent, MimeConstants.MIME_PDF); 
+        
+        XMLRenderer renderer = new XMLRenderer();
+        renderer.mimicRenderer(targetRenderer);
+        renderer.setTransformerHandler(handler);
+        renderer.setUserAgent(userAgent);
+
+        userAgent.setRendererOverride(renderer);
+        
+        Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, userAgent);
+        Result res = new SAXResult(fop.getDefaultHandler());
+        transformer.transform(src, res);
+        
+        return (Document)domResult.getNode();
+    }
+    
+    private void parseAndRender(Source src, OutputStream out, String mime) throws Exception {
+        AreaTreeParser parser = new AreaTreeParser();
+                
+        FOUserAgent userAgent = createUserAgent();
+        FontInfo fontInfo = new FontInfo();
+        AreaTreeModel treeModel = new RenderPagesModel(userAgent, 
+                mime, fontInfo, out); 
+        parser.parse(src, treeModel, userAgent);
+        treeModel.endDocument();
+    }
+    
+    private Document parseAndRenderToAreaTree(Source src) throws Exception {
+        AreaTreeParser parser = new AreaTreeParser();
+                
+        //Set up XMLRenderer to render to a DOM
+        TransformerHandler handler = tFactory.newTransformerHandler();
+        DOMResult domResult = new DOMResult();
+        handler.setResult(domResult);
+        XMLRenderer renderer = new XMLRenderer();
+        renderer.setTransformerHandler(handler);
+
+        FOUserAgent userAgent = createUserAgent();
+        userAgent.setRendererOverride(renderer);
+        renderer.setUserAgent(userAgent);
+
+        FontInfo fontInfo = new FontInfo();
+        AreaTreeModel treeModel = new RenderPagesModel(userAgent, 
+                MimeConstants.MIME_FOP_AREA_TREE, fontInfo, null); 
+        parser.parse(src, treeModel, userAgent);
+        treeModel.endDocument();
+
+        return (Document)domResult.getNode();
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/AreaTreeParserTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.intermediate;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.fop.layoutengine.LayoutEngineTestSuite;
+
+/**
+ * JUnit test suite for the intermediate format
+ */
+public class IntermediateFormatTestSuite {
+
+    /**
+     * @return the test suite with all the tests (one for each XML file)
+     * @throws IOException in case of an I/O problem
+     */
+    public static Test suite() throws IOException {
+        TestSuite suite = new TestSuite();
+
+        Collection files = LayoutEngineTestSuite.getTestFiles();
+
+        Iterator i = files.iterator();
+        while (i.hasNext()) {
+            File f = (File)i.next();
+            addTestCase(suite, f);
+        }
+        
+        return suite;
+    }
+    
+    private static void addTestCase(TestSuite suite, 
+            final File f) {
+        suite.addTest(new AreaTreeParserTestCase(f) {
+            public void runTest() throws Exception {
+                org.apache.commons.logging.LogFactory.getLog(
+                        this.getClass()).info("Starting " + f.getName());
+                testParserToAT();
+                testParserToPDF();
+            }
+        });
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/intermediate/IntermediateFormatTestSuite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTestSuite.java Tue Jan 17 03:07:10 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,11 +18,8 @@
 
 package org.apache.fop.layoutengine;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOException;
-import java.io.Reader;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -129,18 +126,11 @@
     }
     
     /**
-     * @return the test suite with all the tests (one for each XML file)
-     * @throws IOException in case of an I/O problem
+     * @return a Collection of File instances containing all the test cases set up for processing.
+     * @throws IOException if there's a problem gathering the list of test files
      */
-    public static Test suite() throws IOException {
-        TestSuite suite = new TestSuite();
-
+    public static Collection getTestFiles() throws IOException {
         File mainDir = new File("test/layoutengine");
-        File backupDir = new File("build/test-results/layoutengine");
-        backupDir.mkdirs();
-
-        final LayoutEngineTester tester = new LayoutEngineTester(backupDir);
-        
         IOFileFilter filter;
         String single = System.getProperty("fop.layoutengine.single");
         String startsWith = System.getProperty("fop.layoutengine.starts-with");
@@ -166,6 +156,22 @@
                     filter, TrueFileFilter.INSTANCE);
             files.addAll(privateFiles);
         }
+        return files;
+    }
+    
+    /**
+     * @return the test suite with all the tests (one for each XML file)
+     * @throws IOException in case of an I/O problem
+     */
+    public static Test suite() throws IOException {
+        TestSuite suite = new TestSuite();
+
+        File backupDir = new File("build/test-results/layoutengine");
+        backupDir.mkdirs();
+
+        Collection files = getTestFiles();
+
+        final LayoutEngineTester tester = new LayoutEngineTester(backupDir);
         Iterator i = files.iterator();
         while (i.hasNext()) {
             File f = (File)i.next();

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.traits;
+
+import org.apache.fop.area.Trait;
+import org.apache.fop.fo.Constants;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the BorderProps class.
+ */
+public class BorderPropsTestCase extends TestCase {
+
+    /**
+     * Test serialization and deserialization to/from String.
+     * @throws Exception if an error occurs
+     */
+    public void testSerialization() throws Exception {
+        Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
+        //Normalize: Avoid false alarms due to color conversion (rounding)
+        col = Trait.Color.valueOf(col.toString());
+        
+        BorderProps b1 = new BorderProps(Constants.EN_DOUBLE, 1250, 
+                col, BorderProps.COLLAPSE_OUTER);
+        String ser = b1.toString();
+        BorderProps b2 = BorderProps.valueOf(ser);
+        assertEquals(b1, b2);
+
+        b1 = new BorderProps(Constants.EN_INSET, 9999, 
+                col, BorderProps.SEPARATE);
+        ser = b1.toString();
+        b2 = BorderProps.valueOf(ser);
+        assertEquals(b1, b2);
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/BorderPropsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java?rev=369753&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java Tue Jan 17 03:07:10 2006
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.traits;
+
+import org.apache.fop.area.Trait;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the Trait.Color class.
+ */
+public class TraitColorTestCase extends TestCase {
+
+    /**
+     * Test serialization to String.
+     * @throws Exception if an error occurs
+     */
+    public void testSerialization() throws Exception {
+        Trait.Color col = new Trait.Color(1.0f, 1.0f, 0.5f, 1.0f);
+        String s = col.toString();
+        assertEquals("#ffff7f", s);
+        
+        col = new Trait.Color(1.0f, 0.0f, 0.0f, 0.8f);
+        s = col.toString();
+        assertEquals("#ff0000cc", s);
+    }
+    
+    /**
+     * Test deserialization from String.
+     * @throws Exception if an error occurs
+     */
+    public void testDeserialization() throws Exception {
+        float tolerance = 0.5f / 255; //due to color value conversion
+
+        Trait.Color col = Trait.Color.valueOf("#ffff7f");
+        assertEquals(1.0f, col.getRed(), 0.0f);
+        assertEquals(1.0f, col.getGreen(), 0.0f);
+        assertEquals(0.5f, col.getBlue(), tolerance);
+        assertEquals(1.0f, col.getAlpha(), 0.0f);
+
+        col = Trait.Color.valueOf("#ff0000cc");
+        assertEquals(1.0f, col.getRed(), 0.0f);
+        assertEquals(0.0f, col.getGreen(), 0.0f);
+        assertEquals(0.0f, col.getBlue(), 0.0f);
+        assertEquals(0.8f, col.getAlpha(), tolerance);
+    }
+    
+    /**
+     * Test equals().
+     * @throws Exception if an error occurs
+     */
+    public void testEquals() throws Exception {
+        Trait.Color col1 = Trait.Color.valueOf("#ff0000cc");
+        Trait.Color col2 = Trait.Color.valueOf("#ff0000cc");
+        assertTrue(col1 != col2);
+        assertEquals(col1, col2);
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/traits/TraitColorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_border_padding.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_border_padding.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_border_padding.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_border_padding.xml Tue Jan 17 03:07:10 2006
@@ -60,7 +60,7 @@
     <eval expected="10000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-start"/>
     <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
-    <eval expected="20000 20000 46080 46080" xpath="//flow/block[1]/lineArea/viewport/image/@pos"/>
+    <eval expected="20000 20000 46080 46080" xpath="//flow/block[1]/lineArea/viewport/@pos"/>
     <!-- second e-g -->
     <eval expected="46080" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
@@ -76,6 +76,6 @@
     <eval expected="10000" xpath="//flow/block[2]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[2]/lineArea/viewport/@padding-start"/>
     <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@padding-end"/>
-    <eval expected="20000 20000 46080 46080" xpath="//flow/block[2]/lineArea/viewport/image/@pos"/>
+    <eval expected="20000 20000 46080 46080" xpath="//flow/block[2]/lineArea/viewport/@pos"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_display-align.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_display-align.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_display-align.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_display-align.xml Tue Jan 17 03:07:10 2006
@@ -60,26 +60,26 @@
     <eval expected="46080" xpath="//flow/block[2]/lineArea/viewport/@ipda"/>
     <eval expected="60000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
     <eval expected="60000" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 46080 46080" xpath="//flow/block[2]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 46080 46080" xpath="//flow/block[2]/lineArea/viewport/@pos"/>
     <eval expected="46080" xpath="//flow/block[4]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="//flow/block[4]/lineArea/viewport/@ipda"/>
     <eval expected="60000" xpath="//flow/block[4]/lineArea/viewport/@bpd"/>
     <eval expected="60000" xpath="//flow/block[4]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 46080 46080" xpath="//flow/block[4]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 46080 46080" xpath="//flow/block[4]/lineArea/viewport/@pos"/>
     <eval expected="46080" xpath="//flow/block[6]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="//flow/block[6]/lineArea/viewport/@ipda"/>
     <eval expected="60000" xpath="//flow/block[6]/lineArea/viewport/@bpd"/>
     <eval expected="60000" xpath="//flow/block[6]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 46080 46080" xpath="//flow/block[6]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 46080 46080" xpath="//flow/block[6]/lineArea/viewport/@pos"/>
     <eval expected="46080" xpath="//flow/block[8]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="//flow/block[8]/lineArea/viewport/@ipda"/>
     <eval expected="60000" xpath="//flow/block[8]/lineArea/viewport/@bpd"/>
     <eval expected="60000" xpath="//flow/block[8]/lineArea/viewport/@bpda"/>
-    <eval expected="0 6960 46080 46080" xpath="//flow/block[8]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 6960 46080 46080" xpath="//flow/block[8]/lineArea/viewport/@pos"/>
     <eval expected="46080" xpath="//flow/block[10]/lineArea/viewport/@ipd"/>
     <eval expected="46080" xpath="//flow/block[10]/lineArea/viewport/@ipda"/>
     <eval expected="60000" xpath="//flow/block[10]/lineArea/viewport/@bpd"/>
     <eval expected="60000" xpath="//flow/block[10]/lineArea/viewport/@bpda"/>
-    <eval expected="0 13920 46080 46080" xpath="//flow/block[10]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 13920 46080 46080" xpath="//flow/block[10]/lineArea/viewport/@pos"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_svg.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_svg.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_svg.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/external-graphic_svg.xml Tue Jan 17 03:07:10 2006
@@ -56,19 +56,19 @@
     <eval expected="144000" xpath="//flow/block[2]/lineArea/viewport/@ipda"/>
     <eval expected="144000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
     <eval expected="144000" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 144000 144000" xpath="//flow/block[2]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 144000 144000" xpath="//flow/block[2]/lineArea/viewport/@pos"/>
     
     <eval expected="288000" xpath="//flow/block[4]/lineArea/viewport/@ipd"/>
     <eval expected="288000" xpath="//flow/block[4]/lineArea/viewport/@ipda"/>
     <eval expected="288000" xpath="//flow/block[4]/lineArea/viewport/@bpd"/>
     <eval expected="288000" xpath="//flow/block[4]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 288000 288000" xpath="//flow/block[4]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 288000 288000" xpath="//flow/block[4]/lineArea/viewport/@pos"/>
 
     <eval expected="432000" xpath="//flow/block[6]/lineArea/viewport/@ipd"/>
     <eval expected="432000" xpath="//flow/block[6]/lineArea/viewport/@ipda"/>
     <eval expected="288000" xpath="//flow/block[6]/lineArea/viewport/@bpd"/>
     <eval expected="288000" xpath="//flow/block[6]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 432000 288000" xpath="//flow/block[6]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 432000 288000" xpath="//flow/block[6]/lineArea/viewport/@pos"/>
 
     <!-- TODO: This evaluates nicely to 16000mpt with 72dpi in the FOUserAgent but will result 
          in 16080 for 300dpi which is caused by rounding errors because pixels are used internally. -->
@@ -76,6 +76,6 @@
     <eval expected="16000" xpath="//flow/block[8]/lineArea/viewport/@ipda"/>
     <eval expected="16000" xpath="//flow/block[8]/lineArea/viewport/@bpd"/>
     <eval expected="16000" xpath="//flow/block[8]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 16000 16000" xpath="//flow/block[8]/lineArea/viewport/image/@pos"/>
+    <eval expected="0 0 16000 16000" xpath="//flow/block[8]/lineArea/viewport/@pos"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_border_padding.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_border_padding.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_border_padding.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_border_padding.xml Tue Jan 17 03:07:10 2006
@@ -74,7 +74,7 @@
     <eval expected="10000" xpath="//flow/block[1]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[1]/lineArea/viewport/@padding-start"/>
     <eval expected="20000" xpath="//flow/block[1]/lineArea/viewport/@padding-end"/>
-    <eval expected="20000 20000 20000 20000" xpath="//flow/block[1]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[1]/lineArea/viewport/@pos"/>
     <!-- second i-f-o -->
     <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@ipd"/>
     <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
@@ -90,6 +90,6 @@
     <eval expected="10000" xpath="//flow/block[2]/lineArea/viewport/@padding-after"/>
     <eval expected="5000" xpath="//flow/block[2]/lineArea/viewport/@padding-start"/>
     <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@padding-end"/>
-    <eval expected="20000 20000 20000 20000" xpath="//flow/block[2]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="20000 20000 20000 20000" xpath="//flow/block[2]/lineArea/viewport/@pos"/>
   </checks>
 </testcase>

Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_display-align.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_display-align.xml?rev=369753&r1=369752&r2=369753&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_display-align.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/instream-foreign-object_display-align.xml Tue Jan 17 03:07:10 2006
@@ -95,26 +95,26 @@
     <eval expected="20000" xpath="//flow/block[2]/lineArea/viewport/@ipda"/>
     <eval expected="30000" xpath="//flow/block[2]/lineArea/viewport/@bpd"/>
     <eval expected="30000" xpath="//flow/block[2]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 20000 20000" xpath="//flow/block[2]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="0 0 20000 20000" xpath="//flow/block[2]/lineArea/viewport/@pos"/>
     <eval expected="20000" xpath="//flow/block[4]/lineArea/viewport/@ipd"/>
     <eval expected="20000" xpath="//flow/block[4]/lineArea/viewport/@ipda"/>
     <eval expected="30000" xpath="//flow/block[4]/lineArea/viewport/@bpd"/>
     <eval expected="30000" xpath="//flow/block[4]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 20000 20000" xpath="//flow/block[4]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="0 0 20000 20000" xpath="//flow/block[4]/lineArea/viewport/@pos"/>
     <eval expected="20000" xpath="//flow/block[6]/lineArea/viewport/@ipd"/>
     <eval expected="20000" xpath="//flow/block[6]/lineArea/viewport/@ipda"/>
     <eval expected="30000" xpath="//flow/block[6]/lineArea/viewport/@bpd"/>
     <eval expected="30000" xpath="//flow/block[6]/lineArea/viewport/@bpda"/>
-    <eval expected="0 0 20000 20000" xpath="//flow/block[6]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="0 0 20000 20000" xpath="//flow/block[6]/lineArea/viewport/@pos"/>
     <eval expected="20000" xpath="//flow/block[8]/lineArea/viewport/@ipd"/>
     <eval expected="20000" xpath="//flow/block[8]/lineArea/viewport/@ipda"/>
     <eval expected="30000" xpath="//flow/block[8]/lineArea/viewport/@bpd"/>
     <eval expected="30000" xpath="//flow/block[8]/lineArea/viewport/@bpda"/>
-    <eval expected="0 5000 20000 20000" xpath="//flow/block[8]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="0 5000 20000 20000" xpath="//flow/block[8]/lineArea/viewport/@pos"/>
     <eval expected="20000" xpath="//flow/block[10]/lineArea/viewport/@ipd"/>
     <eval expected="20000" xpath="//flow/block[10]/lineArea/viewport/@ipda"/>
     <eval expected="30000" xpath="//flow/block[10]/lineArea/viewport/@bpd"/>
     <eval expected="30000" xpath="//flow/block[10]/lineArea/viewport/@bpda"/>
-    <eval expected="0 10000 20000 20000" xpath="//flow/block[10]/lineArea/viewport/foreignObject/@pos"/>
+    <eval expected="0 10000 20000 20000" xpath="//flow/block[10]/lineArea/viewport/@pos"/>
   </checks>
 </testcase>



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