keiron 01/09/12 02:28:14
Modified: src/org/apache/fop/fo FOTreeBuilder.java TreeBuilder.java
src/org/apache/fop/svg SVGElement.java
SVGElementMapping.java SVGObj.java XMLObj.java
Added: src/org/apache/fop/fo DirectPropertyListBuilder.java
Removed: src/org/apache/fop/svg SVGStringProperty.java
Log:
made the construction of foreign name dom a bit more direct
and simple reducing number of classes
Revision Changes Path
1.27 +12 -1 xml-fop/src/org/apache/fop/fo/FOTreeBuilder.java
Index: FOTreeBuilder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOTreeBuilder.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- FOTreeBuilder.java 2001/08/21 08:26:11 1.26
+++ FOTreeBuilder.java 2001/09/12 09:28:13 1.27
@@ -1,5 +1,5 @@
/*
- * $Id: FOTreeBuilder.java,v 1.26 2001/08/21 08:26:11 keiron Exp $
+ * $Id: FOTreeBuilder.java,v 1.27 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -137,6 +137,17 @@
this.propertylistTable.put(namespaceURI, plb);
} else {
plb.addElementList(localName, list);
+ }
+ }
+
+ 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
}
}
1.4 +3 -14 xml-fop/src/org/apache/fop/fo/TreeBuilder.java
Index: TreeBuilder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/TreeBuilder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TreeBuilder.java 2001/08/20 11:19:22 1.3
+++ TreeBuilder.java 2001/09/12 09:28:13 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: TreeBuilder.java,v 1.3 2001/08/20 11:19:22 keiron Exp $
+ * $Id: TreeBuilder.java,v 1.4 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -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;
/**
*/
@@ -46,6 +33,8 @@
* @param maker Maker for class representing formatting object
*/
public void addPropertyList(String namespaceURI, Hashtable list);
+
+ public void addPropertyListBuilder(String namespaceURI, PropertyListBuilder
list);
/**
* add a mapping from element name to maker.
1.1 xml-fop/src/org/apache/fop/fo/DirectPropertyListBuilder.java
Index: DirectPropertyListBuilder.java
===================================================================
/*
* $Id: DirectPropertyListBuilder.java,v 1.1 2001/09/12 09:28:13 keiron Exp $
* 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;
}
}
}
1.9 +26 -21 xml-fop/src/org/apache/fop/svg/SVGElement.java
Index: SVGElement.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGElement.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SVGElement.java 2001/08/30 10:09:02 1.8
+++ SVGElement.java 2001/09/12 09:28:13 1.9
@@ -1,5 +1,5 @@
/*
- * $Id: SVGElement.java,v 1.8 2001/08/30 10:09:02 keiron Exp $
+ * $Id: SVGElement.java,v 1.9 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -32,7 +32,7 @@
/**
* 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 @@
* @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 @@
}
/* 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 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 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 @@
}
};
((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();
@@ -160,6 +149,22 @@
/* return status */
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;
1.15 +55 -63 xml-fop/src/org/apache/fop/svg/SVGElementMapping.java
Index: SVGElementMapping.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGElementMapping.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SVGElementMapping.java 2001/07/30 20:29:34 1.14
+++ SVGElementMapping.java 2001/09/12 09:28:13 1.15
@@ -1,5 +1,5 @@
/*
- * $Id: SVGElementMapping.java,v 1.14 2001/07/30 20:29:34 tore Exp $
+ * $Id: SVGElementMapping.java,v 1.15 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -9,7 +9,7 @@
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 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, "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, "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, "pattern", Pattern.maker());
-
- 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, "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.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.addMapping(uri, "rect", SVGObj.maker("rect"));
+ builder.addMapping(uri, "line", SVGObj.maker("line"));
+ builder.addMapping(uri, "text", SVGObj.maker("text"));
+
+ 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", 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", SVGObj.maker("pattern"));
+
+ 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", 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.addPropertyListBuilder(uri, new DirectPropertyListBuilder());
}
}
1.7 +43 -11 xml-fop/src/org/apache/fop/svg/SVGObj.java
Index: SVGObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/SVGObj.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SVGObj.java 2001/07/30 20:29:34 1.6
+++ SVGObj.java 2001/09/12 09:28:13 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: SVGObj.java,v 1.6 2001/07/30 20:29:34 tore Exp $
+ * $Id: SVGObj.java,v 1.7 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -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";
}
-
}
1.4 +64 -54 xml-fop/src/org/apache/fop/svg/XMLObj.java
Index: XMLObj.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/svg/XMLObj.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLObj.java 2001/07/30 20:29:34 1.3
+++ XMLObj.java 2001/09/12 09:28:13 1.4
@@ -1,5 +1,5 @@
/*
- * $Id: XMLObj.java,v 1.3 2001/07/30 20:29:34 tore Exp $
+ * $Id: XMLObj.java,v 1.4 2001/09/12 09:28:13 keiron Exp $
* 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.
@@ -15,6 +15,7 @@
import org.apache.fop.layout.LinkSet;
import org.w3c.dom.*;
+import org.xml.sax.Attributes;
import java.util.*;
@@ -26,15 +27,18 @@
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 @@
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;
@@ -112,16 +111,27 @@
javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
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 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);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]