Inserting custom javascript in SVG doc

Hi,
Is there a way to insert custom javascript function while generating the SVG document. As of now I am modifying the generated SVG and adding my JS code. This does not seems to be a good solution.

Mayank

Sure, if you have created a subclass of DefaultDocument, you can override buildSVGDoc() and add your script to the root element after super.buildSVGDoc() has executed.
If you don’t want to create a subclass of DefaultDocument, you can add your script to the document within any of the SVGWriteObject() methods of your JGoObject subclasses:
public void SVGWriteObject(DomDoc svgDoc, DomElement jGoElementGroup)
{
com.nwoods.jgo.svg.DefaultDocument svgDomDoc = (com.nwoods.jgo.svg.DefaultDocument)svgDoc;
DomElement root = svgDomDoc.getDocumentElement();
DomElement script = createElement(“script”);
root.appendChild(script);
DomText text = CreateText(“whatever”);
script.appendChild(text);
}