Hi,
De-lurking to ask a quick Batik / DOM API question.
Does anyone have any idea why this does not work:
Element x = doc.getDocumentElement();
Element target = doc.createElementNS(
SVGDOMImplementation.SVG_NAMESPACE_URI,
"image");
target.setAttributeNS(null, "x", String.valueOf(X));
target.setAttributeNS(null, "y", String.valueOf(Y));
target.setAttributeNS(null, "width", String.valueOf(Width));
target.setAttributeNS(null, "height", String.valueOf(Height));
target.setAttributeNS(null, "id", String.valueOf(spriteID));
target.setAttributeNS(null, "xlink:href",
String.valueOf(spriteFile))
x.appendChild(target);
When I generate a rectangle rather than an image, the rectangle shows up
without a hitch.
However, when I do the above and insert an image element, I get the following
error in my swing application:
"SVG Error:
file:/home/ogerr/Projects/java/lib/BatikCalendarApp/svg/init.svg:-1
The attribute 'xlink:href' of the element <image> is required "
When I serialize the document to which I added the image above (to init.svg
above, ), the following has been generated by the above code:
<image x="0.0" y="0.0" width="100.0"
xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple"
xlink:actuate="onRequest" id="someTailNumber" height="100.0"
preserveAspectRatio="xMidYMid meet" xlink:show="replace"
xlink:href=
"file:///home/ogerr/Projects/java/lib/BatikCalendarApp/svg/resource.svg"/>
However, when I take the above image element and embed it into the document
that the DOM loads into, the image displays.
From what I think I understand, the DOM methods above are appending into the
document defined by file init.svg which is loaded on construction. There
seems to be some information missing when I invoke the xlink:href attribute.
I am a bit confused...
I must be making some batik newbie mistake...
Anyone see anything obvious?
Ronan
--
Ronan Oger
[EMAIL PROTECTED]
www.vectoreal.com ...for scalable solutions.
-------------------------------------
Switzerland
Mobile: +41 76 527 3552
Fax: +41 44 274 2402
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]