SVG::Rasterize::TextNode - workaround to represent a text node
SVG::Rasterize::TextNode
Version 0.003002
According to the DOM specification which SVG::Rasterize uses to traverse SVG document trees, basically everything is a node including simple text. This means that if an SVG element contains text (e.g. a text or tspan element), the getChildNodes method is supposed to return not only the child elements, but also the character data (i.e. text) sections in this list of nodes. However, the getChildNodes method of the SVG::Element class in the SVG distribution only returns the child elements, no character data section.
DOM
SVG
text
tspan
getChildNodes
SVG::Rasterize tries to support not only SVG object trees, but also DOM trees created by a generic XML parser. Due to the behaviour described above, these two scenarios have to be treated differently.
XML
This class acts as a drop-in for a SVG node class representing a character data node. When parsing a SVG object tree, character data of the relevant elements are stored in such an object and pushed to the list of child nodes. Afterwards, the object tree can be accessed uniformly.
This process does not get around the problem that in an SVG::Element object cannot hold multiple character data sections and that it cannot store the order of such sections and child elements. However, this problem can only be solved within the SVG distribution (see RT#58153).
The interface only implements (apart from the constructor) the minimal requirements of SVG::Rasterize, e.g. the following methods:
$node = SVG::Rasterize::TextNode->new(%args)
Creates a new SVG::Rasterize::TextNode object and calls init(%args). If you subclass SVG::Rasterize::TextNode overload init, not new.
init(%args)
new
Supported arguments:
data (mandatory): a SCALAR as defined by Params::Validate, containing the text data.
See new for a description of the interface. If you overload init, your method should also call this one.
init
Returns #text.
#text
Returns undef.
undef
Returns the text.
SVG::Rasterize
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1590626202
Lutz Gehlen, <perl at lutzgehlen.de>
<perl at lutzgehlen.de>
Copyright 2010 Lutz Gehlen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install SVG::Rasterize, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVG::Rasterize
CPAN shell
perl -MCPAN -e shell install SVG::Rasterize
For more information on module installation, please visit the detailed CPAN module installation guide.