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 2008/08/12 14:53:52 UTC

svn commit: r685137 - in /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src: java/org/apache/fop/area/ java/org/apache/fop/fo/ java/org/apache/fop/render/intermediate/ java/org/apache/fop/svg/ java/org/apache/fop/util/ sandbox/org/apache/fop/render/svg/

Author: jeremias
Date: Tue Aug 12 05:53:50 2008
New Revision: 685137

URL: http://svn.apache.org/viewvc?rev=685137&view=rev
Log:
Extracted some often-used XML constants and utility methods into an interface and a class in org.apache.fop.util.

Added:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java   (with props)
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java   (with props)
Modified:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/area/AreaTreeParser.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/fo/XMLObj.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/SVGUtilities.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/DOM2SAX.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/SVGConstants.java

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/area/AreaTreeParser.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/area/AreaTreeParser.java Tue Aug 12 05:53:50 2008
@@ -36,8 +36,22 @@
 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;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.util.QName;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Trait.Background;
 import org.apache.fop.area.Trait.InternalLink;
@@ -65,16 +79,7 @@
 import org.apache.fop.util.ContentHandlerFactoryRegistry;
 import org.apache.fop.util.ConversionUtils;
 import org.apache.fop.util.DefaultErrorListener;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.util.QName;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
+import org.apache.fop.util.XMLUtil;
 
 /**
  * This is a parser for the area tree XML (intermediate format) which is used to reread an area
@@ -381,12 +386,12 @@
                 if (currentPageViewport != null) {
                     throw new IllegalStateException("currentPageViewport must be null");
                 }
-                Rectangle2D viewArea = getAttributeAsRectangle2D(attributes, "bounds");
-                int pageNumber = getAttributeAsInteger(attributes, "nr", -1);
+                Rectangle2D viewArea = XMLUtil.getAttributeAsRectangle2D(attributes, "bounds");
+                int pageNumber = XMLUtil.getAttributeAsInt(attributes, "nr", -1);
                 String key = attributes.getValue("key");
                 String pageNumberString = attributes.getValue("formatted-nr");
                 String pageMaster = attributes.getValue("simple-page-master-name");
-                boolean blank = getAttributeAsBoolean(attributes, "blank", false);
+                boolean blank = XMLUtil.getAttributeAsBoolean(attributes, "blank", false);
                 currentPageViewport = new PageViewport(viewArea,
                         pageNumber, pageNumberString,
                         pageMaster, blank);
@@ -417,10 +422,10 @@
                 if (rv != null) {
                     throw new IllegalStateException("Current RegionViewport must be null");
                 }
-                Rectangle2D viewArea = getAttributeAsRectangle2D(attributes, "rect");
+                Rectangle2D viewArea = XMLUtil.getAttributeAsRectangle2D(attributes, "rect");
                 rv = new RegionViewport(viewArea);
                 transferForeignObjects(attributes, rv);
-                rv.setClip(getAttributeAsBoolean(attributes, "clipped", false));
+                rv.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clipped", false));
                 setAreaAttributes(attributes, rv);
                 setTraits(attributes, rv, SUBSET_COMMON);
                 setTraits(attributes, rv, SUBSET_BOX);
@@ -485,8 +490,8 @@
                     throw new IllegalStateException("Current BodyRegion must be null");
                 }
                 String regionName = attributes.getValue("name");
-                int columnCount = getAttributeAsInteger(attributes, "columnCount", 1);
-                int columnGap = getAttributeAsInteger(attributes, "columnGap", 0);
+                int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
+                int columnGap = XMLUtil.getAttributeAsInt(attributes, "columnGap", 0);
                 RegionViewport rv = getCurrentRegionViewport();
                 body = new BodyRegion(Constants.FO_REGION_BODY,
                         regionName, rv, columnCount, columnGap);
@@ -537,8 +542,8 @@
         private class SpanMaker extends AbstractMaker {
 
             public void startElement(Attributes attributes) {
-                int ipd = getAttributeAsInteger(attributes, "ipd", 0);
-                int columnCount = getAttributeAsInteger(attributes, "columnCount", 1);
+                int ipd = XMLUtil.getAttributeAsInt(attributes, "ipd", 0);
+                int columnCount = XMLUtil.getAttributeAsInt(attributes, "columnCount", 1);
                 BodyRegion body = getCurrentBodyRegion();
                 Span span = new Span(columnCount,
                         body.getColumnGap(), ipd);
@@ -554,7 +559,7 @@
             public void startElement(Attributes attributes) {
                 Footnote fn = getCurrentBodyRegion().getFootnote();
                 transferForeignObjects(attributes, fn);
-                fn.setTop(getAttributeAsInteger(attributes, "top-offset", 0));
+                fn.setTop(XMLUtil.getAttributeAsInt(attributes, "top-offset", 0));
                 areaStack.push(fn);
             }
 
@@ -579,18 +584,18 @@
         private class BlockMaker extends AbstractMaker {
 
             public void startElement(Attributes attributes) {
-                boolean isViewport = getAttributeAsBoolean(attributes,
+                boolean isViewport = XMLUtil.getAttributeAsBoolean(attributes,
                         "is-viewport-area", false);
                 Block block;
                 if (isViewport) {
                     BlockViewport bv = new BlockViewport();
-                    bv.setClip(getAttributeAsBoolean(attributes, "clipped", false));
+                    bv.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clipped", false));
                     bv.setCTM(getAttributeAsCTM(attributes, "ctm"));
                     if (bv.getPositioning() != BlockViewport.RELATIVE) {
                         bv.setXOffset(
-                                getAttributeAsInteger(attributes, "left-position", 0));
+                                XMLUtil.getAttributeAsInt(attributes, "left-position", 0));
                         bv.setYOffset(
-                                getAttributeAsInteger(attributes, "top-position", 0));
+                                XMLUtil.getAttributeAsInt(attributes, "top-position", 0));
                     }
                     block = bv;
                 } else {
@@ -607,10 +612,10 @@
                     block.setPositioning(Block.STACK);
                 }
                 if (attributes.getValue("left-offset") != null) {
-                    block.setXOffset(getAttributeAsInteger(attributes, "left-offset", 0));
+                    block.setXOffset(XMLUtil.getAttributeAsInt(attributes, "left-offset", 0));
                 }
                 if (attributes.getValue("top-offset") != null) {
-                    block.setYOffset(getAttributeAsInteger(attributes, "top-offset", 0));
+                    block.setYOffset(XMLUtil.getAttributeAsInt(attributes, "top-offset", 0));
                 }
                 transferForeignObjects(attributes, block);
                 setAreaAttributes(attributes, block);
@@ -652,7 +657,7 @@
             public void startElement(Attributes attributes) {
                 InlineArea inl = new InlineArea();
                 transferForeignObjects(attributes, inl);
-                inl.setOffset(getAttributeAsInteger(attributes, "offset", 0));
+                inl.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
                 setAreaAttributes(attributes, inl);
                 setTraits(attributes, inl, SUBSET_COMMON);
                 setTraits(attributes, inl, SUBSET_BOX);
@@ -672,7 +677,7 @@
             public void startElement(Attributes attributes) {
                 InlineParent ip = new InlineParent();
                 transferForeignObjects(attributes, ip);
-                ip.setOffset(getAttributeAsInteger(attributes, "offset", 0));
+                ip.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
                 setAreaAttributes(attributes, ip);
                 setTraits(attributes, ip, SUBSET_COMMON);
                 setTraits(attributes, ip, SUBSET_BOX);
@@ -693,7 +698,7 @@
             public void startElement(Attributes attributes) {
                 InlineBlockParent ibp = new InlineBlockParent();
                 transferForeignObjects(attributes, ibp);
-                ibp.setOffset(getAttributeAsInteger(attributes, "offset", 0));
+                ibp.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
                 setAreaAttributes(attributes, ibp);
                 setTraits(attributes, ibp, SUBSET_COMMON);
                 setTraits(attributes, ibp, SUBSET_BOX);
@@ -720,11 +725,11 @@
                 setTraits(attributes, text, SUBSET_BOX);
                 setTraits(attributes, text, SUBSET_COLOR);
                 setTraits(attributes, text, SUBSET_FONT);
-                text.setBaselineOffset(getAttributeAsInteger(attributes, "baseline", 0));
-                text.setOffset(getAttributeAsInteger(attributes, "offset", 0));
-                text.setTextLetterSpaceAdjust(getAttributeAsInteger(attributes,
+                text.setBaselineOffset(XMLUtil.getAttributeAsInt(attributes, "baseline", 0));
+                text.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
+                text.setTextLetterSpaceAdjust(XMLUtil.getAttributeAsInt(attributes,
                         "tlsadjust", 0));
-                text.setTextWordSpaceAdjust(getAttributeAsInteger(attributes,
+                text.setTextWordSpaceAdjust(XMLUtil.getAttributeAsInt(attributes,
                         "twsadjust", 0));
                 Area parent = (Area)areaStack.peek();
                 parent.addChildArea(text);
@@ -739,7 +744,7 @@
         private class WordMaker extends AbstractMaker {
 
             public void endElement() {
-                int offset = getAttributeAsInteger(lastAttributes, "offset", 0);
+                int offset = XMLUtil.getAttributeAsInt(lastAttributes, "offset", 0);
                 int[] letterAdjust
                         = ConversionUtils.toIntArray(
                             lastAttributes.getValue("letter-adjust"), "\\s");
@@ -758,11 +763,11 @@
         private class SpaceMaker extends AbstractMaker {
 
             public void endElement() {
-                int offset = getAttributeAsInteger(lastAttributes, "offset", 0);
+                int offset = XMLUtil.getAttributeAsInt(lastAttributes, "offset", 0);
                 //TODO the isAdjustable parameter is currently not used/implemented
                 if (content.position() > 0) {
                     content.flip();
-                    boolean adjustable = getAttributeAsBoolean(lastAttributes, "adj", true);
+                    boolean adjustable = XMLUtil.getAttributeAsBoolean(lastAttributes, "adj", true);
                     SpaceArea space = new SpaceArea(content.charAt(0), offset, adjustable);
                     AbstractTextArea text = getCurrentText();
                     space.setParentArea(text);
@@ -794,13 +799,13 @@
                 setTraits(attributes, leader, SUBSET_BOX);
                 setTraits(attributes, leader, SUBSET_COLOR);
                 setTraits(attributes, leader, SUBSET_FONT);
-                leader.setOffset(getAttributeAsInteger(attributes, "offset", 0));
+                leader.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
                 String ruleStyle = attributes.getValue("ruleStyle");
                 if (ruleStyle != null) {
                     leader.setRuleStyle(ruleStyle);
                 }
                 leader.setRuleThickness(
-                        getAttributeAsInteger(attributes, "ruleThickness", 0));
+                        XMLUtil.getAttributeAsInt(attributes, "ruleThickness", 0));
                 Area parent = (Area)areaStack.peek();
                 parent.addChildArea(leader);
             }
@@ -815,9 +820,9 @@
                 setTraits(attributes, viewport, SUBSET_COMMON);
                 setTraits(attributes, viewport, SUBSET_BOX);
                 setTraits(attributes, viewport, SUBSET_COLOR);
-                viewport.setContentPosition(getAttributeAsRectangle2D(attributes, "pos"));
-                viewport.setClip(getAttributeAsBoolean(attributes, "clip", false));
-                viewport.setOffset(getAttributeAsInteger(attributes, "offset", 0));
+                viewport.setContentPosition(XMLUtil.getAttributeAsRectangle2D(attributes, "pos"));
+                viewport.setClip(XMLUtil.getAttributeAsBoolean(attributes, "clip", false));
+                viewport.setOffset(XMLUtil.getAttributeAsInt(attributes, "offset", 0));
                 Area parent = (Area)areaStack.peek();
                 parent.addChildArea(viewport);
                 areaStack.push(viewport);
@@ -884,7 +889,8 @@
 
             public void startElement(Attributes attributes) {
                 String title = attributes.getValue("title");
-                boolean showChildren = getAttributeAsBoolean(attributes, "show-children", false);
+                boolean showChildren = XMLUtil.getAttributeAsBoolean(
+                        attributes, "show-children", false);
                 String[] linkdata
                         = InternalLink.parseXMLAttribute(attributes.getValue("internal-link"));
                 PageViewport pv = (PageViewport) pageViewportsByKey.get(linkdata[0]);
@@ -1044,9 +1050,9 @@
                             if (repeat != null) {
                                 bkg.setRepeat(repeat);
                             }
-                            bkg.setHoriz(getAttributeAsInteger(attributes,
+                            bkg.setHoriz(XMLUtil.getAttributeAsInt(attributes,
                                     "bkg-horz-offset", 0));
-                            bkg.setVertical(getAttributeAsInteger(attributes,
+                            bkg.setVertical(XMLUtil.getAttributeAsInt(attributes,
                                     "bkg-vert-offset", 0));
                         }
                         area.addTrait(trait, bkg);
@@ -1058,7 +1064,7 @@
                         String fontName = attributes.getValue("font-name");
                         if (fontName != null) {
                             String fontStyle = attributes.getValue("font-style");
-                            int fontWeight = getAttributeAsInteger(
+                            int fontWeight = XMLUtil.getAttributeAsInt(
                                     attributes, "font-weight", Font.WEIGHT_NORMAL);
                             area.addTrait(trait,
                                     FontInfo.createFontKey(fontName, fontStyle, fontWeight));
@@ -1068,26 +1074,6 @@
             }
         }
 
-        private static boolean getAttributeAsBoolean(Attributes attributes, String name,
-                boolean defaultValue) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return defaultValue;
-            } else {
-                return Boolean.valueOf(s).booleanValue();
-            }
-        }
-
-        private static int getAttributeAsInteger(Attributes attributes, String name,
-                int defaultValue) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return defaultValue;
-            } else {
-                return Integer.parseInt(s);
-            }
-        }
-
         private static CTM getAttributeAsCTM(Attributes attributes, String name) {
             String s = attributes.getValue(name).trim();
             if (s.startsWith("[") && s.endsWith("]")) {
@@ -1102,15 +1088,6 @@
             }
         }
 
-        private static Rectangle2D getAttributeAsRectangle2D(Attributes attributes, String name) {
-            String s = attributes.getValue(name).trim();
-            double[] values = ConversionUtils.toDoubleArray(s, "\\s");
-            if (values.length != 4) {
-                throw new IllegalArgumentException("Rectangle must consist of 4 double values!");
-            }
-            return new Rectangle2D.Double(values[0], values[1], values[2], values[3]);
-        }
-
         private static void transferForeignObjects(Attributes atts, AreaTreeObject ato) {
             for (int i = 0, c = atts.getLength(); i < c; i++) {
                 String ns = atts.getURI(i);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/fo/XMLObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/fo/XMLObj.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/fo/XMLObj.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/fo/XMLObj.java Tue Aug 12 05:53:50 2008
@@ -33,6 +33,7 @@
 
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.util.XMLConstants;
 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
 
 /**
@@ -41,8 +42,6 @@
  */
 public abstract class XMLObj extends FONode implements ObjectBuiltListener {
 
-    private static final String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
-
     // temp reference for attributes
     private Attributes attr = null;
 
@@ -116,7 +115,7 @@
 
     private static HashMap ns = new HashMap();
     static {
-        ns.put("xlink", "http://www.w3.org/1999/xlink");
+        ns.put(XMLConstants.XLINK_PREFIX, XMLConstants.XLINK_NAMESPACE);
     }
 
     /**
@@ -143,7 +142,7 @@
             } else {
                 String pref = qname.substring(0, idx);
                 String tail = qname.substring(idx + 1);
-                if (pref.equals("xmlns")) {
+                if (pref.equals(XMLConstants.XMLNS_PREFIX)) {
                     ns.put(tail, rf);
                 } else {
                     element.setAttributeNS((String)ns.get(pref), tail, rf);
@@ -181,8 +180,9 @@
 
             element = doc.getDocumentElement();
             buildTopLevel(doc, element);
-            if (!element.hasAttributeNS(XMLNS_NAMESPACE_URI, "xmlns")) {
-                element.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns",
+            if (!element.hasAttributeNS(
+                    XMLConstants.XMLNS_NAMESPACE_URI, XMLConstants.XMLNS_PREFIX)) {
+                element.setAttributeNS(XMLConstants.XMLNS_NAMESPACE_URI, XMLConstants.XMLNS_PREFIX,
                                 getNamespaceURI());
             }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java Tue Aug 12 05:53:50 2008
@@ -39,6 +39,7 @@
 
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.util.DecimalFormatCache;
+import org.apache.fop.util.XMLUtil;
 
 /**
  * Abstract base class for XML-writing IFPainter implementations.
@@ -47,9 +48,6 @@
 
     private static final Attributes EMPTY_ATTS = new AttributesImpl();
 
-    /** Constant for the "CDATA" attribute type. */
-    protected static final String CDATA = "CDATA";
-
     /**
      * Default SAXTransformerFactory that can be used by subclasses.
      */
@@ -228,7 +226,18 @@
      */
     protected void addAttribute(AttributesImpl atts, QName attribute, String value) {
         atts.addAttribute(attribute.getNamespaceURI(),
-                attribute.getLocalName(), attribute.getQName(), CDATA, value);
+                attribute.getLocalName(), attribute.getQName(), XMLUtil.CDATA, value);
+    }
+
+    /**
+     * Adds an attribute to a given {@code AttributesImpl} instance. The attribute will be
+     * added in the default namespace.
+     * @param atts the attributes collection
+     * @param localName the local name of the attribute
+     * @param value the attribute's CDATA value
+     */
+    protected void addAttribute(AttributesImpl atts, String localName, String value) {
+        atts.addAttribute("", localName, localName, XMLUtil.CDATA, value);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFConstants.java Tue Aug 12 05:53:50 2008
@@ -19,14 +19,13 @@
 
 package org.apache.fop.render.intermediate;
 
-import org.apache.xmlgraphics.util.QName;
-
 import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.util.XMLConstants;
 
 /**
  * Constants for the intermediate format.
  */
-public interface IFConstants {
+public interface IFConstants extends XMLConstants {
 
     /** MIME type of the intermediate format. */
     String MIME_TYPE = MimeConstants.MIME_FOP_IF;
@@ -34,16 +33,6 @@
     /** XML namespace of the intermediate format. */
     String NAMESPACE = "http://xmlgraphics.apache.org/fop/intermediate";
 
-    /** XML namespace. */
-    String XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
-
-    /** Namespace prefix for XLink */
-    String XLINK_PREFIX = "xlink";
-    /** XML namespace for XLink */
-    String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
-    /** xlink:href attribute */
-    QName XLINK_HREF = new QName(XLINK_NAMESPACE, XLINK_PREFIX, "href");
-
     String EL_DOCUMENT = "document";
     String EL_HEADER = "header";
     String EL_PAGE_SEQUENCE = "page-sequence";

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFParser.java Tue Aug 12 05:53:50 2008
@@ -23,7 +23,6 @@
 import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
 import java.util.Map;
 
 import javax.xml.transform.Source;
@@ -47,14 +46,15 @@
 import org.apache.xmlgraphics.util.QName;
 
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.ElementMappingRegistry;
 import org.apache.fop.fo.expr.PropertyException;
 import org.apache.fop.util.ColorUtil;
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactoryRegistry;
-import org.apache.fop.util.ConversionUtils;
 import org.apache.fop.util.DOMBuilderContentHandlerFactory;
 import org.apache.fop.util.DefaultErrorListener;
+import org.apache.fop.util.XMLUtil;
 
 /**
  * This is a parser for the intermediate format XML which converts the intermediate file into
@@ -173,8 +173,11 @@
                         DOMImplementation domImplementation
                             = elementMappingRegistry.getDOMImplementationForNamespace(uri);
                         if (domImplementation == null) {
+                            domImplementation = ElementMapping.getDefaultDOMImplementation();
+                            /*
                             throw new SAXException("No DOMImplementation could be"
                                     + " identified to handle namespace: " + uri);
+                                    */
                         }
                         factory = new DOMBuilderContentHandlerFactory(uri, domImplementation);
                     }
@@ -363,7 +366,7 @@
                     = AffineTransformArrayParser.createAffineTransform(transform);
                 int width = Integer.parseInt(attributes.getValue("width"));
                 int height = Integer.parseInt(attributes.getValue("height"));
-                Rectangle clipRect = getAttributeAsRectangle(attributes, "clip-rect");
+                Rectangle clipRect = XMLUtil.getAttributeAsRectangle(attributes, "clip-rect");
                 painter.startViewport(transforms, new Dimension(width, height), clipRect);
             }
 
