view Lib/IMPL/DOM/Schema/ComplexNode.pm @ 7:94d47b388442

Улучшены тесты Исправлены ошибки Улучшена документация Работа над схемой DOM
author Sergey
date Mon, 24 Aug 2009 01:05:34 +0400
parents
children fffb153be599
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 nodeType => prop_all;
    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};
        
        if (@errors and $this->Message) {
            return {
                Error => 1,
                Message => $this->formatMessage($node),
                InnerErrors => \@errors
            };
        } else {
            return @errors;
        }
    }
}

1;

__END__

=pod

=head1 DESCRIPTION

  .    ,  
.

        ..
       , . C<content>

=head2 PROPERTIES

=over

=item C<nodeType>

   ,     .  
 C<content>   .

=item C<content>

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

=back

=cut