* Compiled FOP with commons-logging-1.1, which is also needed by JEuclid,
  instead of commons-logging-1.0.4.

  Ran: ant clean jar-main

* src/java/org/apache/fop/apps/FopFactoryConfigurator.java: changed 
  DEFAULT_SOURCE_RESOLUTION from 72 to 120dpi (like RenderX XEP).

* The DOM builder of Saxon is not namespace aware and we really need to DOM
  builder which is namespace aware, otherwise SVG instream-foreign-object are
  not properly processed.

  We have tried to use Java 1.5+
  com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
  .newTransformerHandler() but it does not work because (I think) 
  Batik expects null for the absence of namespace and not "", the empty string.

New file src/java/org/apache/fop/util/SAXToDOM.java:
===============================================================
package org.apache.fop.util;

import java.util.Stack;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.w3c.dom.Document;

public final class SAXToDOM extends DefaultHandler {
    private Stack nodeStack;
    private StringBuilder buffer;
    private Document doc;

    public SAXToDOM(Document doc) {
        nodeStack = new Stack();
        buffer = null;

        this.doc = doc;
        nodeStack.push(doc);
    }

    public void startElement(String uri, String localName, String qName,
                             Attributes atts)
        throws SAXException {
        flushBuffer();

        Element element = doc.createElementNS(uri, qName);

        int attCount = atts.getLength();
        for (int i = 0; i < attCount; ++i) {
            String attName = atts.getQName(i);
            if (attName.startsWith("xmlns")) {
                continue;
            }

            String attURI = atts.getURI(i);

            element.setAttributeNS((attURI.length() == 0)? null : attURI, 
                                   attName, atts.getValue(i));
        }

        Node parent = (Node) nodeStack.peek();
        parent.appendChild(element);

        nodeStack.push(element);
    }

    public void endElement(String uri, String localName, String qName)
        throws SAXException {
        flushBuffer();

        nodeStack.pop();
    }

    private void flushBuffer() {
        if (buffer != null) {
            Node parent = (Node) nodeStack.peek();
            parent.appendChild(doc.createTextNode(buffer.toString()));
            buffer = null;
        }
    }

    public void characters(char[] ch, int start, int length)
        throws SAXException {
        if (buffer == null) {
            buffer = new StringBuilder();
        }
        buffer.append(ch, start, length);
    }
}
===============================================================

src/java/org/apache/fop/util/:
===============================================================
--- DOMBuilderContentHandlerFactory.java.ORI	2010-10-16 15:48:35.000000000 +0200
+++ DOMBuilderContentHandlerFactory.java	2012-02-10 13:32:12.000000000 +0100
@@ -19,11 +19,6 @@
 
 package org.apache.fop.util;
 
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.xml.sax.Attributes;
@@ -34,10 +29,6 @@
  * ContentHandlerFactory which constructs ContentHandlers that build DOM Documents.
  */
 public class DOMBuilderContentHandlerFactory implements ContentHandlerFactory {
-
-    private static SAXTransformerFactory tFactory
-            = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
     private String namespaceURI;
     private DOMImplementation domImplementation;
 
@@ -103,23 +94,19 @@
         /**
          * {@inheritDoc}
          */
-        public void startElement(String uri, String localName, String qName, Attributes atts)
-                    throws SAXException {
+        public void startElement(String uri, String localName, String qName, 
+                                 Attributes atts) 
+            throws SAXException {
             if (doc == null) {
-                TransformerHandler handler;
-                try {
-                    handler = tFactory.newTransformerHandler();
-                } catch (TransformerConfigurationException e) {
-                    throw new SAXException("Error creating a new TransformerHandler", e);
-                }
-                doc = domImplementation.createDocument(namespaceURI, qName, null);
-                //It's easier to work with an empty document, so remove the root element
+                doc = domImplementation.createDocument(namespaceURI, qName, 
+                                                       null);
+                // It's easier to work with an empty document, so remove the
+                // root element
                 doc.removeChild(doc.getDocumentElement());
-                handler.setResult(new DOMResult(doc));
-                setDelegateContentHandler(handler);
-                setDelegateLexicalHandler(handler);
-                setDelegateDTDHandler(handler);
-                handler.startDocument();
+                
+                ContentHandler delegate = new SAXToDOM(doc);
+                setDelegateContentHandler(delegate);
+                delegate.startDocument();
             }
             super.startElement(uri, localName, qName, atts);
         }
@@ -133,7 +120,5 @@
                 obListener.notifyObjectBuilt(getObject());
             }
         }
-
     }
-
 }
===============================================================

src/java/org/apache/fop/fo/extensions/svg/:
===============================================================
--- SVGDOMContentHandlerFactory.java.ORI	2012-02-10 14:47:02.000000000 +0100
+++ SVGDOMContentHandlerFactory.java	2012-02-10 14:51:18.000000000 +0100
@@ -19,11 +19,6 @@
 
 package org.apache.fop.fo.extensions.svg;
 
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 
@@ -35,16 +30,13 @@
 
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.DelegatingContentHandler;
+import org.apache.fop.util.SAXToDOM;
 
 /**
  * ContentHandlerFactory which constructs ContentHandlers that build SVG DOM
  * Documents.
  */
 public class SVGDOMContentHandlerFactory implements ContentHandlerFactory {
-
-    private static SAXTransformerFactory tFactory
-        = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
-
     /**
      * Default Constructor.
      */
@@ -114,26 +106,21 @@
         }
 
         /** {@inheritDoc} */
-        public void startElement(String uri, String localName, String qName, Attributes atts)
+        public void startElement(String uri, String localName, String qName, 
+                                 Attributes atts)
                 throws SAXException {
             if (doc == null) {
-                TransformerHandler handler;
-                try {
-                    handler = tFactory.newTransformerHandler();
-                } catch (TransformerConfigurationException e) {
-                    throw new SAXException("Error creating a new TransformerHandler", e);
-                }
                 String version = atts.getValue("version");
-                DOMImplementation domImplementation = getDOMImplementation(version);
+                DOMImplementation domImplementation = 
+                    getDOMImplementation(version);
                 doc = domImplementation.createDocument(uri, qName, null);
                 // It's easier to work with an empty document, so remove the
                 // root element
                 doc.removeChild(doc.getDocumentElement());
-                handler.setResult(new DOMResult(doc));
-                setDelegateContentHandler(handler);
-                setDelegateLexicalHandler(handler);
-                setDelegateDTDHandler(handler);
-                handler.startDocument();
+
+                ContentHandler delegate = new SAXToDOM(doc);
+                setDelegateContentHandler(delegate);
+                delegate.startDocument();
             }
             super.startElement(uri, localName, qName, atts);
         }
===============================================================