@@ -393,9 +396,9 @@
             public void startElement(Attributes attributes) throws IFException {
                 String family = attributes.getValue("family");
                 String style = attributes.getValue("style");
-                Integer weight = getAttributeAsInteger(attributes, "weight");
+                Integer weight = XMLUtil.getAttributeAsInteger(attributes, "weight");
                 String variant = attributes.getValue("variant");
-                Integer size = getAttributeAsInteger(attributes, "size");
+                Integer size = XMLUtil.getAttributeAsInteger(attributes, "size");
                 Color color;
                 try {
                     color = getAttributeAsColor(attributes, "color");
@@ -412,8 +415,8 @@
             public void endElement() throws IFException {
                 int x = Integer.parseInt(lastAttributes.getValue("x"));
                 int y = Integer.parseInt(lastAttributes.getValue("y"));
-                int[] dx = getAttributeAsIntArray(lastAttributes, "dx");
-                int[] dy = getAttributeAsIntArray(lastAttributes, "dy");
+                int[] dx = XMLUtil.getAttributeAsIntArray(lastAttributes, "dx");
+                int[] dy = XMLUtil.getAttributeAsIntArray(lastAttributes, "dy");
                 painter.drawText(x, y, dx, dy, content.toString());
             }
 
@@ -504,37 +507,8 @@
             }
         }
 
