diff Lib/IMPL/DOM/Schema/SwitchNode.pm @ 389:5aff94ba842f

DOM Schema refactoring complete
author cin
date Wed, 12 Feb 2014 13:36:24 +0400
parents b8c724f6de36
children
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/SwitchNode.pm	Tue Feb 11 20:22:01 2014 +0400
+++ b/Lib/IMPL/DOM/Schema/SwitchNode.pm	Wed Feb 12 13:36:24 2014 +0400
@@ -2,24 +2,24 @@
 use strict;
 use warnings;
 
-use parent qw(IMPL::DOM::Schema::AnyNode);
-use IMPL::Class::Property;
-require IMPL::DOM::Schema::ValidationError;
-use IMPL::DOM::Property qw(_dom);
-
-our %CTOR = (
-    'IMPL::DOM::Schema::AnyNode' => sub {
-        my %args = @_;
-        
-        $args{nodeName} ||= 'SwitchNode';
-        
-        %args;
-    }
-);
-
-BEGIN {
-    public _dom property messageNoMatch => prop_all;
-}
+use IMPL::declare {
+	require => {
+		Label => 'IMPL::DOM::Schema::Label',
+		ValidationError => 'IMPL::DOM::Schema::ValidationError'
+	},
+	base => [
+		'IMPL::DOM::Schema::AnyNode' => sub {
+	        my %args = @_;
+	        
+	        $args{nodeName} ||= 'SwitchNode';
+	        
+	        %args;
+	    }
+	],
+	props => [
+		messageNoMatch => { get => 1, set => 1, dom => 1 } 
+	]
+};
 
 sub CTOR {
     my ($this,%args) = @_;
@@ -31,16 +31,25 @@
     my ($this,$node,$ctx) = @_;
         
     if ( my ($schema) = $this->selectNodes(sub {$_[0]->name eq $node->nodeName} ) ) {
-        return $schema->Validate($node);
+        return $schema->Validate($node,$ctx);
     } else {
-        return new IMPL::DOM::Schema::ValidationError(
+        return ValidationError->new(
             node => $node,
-            source => $this,
-            message => $this->messageNoMatch
+            message => $this->_MakeLabel($this->messageNoMatch)
         );
     }
 }
 
+sub _MakeLabel {
+	my ($this,$label) = @_;
+	
+	if ($label =~ /^ID:(\w+)$/) {
+		return Label->new($this->document->stringMap, $1);
+	} else {
+		return $label;
+	}
+}
+
 1;
 
 __END__