changeset 246:2746a8e5a6c4

Fixed regressions in DOM due previous refactorings Fixed ObjectToDOM transformation to handle a schema with mixed node types
author sergey
date Tue, 30 Oct 2012 01:17:31 +0400
parents 7c517134c42f
children 2270de2469ff
files Lib/IMPL/DOM/Navigator/Builder.pm Lib/IMPL/DOM/Navigator/SchemaNavigator.pm Lib/IMPL/DOM/Schema.pm Lib/IMPL/DOM/Transform/ObjectToDOM.pm
diffstat 4 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Navigator/Builder.pm	Mon Oct 29 03:15:22 2012 +0400
+++ b/Lib/IMPL/DOM/Navigator/Builder.pm	Tue Oct 30 01:17:31 2012 +0400
@@ -102,11 +102,11 @@
     my $result = eval { $nodeSchema->inflateValue($value) };
     if (my $e=$@) {
         $this->BuildErrors->Append(new IMPL::DOM::Schema::ValidationError(
-            Schema =>  $nodeSchema,
-            Node => $node,
-            Error => $e,
-            Message => $nodeSchema->messageInflateError,
-            Source => $this->{$_schemaNavi}->SourceSchemaNode
+            schema =>  $nodeSchema,
+            node => $node,
+            error => $e,
+            message => $nodeSchema->messageInflateError,
+            source => $this->{$_schemaNavi}->SourceSchemaNode
         ));
         return $value;
     } else {
--- a/Lib/IMPL/DOM/Navigator/SchemaNavigator.pm	Mon Oct 29 03:15:22 2012 +0400
+++ b/Lib/IMPL/DOM/Navigator/SchemaNavigator.pm	Tue Oct 30 01:17:31 2012 +0400
@@ -2,7 +2,6 @@
 use strict;
 use warnings;
 
-use parent qw(IMPL::DOM::Navigator);
 use IMPL::Class::Property;
 use IMPL::Class::Property::Direct;
 
@@ -10,7 +9,11 @@
 require IMPL::DOM::Schema::NodeSet;
 require IMPL::DOM::Schema::AnyNode;
 
-__PACKAGE__->PassThroughArgs;
+use IMPL::declare {
+    base => [
+        'IMPL::DOM::Navigator' => '@_'
+    ]
+};
 
 BEGIN {
     public _direct property Schema => prop_get;
@@ -20,9 +23,9 @@
 sub CTOR {
     my ($this,$schema) = @_;
     
-    $this->{$Schema} = $schema;
+    $this->{$Schema} = $schema->isa('IMPL::DOM::Schema::ComplexNode') ? $schema->document : $schema;
     
-    die new IMPL::InvalidArgumentException("A schema object is required") unless $schema->isa('IMPL::DOM::Schema') || $schema->isa('IMPL::DOM::Schema::ComplexNode');
+    die new IMPL::InvalidArgumentException("A schema object is required") unless ref $this->{$Schema} && eval { $this->{$Schema}->isa('IMPL::DOM::Schema') };
 }
 
 my $schemaAnyNode = IMPL::DOM::Schema::ComplexType->new(type => '::AnyNodeType', nativeType => 'IMPL::DOM::ComplexNode')->appendRange(
--- a/Lib/IMPL/DOM/Schema.pm	Mon Oct 29 03:15:22 2012 +0400
+++ b/Lib/IMPL/DOM/Schema.pm	Tue Oct 30 01:17:31 2012 +0400
@@ -38,7 +38,7 @@
 my $validatorLoader = Loader->new(prefix => Validator, verifyNames => 1);
 
 sub resolveType {
-    $_[0]->{$_TypesMap}->{$_[1]};
+    $_[0]->{$_TypesMap}->{$_[1]} or die IMPL::KeyNotFoundException->new($_[1]);
 }
 
 sub CTOR {
--- a/Lib/IMPL/DOM/Transform/ObjectToDOM.pm	Mon Oct 29 03:15:22 2012 +0400
+++ b/Lib/IMPL/DOM/Transform/ObjectToDOM.pm	Tue Oct 30 01:17:31 2012 +0400
@@ -24,10 +24,14 @@
     ]
 };
 
+use constant {
+    SchemaNode => 'IMPL::DOM::Schema::Node'
+};
+
 sub CTOR {
     my ($this,$docName,$docSchema,$transforms) = @_;
     
-    my $docNodeSchema = $docSchema->selectSingleNode(sub { $_->name eq $docName })
+    my $docNodeSchema = $docSchema->selectSingleNode(sub { $_->isa(SchemaNode) and $_->name eq $docName } )
         or die OperationException->new("Can't find a node schema for the document '$docName'");
        
     my $docClass = ($docNodeSchema->can('nativeType') ? $docNodeSchema->nativeType : undef) || 'IMPL::DOM::Document';