diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2003-01-26 19:35:03 +0000 |
---|---|---|
committer | <> | 2015-02-23 10:18:26 +0000 |
commit | a2d12bc84fb2af87dd1c0c6e5bc854554902cd67 (patch) | |
tree | 7665979c7c281b21971de576d93246a022bff649 /XPath/Node/Comment.pm | |
download | perl-xml-xpath-master.tar.gz |
Imported from /home/lorry/working-area/delta_perl-xml-xpath/XML-XPath-1.13.tar.gz.HEADXML-XPath-1.13master
Diffstat (limited to 'XPath/Node/Comment.pm')
-rw-r--r-- | XPath/Node/Comment.pm | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/XPath/Node/Comment.pm b/XPath/Node/Comment.pm new file mode 100644 index 0000000..e110710 --- /dev/null +++ b/XPath/Node/Comment.pm @@ -0,0 +1,91 @@ +# $Id: Comment.pm,v 1.5 2000/09/05 13:05:46 matt Exp $ + +package XML::XPath::Node::Comment; + +use strict; +use vars qw/@ISA/; + +@ISA = ('XML::XPath::Node'); + +package XML::XPath::Node::CommentImpl; + +use vars qw/@ISA/; +@ISA = ('XML::XPath::NodeImpl', 'XML::XPath::Node::Comment'); +use XML::XPath::Node ':node_keys'; + +sub new { + my $class = shift; + my ($comment) = @_; + + my $pos = XML::XPath::Node->nextPos; + + my @vals; + @vals[node_global_pos, node_comment] = + ($pos, $comment); + my $self = \@vals; + + bless $self, $class; +} + +sub getNodeType { COMMENT_NODE } + +sub isCommentNode { 1; } + +sub getNodeValue { + return shift->[node_comment]; +} + +sub getData { + shift->getNodeValue; +} + +sub setNodeValue { + shift->[node_comment] = shift; +} + +sub _to_sax { + my $self = shift; + my ($doch, $dtdh, $enth) = @_; + + $doch->comment( { Data => $self->getValue } ); +} + +sub comment_escape { + my $data = shift; + $data =~ s/--/--/g; + return $data; +} + +sub string_value { + my $self = shift; + return $self->[node_comment]; +} + +sub toString { + my $self = shift; + return '<!--' . comment_escape($self->[node_comment]) . '-->'; +} + +1; +__END__ + +=head1 NAME + +Comment - an XML comment: <!--comment--> + +=head1 API + +=head2 new ( data ) + +Create a new comment node. + +=head2 getValue / getData + +Returns the value in the comment + +=head2 toString + +Returns the comment with -- encoded as a numeric entity (if it +exists in the comment text). + +=cut |