cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ross Burton" <>
Subject Manipulating SVGs
Date Wed, 14 Jun 2000 18:48:33 GMT

A need has arisen for Cocoon 2 to be able to manipulate and render SVG
files.  The rendering is easy - I enhanced the SVGSerializer some time ago.
However, manipulation of SVGs is harder.  Although this message is in the
context of a SVG document, it could be any DOM-based document.

The options for manipulating SVGs:

* Filters
* XSP taglibs


I have created an AbstractDOMFilter which wraps the SAX -> DOM -> SAX
conversion, which I extend to allow me to filter the Document object.  With
this I can perform any operation I wish it to support - at the moment I have
support for adding any transformation to the root element (such as
"rotate(90) scale(2)" which will rotate the image by 90 degrees clockwise
and double the size).  However, these operations cannot be arbitary - if I
want to add a new element or replace the text in a certain tag I have to
cater for these possibilities in the filter.


With XSP it would be perfectly possible to create dynamic SVG documents, but
they would have to be created from scratch.  As far as I know it is not
possible to take a SVG file from the filesystem, perform arbitary
modifications and stream it along the pipeline.

What I need is a mixture of the two.  This is where my mad idea came in -
JavaScript.  If one of the parameters on my SVGFilter was a "execute"
parameter, the value of which was Javascript code, I could use Mozilla Rhino
to execute this code.  If I give the JavaScript engine access to a SVG
document and the Request object, arbitary and complex JavaScript could be
written to modify the document, create new elements and change text to
create dynamic images (similar to Flash Generator).

Am I correct?  Is there a use case of XSP which I do not know about?
Comments on this issue would be appreciated.

Ross Burton

View raw message