From a2d12bc84fb2af87dd1c0c6e5bc854554902cd67 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Sun, 26 Jan 2003 19:35:03 +0000 Subject: Imported from /home/lorry/working-area/delta_perl-xml-xpath/XML-XPath-1.13.tar.gz. --- XPath/Node/Text.pm | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 XPath/Node/Text.pm (limited to 'XPath/Node/Text.pm') diff --git a/XPath/Node/Text.pm b/XPath/Node/Text.pm new file mode 100644 index 0000000..dad3c04 --- /dev/null +++ b/XPath/Node/Text.pm @@ -0,0 +1,96 @@ +# $Id: Text.pm,v 1.5 2000/09/05 13:05:47 matt Exp $ + +package XML::XPath::Node::Text; + +use strict; +use vars qw/@ISA/; + +@ISA = ('XML::XPath::Node'); + +package XML::XPath::Node::TextImpl; + +use vars qw/@ISA/; +@ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Text'); +use XML::XPath::Node ':node_keys'; + +sub new { + my $class = shift; + my ($text) = @_; + + my $pos = XML::XPath::Node->nextPos; + + my @vals; + @vals[node_global_pos, node_text] = ($pos, $text); + my $self = \@vals; + + bless $self, $class; +} + +sub getNodeType { TEXT_NODE } + +sub isTextNode { 1; } + +sub appendText { + my $self = shift; + my ($text) = @_; + $self->[node_text] .= $text; +} + +sub getNodeValue { + my $self = shift; + $self->[node_text]; +} + +sub getData { + my $self = shift; + $self->[node_text]; +} + +sub setNodeValue { + my $self = shift; + $self->[node_text] = shift; +} + +sub _to_sax { + my $self = shift; + my ($doch, $dtdh, $enth) = @_; + + $doch->characters( { Data => $self->getValue } ); +} + +sub string_value { + my $self = shift; + $self->[node_text]; +} + +sub toString { + my $self = shift; + XML::XPath::Node::XMLescape($self->[node_text], "<&"); +} + +1; +__END__ + +=head1 NAME + +Text - an XML text node + +=head1 API + +=head2 new ( text ) + +Create a new text node. + +=head2 getValue / getData + +Returns the text + +=head2 string_value + +Returns the text + +=head2 appendText ( text ) + +Adds the given text string to this node. + +=cut -- cgit v1.2.1