Mercurial > pub > Impl
view Lib/IMPL/DOM/Schema/ComplexType.pm @ 122:a7efb3117295
Fixed bug in IMPL::DOM::Navigator::selectNodes
Fixed bug in IMPL::DOM::Node::selectNodes
renamed operator 'type' to 'typeof' in IMPL::Object::Abstract
A proper implementation of the IMPL::DOM::Node::nodeProperty and a related changes in the IMPL::DOM::Property module, now the last is very simple.
author | wizard |
---|---|
date | Tue, 08 Jun 2010 20:12:45 +0400 |
parents | a6e9759ff88a |
children | e30bdd040fe3 |
line wrap: on
line source
package IMPL::DOM::Schema::ComplexType; use strict; use warnings; use base qw(IMPL::DOM::Schema::ComplexNode); use IMPL::Class::Property; use IMPL::Class::Property::Direct; BEGIN { public _direct property nativeType => prop_get; public _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'; %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 && $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;