This prob won't compile, and some methods may be misnamed, but it should be
close in spirit!
note that you need to use the xlink namespace for the xlink:href attribute
as shown below. Since a node can only be in one place I chose to use the
shorcut of adding n to a and letting the dom remove it from n.parent.
hope it helps
...
SVGElement a = null;
for(int i=0;i<labels.getLength();i++) {
n = labels.item(i);
log.info("A label:"+n.getFirstChild().**getNodeValue());
//presumably, replace n with a link element that contains n?
a = document.createElementNS(SVGNAMESPACE, "a");
a.setAttributeNS(XLINKNAMESPACE, "xlink;href", my_special_url);
n.getParentNode().appendChild(a);
a.appendChild(n);
}
...
On Thu, Aug 8, 2013 at 6:25 PM, James Burton <[email protected]>wrote:
> I'm new to using batik, and I want to turn all text elements in an
> SVGDocument into links which pass the text to a callback. Can you point me
> to an example of something similar? I'm finding the text elements like this:
>
> SVGDocument doc = ...
> Element svgRoot = doc.getDocumentElement();
> NodeList labels = svgRoot.**getElementsByTagNameNS("*", "text");
> Node n;
> for(int i=0;i<labels.getLength();i++) {
> n = labels.item(i);
> log.info("A label:"+n.getFirstChild().**getNodeValue());
> //presumably, replace n with a link element that contains n?
> }
>
> Thanks in advance,
>
> Jim
>
> ______________________________**_____________________________
> This email has been scanned by MessageLabs' Email Security
> System on behalf of the University of Brighton.
> For more information see
> http://www.brighton.ac.uk/is/**spam/<http://www.brighton.ac.uk/is/spam/>
> ______________________________**_____________________________
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@**xmlgraphics.apache.org<[email protected]>
> For additional commands, e-mail:
> batik-users-help@xmlgraphics.**apache.org<[email protected]>
>
>