source: gs2-extensions/parallel-building/trunk/src/perllib/cpan/XML/XPath/Node/Comment.pm@ 24626

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.5 KB
Line 
1# $Id: Comment.pm 7909 2004-08-06 05:11:55Z mdewsnip $
2
3package XML::XPath::Node::Comment;
4
5use strict;
6use vars qw/@ISA/;
7
8@ISA = ('XML::XPath::Node');
9
10package XML::XPath::Node::CommentImpl;
11
12use vars qw/@ISA/;
13@ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Comment');
14use XML::XPath::Node ':node_keys';
15
16sub new {
17 my $class = shift;
18 my ($comment) = @_;
19
20 my $pos = XML::XPath::Node->nextPos;
21
22 my @vals;
23 @vals[node_global_pos, node_comment] =
24 ($pos, $comment);
25 my $self = \@vals;
26
27 bless $self, $class;
28}
29
30sub getNodeType { COMMENT_NODE }
31
32sub isCommentNode { 1; }
33
34sub getNodeValue {
35 return shift->[node_comment];
36}
37
38sub getData {
39 shift->getNodeValue;
40}
41
42sub setNodeValue {
43 shift->[node_comment] = shift;
44}
45
46sub _to_sax {
47 my $self = shift;
48 my ($doch, $dtdh, $enth) = @_;
49
50 $doch->comment( { Data => $self->getValue } );
51}
52
53sub comment_escape {
54 my $data = shift;
55 $data =~ s/--/--/g;
56 return $data;
57}
58
59sub string_value {
60 my $self = shift;
61 return $self->[node_comment];
62}
63
64sub toString {
65 my $self = shift;
66 return '<!--' . comment_escape($self->[node_comment]) . '-->';
67}
68
691;
70__END__
71
72=head1 NAME
73
74Comment - an XML comment: <!--comment-->
75
76=head1 API
77
78=head2 new ( data )
79
80Create a new comment node.
81
82=head2 getValue / getData
83
84Returns the value in the comment
85
86=head2 toString
87
88Returns the comment with -- encoded as a numeric entity (if it
89exists in the comment text).
90
91=cut
Note: See TracBrowser for help on using the repository browser.