Browse Source

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
tags/fop-0_20_3
Keiron Liddle 23 years ago
parent
commit
fdabc4dd38

+ 1
- 25
build.xml View File

@@ -228,13 +228,9 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
<property name="src.propmaker.xsl" value="${src.codegen}/propmaker.xsl"/>
<property name="foproperties.xml" value="${build.codegen}/foproperties.xml"/>
<property name="colorkw.xml" value="${build.codegen}/colorkw.xml"/>
<property name="svgproperties.xml" value="${build.codegen}/svgproperties.xml"/>
<property name="extproperties.xml" value="${build.codegen}/extproperties.xml"/>
<property name="allprops.xml" value="${build.codegen}/allprops.xml"/>

<property name="svgelements.xml" value="${build.codegen}/svgelements.xml"/>
<property name="elements.xsl" value="${build.codegen}/elements.xsl"/>

<property name="properties.xsl" value="${build.codegen}/properties.xsl"/>
<property name="propmap.xsl" value="${build.codegen}/propmap.xsl"/>
<property name="enumgen.xsl" value="${build.codegen}/enumgen.xsl"/>
@@ -433,13 +429,8 @@ Sometimes ant gives out this warnings, but the build is finished without any pro

<!-- generate the java files from xml resources -->
<echo message="Generating the java files from xml resources"/>

<xslt infile="${svgelements.xml}" xsltfile="${src.propmaker.xsl}"
dependent="${propinc.xsl}"
outfile="${svgproperties.xml}" smart="yes"/>

<xslt infile="${allprops.xml}" xsltfile="${genconst.xsl}"
dependent="${foproperties.xml},${svgproperties.xml},${extproperties.xml},${colorkw.xml}"
dependent="${foproperties.xml},${extproperties.xml},${colorkw.xml}"
outfile="${build.src}/${replacestring}/fo/properties/Constants.java" smart="yes"/>

<xslt infile="${foproperties.xml}" xsltfile="${properties.xsl}"
@@ -452,16 +443,6 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/foenums_${ignore_this}" smart="yes"/>

<xslt infile="${svgproperties.xml}" xsltfile="${properties.xsl}"
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/svg_${ignore_this}" smart="yes"/>
<xslt infile="${svgproperties.xml}" xsltfile="${propmap.xsl}"
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/SVGPropertyMapping.java" smart="yes"/>
<xslt infile="${svgproperties.xml}" xsltfile="${enumgen.xsl}"
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/svgenums_${ignore_this}" smart="yes"/>

<xslt infile="${extproperties.xml}" xsltfile="${properties.xsl}"
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/ext_${ignore_this}" smart="yes"/>
@@ -472,11 +453,6 @@ Sometimes ant gives out this warnings, but the build is finished without any pro
dependent="${propinc.xsl}"
outfile="${build.src}/${replacestring}/fo/properties/extenums_${ignore_this}" smart="yes"/>


<xslt infile="${svgelements.xml}" xsltfile="${elements.xsl}"
outfile="${build.src}/${replacestring}/svg/ele_${ignore_this}" smart="yes"/>


<xslt infile="${charlist.xml}" xsltfile="${charlist.xsl}"
outfile="${build.src}/${replacestring}/render/pdf/CodePointMapping.java" smart="yes"/>
<xslt infile="${Courier.xml}" xsltfile="${fontfile.xsl}"

+ 49
- 0
src/org/apache/fop/fo/DirectPropertyListBuilder.java View File

@@ -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;
}
}
}

+ 11
- 0
src/org/apache/fop/fo/FOTreeBuilder.java View File

@@ -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
*/

+ 2
- 13
src/org/apache/fop/fo/TreeBuilder.java View File

@@ -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.
*

+ 25
- 20
src/org/apache/fop/svg/SVGElement.java View File

@@ -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();

+ 48
- 56
src/org/apache/fop/svg/SVGElementMapping.java View File

@@ -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());
}

}

+ 42
- 10
src/org/apache/fop/svg/SVGObj.java View File

@@ -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";
}

}


+ 0
- 91
src/org/apache/fop/svg/SVGStringProperty.java View File

@@ -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;
}

}

+ 63
- 53
src/org/apache/fop/svg/XMLObj.java View File

@@ -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);

Loading…
Cancel
Save