[EMAIL PROTECTED]
Dear all.
I am trying to display an image using batik, but keep getting exceptions.
Can anyone help me with the
following code?
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);
// get the root element (the svg element)
Element svgRoot = doc.getDocumentElement();
svgRoot.setAttributeNS(null, "width", Integer.toString(CHART_WIDTH +
50));
svgRoot.setAttributeNS(null, "height", Integer.toString(CHART_HEIGHT +
200));
svgRoot.setAttributeNS(null, "xmlns", "http://www.w3.org/2000/svg");
svgRoot.setAttributeNS("xmlns", "xlink",
"http://www.w3.org/1999/xlink");
Element e = doc.createElementNS(svgNS, "image");
e.setAttributeNS(null, "x", "200" );
e.setAttributeNS(null, "y", "200" );
e.setAttributeNS(null, "width", "50" );
e.setAttributeNS(null, "height","70" );
String url = "graphics/z.gif" ;
MaintanenceChartBuilder mcb = new MaintanenceChartBuilder();
ClassLoader cl = mcb.getClass().getClassLoader();
URL fullUrl = cl.getResource(url);
e.setAttributeNS("xlink", "href", fullUrl.toString() );
svgRoot.appendChild(e);
If I run this in the application, I get an error like:
org.apache.batik.bridge.BridgeException: null:0
The attribute 'xlink:href' of the element <image> is required
at
org.apache.batik.bridge.SVGImageElementBridge.createGraphicsNode(SVGImageEle
mentBridge.java:79)
at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:170)
at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:136)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:69)
at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:72)
Can anyone help me? This is very urgent and ive tried every combination of
attributes I can think of.
Thanks in advance,
DS
************************************************************************
This Internet E-mail is intended solely for the person to whom it is addressed. It may
contain confidential or privileged information. If you have received it in error
please notify us immediately by telephone and destroy the transmission. You must not
copy, distribute or take any action in reliance on it.
Aerosystems International Phone: +44 (0)1935 443000
Fax : +44 (0)1935 443111
Web : www.aeroint.com
************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]