summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-09-12 09:30:40 +0000
committerKeiron Liddle <keiron@apache.org>2001-09-12 09:30:40 +0000
commitfdabc4dd38c3903f8d141ca5e0cfdb241b400771 (patch)
tree0af748b34f2b6947d48b5a37eb7489d739e97fca /src
parent94497c3885d349ca35cf4756f0732f88a26d956f (diff)
downloadxmlgraphics-fop-fdabc4dd38c3903f8d141ca5e0cfdb241b400771.tar.gz
xmlgraphics-fop-fdabc4dd38c3903f8d141ca5e0cfdb241b400771.zip
made the construction of foreign name dom a bit more direct
and simple reducing number of classes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194461 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/org/apache/fop/fo/DirectPropertyListBuilder.java49
-rw-r--r--src/org/apache/fop/fo/FOTreeBuilder.java11
-rw-r--r--src/org/apache/fop/fo/TreeBuilder.java15
-rw-r--r--src/org/apache/fop/svg/SVGElement.java45
-rw-r--r--src/org/apache/fop/svg/SVGElementMapping.java104
-rw-r--r--src/org/apache/fop/svg/SVGObj.java52
-rw-r--r--src/org/apache/fop/svg/SVGStringProperty.java91
-rw-r--r--src/org/apache/fop/svg/XMLObj.java116
8 files changed, 240 insertions, 243 deletions
diff --git a/src/org/apache/fop/fo/DirectPropertyListBuilder.java b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
new file mode 100644
index 000000000..e039b3731
--- /dev/null
+++ b/src/org/apache/fop/fo/DirectPropertyListBuilder.java
@@ -0,0 +1,49 @@
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.fo;
+
+import org.apache.fop.fo.properties.*;
+import org.apache.fop.svg.*;
+import org.apache.fop.datatypes.*;
+
+import org.apache.fop.apps.FOPException;
+
+import org.xml.sax.Attributes;
+
+/**
+ * This is a property list builder that bypasses overhead.
+ * The attribute list is made available directly so it can
+ * be used to build a dom.
+ * Note: there should be a better way to handle this and
+ * the attribute list is only valid within the startElement
+ * call of the sax events.
+ */
+public class DirectPropertyListBuilder extends PropertyListBuilder {
+
+ public DirectPropertyListBuilder() {
+ }
+
+ public PropertyList makeList(String elementName, Attributes attributes,
+ PropertyList parentPropertyList,
+ FObj parentFO) throws FOPException {
+ AttrPropertyList ret = new AttrPropertyList(attributes);
+ return ret;
+ }
+
+ public class AttrPropertyList extends PropertyList {
+ Attributes attributes;
+ AttrPropertyList(Attributes attr) {
+ super(null, null, null);
+ attributes = attr;
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+ }
+}
diff --git a/src/org/apache/fop/fo/FOTreeBuilder.java b/src/org/apache/fop/fo/FOTreeBuilder.java
index 72ac6f146..359ca6fbc 100644
--- a/src/org/apache/fop/fo/FOTreeBuilder.java
+++ b/src/org/apache/fop/fo/FOTreeBuilder.java
@@ -140,6 +140,17 @@ public class FOTreeBuilder extends DefaultHandler implements TreeBuilder {
}
}
+ public void addPropertyListBuilder(String namespaceURI,
+ PropertyListBuilder propbuilder) {
+ PropertyListBuilder plb;
+ plb = (PropertyListBuilder)this.propertylistTable.get(namespaceURI);
+ if (plb == null) {
+ this.propertylistTable.put(namespaceURI, propbuilder);
+ } else {
+ // Error already added
+ }
+ }
+
/**
* SAX Handler for characters
*/
diff --git a/src/org/apache/fop/fo/TreeBuilder.java b/src/org/apache/fop/fo/TreeBuilder.java
index 6b98b7539..5342dd54c 100644
--- a/src/org/apache/fop/fo/TreeBuilder.java
+++ b/src/org/apache/fop/fo/TreeBuilder.java
@@ -7,21 +7,8 @@
package org.apache.fop.fo;
-// FOP
-import org.apache.fop.layout.AreaTree;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.fo.pagination.Root;
-
-// SAX
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.InputSource;
-import org.xml.sax.Attributes;
-
// Java
import java.util.Hashtable;
-import java.util.Stack;
-import java.io.IOException;
/**
*/
@@ -47,6 +34,8 @@ public interface TreeBuilder {
*/
public void addPropertyList(String namespaceURI, Hashtable list);
+ public void addPropertyListBuilder(String namespaceURI, PropertyListBuilder list);
+
/**
* add a mapping from element name to maker.
*
diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java
index b4f3dd811..211178803 100644
--- a/src/org/apache/fop/svg/SVGElement.java
+++ b/src/org/apache/fop/svg/SVGElement.java
@@ -32,7 +32,7 @@ import java.util.ArrayList;
/**
* class representing svg:svg pseudo flow object.
*/
-public class SVGElement extends Svg {
+public class SVGElement extends SVGObj {
/**
* inner class for making SVG objects.
@@ -72,7 +72,8 @@ public class SVGElement extends Svg {
* @param propertyList the explicit properties of this object
*/
public SVGElement(FObj parent, PropertyList propertyList) {
- super(parent, propertyList);
+ super(parent, propertyList, "svg");
+ init();
}
/**
@@ -96,19 +97,7 @@ public class SVGElement extends Svg {
}
/* create an SVG area */
- /* if width and height are zero, may want to get the bounds of the content. */
-
- DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
- String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
- Document doc = impl.createDocument(svgNS, "svg", null);
-
- final Element svgRoot = doc.getDocumentElement();
-
- try {
- String baseDir = Configuration.getStringValue("baseDir");
- ((SVGOMDocument)doc).setURLObject(new URL(baseDir));
- } catch (Exception e) {}
-
+ /* if width and height are zero, get the bounds of the content. */
DefaultSVGContext dc = new DefaultSVGContext() {
public float getPixelToMM() {
// 72 dpi
@@ -116,7 +105,7 @@ public class SVGElement extends Svg {
}
public float getViewportWidth(Element e) throws IllegalStateException {
- if(e == svgRoot) {
+ if(e == element) {
ForeignObjectArea foa = (ForeignObjectArea)area;
if(!foa.isContentWidthAuto()) {
return foa.getContentWidth();
@@ -126,7 +115,7 @@ public class SVGElement extends Svg {
}
public float getViewportHeight(Element e) throws IllegalStateException {
- if(e == svgRoot) {
+ if(e == element) {
ForeignObjectArea foa = (ForeignObjectArea)area;
if(!foa.isContentHeightAuto()) {
return foa.getContentHeight();
@@ -140,11 +129,11 @@ public class SVGElement extends Svg {
}
};
((SVGOMDocument)doc).setSVGContext(dc);
- buildTopLevel(doc, svgRoot);
+
float width =
- ((SVGSVGElement)svgRoot).getWidth().getBaseVal().getValue();
+ ((SVGSVGElement)element).getWidth().getBaseVal().getValue();
float height =
- ((SVGSVGElement)svgRoot).getHeight().getBaseVal().getValue();
+ ((SVGSVGElement)element).getHeight().getBaseVal().getValue();
SVGArea svg = new SVGArea(fs, width, height);
svg.setSVGDocument(doc);
svg.start();
@@ -162,6 +151,22 @@ public class SVGElement extends Svg {
return new Status(Status.OK);
}
+ private void init() {
+ DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
+ String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+ doc = impl.createDocument(svgNS, "svg", null);
+
+ element = doc.getDocumentElement();
+
+ try {
+ String baseDir = Configuration.getStringValue("baseDir");
+ ((SVGOMDocument)doc).setURLObject(new URL(baseDir));
+ } catch (Exception e) {
+ log.error("Could not set base URL for svg", e);
+ }
+ buildTopLevel(doc, element);
+ }
+
public final static List FONT_FAMILY;
static {
FONT_FAMILY = new ArrayList();
diff --git a/src/org/apache/fop/svg/SVGElementMapping.java b/src/org/apache/fop/svg/SVGElementMapping.java
index c6d876f61..9069a7a0e 100644
--- a/src/org/apache/fop/svg/SVGElementMapping.java
+++ b/src/org/apache/fop/svg/SVGElementMapping.java
@@ -9,7 +9,7 @@ package org.apache.fop.svg;
import java.util.Enumeration;
-import org.apache.fop.fo.properties.SVGPropertyMapping;
+import org.apache.fop.fo.DirectPropertyListBuilder;
import org.apache.fop.fo.TreeBuilder;
import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.ElementMapping;
@@ -19,67 +19,59 @@ public class SVGElementMapping implements ElementMapping {
public void addToBuilder(TreeBuilder builder) {
String uri = "http://www.w3.org/2000/svg";
builder.addMapping(uri, "svg", SVGElement.maker());
- builder.addMapping(uri, "rect", Rect.maker());
- builder.addMapping(uri, "line", Line.maker());
- builder.addMapping(uri, "text", Text.maker());
+ builder.addMapping(uri, "rect", SVGObj.maker("rect"));
+ builder.addMapping(uri, "line", SVGObj.maker("line"));
+ builder.addMapping(uri, "text", SVGObj.maker("text"));
- builder.addMapping(uri, "desc", Desc.maker());
- builder.addMapping(uri, "title", Title.maker());
- builder.addMapping(uri, "circle", Circle.maker());
- builder.addMapping(uri, "ellipse", Ellipse.maker());
- builder.addMapping(uri, "g", G.maker());
- builder.addMapping(uri, "polyline", Polyline.maker());
- builder.addMapping(uri, "polygon", Polygon.maker());
- builder.addMapping(uri, "defs", Defs.maker());
- builder.addMapping(uri, "path", Path.maker());
- builder.addMapping(uri, "use", Use.maker());
- builder.addMapping(uri, "tspan", Tspan.maker());
- builder.addMapping(uri, "tref", Tref.maker());
- builder.addMapping(uri, "image", Image.maker());
- builder.addMapping(uri, "style", Style.maker());
+ builder.addMapping(uri, "desc", SVGObj.maker("desc"));
+ builder.addMapping(uri, "title", SVGObj.maker("title"));
+ builder.addMapping(uri, "circle", SVGObj.maker("circle"));
+ builder.addMapping(uri, "ellipse", SVGObj.maker("ellipse"));
+ builder.addMapping(uri, "g", SVGObj.maker("g"));
+ builder.addMapping(uri, "polyline", SVGObj.maker("polyline"));
+ builder.addMapping(uri, "polygon", SVGObj.maker("polygon"));
+ builder.addMapping(uri, "defs", SVGObj.maker("defs"));
+ builder.addMapping(uri, "path", SVGObj.maker("path"));
+ builder.addMapping(uri, "use", SVGObj.maker("use"));
+ builder.addMapping(uri, "tspan", SVGObj.maker("tspan"));
+ builder.addMapping(uri, "tref", SVGObj.maker("tref"));
+ builder.addMapping(uri, "image", SVGObj.maker("image"));
+ builder.addMapping(uri, "style", SVGObj.maker("style"));
- builder.addMapping(uri, "textPath", TextPath.maker());
- builder.addMapping(uri, "clipPath", ClipPath.maker());
- builder.addMapping(uri, "mask", Mask.maker());
- builder.addMapping(uri, "linearGradient", LinearGradient.maker());
- builder.addMapping(uri, "radialGradient", RadialGradient.maker());
- builder.addMapping(uri, "stop", Stop.maker());
- builder.addMapping(uri, "a", A.maker());
- builder.addMapping(uri, "switch", Switch.maker());
- builder.addMapping(uri, "symbol", Symbol.maker());
+ builder.addMapping(uri, "textPath", SVGObj.maker("textPath"));
+ builder.addMapping(uri, "clipPath", SVGObj.maker("clipPath"));
+ builder.addMapping(uri, "mask", SVGObj.maker("mask"));
+ builder.addMapping(uri, "linearGradient", SVGObj.maker("linearGradient"));
+ builder.addMapping(uri, "radialGradient", SVGObj.maker("radialGradient"));
+ builder.addMapping(uri, "stop", SVGObj.maker("stop"));
+ builder.addMapping(uri, "a", SVGObj.maker("a"));
+ builder.addMapping(uri, "switch", SVGObj.maker("switch"));
+ builder.addMapping(uri, "symbol", SVGObj.maker("symbol"));
- builder.addMapping(uri, "pattern", Pattern.maker());
+ builder.addMapping(uri, "pattern", SVGObj.maker("pattern"));
- builder.addMapping(uri, "marker", Marker.maker());
- builder.addMapping(uri, "animate", Animate.maker());
- builder.addMapping(uri, "altGlyph", AltGlyph.maker());
- builder.addMapping(uri, "font", Font.maker());
- builder.addMapping(uri, "glyph", Glyph.maker());
- builder.addMapping(uri, "missing-glyph", MissingGlyph.maker());
- builder.addMapping(uri, "hkern", Hkern.maker());
- builder.addMapping(uri, "vkern", Vkern.maker());
- builder.addMapping(uri, "set", Set.maker());
- builder.addMapping(uri, "animateMotion", AnimateMotion.maker());
- builder.addMapping(uri, "animateColor", AnimateColor.maker());
- builder.addMapping(uri, "animateTransform", AnimateTransform.maker());
- builder.addMapping(uri, "cursor", Cursor.maker());
- builder.addMapping(uri, "filter", Filter.maker());
+ builder.addMapping(uri, "marker", SVGObj.maker("marker"));
+ builder.addMapping(uri, "animate", SVGObj.maker("animate"));
+ builder.addMapping(uri, "altGlyph", SVGObj.maker("altGlyph"));
+ builder.addMapping(uri, "font", SVGObj.maker("font"));
+ builder.addMapping(uri, "glyph", SVGObj.maker("glyph"));
+ builder.addMapping(uri, "missing-glyph", SVGObj.maker("missing-glyph"));
+ builder.addMapping(uri, "hkern", SVGObj.maker("hkern"));
+ builder.addMapping(uri, "vkern", SVGObj.maker("vkern"));
+ builder.addMapping(uri, "set", SVGObj.maker("set"));
+ builder.addMapping(uri, "animateMotion", SVGObj.maker("animateMotion"));
+ builder.addMapping(uri, "animateColor", SVGObj.maker("animateColor"));
+ builder.addMapping(uri, "animateTransform", SVGObj.maker("animateTransform"));
+ builder.addMapping(uri, "cursor", SVGObj.maker("cursor"));
+ builder.addMapping(uri, "filter", SVGObj.maker("filter"));
- builder.addMapping(uri, "feFlood", FeFlood.maker());
- builder.addMapping(uri, "feGaussianBlur", FeGaussianBlur.maker());
- builder.addMapping(uri, "feOffset", FeOffset.maker());
- builder.addMapping(uri, "feMerge", FeMerge.maker());
- builder.addMapping(uri, "feMergeNode", FeMergeNode.maker());
+ builder.addMapping(uri, "feFlood", SVGObj.maker("feFlood"));
+ builder.addMapping(uri, "feGaussianBlur", SVGObj.maker("feGaussianBlur"));
+ builder.addMapping(uri, "feOffset", SVGObj.maker("feOffset"));
+ builder.addMapping(uri, "feMerge", SVGObj.maker("feMerge"));
+ builder.addMapping(uri, "feMergeNode", SVGObj.maker("feMergeNode"));
-
- builder.addPropertyList(uri, SVGPropertyMapping.getGenericMappings());
- /* Add any element mappings */
- for (Enumeration e = SVGPropertyMapping.getElementMappings();
- e.hasMoreElements(); ) {
- String elem = (String)e.nextElement();
- builder.addElementPropertyList(uri, elem,
- SVGPropertyMapping.getElementMapping(elem));
- }
+ builder.addPropertyListBuilder(uri, new DirectPropertyListBuilder());
}
}
diff --git a/src/org/apache/fop/svg/SVGObj.java b/src/org/apache/fop/svg/SVGObj.java
index 2a215d730..78a84bdda 100644
--- a/src/org/apache/fop/svg/SVGObj.java
+++ b/src/org/apache/fop/svg/SVGObj.java
@@ -7,28 +7,60 @@
package org.apache.fop.svg;
-// FOP
import org.apache.fop.fo.*;
+import org.apache.fop.layout.Area;
+import org.apache.fop.layout.FontState;
+import org.apache.fop.apps.FOPException;
-/**
- * Since SVG objects are not layed out then this class checks
- * that this element is not being layed out inside some incorrect
- * element.
- */
-public abstract class SVGObj extends XMLObj {
+import org.w3c.dom.Element;
+
+public class SVGObj extends XMLObj {
+ /**
+ * inner class for making svg objects.
+ */
+ public static class Maker extends FObj.Maker {
+ String tag;
+
+ Maker(String str) {
+ tag = str;
+ }
+
+ /**
+ * make an svg object.
+ *
+ * @param parent the parent formatting object
+ * @param propertyList the explicit properties of this object
+ *
+ * @return the svg object
+ */
+ public FObj make(FObj parent,
+ PropertyList propertyList) throws FOPException {
+ return new SVGObj(parent, propertyList, tag);
+ }
+ }
/**
+ * returns the maker for this object.
+ *
+ * @return the maker for an svg object
+ */
+ public static FObj.Maker maker(String str) {
+ return new SVGObj.Maker(str);
+ }
+
+ /**
+ * constructs an svg object (called by Maker).
*
* @param parent the parent formatting object
* @param propertyList the explicit properties of this object
*/
- public SVGObj(FObj parent, PropertyList propertyList) {
- super(parent, propertyList);
+ protected SVGObj(FObj parent, PropertyList propertyList, String tag) {
+ super(parent, propertyList, tag);
+ this.name = "svg:" + tag;
}
public String getNameSpace() {
return "http://www.w3.org/2000/svg";
}
-
}
diff --git a/src/org/apache/fop/svg/SVGStringProperty.java b/src/org/apache/fop/svg/SVGStringProperty.java
deleted file mode 100644
index c483773f2..000000000
--- a/src/org/apache/fop/svg/SVGStringProperty.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-package org.apache.fop.svg;
-
-import java.util.*;
-
-// FOP
-import org.apache.fop.fo.*;
-import org.apache.fop.apps.FOPException;
-
-/**
- * a class representing all properties in SVG
- */
-public class SVGStringProperty extends Property {
-
- /**
- * inner class for making SVG String objects.
- */
- public static class Maker extends Property.Maker {
-
- /**
- * whether this property is inherited or not.
- *
- * @return is this inherited?
- */
- public boolean isInherited() {
- return false;
- }
-
- /**
- * make an SVG String property with the given value.
- *
- * @param propertyList the property list this is a member of
- * @param value the explicit string value of the property
- */
- public Property make(PropertyList propertyList, String value,
- FObj fo) throws FOPException {
- return new SVGStringProperty(propertyList, value);
- }
-
- /**
- * make an SVG String property with the default value.
- *
- * @param propertyList the property list the property is a member of
- */
- public Property make(PropertyList propertyList) throws FOPException {
- return make(propertyList, null, null);
- }
-
- }
-
- /**
- * returns the maker for this object.
- *
- * @return the maker for SVG Length objects
- */
- public static Property.Maker maker(String name) {
- return new SVGStringProperty.Maker();
- }
-
- /**
- * the value
- */
- protected String value;
-
- /**
- * construct an SVG String (called by the Maker).
- *
- * @param propertyList the property list this is a member of
- * @param explicitValue the explicit value as a Length object
- */
- protected SVGStringProperty(PropertyList propertyList,
- String explicitValue) {
- this.value = explicitValue;
- }
-
- /**
- * get the value
- *
- * @return the length as a Length object
- */
- public String getString() {
- return this.value;
- }
-
-}
diff --git a/src/org/apache/fop/svg/XMLObj.java b/src/org/apache/fop/svg/XMLObj.java
index e9b41669b..383005b02 100644
--- a/src/org/apache/fop/svg/XMLObj.java
+++ b/src/org/apache/fop/svg/XMLObj.java
@@ -15,6 +15,7 @@ import org.apache.fop.apps.FOPException;
import org.apache.fop.layout.LinkSet;
import org.w3c.dom.*;
+import org.xml.sax.Attributes;
import java.util.*;
@@ -26,15 +27,18 @@ import java.util.*;
public abstract class XMLObj extends FObj {
protected String tagName = "";
- protected String[] props = {};
+
+ protected Element element;
+ protected Document doc;
/**
*
* @param parent the parent formatting object
* @param propertyList the explicit properties of this object
*/
- public XMLObj(FObj parent, PropertyList propertyList) {
+ public XMLObj(FObj parent, PropertyList propertyList, String tag) {
super(parent, propertyList);
+ tagName = tag;
}
public abstract String getNameSpace();
@@ -42,68 +46,63 @@ public abstract class XMLObj extends FObj {
protected static Hashtable ns = new Hashtable();
public void addGraphic(Document doc, Element parent) {
- Element element = doc.createElementNS(getNameSpace(), tagName);
- // Element element = doc.createElement(tagName);
- for (int count = 0; count < props.length; count++) {
- if (this.properties.get(props[count]) != null) {
- String rf = this.properties.get(props[count]).getString();
- if (rf != null) {
- if (props[count].indexOf(":") == -1) {
- element.setAttribute(props[count], rf);
- } else {
- String pref =
- props[count].substring(0,
- props[count].indexOf(":"));
- if (pref.equals("xmlns")) {
- ns.put(props[count].substring(props[count].indexOf(":")
- + 1), rf);
- }
- ns.put("xlink", "http://www.w3.org/1999/xlink");
- element.setAttributeNS((String)ns.get(pref),
- props[count], rf);
+ this.doc = doc;
+ element = doc.createElementNS(getNameSpace(), tagName);
+
+ if(this.properties instanceof DirectPropertyListBuilder.AttrPropertyList) {
+ Attributes attr = ((DirectPropertyListBuilder.AttrPropertyList)this.properties).getAttributes();
+ for (int count = 0; count < attr.getLength(); count++) {
+ String rf = attr.getValue(count);
+ String qname = attr.getQName(count);
+ if (qname.indexOf(":") == -1) {
+ element.setAttribute(qname, rf);
+ } else {
+ String pref =
+ qname.substring(0, qname.indexOf(":"));
+ if (pref.equals("xmlns")) {
+ ns.put(qname.substring(qname.indexOf(":")
+ + 1), rf);
}
+ ns.put("xlink", "http://www.w3.org/1999/xlink");
+ element.setAttributeNS((String)ns.get(pref),
+ qname, rf);
}
}
+ } else {
}
+
parent.appendChild(element);
- int numChildren = this.children.size();
- for (int i = 0; i < numChildren; i++) {
- Object child = children.elementAt(i);
- if (child instanceof XMLObj) {
- ((XMLObj)child).addGraphic(doc, element);
- } else if (child instanceof String) {
- org.w3c.dom.Text text = doc.createTextNode((String)child);
- element.appendChild(text);
- }
- }
}
public void buildTopLevel(Document doc, Element svgRoot) {
// build up the info for the top level element
- for (int count = 0; count < props.length; count++) {
- if (this.properties.get(props[count]) != null) {
- String rf = this.properties.get(props[count]).getString();
- if (rf != null)
- svgRoot.setAttributeNS(null, props[count], rf);
- }
- }
- // doc.appendChild(topLevel);
- int numChildren = this.children.size();
- for (int i = 0; i < numChildren; i++) {
- Object child = children.elementAt(i);
- if (child instanceof XMLObj) {
- ((XMLObj)child).addGraphic(doc, svgRoot);
- } else if (child instanceof String) {
- org.w3c.dom.Text text = doc.createTextNode((String)child);
- svgRoot.appendChild(text);
+ if(this.properties instanceof DirectPropertyListBuilder.AttrPropertyList) {
+ Attributes attr = ((DirectPropertyListBuilder.AttrPropertyList)this.properties).getAttributes();
+ for (int count = 0; count < attr.getLength(); count++) {
+ String rf = attr.getValue(count);
+ String qname = attr.getQName(count);
+ if (qname.indexOf(":") == -1) {
+ element.setAttribute(qname, rf);
+ } else {
+ String pref =
+ qname.substring(0, qname.indexOf(":"));
+ if (pref.equals("xmlns")) {
+ ns.put(qname.substring(qname.indexOf(":")
+ + 1), rf);
+ }
+ ns.put("xlink", "http://www.w3.org/1999/xlink");
+ element.setAttributeNS((String)ns.get(pref),
+ qname, rf);
+ }
}
+ } else {
}
}
public Document createBasicDocument() {
- Document doc = null;
+ doc = null;
- Element svgRoot = null;
+ element = null;
try {
// DOMImplementation impl = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
// String ns = GraphElementMapping.URI;
@@ -113,15 +112,26 @@ public abstract class XMLObj extends FObj {
Element el = doc.createElement("graph");
doc.appendChild(el);
- svgRoot = doc.getDocumentElement();
- buildTopLevel(doc, svgRoot);
-
+ element = doc.getDocumentElement();
+ buildTopLevel(doc, element);
} catch (Exception e) {
e.printStackTrace();
}
return doc;
}
+ protected void addChild(FONode child) {
+ if (child instanceof XMLObj) {
+ ((XMLObj)child).addGraphic(doc, element);
+ }
+ }
+
+ protected void addCharacters(char data[], int start, int length) {
+ String str = new String(data, start, length - start);
+ org.w3c.dom.Text text = doc.createTextNode(str);
+ element.appendChild(text);
+ }
+
/**
* layout this formatting object.
*
@@ -130,7 +140,7 @@ public abstract class XMLObj extends FObj {
*/
public Status layout(Area area) throws FOPException {
/* generate a warning */
- System.err.println("WARNING: " + this.name + " outside foreign xml");
+ log.error("" + this.name + " outside foreign xml");
/* return status */
return new Status(Status.OK);