annotate Lib/IMPL/DOM/Schema/ComplexType.pm @ 125:a4b0a819bbda

Small fixes in IMPL::DOM::Schema
author wizard
date Thu, 10 Jun 2010 17:43:51 +0400
parents e30bdd040fe3
children 1e7f03414b65
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
5 use base qw(IMPL::DOM::Schema::ComplexNode);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
7 use IMPL::Class::Property::Direct;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
9 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
10 public _direct property nativeType => prop_get;
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
11 public _direct property messageWrongType => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
12 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
14 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
15 'IMPL::DOM::Schema::ComplexNode' => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
16 my %args = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
17 $args{nodeName} ||= 'ComplexType';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
18 $args{minOccur} = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
19 $args{maxOccur} = 'unbounded';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
20 $args{name} ||= 'ComplexType';
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 105
diff changeset
21 delete @args{qw(nativeType messageWrongType)};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
22 %args
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
23 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
24 );
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 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
27 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
28
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
29 $this->{$nativeType} = $args{nativeType};
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
30 $this->{$messageWrongType} = $args{messageWrongType} || "A complex node '%Node.path%' is expected to be %Schema.nativeType%";
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
31 }
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
32
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
33 sub Validate {
105
a6e9759ff88a Fixed a validation errors parameters
wizard
parents: 103
diff changeset
34 my ($this, $node,$ctx) = @_;
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
35
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
36 if ($this->{$nativeType}) {
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
37 return new IMPL::DOM::Schema::ValidationError(
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
38 Node => $node,
125
a4b0a819bbda Small fixes in IMPL::DOM::Schema
wizard
parents: 124
diff changeset
39 Source => $ctx->{Source} || $this,
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
40 Schema => $this,
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
41 Message => $this->messageWrongType
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
42 ) unless $node->isa($this->{$nativeType});
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
43 }
105
a6e9759ff88a Fixed a validation errors parameters
wizard
parents: 103
diff changeset
44 return $this->SUPER::Validate($node,$ctx);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
45 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
46
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
47 sub qname {
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
48 $_[0]->nodeName.'[type='.$_[0]->type.']';
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
49 }
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
50
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
51
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
52 1;