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';
|
|
21 %args
|
|
22 }
|
|
23 );
|
|
24
|
|
25 sub CTOR {
|
|
26 my ($this,%args) = @_;
|
|
27
|
|
28 $this->{$nativeType} = $args{nativeType};
|
103
|
29 $this->{$messageWrongType} = $args{messageWrongType} || "A complex node '%Node.path%' is expected to be %Schema.nativeType%";
|
|
30 }
|
|
31
|
|
32 sub Validate {
|
105
|
33 my ($this, $node,$ctx) = @_;
|
103
|
34
|
|
35 if ($this->{$nativeType}) {
|
|
36 return new IMPL::DOM::Schema::ValidationError(
|
|
37 Node => $node,
|
105
|
38 Source => $ctx && $ctx->{Source} || $this,
|
103
|
39 Schema => $this,
|
|
40 Message => $this->messageWrongType
|
|
41 ) unless $node->isa($this->{$nativeType});
|
|
42 }
|
105
|
43 return $this->SUPER::Validate($node,$ctx);
|
49
|
44 }
|
|
45
|
102
|
46 sub qname {
|
103
|
47 $_[0]->nodeName.'[type='.$_[0]->type.']';
|
102
|
48 }
|
|
49
|
49
|
50
|
|
51 1;
|