diff Lib/IMPL/DOM/Schema/SimpleNode.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 e30bdd040fe3
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/SimpleNode.pm	Fri May 07 18:17:40 2010 +0400
+++ b/Lib/IMPL/DOM/Schema/SimpleNode.pm	Tue May 11 02:42:59 2010 +0400
@@ -8,6 +8,7 @@
 
 BEGIN {
 	public _direct property inflator => prop_get;
+	public _direct property messageInflateError => prop_get;
 }
 
 our %CTOR = (
@@ -17,13 +18,28 @@
 sub CTOR {
 	my ($this,%args) = @_;
 	
-	$this->{$inflator} = $args{inflator} if $args{iflator};
+	$this->{$inflator} = $args{inflator} if $args{inflator};
+	$this->{$messageInflateError} = $args{messageInflateError} || 'Failed to inflate nodeValue %Node.path%: %Error%';
 }
 
 sub Validate {
-    my ($this,$node) = @_;
+    my ($this,$node,$ctx) = @_;
+    
+    my @result;
+    
+    push @result, $_->Validate($node,$ctx) foreach $this->childNodes;
     
-    return map $_->Validate($node), @{$this->childNodes};
+    return @result;
+}
+
+sub inflateValue {
+	my ($this,$value) = @_;
+	
+	if ( my $inflator = $this->inflator ) {
+		return $inflator->new($value);
+	} else {
+		return $value;
+	}
 }
 
 1;