Last change
on this file since 24626 was 24626, checked in by jmt12, 13 years ago |
An (almost) complete copy of the perllib directory from a (circa SEP2011) head checkout from Greenstone 2 trunk - in order to try and make merging in this extension a little easier later on (as there have been some major changes to buildcol.pl commited in the main trunk but not in the x64 branch)
|
File size:
1.4 KB
|
Line | |
---|
1 | # $Id: Text.pm 7909 2004-08-06 05:11:55Z mdewsnip $
|
---|
2 |
|
---|
3 | package XML::XPath::Node::Text;
|
---|
4 |
|
---|
5 | use strict;
|
---|
6 | use vars qw/@ISA/;
|
---|
7 |
|
---|
8 | @ISA = ('XML::XPath::Node');
|
---|
9 |
|
---|
10 | package XML::XPath::Node::TextImpl;
|
---|
11 |
|
---|
12 | use vars qw/@ISA/;
|
---|
13 | @ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Text');
|
---|
14 | use XML::XPath::Node ':node_keys';
|
---|
15 |
|
---|
16 | sub 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 |
|
---|
29 | sub getNodeType { TEXT_NODE }
|
---|
30 |
|
---|
31 | sub isTextNode { 1; }
|
---|
32 |
|
---|
33 | sub appendText {
|
---|
34 | my $self = shift;
|
---|
35 | my ($text) = @_;
|
---|
36 | $self->[node_text] .= $text;
|
---|
37 | }
|
---|
38 |
|
---|
39 | sub getNodeValue {
|
---|
40 | my $self = shift;
|
---|
41 | $self->[node_text];
|
---|
42 | }
|
---|
43 |
|
---|
44 | sub getData {
|
---|
45 | my $self = shift;
|
---|
46 | $self->[node_text];
|
---|
47 | }
|
---|
48 |
|
---|
49 | sub setNodeValue {
|
---|
50 | my $self = shift;
|
---|
51 | $self->[node_text] = shift;
|
---|
52 | }
|
---|
53 |
|
---|
54 | sub _to_sax {
|
---|
55 | my $self = shift;
|
---|
56 | my ($doch, $dtdh, $enth) = @_;
|
---|
57 |
|
---|
58 | $doch->characters( { Data => $self->getValue } );
|
---|
59 | }
|
---|
60 |
|
---|
61 | sub string_value {
|
---|
62 | my $self = shift;
|
---|
63 | $self->[node_text];
|
---|
64 | }
|
---|
65 |
|
---|
66 | sub toString {
|
---|
67 | my $self = shift;
|
---|
68 | XML::XPath::Node::XMLescape($self->[node_text], "<&");
|
---|
69 | }
|
---|
70 |
|
---|
71 | 1;
|
---|
72 | __END__
|
---|
73 |
|
---|
74 | =head1 NAME
|
---|
75 |
|
---|
76 | Text - an XML text node
|
---|
77 |
|
---|
78 | =head1 API
|
---|
79 |
|
---|
80 | =head2 new ( text )
|
---|
81 |
|
---|
82 | Create a new text node.
|
---|
83 |
|
---|
84 | =head2 getValue / getData
|
---|
85 |
|
---|
86 | Returns the text
|
---|
87 |
|
---|
88 | =head2 string_value
|
---|
89 |
|
---|
90 | Returns the text
|
---|
91 |
|
---|
92 | =head2 appendText ( text )
|
---|
93 |
|
---|
94 | Adds the given text string to this node.
|
---|
95 |
|
---|
96 | =cut
|
---|
Note:
See
TracBrowser
for help on using the repository browser.