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