my svg likes this:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
...
</svg>
not only one xmlns
,how to define xmlns
in batik
? and how parse to a Document
?
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
File file = new File(svgURI);
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
Document doc = f.createDocument(svgNS, "svg", file.toURI().toString());
above code have exceptions when run:
Exception in thread "main" org.w3c.dom.DOMException: The current document is unable to create an element of the requested type (namespace: http://www.w3.org/2000/svg, name: usrs).
at org.apache.batik.dom.AbstractNode.createDOMException(AbstractNode.java:407)
at org.apache.batik.anim.dom.SVGDOMImplementation.createElementNS(SVGDOMImplementation.java:202)
at org.apache.batik.anim.dom.SVGOMDocument.createElementNS(SVGOMDocument.java:373)
``
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(uri);