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 2007/12/14 11:12:42 UTC

svn commit: r604144 - in /xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml: resources/META-INF/services/ src/org/apache/fop/mathml/

Author: jeremias
Date: Fri Dec 14 02:12:41 2007
New Revision: 604144

URL: http://svn.apache.org/viewvc?rev=604144&view=rev
Log:
Switch to new image package. At some point we will probably want to remove this example as JEuclid has a better plug-in now.

Added:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImageLoaderFactory
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImagePreloader
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java   (with props)
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImageLoaderFactory
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImageLoaderFactory?rev=604144&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImageLoaderFactory (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImageLoaderFactory Fri Dec 14 02:12:41 2007
@@ -0,0 +1 @@
+org.apache.fop.mathml.ImageLoaderFactoryMathML

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImagePreloader
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImagePreloader?rev=604144&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImagePreloader (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/resources/META-INF/services/org.apache.fop.image2.spi.ImagePreloader Fri Dec 14 02:12:41 2007
@@ -0,0 +1 @@
+org.apache.fop.mathml.PreloaderMathML

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java?rev=604144&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java Fri Dec 14 02:12:41 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.mathml;
+
+import org.apache.fop.image2.ImageFlavor;
+import org.apache.fop.image2.spi.ImageLoader;
+import org.apache.fop.image2.spi.ImageLoaderFactory;
+
+/**
+ * Factory class for the ImageLoader for MathML.
+ */
+public class ImageLoaderFactoryMathML implements ImageLoaderFactory {
+
+    /** MathML MIME type */
+    public static final String MIME_MATHML = "text/mathml";
+    
+    private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
+        ImageFlavor.GRAPHICS2D};
+    
+    private static final String[] MIMES = new String[] {
+        MIME_MATHML};
+    
+    /** {@inheritDoc} */
+    public String[] getSupportedMIMETypes() {
+        return MIMES;
+    }
+    
+    /** {@inheritDoc} */
+    public ImageFlavor[] getSupportedFlavors(String mime) {
+        return FLAVORS;
+    }
+    
+    /** {@inheritDoc} */
+    public ImageLoader newImageLoader(ImageFlavor targetFlavor) {
+        return new ImageLoaderMathML(targetFlavor);
+    }
+    
+    /** {@inheritDoc} */
+    public int getUsagePenalty(String mime, ImageFlavor flavor) {
+        return 0;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isAvailable() {
+        //TODO Refine!
+        return true;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderFactoryMathML.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java?rev=604144&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java Fri Dec 14 02:12:41 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.mathml;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.fop.image2.Image;
+import org.apache.fop.image2.ImageException;
+import org.apache.fop.image2.ImageFlavor;
+import org.apache.fop.image2.ImageInfo;
+import org.apache.fop.image2.ImageSessionContext;
+import org.apache.fop.image2.impl.AbstractImageLoader;
+import org.apache.fop.image2.impl.ImageGraphics2D;
+
+/**
+ * ImageLoader for MathML (using JEuclid).
+ */
+public class ImageLoaderMathML extends AbstractImageLoader {
+
+    private ImageFlavor targetFlavor;
+
+    /**
+     * Main constructor.
+     * @param targetFlavor the target flavor
+     */
+    public ImageLoaderMathML(ImageFlavor targetFlavor) {
+        if (!(ImageFlavor.GRAPHICS2D.equals(targetFlavor))) {
+            throw new IllegalArgumentException("Unsupported target ImageFlavor: " + targetFlavor);
+        }
+        this.targetFlavor = targetFlavor;
+    }
+    
+    /** {@inheritDoc} */
+    public ImageFlavor getTargetFlavor() {
+        return this.targetFlavor;
+    }
+
+    /** {@inheritDoc} */
+    public Image loadImage(ImageInfo info, Map hints, ImageSessionContext session)
+                throws ImageException, IOException {
+        if (!ImageLoaderFactoryMathML.MIME_MATHML.equals(info.getMimeType())) {
+            throw new IllegalArgumentException("ImageInfo must be from an MathML image");
+        }
+        Image img = info.getOriginalImage();
+        if (!(img instanceof ImageGraphics2D)) {
+            throw new IllegalArgumentException(
+                    "ImageInfo was expected to contain the MathML document as Graphics2D image");
+        }
+        ImageGraphics2D g2dImage = (ImageGraphics2D)img;
+        return g2dImage;
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/ImageLoaderMathML.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java?rev=604144&r1=604143&r2=604144&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java Fri Dec 14 02:12:41 2007
@@ -23,9 +23,9 @@
 import java.awt.Dimension;
 import java.awt.geom.Point2D;
 
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.PropertyList;
+import net.sourceforge.jeuclid.DOMMathBuilder;
+import net.sourceforge.jeuclid.MathBase;
+
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -34,11 +34,12 @@
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 
-import org.apache.batik.svggen.SVGGraphics2D;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.svggen.SVGGraphics2D;
 
-import net.sourceforge.jeuclid.MathBase;
-import net.sourceforge.jeuclid.DOMMathBuilder;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.PropertyList;
 
 /**
  * Defines the top-level element for MathML.
@@ -57,9 +58,7 @@
         super(parent);
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#processNode
-     */
+    /** {@inheritDoc} */
     public void processNode(String elementName, 
                             Locator locator, 
                             Attributes attlist, 
@@ -141,15 +140,13 @@
 
     }
 
-    /** @see org.apache.fop.fo.XMLObj#getDOMDocument() */
+    /** {@inheritDoc} */
     public Document getDOMDocument() {
         convertToSVG();
         return doc;
     }
 
-    /**
-     * @see org.apache.fop.fo.FONode#getNamespaceURI()
-     */
+    /** {@inheritDoc} */
     public String getNamespaceURI() {
         if (svgDoc == null) {
             return MathMLElementMapping.NAMESPACE;
@@ -157,9 +154,7 @@
         return "http://www.w3.org/2000/svg";
     }
 
-    /**
-     * @see org.apache.fop.fo.XMLObj#getDimension(Point2D)
-     */
+    /** {@inheritDoc} */
     public Point2D getDimension(Point2D view) {
         convertToSVG();
         return new Point2D.Float(width, height);

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java?rev=604144&r1=604143&r2=604144&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java Fri Dec 14 02:12:41 2007
@@ -19,17 +19,12 @@
  
 package org.apache.fop.mathml;
 
-import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.ElementMapping;
-import org.apache.fop.image.analyser.XMLReader;
-import org.apache.fop.image.FopImage;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-
 import java.util.HashMap;
 
-import net.sourceforge.jeuclid.MathBase;
-import net.sourceforge.jeuclid.DOMMathBuilder;
+import org.w3c.dom.DOMImplementation;
+
+import org.apache.fop.fo.ElementMapping;
+import org.apache.fop.fo.FONode;
 
 /**
  * This class provides the element mapping for FOP.
@@ -44,19 +39,17 @@
         this.namespaceURI = NAMESPACE;
     }
 
-    /** @see org.apache.fop.fo.ElementMapping#getDOMImplementation() */
+    /** {@inheritDoc} */
     public DOMImplementation getDOMImplementation() {
         return getDefaultDOMImplementation();
     }
 
-    /** @see org.apache.fop.fo.ElementMapping#initialize() */
+    /** {@inheritDoc} */
     protected void initialize() {
         if (foObjs == null) {
             foObjs = new HashMap();
             foObjs.put("math", new ME());
             foObjs.put(DEFAULT, new MathMLMaker());
-
-            XMLReader.setConverter(this.namespaceURI, new MathMLConverter());
         }
     }
 
@@ -69,40 +62,6 @@
     static class ME extends ElementMapping.Maker {
         public FONode make(FONode parent) {
             return new MathMLElement(parent);
-        }
-    }
-
-    static class MathMLConverter implements XMLReader.Converter {
-        public FopImage.ImageInfo convert(Document doc) {
-            try {
-                FopImage.ImageInfo info = new FopImage.ImageInfo();
-                String fontname = "Helvetica";
-                int fontstyle = 0;
-                int inlinefontstyle = 0;
-                int inlinefontsize = 12;
-                int displayfontsize = 12;
-
-                MathBase base = new MathBase(
-                                  (new DOMMathBuilder(doc)).getMathRootElement(),
-                                  fontname, fontstyle, inlinefontsize,
-                                  displayfontsize);
-
-                base.setDebug(false);
-
-                info.data = MathMLElement.createSVG(base);
-
-                info.width = base.getWidth();
-                info.height = base.getHeight();
-
-                info.mimeType = "image/svg+xml";
-                info.str = "http://www.w3.org/2000/svg";
-
-                return info;
-            } catch (Throwable t) {
-                /**@todo log that properly */
-            }
-            return null;
-
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java?rev=604144&r1=604143&r2=604144&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java (original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java Fri Dec 14 02:12:41 2007
@@ -35,12 +35,12 @@
         super(parent);
     }
 
-    /** @see org.apache.fop.fo.FONode#getNamespaceURI() */
+    /** {@inheritDoc} */
     public String getNamespaceURI() {
         return MathMLElementMapping.NAMESPACE;
     }
 
-    /** @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */
+    /** {@inheritDoc} */
     public String getNormalNamespacePrefix() {
         return "mathml";
     }

Added: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java?rev=604144&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java (added)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java Fri Dec 14 02:12:41 2007
@@ -0,0 +1,179 @@
+/*
+ * 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.mathml;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import net.sourceforge.jeuclid.MathBase;
+import net.sourceforge.jeuclid.SAXMathBuilder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.image2.Image;
+import org.apache.fop.image2.ImageContext;
+import org.apache.fop.image2.ImageInfo;
+import org.apache.fop.image2.ImageSize;
+import org.apache.fop.image2.impl.AbstractImagePreloader;
+import org.apache.fop.image2.impl.ImageGraphics2D;
+import org.apache.fop.image2.util.ImageUtil;
+import org.apache.fop.render.Graphics2DImagePainter;
+import org.apache.fop.util.UnclosableInputStream;
+
+/**
+ * Image preloader for MathML images.
+ */
+public class PreloaderMathML extends AbstractImagePreloader {
+
+    /** Logger instance */
+    private static Log log = LogFactory.getLog(PreloaderMathML.class);
+
+    private boolean jeuclidAvailable = true;
+    
+    /** {@inheritDoc} */ 
+    public ImageInfo preloadImage(String uri, Source src, ImageContext context)
+            throws IOException {
+        if (!ImageUtil.hasInputStream(src)) {
+            //TODO Remove this and support DOMSource and possibly SAXSource
+            return null;
+        }
+        ImageInfo info = null;
+        if (jeuclidAvailable) {
+            try {
+                Loader loader = new Loader();
+                info = loader.getImage(uri, src, context);
+            } catch (NoClassDefFoundError e) {
+                jeuclidAvailable = false;
+                log.warn("JEuclid not in class path", e);
+                return null;
+            }
+        }
+        if (info != null) {
+            ImageUtil.closeQuietly(src); //Image is fully read
+        }
+        return info;
+    }
+
+    /**
+     * This method is put in another class so that the class loader does not
+     * attempt to load JEuclid related classes when constructing the MathMLPreloader
+     * class.
+     */
+    class Loader {
+        
+        private ImageInfo getImage(String uri, Source src, ImageContext context) {
+
+            InputStream in = new UnclosableInputStream(ImageUtil.needInputStream(src));
+            try {
+                int length = in.available();
+                in.mark(length + 1);
+                
+                TransformerFactory tFactory = TransformerFactory.newInstance();
+                Transformer transformer = tFactory.newTransformer();
+                Source source = new StreamSource(in);
+                SAXMathBuilder mathBuilder = new SAXMathBuilder();
+                SAXResult res = new SAXResult(mathBuilder);
+                transformer.transform(source, res);
+                
+                String fontname = "Helvetica";
+                int fontstyle = 0;
+                int displayfontsize = 12;
+                int inlinefontsize = 12;
+
+                final MathBase base = new MathBase(
+                                  mathBuilder.getMathRootElement(),
+                                  fontname, fontstyle, inlinefontsize,
+                                  displayfontsize);
+                
+                ImageInfo info = new ImageInfo(uri, "text/mathml");
+                final ImageSize size = new ImageSize();
+                size.setSizeInMillipoints(
+                        Math.round(base.getWidth() * 1000),
+                        Math.round(base.getHeight() * 1000));
+                //Set the resolution to that of the FOUserAgent
+                size.setResolution(context.getSourceResolution());
+                size.calcPixelsFromSize();
+                info.setSize(size);
+
+                Graphics2DImagePainter painter = new Graphics2DImagePainter() {
+
+                    public Dimension getImageSize() {
+                        return size.getDimensionMpt();
+                    }
+
+                    public void paint(Graphics2D g2d, Rectangle2D area) {
+                        base.paint(g2d);
+                    }
+                    
+                };
+                
+                //The whole image had to be loaded for this, so keep it
+                Image image = new ImageGraphics2D(info, painter);
+                info.getCustomObjects().put(ImageInfo.ORIGINAL_IMAGE, image);
+                
+                return info;
+            } catch (NoClassDefFoundError ncdfe) {
+                try {
+                    in.reset();
+                } catch (IOException ioe) {
+                    // we're more interested in the original exception
+                }
+                jeuclidAvailable = false;
+                log.warn("JEuclid not in class path", ncdfe);
+                return null;
+            } catch (IOException e) {
+                // If the MathML is invalid then it throws an IOException
+                // so there is no way of knowing if it is an svg document
+
+                log.debug("Error while trying to load stream as an MathML file: "
+                                       + e.getMessage());
+                // assuming any exception means this document is not svg
+                // or could not be loaded for some reason
+                try {
+                    in.reset();
+                } catch (IOException ioe) {
+                    // we're more interested in the original exception
+                }
+                return null;
+            } catch (TransformerException e) {
+                try {
+                    in.reset();
+                } catch (IOException ioe) {
+                    // we're more interested in the original exception
+                }
+                log.debug("Error while trying to parsing a MathML file: "
+                        + e.getMessage());
+                return null;
+            }
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/examples/mathml/src/org/apache/fop/mathml/PreloaderMathML.java
------------------------------------------------------------------------------
    svn:keywords = Id



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