24
|
1 package IMPL::DOM::Schema::SwitchNode;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use base qw(IMPL::DOM::Schema::AnyNode);
|
|
6 use IMPL::Class::Property;
|
|
7 require IMPL::DOM::Schema::ValidationError;
|
|
8
|
|
9 our %CTOR = (
|
|
10 'IMPL::DOM::Schema::AnyNode' => sub {
|
|
11 my %args = @_;
|
|
12
|
|
13 $args{nodeName} ||= 'SwitchNode';
|
|
14
|
|
15 %args;
|
|
16 }
|
|
17 );
|
|
18
|
|
19 BEGIN {
|
|
20 public property messageNoMatch => prop_all;
|
|
21 }
|
|
22
|
|
23 sub CTOR {
|
|
24 my ($this,%args) = @_;
|
|
25
|
|
26 $this->messageNoMatch($args{messageNoMatch} || 'A node %Node.nodeName% isn\'t expected in the %Node.parentNode.path%');
|
|
27 }
|
|
28
|
|
29 sub Validate {
|
|
30 my ($this,$node) = @_;
|
|
31
|
|
32 if ( my ($schema) = $this->selectNodes(sub {$_[0]->name eq $node->nodeName} ) ) {
|
|
33 return $schema->Validate($node);
|
|
34 } else {
|
|
35 return new IMPL::DOM::Schema::ValidationError(
|
|
36 Node => $node,
|
|
37 Source => $this,
|
|
38 Message => $this->messageNoMatch
|
|
39 );
|
|
40 }
|
|
41 }
|
|
42
|
|
43 1;
|
|
44
|
|
45 __END__
|
|
46
|
|
47 =pod
|
|
48
|
|
49 =head1 DESCRIPTION
|
|
50
|
|
51 , , .
|
|
52 C<IMPL::DOM::Schema::AnyNode>.
|
|
53
|
|
54 =cut
|