[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/linuxaux/opt/perl/lib/site_perl/5.10.0/XML/XPath/Node/ -> Comment.pm (source)

   1  # $Id: Comment.pm,v 1.5 2000/09/05 13:05:46 matt Exp $
   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


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1