view Lib/IMPL/DOM/Schema/ComplexNode.pm @ 16:75d55f4ee263

Окончательная концепция описания схем и построения DOM документов
author Sergey
date Tue, 08 Sep 2009 17:29:07 +0400
parents 5899df8c289e
children 818c74b038ae
line wrap: on
line source

package IMPL::DOM::Schema::ComplexNode;
use strict;
use warnings;

use base qw(IMPL::DOM::Schema::Item);
use IMPL::Class::Property;

BEGIN {
    public property content => {
        get => \&_getContent,
        set => \&_setContent
    }
}

__PACKAGE__->PassThroughArgs;

sub _getContent {
    $_[0]->firstChild;
}

sub _setContent {
    $_[0]->firstChild($_[1]);
}

sub Validate {
    my ($this,$node) = @_;
    
    if (my $type = $this->nodeType) {
        my $schemaType = $this->Schema->ResolveType($type);
        return $schemaType->Validate($node);
    } else {
        my @errors;
        push @errors, $_->Validate foreach @{$this->childNodes};
        
        return @errors;
    }
}

1;

__END__

=pod

=head1 DESCRIPTION

  .    ,  
.

        ..
       , . C<content>

=head2 PROPERTIES

=over

=item C<content>

 ,    C<IMPL::DOM::Schema::NodeSet> 
C<IMPL::DOM::Schema::NodeList>,        .
       .

=back

=cut