source: trunk/gsdl/perllib/cpan/XML/XPath/Node/Text.pm@ 7909

Last change on this file since 7909 was 7909, checked in by mdewsnip, 20 years ago

CPAN module for processing XPath expressions.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1# $Id: Text.pm 7909 2004-08-06 05:11:55Z mdewsnip $
2
3package XML::XPath::Node::Text;
4
5use strict;
6use vars qw/@ISA/;
7
8@ISA = ('XML::XPath::Node');
9
10package XML::XPath::Node::TextImpl;
11
12use vars qw/@ISA/;
13@ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Text');
14use XML::XPath::Node ':node_keys';
15
16sub new {
17 my $class = shift;
18 my ($text) = @_;
19
20 my $pos = XML::XPath::Node->nextPos;
21
22 my @vals;
23 @vals[node_global_pos, node_text] = ($pos, $text);
24 my $self = \@vals;
25
26 bless $self, $class;
27}
28
29sub getNodeType { TEXT_NODE }
30
31sub isTextNode { 1; }
32
33sub appendText {
34 my $self = shift;
35 my ($text) = @_;
36 $self->[node_text] .= $text;
37}
38
39sub getNodeValue {
40 my $self = shift;
41 $self->[node_text];
42}
43
44sub getData {
45 my $self = shift;
46 $self->[node_text];
47}
48
49sub setNodeValue {
50 my $self = shift;
51 $self->[node_text] = shift;
52}
53
54sub _to_sax {
55 my $self = shift;
56 my ($doch, $dtdh, $enth) = @_;
57
58 $doch->characters( { Data => $self->getValue } );
59}
60
61sub string_value {
62 my $self = shift;
63 $self->[node_text];
64}
65
66sub toString {
67 my $self = shift;
68 XML::XPath::Node::XMLescape($self->[node_text], "<&");
69}
70
711;
72__END__
73
74=head1 NAME
75
76Text - an XML text node
77
78=head1 API
79
80=head2 new ( text )
81
82Create a new text node.
83
84=head2 getValue / getData
85
86Returns the text
87
88=head2 string_value
89
90Returns the text
91
92=head2 appendText ( text )
93
94Adds the given text string to this node.
95
96=cut
Note: See TracBrowser for help on using the repository browser.