Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Interfacing Perl and SVG

by Matts (Deacon)
on Aug 14, 2002 at 07:48 UTC ( [id://190002] : note . print w/replies, xml ) Need Help??

in reply to Interfacing Perl and SVG

If you're doing the highlighting client-side (via rollovers) I'd just use the SVG DOM for it. Unfortunately perl doesn't have a fully capable SVG parser yet (though AxPoint contains an SVG path parser which you may find useful - that's probably the hardest part), so in order to get at those bits you're better off doing it client side.

Unlike HTML, SVG has a very stable client-side Javascript spec, and works very well in the Adobe viewer (using the mozilla javascript engine).

If that doesn't cover what you're after, then yes, parse with a SAX parser and extract the paths. I don't know how they'll be done in your SVG (there are various different ways in SVG to define a path).

The other thing to do is to hand-refine your SVG, so that each region is a <g> group. Then you can do funky things with those groups like enlarge and bring them forward as you mouse over them. There's been some good examples of this on

Replies are listed 'Best First'.
Re: Re: Interfacing Perl and SVG
by Baz (Friar) on Aug 14, 2002 at 16:31 UTC
    Thanks Matts,

    I've now defined my paths inside the "def" tags so I can make use of the "use" tags which allow me to display multiple versions of my map. I was thinking of making all the dynamic values, such as the type of fill required for each county, part of a Javascript array. That would make the parsing procedure much easier, as I'd just have to stick this in at the top somewhere.

    I was also wondering about whether it would be possible to send the SVG version to the client - which is a large file at this stage, and then for each statistical set (same maps, but with new shadings) I could send them this array. No idea as of yet how this might be done... For my site I have a list of surnames, and I shade a map to show the distribution of a selected surname. Here the current png version of this