1package XML::DOM2::Element::Comment;
2
3=head1 NAME
4
5  XML::DOM2::Element::Comment
6
7=head1 DISCRIPTION
8
9  Comment element object class.
10
11=head1 METHODS
12
13=cut
14
15use base "XML::DOM2::Element";
16
17use strict;
18use warnings;
19
20=head2 $element->new( $name, %options )
21
22  Create a new comment element object.
23
24=cut
25sub new
26{
27	my ($proto, $text, %args) = @_;
28	$args{'text'} = $text;
29	my $self = $proto->SUPER::new('comment', %args);
30	return $self;
31}
32
33=head2 $element->xmlify()
34
35  Returns the comment as xml.
36
37=cut
38sub xmlify
39{
40	my ($self, %p) = @_;
41	my $sep = $p{'seperator'} || "\n";
42	my $indent = ($p{'indent'} || '  ') x ( $p{'level'} || 0 );
43	my $text = $self->{'text'};
44	$text =~ s/$sep/$sep$indent/g;
45	return $sep.$indent.'<!--'.$text.'-->';
46}
47
48=head2 $element->text()
49
50  Return plain text (UTF-8)
51
52=cut
53sub text
54{
55	my ($self) = @_;
56	return $self->{'text'} || '';
57}
58
59=head2 $element->setComment( $text )
60
61  Replace comment with $text
62
63=cut
64sub setComment
65{
66	my ($self, $text) = @_;
67	$self->{'text'} = $text;
68}
69
70=head2 $element->appendComment( $text )
71
72  Append to the end of existing comment text $text
73
74=cut
75sub appendComment
76{
77	my ($self, $text) = @_;
78	$self->{'text'} .= $text;
79}
80
81=head2 $element->_can_contain_elements()
82
83  The element can not contain sub elements.
84
85=cut
86sub _can_contain_elements { 0 }
87
88=head2 $element->_can_contain_attributes()
89
90  The element can not contain attributes
91
92=cut
93sub _can_contain_attributes { 0 }
94
95=head1 COPYRIGHT
96
97Martin Owens, doctormo@cpan.org
98
99=head1 SEE ALSO
100
101L<XML::DOM2>,L<XML::DOM2::DOM::Element>
102
103=cut
1041;
105