diff Lib/IMPL/DOM/Navigator/Builder.pm @ 103:c289ed9662ca

Schema beta 2 More strict validation, support for inflating a simple nodes and properties
author wizard
date Fri, 07 May 2010 18:17:40 +0400
parents cf3b6ef2be22
children 196bf443b5e1
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator/Builder.pm	Fri May 07 08:05:23 2010 +0400
+++ b/Lib/IMPL/DOM/Navigator/Builder.pm	Fri May 07 18:17:40 2010 +0400
@@ -11,7 +11,7 @@
     private _direct property _schemaNavi => prop_all;
     private _direct property _nodesPath => prop_all;
     private _direct property _nodeCurrent => prop_all;
-    private _direct property _docClass => prop_all
+    private _direct property _docClass => prop_all;
     public _direct property Document => prop_get | owner_set;
 }
 
@@ -27,6 +27,7 @@
     
     if (my $schemaNode = $this->{$_schemaNavi}->NavigateName($nodeName)) {
         my $class = $schemaNode->can('nativeType') ? $schemaNode->nativeType : 'IMPL::DOM::Node';
+        $this->inflateProperties($schemaNode,\%props);
         
         my $node;
         if (! $this->{$Document}) {
@@ -42,11 +43,31 @@
         
         return $node;
     } else {
-    	warn $nodeName;
         die new IMPL::InvalidOperationException("The specified node is undefined", $nodeName);
     }
 }
 
+sub inflateProperties {
+	my ($this,$schemaNode,$refProps) = @_;
+	
+	$refProps->{$_->name} = $_->inflator->new($refProps->{$_->name})
+		foreach $schemaNode->selectNodes(
+			sub {
+				$_->nodeName eq 'Property' and exists $refProps->{$_->name} and $_->inflator 
+			}
+		);
+}
+
+sub inflateValue {
+	my ($this,$value) = @_;
+	my $schemaNode = $this->{$_schemaNavi}->Current;
+	if ($schemaNode->can('inflator') and my $inflator = $schemaNode->inflator) {
+		return $inflator->new($value);
+	} else {
+		return $value;
+	}
+}
+
 sub Back {
     my ($this) = @_;