Hi,
i'm using Batik 1.5 on Linux with java 1.4.1
OK, it is resolved, this works:
function doInit(evt) { var svgDoc = evt.target.ownerDocument; var svgNS = "http://www.w3.org/2000/svg"; var svgXLink = "http://www.w3.org/1999/xlink"; var svgRoot = svgDoc.getDocumentElement(); // get the root element (the svg element)
var use = svgDoc.createElementNS(svgNS, "use"); use.setAttributeNS(null, "id", "ZZ"); use.setAttributeNS(svgXLink, "xlink:href", "#XX"); svgRoot.appendChild(use); }
(it is described in the batik FAQ)
thanks
Marcel
In the <defs> section i have defined a rectangle from which i want to create many instances with Javascript, but nothing is displayed. Showing the <def> directly with
<use id="ZZ" xlink:href="#XX"/>
works fine. Here is the failing code:
------------------------------------------ <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="800" height="500" viewBox="0 0 800 500"
onload="doInit(evt)">
<defs> <script type="text/ecmascript"> <![CDATA[ function doInit(evt) { var svgDoc = evt.target.ownerDocument; var svgTag = svgDoc.getFirstChild(); var use = svgDoc.createElement("use"); use.setAttribute("id", "ZZ"); use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#XX"); svgTag.appendChild(use);
// test: var el = svgDoc.getElementById("ZZ"); alert("elem=" + use.getAttribute("id")); alert("elem=" + use.getAttribute("href")); } ]]> </script>
<rect id="XX" x="10" y="10" width="20" height="100" style="fill:blue"/> </defs>
<!-- use id="ZZ" xlink:href="#XX"/ -->
</svg> ---------------------------------------------
Is this a bug in batik or do i make a mistake?
thanks for some help
Marcel
-- http://www.xmlBlaster.org
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]