Mercurial > pub > Impl
view Lib/IMPL/DOM/Schema/SwitchNode.pm @ 151:e36ffd8c29db
Fixed major bug in conversion from a POST request to the DOM document (when instanceId == 0)
minor fixes
author | wizard |
---|---|
date | Fri, 20 Aug 2010 16:33:37 +0400 |
parents | a4b0a819bbda |
children | 1e7f03414b65 |
line wrap: on
line source
package IMPL::DOM::Schema::SwitchNode; use strict; use warnings; use base qw(IMPL::DOM::Schema::AnyNode); use IMPL::Class::Property; require IMPL::DOM::Schema::ValidationError; our %CTOR = ( 'IMPL::DOM::Schema::AnyNode' => sub { my %args = @_; $args{nodeName} ||= 'SwitchNode'; %args; } ); BEGIN { public property messageNoMatch => prop_all; } sub CTOR { my ($this,%args) = @_; $this->messageNoMatch($args{messageNoMatch} || 'A node %Node.nodeName% isn\'t expected in the %Parent.path%'); } sub Validate { my ($this,$node,$ctx) = @_; if ( my ($schema) = $this->selectNodes(sub {$_[0]->name eq $node->nodeName} ) ) { return $schema->Validate($node); } else { return new IMPL::DOM::Schema::ValidationError( Node => $node, Source => $this, Message => $this->messageNoMatch ); } } 1; __END__ =pod =head1 DESCRIPTION Представляет узел, который может быть одним из узлов, которые лежат внутри него. Это более строгий вариант C<IMPL::DOM::Schema::AnyNode>. =cut