How to resolve SVGOMUseElement fragments?

<[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <0E4D0F7AD75E694985E184D6A869BE4E17769C3144@GBLONZ-PMSGEM02.emrsn.org>
Hallo,

I'm very new to batik, and I spent several hours with Google to find a solution for my problem, but without success.
I'm trying to parse a SVG which uses several "use" tags with "xlink:href". The goal is to transform the svg into dxf format. The "parent" SVG can consist of many use-tags, that address external SVG files with fragments (#):

<svg>
	...
	<use xlink:href="file:/C:/files/mySVG_1.SVG#Fragment_1" x="0" y="0"/>
	<use xlink:href="file:/C:/files/mySVG_2.SVG#Fragment_2" x="0" y="0"/>
	...
</svg>


The external files themselves consist of several group-tags, that can be addressed by internal fragments again, e. g. "mySVG_1.SVG":


<svg>
	...
	<g id=" Fragment_1" >
		<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#internalFragment_1"/>
		<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#internalFragment_2"/>
	</g>
	...
	<g id="internalFragment_1" >
		<circle cx="491.5" cy="130" r="12.5" />    
		...
		<path d="M 477 210 L 513 210 L 513 50 L 477 50  z" />
		...
	</g>
	<g id="internalFragment_2" >
		...
	</g>
	...
</svg>


What I need is the "primitives" of the "internalFragment_1" (circles, paths, rectangles, etc.) to pass them to the appropriate dxf-methods.
In my SVG-parsing code I can detect the "SVGOMUseElement". I "manually" load the external SVG (e. g. "mySVG_1.SVG") and recursively call my parsing method with it:

void myTransform(Document doc, dxfContext);
...
else if (node instanceof SVGOMUseElement)
{
	Document innerDoc = loadDocument(XLinkSupport.getXLinkHref((Element) n));
	if (innerDoc != null)
	{
		myTransform(innerDoc, dxfContext);
	}
	else
	{
		//if loadDocument (my own method) returns null, the link target was not an external file but a simple internal fragment
		//what to do here to resolve the internalFragments down to the primitives?	
	}
...


But when I get the internal SVGOMUseElement addressed by "Fragment_1" I don't know how to resolve the content of the addressed "internalFragment_1". There are no childNodes or a shadowtree or something like that. 
What is the right way to resolve the internal fragment of a SVG to get its' primitives?
Thank you very much for your help.

Kind Regards.

Michael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.