view Lib/IMPL/DOM/Schema/Node.pm @ 134:44977efed303

Significant performance optimizations Fixed recursion problems due converting objects to JSON Added cache support for the templates Added discovery feature for the web methods
author wizard
date Mon, 21 Jun 2010 02:39:53 +0400
parents 196bf443b5e1
children e6447ad85cb4
line wrap: on
line source

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

use base qw(IMPL::DOM::Node);
use IMPL::Class::Property;
use IMPL::DOM::Property qw(_dom);
use IMPL::Class::Property::Direct;

BEGIN {
    public _direct property minOccur => prop_all;
    public _direct property maxOccur => prop_all;
    public _direct property type => prop_all;
    public _direct property name => prop_all;
    public _direct property display => prop_all;
    public _direct property display_no => prop_all;
    public _direct property display_blame => prop_all;
}

our %CTOR = (
    'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args}
);

sub CTOR {
    my ($this,%args) = @_;
    
    $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1;
    $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1;
    $this->{$type} = $args{type};
    $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name');
    $this->{$display} = $args{display};
    $this->{$display_no} = $args{display_no};
    $this->{$display_blame} = $args{display_blame};
}

sub Validate {
    my ($this,$node) = @_;
    
    if (my $schemaType = $this->{$type} ? $this->document->resolveType($this->{$type}) : undef ) {
        my @errors = $schemaType->Validate($node,{Source => $this});
        return @errors;
    } else {
        return ();
    }
}

sub inflateValue {
	$_[1];
}

sub inflator { undef }

sub qname {
    $_[0]->nodeName.'[name='.$_[0]->{$name}.']';
}

1;

__END__
=pod

=head1 SYNOPSIS

package SchemaEntity;
use base qw(IMPL::DOM::Schema::Node);

sub Validate {
    my ($this,$node) = @_;
}

=head1 DESCRIPTION

Базовый класс для элементов схемы.

=cut