* Implements {@link
* org.apache.batik.script.Window#parseXML(String,Document)}.
*/
public DocumentFragment parseXML(String text, Document doc) {
// System.out.println("Text: " + text);
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
(XMLResourceDescriptor.getXMLParserClassName());
String uri = ((SVGOMDocument)bridgeContext.getDocument()).
getURLObject().toString();
DocumentFragment result = null;
try {
Document d = df.createDocument(uri, new StringReader(text));
result = doc.createDocumentFragment();
result.appendChild(doc.importNode(d.getDocumentElement(),
true));
} catch (Exception ex) {
StringBuffer sb = new StringBuffer(text.length() +
FRAGMENT_PREFIX.length() +
"</svg>".length());
sb.append(FRAGMENT_PREFIX);
sb.append(text);
sb.append("</svg>");
String newText = sb.toString();
try {
Document d = df.createDocument
(uri, new StringReader(newText));
for (Node n = d.getDocumentElement().getFirstChild();
n != null;
n = n.getNextSibling()) {
if (n.getNodeType() == n.ELEMENT_NODE) {