49
|
1 package IMPL::DOM::Schema::ComplexType;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use base qw(IMPL::DOM::Schema::ComplexNode);
|
|
6 use IMPL::Class::Property;
|
|
7 use IMPL::Class::Property::Direct;
|
|
8
|
|
9 BEGIN {
|
|
10 public _direct property nativeType => prop_get;
|
103
|
11 public _direct property messageWrongType => prop_get;
|
49
|
12 }
|
|
13
|
|
14 our %CTOR = (
|
|
15 'IMPL::DOM::Schema::ComplexNode' => sub {
|
|
16 my %args = @_;
|
|
17 $args{nodeName} ||= 'ComplexType';
|
|
18 $args{minOccur} = 0;
|
|
19 $args{maxOccur} = 'unbounded';
|
|
20 $args{name} ||= 'ComplexType';
|
124
|
21 delete @args{qw(nativeType messageWrongType)};
|
49
|
22 %args
|
|
23 }
|
|
24 );
|
|
25
|
|
26 sub CTOR {
|
|
27 my ($this,%args) = @_;
|
|
28
|
|
29 $this->{$nativeType} = $args{nativeType};
|
103
|
30 $this->{$messageWrongType} = $args{messageWrongType} || "A complex node '%Node.path%' is expected to be %Schema.nativeType%";
|
|
31 }
|
|
32
|
|
33 sub Validate {
|
105
|
34 my ($this, $node,$ctx) = @_;
|
103
|
35
|
|
36 if ($this->{$nativeType}) {
|
|
37 return new IMPL::DOM::Schema::ValidationError(
|
|
38 Node => $node,
|
125
|
39 Source => $ctx->{Source} || $this,
|
103
|
40 Schema => $this,
|
|
41 Message => $this->messageWrongType
|
|
42 ) unless $node->isa($this->{$nativeType});
|
|
43 }
|
105
|
44 return $this->SUPER::Validate($node,$ctx);
|
49
|
45 }
|
|
46
|
102
|
47 sub qname {
|
103
|
48 $_[0]->nodeName.'[type='.$_[0]->type.']';
|
102
|
49 }
|
|
50
|
49
|
51
|
|
52 1;
|