I am new using Batik so may be the my problem has a
trivial solution, sorry if it is the case. I need to insert some
application-dependent attributes as for example:
<rect x="10"
y="20" width="100" height="50"/>
In order to insert the new properties I simply do
the following:
SVGElement rectangle = (SVGElement)
doc.createElementNS(svgNS, "rect");
rectangle.setAttributeNS(null, "x", "10");
rectangle.setAttributeNS(null, "y", "20");
rectangle.setAttributeNS(null, "width", "100");
rectangle.setAttributeNS(null, "height",
"50");
svgRoot.appendChild(rectangle);
Element myProps =
doc.createElement("myProps");
myProps.setAttribute("a",
"147");
rectangle.appendChild(myProps);
but I then have problems when trying to read it
because I get the following exception:
org.w3c.dom.DOMException: The current document is
unable to create an element of the requested type (namespace: http://www.w3.org/2000/svg, name:
myProps).
I guess it is because I need to add the new
definition to but it is not clear to me which is the proper way to do it
using Batik.
I would also need to listen for the svg-document
reading process not at the begining,or the end as allows the
SVGDocumentLoaderListener but for each read element.
I would appreciate any help.
|