diff options
author | Yorhel <git@yorhel.nl> | 2011-01-27 15:26:16 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2011-01-27 15:26:59 +0100 |
commit | b4f67d1a3f26f02fd9ca2d75f1a38ab36708380f (patch) | |
tree | fc9377aeb45145c85b4584c0da341b51168e847e /lib/Multi/RG.pm | |
parent | 7f603c63c6a7081e66387b1600cd14376bca8621 (diff) |
Multi::RG: Use TUWF::XML instead of XML::Writer
This removes the last dependency on XML::Writer.
Diffstat (limited to 'lib/Multi/RG.pm')
-rw-r--r-- | lib/Multi/RG.pm | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm index a04ae062..e8ef52ee 100644 --- a/lib/Multi/RG.pm +++ b/lib/Multi/RG.pm @@ -10,7 +10,7 @@ use warnings; use POE 'Wheel::Run', 'Filter::Stream'; use Encode 'encode_utf8'; use XML::Parser; -use XML::Writer; +use TUWF::XML; use Time::HiRes 'time'; @@ -147,7 +147,7 @@ sub savegraph { # - Remove first <polygon> element (emulates the background color) # - Replace stroke and fill attributes with classes (so that coloring is done in CSS) my $svg = ''; - my $w = XML::Writer->new(OUTPUT => \$svg); + my $w = TUWF::XML->new(write => sub { $svg .= shift }); my $p = XML::Parser->new; $p->setHandlers( Start => sub { @@ -160,24 +160,21 @@ sub savegraph { delete @attr{qw|stroke fill xmlns xmlns:xlink|}; delete $attr{id} if $attr{id} && $attr{id} !~ /^node_[vp]\d+$/; - $el eq 'path' || $el eq 'polygon' - ? $w->emptyTag("svg:$el", %attr) - : $w->startTag("svg:$el", %attr); + $w->tag("svg:$el", %attr, $el eq 'path' || $el eq 'polygon' ? undef : ()); }, End => sub { my($expat, $el) = @_; return if $el eq 'title' || $expat->in_element('title'); return if $el eq 'polygon' && $expat->depth == 2; - $w->endTag("svg:$el") if $el ne 'path' && $el ne 'polygon'; + $w->end("svg:$el") if $el ne 'path' && $el ne 'polygon'; }, Char => sub { my($expat, $str) = @_; return if $expat->in_element('title'); - $w->characters($str) if $str !~ /^[\s\t\r\n]*$/s; + $w->txt($str) if $str !~ /^[\s\t\r\n]*$/s; } ); $p->parsestring($_[HEAP]{svg}); - $w->end(); # save the processed SVG in the database and fetch graph ID $_[KERNEL]->post(pg => query => 'INSERT INTO relgraphs (svg) VALUES (?) RETURNING id', [ $svg ], 'finish'); |