SVGDocument doc = null;
try {
doc = parseFromString(rawSvg, "text/xml").cast();
} catch(JavaScriptException e) {
throw new ParserException(ParserException.Type.NotWellFormed, e.getMessage());
}
Element elt = doc.getDocumentElement();
if ("parsererror".equals(DOMHelper.getLocalName(elt))) {
String message = "Parsing error";
if (elt.getFirstChild() != null) {
message = elt.getFirstChild().<Text>cast().getData();
}
throw new ParserException(ParserException.Type.NotWellFormed, message);
}
SVGSVGElement svg = DOMHelper.importNode(DOMHelper.getCurrentDocument(), elt, true).cast();
// IE9 bug workaround: update all SVG style elements by
// adding a trailing whitespace char, otherwise IE9 will
// ignore them