| Doc-Perlish documentation | view source | Contained in the Doc-Perlish distribution. |
Doc::Perlish::DOM::Node - node in a Perldoc::DOM tree
# construct a Doc::Perlish::DOM fragment from this:
#
# =head1 NAME
#
# foo
#
# =cut
#
# corresponding normative XML tree;
#
# <sect1><title>NAME</title><para>foo</para></sect1>
# Doc::Perlish::DOM::Node representation;
my $node = Doc::Perlish::DOM::Element->new
({ name => "sect1",
source => "=head1 ", # text "eaten" by this node
});
# no "source", as this is an "implied" tag
my $title = Doc::Perlish::DOM::Element->new ({ name => "title" });
$node->add_daughter($title);
# text nodes are different, like W3C DOM - don't moan
# kiddies, this is for your own good :)
my $text = Doc::Perlish::DOM::Text->new ("NAME");
# note that Texts *can* have an alternate source fragment, but it
# defaults to be the same as the content, modulo whatever we end up
# doing with whitespace for the round-tripping
$title->add_daughter($text);
# etc etc
my $para = Doc::Perlish::DOM::Element->new({ name => "para",
source => "\n\n" });
$node->add_daughter($para);
# alternate way of creating Texts with content
$para->add_daughter(Doc::Perlish::DOM::Text->new
({ content => "foo" }));
# dummy nodes used only for reconstruction to source.
# represented as processing instructions, or maybe comments
# in the "normative XML"
$node->add_daughter
(Doc::Perlish::DOM::PI->new({ source => "\n\n=cut"}));
Well, with that informative but utterly confusing synopsis, you should be left with nothing but questions about what this object represents.
It represents a node in the Doc::Perlish DOM tree (see Perldoc::DOM for more).
The DOM tree has a root node, which is a "body" element of sorts.
Different types of nodes in a Doc::Perlish DOM tree have different properties, you should see the subclasses for more.
In short, those subclasses are;
It's all about meta-data and structure, not content!
The Text nodes are where it's at, baby, yeah!
Placeholder for dummy nodes that contain only source representation.
These methods must be implemented by subclasses... though a default implementation exists, too.
Returns the representation of this node in the original text, or at least a valid representation of it that "honours the spirit of the dialect", if the original form is not available or has been discarded.
Tree::DAG_Node - details on how to navigate the DAG.
| Doc-Perlish documentation | view source | Contained in the Doc-Perlish distribution. |