annotate Lib/IMPL/DOM/Schema/ComplexType.pm @ 388:648dfaf642e0

DOM refactoring, removed inflators from DOM Schema, DOM validation - in progress
author cin
date Tue, 11 Feb 2014 20:22:01 +0400
parents 4ddb27ff4a0b
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: 20
diff changeset
1 package IMPL::DOM::Schema::ComplexType;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
4
388
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
5 use IMPL::declare {
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
6 base => [
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
7 'IMPL::DOM::Schema::ComplexNode' => sub {
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
8 my %args = @_;
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
9 $args{nodeName} ||= 'ComplexType';
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
10 $args{minOccur} = 0;
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
11 $args{maxOccur} = 'unbounded';
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
12 $args{name} ||= 'ComplexType';
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
13 delete @args{qw(nativeType messageWrongType)};
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
14 %args
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
15 }
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
16 ],
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
17 props => [
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
18 nativeType => { get => 1, set => 1, direct => 1, dom => 1 },
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
19 messageWrongType => { get => 1, set => 1, direct => 1, dom => 1 }
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
20 ]
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
21 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
22
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
23 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
24 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
26 $this->{$nativeType} = $args{nativeType};
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
27 $this->{$messageWrongType} = $args{messageWrongType} || "A complex node '%node.path%' is expected to be %schema.nativeType%";
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
28 }
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
29
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
30 sub Validate {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
31 my ($this, $node,$ctx) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
32
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
33 if ($this->{$nativeType}) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
34 return new IMPL::DOM::Schema::ValidationError(
236
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
35 node => $node,
388
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
36 schemaNode => $ctx->{schemaNode} || $this,
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
37 schemaType => $this,
236
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
38 message => $this->messageWrongType
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
39 ) unless $node->isa($this->{$nativeType});
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
40 }
388
648dfaf642e0 DOM refactoring,
cin
parents: 278
diff changeset
41
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
42 return $this->SUPER::Validate($node,$ctx);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
43 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
44
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
45 sub qname {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
46 $_[0]->nodeName.'[type='.$_[0]->type.']';
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
47 }
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
48
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
50 1;