hillion 02/04/12 09:04:24 Modified: sources/org/apache/batik/bridge ScriptingEnvironment.java Log: Accept more XML in parseXML() Revision Changes Path 1.21 +18 -3 xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java Index: ScriptingEnvironment.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- ScriptingEnvironment.java 12 Apr 2002 09:17:52 -0000 1.20 +++ ScriptingEnvironment.java 12 Apr 2002 16:04:24 -0000 1.21 @@ -46,7 +46,7 @@ * This class contains the informations needed by the SVG scripting. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: ScriptingEnvironment.java,v 1.20 2002/04/12 09:17:52 hillion Exp $ + * @version $Id: ScriptingEnvironment.java,v 1.21 2002/04/12 16:04:24 hillion Exp $ */ public class ScriptingEnvironment extends BaseScriptingEnvironment { @@ -635,7 +635,6 @@ * org.apache.batik.script.Window#parseXML(String,Document)}. */ public DocumentFragment parseXML(String text, Document doc) { - text = "<svg>" + text + "</svg>"; SAXSVGDocumentFactory df = new SAXSVGDocumentFactory (XMLResourceDescriptor.getXMLParserClassName()); String uri = ((SVGOMDocument)bridgeContext.getDocument()). @@ -654,7 +653,23 @@ } } } catch (Exception ex) { - // !!! TODO: warning + text = "<svg>" + text + "</svg>"; + try { + Document d = df.createDocument(uri, + new StringReader(text)); + for (Node n = d.getDocumentElement().getFirstChild(); + n != null; + n = n.getNextSibling()) { + if (n.getNodeType() == n.ELEMENT_NODE) { + n = doc.importNode(n, true); + result = doc.createDocumentFragment(); + result.appendChild(n); + break; + } + } + } catch (Exception exc) { + // !!! TODO: warning + } } return result; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]