-        private static boolean getAttributeAsBoolean(Attributes attributes, String name,
-                boolean defaultValue) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return defaultValue;
-            } else {
-                return Boolean.valueOf(s).booleanValue();
-            }
-        }
-
-        private static int getAttributeAsInteger(Attributes attributes, String name,
-                int defaultValue) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return defaultValue;
-            } else {
-                return Integer.parseInt(s);
-            }
-        }
-
-        private static Integer getAttributeAsInteger(Attributes attributes, String name) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return null;
-            } else {
-                return new Integer(s);
-            }
-        }
-
         private Color getAttributeAsColor(Attributes attributes, String name)
-                throws PropertyException {
+                    throws PropertyException {
             String s = attributes.getValue(name);
             if (s == null) {
                 return null;
@@ -543,36 +517,6 @@
             }
         }
 
-        private static Rectangle2D getAttributeAsRectangle2D(Attributes attributes, String name) {
-            String s = attributes.getValue(name).trim();
-            double[] values = ConversionUtils.toDoubleArray(s, "\\s");
-            if (values.length != 4) {
-                throw new IllegalArgumentException("Rectangle must consist of 4 double values!");
-            }
-            return new Rectangle2D.Double(values[0], values[1], values[2], values[3]);
-        }
-
-        private static Rectangle getAttributeAsRectangle(Attributes attributes, String name) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return null;
-            }
-            int[] values = ConversionUtils.toIntArray(s.trim(), "\\s");
-            if (values.length != 4) {
-                throw new IllegalArgumentException("Rectangle must consist of 4 int values!");
-            }
-            return new Rectangle(values[0], values[1], values[2], values[3]);
-        }
-
-        private static int[] getAttributeAsIntArray(Attributes attributes, String name) {
-            String s = attributes.getValue(name);
-            if (s == null) {
-                return null;
-            } else {
-                return ConversionUtils.toIntArray(s.trim(), "\\s");
-            }
-        }
-
         private static Map getForeignAttributes(Attributes atts) {
             Map foreignAttributes = null;
             for (int i = 0, c = atts.getLength(); i < c; i++) {

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFSerializer.java Tue Aug 12 05:53:50 2008
@@ -38,6 +38,7 @@
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.util.ColorUtil;
 import org.apache.fop.util.DOM2SAX;
+import org.apache.fop.util.XMLUtil;
 
 /**
  * IFPainter implementation that serializes the intermediate format to XML.
@@ -112,7 +113,7 @@
         try {
             AttributesImpl atts = new AttributesImpl();
             if (id != null) {
-                atts.addAttribute(XML_NAMESPACE, "id", "xml:id", CDATA, id);
+                atts.addAttribute(XML_NAMESPACE, "id", "xml:id", XMLUtil.CDATA, id);
             }
             startElement(EL_PAGE_SEQUENCE, atts);
         } catch (SAXException e) {
@@ -133,10 +134,10 @@
     public void startPage(int index, String name, Dimension size) throws IFException {
         try {
             AttributesImpl atts = new AttributesImpl();
-            atts.addAttribute("", "index", "index", CDATA, Integer.toString(index));
-            atts.addAttribute("", "name", "name", CDATA, name);
-            atts.addAttribute("", "width", "width", CDATA, Integer.toString(size.width));
-            atts.addAttribute("", "height", "height", CDATA, Integer.toString(size.height));
+            addAttribute(atts, "index", Integer.toString(index));
+            addAttribute(atts, "name", name);
+            addAttribute(atts, "width", Integer.toString(size.width));
+            addAttribute(atts, "height", Integer.toString(size.height));
             startElement(EL_PAGE, atts);
         } catch (SAXException e) {
             throw new IFException("SAX error in startPage()", e);
@@ -223,12 +224,12 @@
         try {
             AttributesImpl atts = new AttributesImpl();
             if (transform != null && transform.length() > 0) {
-                atts.addAttribute("", "transform", "transform", CDATA, transform);
+                addAttribute(atts,"transform", transform);
             }
-            atts.addAttribute("", "width", "width", CDATA, Integer.toString(size.width));
-            atts.addAttribute("", "height", "height", CDATA, Integer.toString(size.height));
+            addAttribute(atts, "width", Integer.toString(size.width));
+            addAttribute(atts, "height", Integer.toString(size.height));
             if (clipRect != null) {
-                atts.addAttribute("", "clip-rect", "clip-rect", CDATA, toString(clipRect));
+                addAttribute(atts, "clip-rect", toString(clipRect));
             }
             startElement(EL_VIEWPORT, atts);
         } catch (SAXException e) {
@@ -259,7 +260,7 @@
         try {
             AttributesImpl atts = new AttributesImpl();
             if (transform != null && transform.length() > 0) {
-                atts.addAttribute("", "transform", "transform", CDATA, transform);
+                addAttribute(atts, "transform", transform);
             }
             startElement(EL_GROUP, atts);
         } catch (SAXException e) {
@@ -281,10 +282,10 @@
         try {
             AttributesImpl atts = new AttributesImpl();
             addAttribute(atts, XLINK_HREF, uri);
-            atts.addAttribute("", "x", "x", CDATA, Integer.toString(rect.x));
-            atts.addAttribute("", "y", "y", CDATA, Integer.toString(rect.y));
-            atts.addAttribute("", "width", "width", CDATA, Integer.toString(rect.width));
-            atts.addAttribute("", "height", "height", CDATA, Integer.toString(rect.height));
+            addAttribute(atts, "x", Integer.toString(rect.x));
+            addAttribute(atts, "y", Integer.toString(rect.y));
+            addAttribute(atts, "width", Integer.toString(rect.width));
+            addAttribute(atts, "height", Integer.toString(rect.height));
             if (foreignAttributes != null) {
                 Iterator iter = foreignAttributes.entrySet().iterator();
                 while (iter.hasNext()) {
@@ -302,10 +303,10 @@
     public void drawImage(Document doc, Rectangle rect, Map foreignAttributes) throws IFException {
         try {
             AttributesImpl atts = new AttributesImpl();
-            atts.addAttribute("", "x", "x", CDATA, Integer.toString(rect.x));
-            atts.addAttribute("", "y", "y", CDATA, Integer.toString(rect.y));
-            atts.addAttribute("", "width", "width", CDATA, Integer.toString(rect.width));
-            atts.addAttribute("", "height", "height", CDATA, Integer.toString(rect.height));
+            addAttribute(atts, "x", Integer.toString(rect.x));
+            addAttribute(atts, "y", Integer.toString(rect.y));
+            addAttribute(atts, "width", Integer.toString(rect.width));
+            addAttribute(atts, "height", Integer.toString(rect.height));
             if (foreignAttributes != null) {
                 Iterator iter = foreignAttributes.entrySet().iterator();
                 while (iter.hasNext()) {
@@ -342,15 +343,15 @@
         }
         try {
             AttributesImpl atts = new AttributesImpl();
-            atts.addAttribute("", "x", "x", CDATA, Integer.toString(rect.x));
-            atts.addAttribute("", "y", "y", CDATA, Integer.toString(rect.y));
-            atts.addAttribute("", "width", "width", CDATA, Integer.toString(rect.width));
-            atts.addAttribute("", "height", "height", CDATA, Integer.toString(rect.height));
+            addAttribute(atts, "x", Integer.toString(rect.x));
+            addAttribute(atts, "y", Integer.toString(rect.y));
+            addAttribute(atts, "width", Integer.toString(rect.width));
+            addAttribute(atts, "height", Integer.toString(rect.height));
             if (fill != null) {
-                atts.addAttribute("", "fill", "fill", CDATA, toString(fill));
+                addAttribute(atts, "fill", toString(fill));
             }
             if (stroke != null) {
-                atts.addAttribute("", "stroke", "sroke", CDATA, toString(stroke));
+                addAttribute(atts, "sroke", toString(stroke));
             }
             element("rect", atts);
         } catch (SAXException e) {
@@ -362,13 +363,13 @@
     public void drawText(int x, int y, int[] dx, int[] dy, String text) throws IFException {
         try {
             AttributesImpl atts = new AttributesImpl();
-            atts.addAttribute("", "x", "x", CDATA, Integer.toString(x));
-            atts.addAttribute("", "y", "y", CDATA, Integer.toString(y));
+            addAttribute(atts, "x", Integer.toString(x));
+            addAttribute(atts, "y", Integer.toString(y));
             if (dx != null) {
-                atts.addAttribute("", "dx", "dx", CDATA, toString(dx));
+                addAttribute(atts, "dx", toString(dx));
             }
             if (dy != null) {
-                atts.addAttribute("", "dy", "dy", CDATA, toString(dy));
+                addAttribute(atts, "dy", toString(dy));
             }
             startElement("text", atts);
             char[] chars = text.toCharArray();
@@ -385,22 +386,22 @@
         try {
             AttributesImpl atts = new AttributesImpl();
             if (family != null) {
-                atts.addAttribute("", "family", "family", CDATA, family);
+                addAttribute(atts, "family", family);
             }
             if (style != null) {
-                atts.addAttribute("", "style", "style", CDATA, style);
+                addAttribute(atts, "style", style);
             }
             if (weight != null) {
-                atts.addAttribute("", "weight", "weight", CDATA, weight.toString());
+                addAttribute(atts, "weight", weight.toString());
             }
             if (variant != null) {
-                atts.addAttribute("", "variant", "variant", CDATA, variant);
+                addAttribute(atts, "variant", variant);
             }
             if (size != null) {
-                atts.addAttribute("", "size", "size", CDATA, size.toString());
+                addAttribute(atts, "size", size.toString());
             }
             if (color != null) {
-                atts.addAttribute("", "color", "color", CDATA, toString(color));
+                addAttribute(atts, "color", toString(color));
             }
             element("font", atts);
         } catch (SAXException e) {
@@ -418,7 +419,8 @@
             }
         } else {
             throw new UnsupportedOperationException(
-                    "Don't know how to handle extension object: " + extension);
+                    "Don't know how to handle extension object: "
+                    + extension + " (" + extension.getClass().getName() + ")");
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/SVGUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/SVGUtilities.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/SVGUtilities.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/svg/SVGUtilities.java Tue Aug 12 05:53:50 2008
@@ -19,16 +19,17 @@
 
 package org.apache.fop.svg;
 
-import java.util.StringTokenizer;
+import java.awt.font.FontRenderContext;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
-import java.awt.font.FontRenderContext;
+import java.util.StringTokenizer;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
 import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.util.XMLConstants;
 
 /**
  * Some utilities for creating svg DOM documents and elements.
@@ -218,7 +219,7 @@
     public static final Element createImage(Document doc, String ref,
                                             float width, float height) {
         Element border = doc.createElementNS(SVG_NS, "image");
-        border.setAttributeNS("http://www.w3.org/1999/xlink", "href",
+        border.setAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href",
                               ref);
         border.setAttributeNS(null, "width", "" + width);
         border.setAttributeNS(null, "height", "" + height);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/DOM2SAX.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/DOM2SAX.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/DOM2SAX.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/DOM2SAX.java Tue Aug 12 05:53:50 2008
@@ -232,7 +232,7 @@
 
                     // Add attribute to list
                     attrs.addAttribute(attr.getNamespaceURI(),
-                            getLocalName(attr), qnameAttr, "CDATA", attr
+                            getLocalName(attr), qnameAttr, XMLUtil.CDATA, attr
                                     .getNodeValue());
                 }
             }

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java?rev=685137&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java Tue Aug 12 05:53:50 2008
@@ -0,0 +1,49 @@
+/*
+ * 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.util;
+
+
+/**
+ * A collection of constants for XML handling.
+ */
+public interface XMLConstants {
+
+    /** "CDATA" constant */
+    String CDATA = "CDATA";
+
+    /** XML namespace prefix */
+    String XML_PREFIX = "xml";
+    /** XML namespace URI */
+    String XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
+
+    /** XMLNS namespace prefix */
+    String XMLNS_PREFIX = "xmlns";
+    /** XMLNS namespace URI */
+    String XMLNS_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
+
+    /** Namespace prefix for XLink */
+    String XLINK_PREFIX = "xlink";
+    /** XML namespace for XLink */
+    String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
+    /** xlink:href attribute */
+    org.apache.xmlgraphics.util.QName XLINK_HREF = new org.apache.xmlgraphics.util.QName(
+            XLINK_NAMESPACE, XLINK_PREFIX, "href");
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java?rev=685137&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java (added)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java Tue Aug 12 05:53:50 2008
@@ -0,0 +1,149 @@
+/*
+ * 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.util;
+
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * A collection of utility method for XML handling.
+ */
+public class XMLUtil implements XMLConstants {
+
+    /**
+     * Returns an attribute value as a boolean value.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @param defaultValue the default value if the attribute is not specified
+     * @return the attribute value as a boolean
+     */
+    public static boolean getAttributeAsBoolean(Attributes attributes, String name,
+            boolean defaultValue) {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            return defaultValue;
+        } else {
+            return Boolean.valueOf(s).booleanValue();
+        }
+    }
+
+    /**
+     * Returns an attribute value as a int value.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @param defaultValue the default value if the attribute is not specified
+     * @return the attribute value as an int
+     */
+    public static int getAttributeAsInt(Attributes attributes, String name,
+            int defaultValue) {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            return defaultValue;
+        } else {
+            return Integer.parseInt(s);
+        }
+    }
+
+    /**
+     * Returns an attribute value as a int value.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @return the attribute value as an int
+     * @throws SAXException if the attribute is missing
+     */
+    public static int getAttributeAsInt(Attributes attributes, String name) throws SAXException {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            throw new SAXException("Attribute '" + name + "' is missing");
+        } else {
+            return Integer.parseInt(s);
+        }
+    }
+
+    /**
+     * Returns an attribute value as a Integer value.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @return the attribute value as an Integer or null if the attribute is missing
+     */
+    public static Integer getAttributeAsInteger(Attributes attributes, String name) {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            return null;
+        } else {
+            return new Integer(s);
+        }
+    }
+
+    /**
+     * Returns an attribute value as a Rectangle2D value. The string value is expected as 4
+     * double-precision numbers separated by whitespace.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @return the attribute value as an Rectangle2D
+     */
+    public static Rectangle2D getAttributeAsRectangle2D(Attributes attributes, String name) {
+        String s = attributes.getValue(name).trim();
+        double[] values = ConversionUtils.toDoubleArray(s, "\\s");
+        if (values.length != 4) {
+            throw new IllegalArgumentException("Rectangle must consist of 4 double values!");
+        }
+        return new Rectangle2D.Double(values[0], values[1], values[2], values[3]);
+    }
+
+    /**
+     * Returns an attribute value as a Rectangle value. The string value is expected as 4
+     * integer numbers separated by whitespace.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @return the attribute value as an Rectangle
+     */
+    public static Rectangle getAttributeAsRectangle(Attributes attributes, String name) {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            return null;
+        }
+        int[] values = ConversionUtils.toIntArray(s.trim(), "\\s");
+        if (values.length != 4) {
+            throw new IllegalArgumentException("Rectangle must consist of 4 int values!");
+        }
+        return new Rectangle(values[0], values[1], values[2], values[3]);
+    }
+
+    /**
+     * Returns an attribute value as a integer array. The string value is expected as 4
+     * integer numbers separated by whitespace.
+     * @param attributes the Attributes object
+     * @param name the name of the attribute
+     * @return the attribute value as an int array
+     */
+    public static int[] getAttributeAsIntArray(Attributes attributes, String name) {
+        String s = attributes.getValue(name);
+        if (s == null) {
+            return null;
+        } else {
+            return ConversionUtils.toIntArray(s.trim(), "\\s");
+        }
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/XMLUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/SVGConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/SVGConstants.java?rev=685137&r1=685136&r2=685137&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/SVGConstants.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/sandbox/org/apache/fop/render/svg/SVGConstants.java Tue Aug 12 05:53:50 2008
@@ -22,11 +22,12 @@
 import org.apache.xmlgraphics.util.QName;
 
 import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.util.XMLConstants;
 
 /**
  * Constants for the intermediate format.
  */
-public interface SVGConstants {
+public interface SVGConstants extends XMLConstants {
 
     /** MIME type for SVG. */
     String MIME_TYPE = MimeConstants.MIME_SVG;
@@ -40,14 +41,6 @@
     /** XML namespace for SVG. */
     String NAMESPACE = "http://www.w3.org/2000/svg";
 
-    /** XML namespace. */
-    String XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
-
-    /** Namespace prefix for XLink */
-    String XLINK_PREFIX = "xlink";
-    /** XML namespace for XLink */
-    String XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
-
     /** the SVG element */
     QName SVG_ELEMENT = new QName(NAMESPACE, null, "svg");
 



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