Mercurial > pub > Impl
view Lib/IMPL/DOM/Schema/ComplexType.pm @ 347:3eafa6fefa9f
sync
author | cin |
---|---|
date | Mon, 30 Sep 2013 17:36:17 +0400 |
parents | 4ddb27ff4a0b |
children | 648dfaf642e0 |
line wrap: on
line source
package IMPL::DOM::Schema::ComplexType; use strict; use warnings; use parent qw(IMPL::DOM::Schema::ComplexNode); use IMPL::Class::Property; use IMPL::DOM::Property qw(_dom); BEGIN { public _dom _direct property nativeType => prop_get; public _dom _direct property messageWrongType => prop_get; } our %CTOR = ( 'IMPL::DOM::Schema::ComplexNode' => sub { my %args = @_; $args{nodeName} ||= 'ComplexType'; $args{minOccur} = 0; $args{maxOccur} = 'unbounded'; $args{name} ||= 'ComplexType'; delete @args{qw(nativeType messageWrongType)}; %args } ); sub CTOR { my ($this,%args) = @_; $this->{$nativeType} = $args{nativeType}; $this->{$messageWrongType} = $args{messageWrongType} || "A complex node '%node.path%' is expected to be %schema.nativeType%"; } sub Validate { my ($this, $node,$ctx) = @_; if ($this->{$nativeType}) { return new IMPL::DOM::Schema::ValidationError( node => $node, source => $ctx->{Source} || $this, schema => $this, message => $this->messageWrongType ) unless $node->isa($this->{$nativeType}); } return $this->SUPER::Validate($node,$ctx); } sub qname { $_[0]->nodeName.'[type='.$_[0]->type.']'; } 1;