You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Mi...@Emerson.com on 2011/10/17 13:16:35 UTC

How can I get the UseElement of trancoded SVG?

Hello all,

I`ve got a problem to obtain the original "use"-element of a dynamically generated SVG. E. g. my program creates a SVG containing this fragment:

<g transform="rotate(0,0,0) translate(0,0)">
<use xlink:href="file:/C:/dummy/MyFirstSVG.SVG#E3" x="0" y="0"/>
     <g transform="translate(8,32) rotate(0,0,0)">
          <use xlink:href="file:/C:/dummy/MySecondSVG.SVG#E3" x="0" y="0"/>
     </g>
</g>

This SVG then is transcoded and painted in a BridgeContext. When "painting" via the "convertFillAndStroke"-method of my batik.bridge.PainServer-implementation I need some information of the original UseElement, but asking for

Element elem = (Element)((SVGOMUseShadowRoot)myNode).getCSSParentNode();

and then

String value = elem.getAttributeNS(XMLConstants.XLINK_NAMESPACE_URI, "href");

delivers the embedded contents of the referenced SVG parts.

When debugging, I can see the original content somewhere in the deep of the DOM (myNode -> ownerDocument -> referent -> (several childNodes) -> SVGOMUseElement -> attributes -> "href" -> GenericAttrNS -> "file:/C:/dummy/MyFirstSVG.SVG#E3"), but how can I get it programmatically?
I need the "MyFirstSVG#E3" or "MySecondSVG#E3" from the original UseElements, but what I get is the embedded content of the referenced "MyFirstSVG.SVG", "MySecondSVG.SVG"

Thank you very much for your help.

Kind regards


Michael