Sorry, I guess I wasn't really clear on the string2Dom, it was just meant as an example,
You need to use the org.apache.batik.dom.svg.SVGDOMImplementation class to create new SVGDocument objects and org.apache.batik.dom.svg.SAXSVGDocumentFactory to parse existing ones. The easiest way I see of doing this is to create a new SVGDocument private static String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; private static DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); doc = impl.createDocument( svgNS, "svg", null ); and then just import all the nodes from your existing DOM into the SVGDoc through importNode(); ----- Original Message ----- From: "Joseph Foster" <[EMAIL PROTECTED]> To: "'Batik Users'" <[EMAIL PROTECTED]> Sent: Wednesday, July 16, 2003 11:33 AM Subject: RE: Loading a SVG Document from a String > Thanks for all your help but I still have one question, won't this > return a Document type when what I really need is a SVGDocument? I know > that you mentioned casting the document, but it seems that an explicit > cast only throws a ClassCastException > e.g. > Document d = Util.string2Dom(xmlString); > JSVGCanvas canvas = new JSVGCanvas(); > canvas.setSVGDocument((SVGDocument)d); > > The above throws a class cast exception. > > Is there some sort of conversion utility that I need to be using instead > of an explicit cast? > > Joe Foster > > > -----Original Message----- > > From: tomas lin [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, July 15, 2003 4:36 PM > > To: Batik Users; [EMAIL PROTECTED] > > Subject: Re: Loading a SVG Document from a String > > > > > > That last part should look something like this.... > > > > public static Document string2Dom(String xml) > > throws ParserConfigurationException, IOException, SAXException > > { > > if(db == null) { > > DocumentBuilderFactory dbf = > > DocumentBuilderFactory.newInstance(); > > db = dbf.newDocumentBuilder(); > > } > > return db.parse(new InputSource(new StringReader(xml ) ) ); > > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]