Doc::Perlish::DOM::WS - ignorable whitespace in a Perldoc::DOM tree


Doc-Perlish documentation Contained in the Doc-Perlish distribution.

Index


Code Index:

NAME

Top

Doc::Perlish::DOM::WS - ignorable whitespace in a Perldoc::DOM tree

SYNOPSIS

Top

See Doc::Perlish::DOM::Node.

DESCRIPTION

Top

Sometimes you need to put in a little whitespace to fill an XML document. This node type is for that.

SUB-CLASS PROPERTIES

This node type keeps the source property, and adds content, which is the whitespace to be represented in the normative XML.


Doc-Perlish documentation Contained in the Doc-Perlish distribution.

package Doc::Perlish::DOM::WS;

use Carp;
use Doc::Perlish::DOM::Node -Base;

sub _init {
    my $o = shift;
    $self->content($o->{content}) if exists $o->{content};
    super($o);
}

sub new {
    #print STDERR "WS: new with '$_[0]'\n";
    if ( ref $_[0] ) {
	super(@_);
    } else {
	my $text = shift;
	my $o = shift || {};
	$o->{content} = $text;
	super($o);
    }
}

sub content {
    if ( @_ ) {
	# FIXME - unicode :)
	my $content = shift;
	$content =~ /\S/
	    && croak "tried to put non-whitespace in a whitespace node";
	$self->{content} = $content;
    } else {
	$self->{content};
    }
}

sub dom_fields {
    super, qw(content);
}

sub event_type {
    "ignorable_whitespace"
}

1;