comparison Lib/IMPL/DOM/Schema/SimpleType.pm @ 104:196bf443b5e1

DOM::Schema RC0 inflators support, validation and some other things, Minor and major fixes almost for everything. A 'Source' property of the ValidationErrors generated from a NodeSet or a NodeList is subject to change in the future.
author wizard
date Tue, 11 May 2010 02:42:59 +0400
parents c289ed9662ca
children a6e9759ff88a
comparison
equal deleted inserted replaced
103:c289ed9662ca 104:196bf443b5e1
23 ); 23 );
24 24
25 sub CTOR { 25 sub CTOR {
26 my ($this,%args) = @_; 26 my ($this,%args) = @_;
27 27
28 $this->{$nativeType} = $args{nativeType}; 28 $this->{$nativeType} = $args{nativeType} if $args{nativeType};
29 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%Node.path%' is expected to be %Schema.nativeType%"; 29 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%Node.path%' is expected to be %Schema.nativeType%";
30 } 30 }
31 31
32 sub Validate { 32 sub Validate {
33 my ($this, $node) = @_; 33 my ($this, $node, $ctx) = @_;
34 34
35 if ($this->{$nativeType}) { 35 if ($this->{$nativeType}) {
36 return new IMPL::DOM::Schema::ValidationError( 36 return new IMPL::DOM::Schema::ValidationError(
37 Node => $node, 37 Node => $node,
38 Source => $this, 38 Source => $ctx && $ctx->{Source} || $this,
39 Schema => $this, 39 Schema => $this,
40 Message => $this->messageWrongType 40 Message => $this->messageWrongType
41 ) unless $node->isa($this->{$nativeType}); 41 ) unless $node->isa($this->{$nativeType});
42 } 42 }
43 return $this->SUPER::Validate($node); 43 return $this->SUPER::Validate($node);