File: Text.pm

package info (click to toggle)
libxml-xpath-perl 1.48-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 608 kB
  • sloc: perl: 4,444; xml: 34; makefile: 10
file content (94 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package XML::XPath::Node::Text;

use strict;
use warnings;
use parent qw/XML::XPath::Node/;

our $VERSION = '1.48';

package XML::XPath::Node::TextImpl;

use XML::XPath::Node ':node_keys';
use parent qw/-norequire XML::XPath::NodeImpl XML::XPath::Node::Text/;

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