SVG::Rasterize::TextNode - workaround to represent a text node
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.
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.
getChildNodes method of the SVG::Element class in the SVG distribution only returns the child elements,
no character data section.
SVG::Rasterize tries to support not only SVG object trees,
DOM trees created by a generic
Due to the behaviour described above,
these two scenarios have to be treated differently.
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.
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
See new for a description of the interface. If you overload
init, your method should also call this one.
Returns the text.
<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.