xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: attributes of <use> element
Date Tue, 01 Apr 2008 10:15:16 GMT
Hi HardCod3r,

hardc0d3r <hardc0d3r@gmail.com> wrote on 03/23/2008 09:33:10 PM:

> sir, i tried what you suggested but it gives me the wrong node.. are
> any solutions for getting an attribute of a use element?

   Since you are registering a single event handler at the root of the
document (rather than placing the event handler on individual elements)
you will need to walk up the DOM tree from the 'target' looking for
your use element.  The following code will do that.

    Element e = evt.getTarget();
    while (e != null) {
      if (e.getLocalName().equals(SVG_NAMESPACE_URI) &&

      e = (Element)e.getParentNode();

    The only issue you are likely to encounter is knowing if the
use element is _the_ use element (you could have multiple use
elements).  I've done that by attaching an attribute in a custom
namespace to the element that you can look for in the loop above.
View raw message