annotate Lib/IMPL/DOM/Schema/SwitchNode.pm @ 319:d485467eca92

small fixes
author cin
date Wed, 15 May 2013 02:00:42 +0400
parents b8c724f6de36
children 5aff94ba842f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
1 package IMPL::DOM::Schema::SwitchNode;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
5 use parent qw(IMPL::DOM::Schema::AnyNode);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
7 require IMPL::DOM::Schema::ValidationError;
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 125
diff changeset
8 use IMPL::DOM::Property qw(_dom);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
10 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
11 'IMPL::DOM::Schema::AnyNode' => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
12 my %args = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
14 $args{nodeName} ||= 'SwitchNode';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
16 %args;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
18 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
20 BEGIN {
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 125
diff changeset
21 public _dom property messageNoMatch => prop_all;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
22 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
24 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
25 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
26
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
27 $this->messageNoMatch($args{messageNoMatch} || 'A node %node.nodeName% isn\'t expected in the %parent.path%');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
28 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
30 sub Validate {
125
a4b0a819bbda Small fixes in IMPL::DOM::Schema
wizard
parents: 49
diff changeset
31 my ($this,$node,$ctx) = @_;
a4b0a819bbda Small fixes in IMPL::DOM::Schema
wizard
parents: 49
diff changeset
32
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
33 if ( my ($schema) = $this->selectNodes(sub {$_[0]->name eq $node->nodeName} ) ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
34 return $schema->Validate($node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
35 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
36 return new IMPL::DOM::Schema::ValidationError(
236
2904da230022 DOM refactoring
sergey
parents: 180
diff changeset
37 node => $node,
2904da230022 DOM refactoring
sergey
parents: 180
diff changeset
38 source => $this,
2904da230022 DOM refactoring
sergey
parents: 180
diff changeset
39 message => $this->messageNoMatch
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
40 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
41 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
42 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
43
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
44 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
45
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
46 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
48 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
50 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
51
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
52 Представляет узел, который может быть одним из узлов, которые лежат внутри него.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
53 Это более строгий вариант C<IMPL::DOM::Schema::AnyNode>.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
55 =cut