*/
public StyleSheet getCSSStyleSheet() {
if (styleSheet == null) {
if (getType().equals("text/css")) {
SVGOMDocument doc = (SVGOMDocument)getOwnerDocument();
CSSEngine e = doc.getCSSEngine();
String text = "";
Node n = getFirstChild();
if (n != null) {
StringBuffer sb = new StringBuffer();
while (n != null) {
if (n.getNodeType() == n.CDATA_SECTION_NODE
|| n.getNodeType() == n.TEXT_NODE)
sb.append(n.getNodeValue());
n = n.getNextSibling();
}
text = sb.toString();
}
URL burl = null;
try {
String bu = XMLBaseSupport.getCascadedXMLBase(this);
if (bu != null) {
burl = new URL(bu);
}
} catch (MalformedURLException ex) {
// !!! TODO
ex.printStackTrace();
throw new InternalError();
}
String media = getAttributeNS(null, SVG_MEDIA_ATTRIBUTE);
styleSheet = e.parseStyleSheet(text, burl, media);
addEventListener("DOMCharacterDataModified",
domCharacterDataModifiedListener,
false);
}
}