diff Lib/IMPL/DOM/Schema/Node.pm @ 20:267460284fb3

DOM Schema
author Sergey
date Tue, 22 Sep 2009 17:17:38 +0400
parents 1ca530e5c9c5
children 7f00786f8210
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/Node.pm	Fri Sep 11 16:30:39 2009 +0400
+++ b/Lib/IMPL/DOM/Schema/Node.pm	Tue Sep 22 17:17:38 2009 +0400
@@ -10,17 +10,21 @@
 BEGIN {
     public property minOccur => prop_all;
     public property maxOccur => prop_all;
-    public property type => prop_all
+    public property type => prop_all;
+    public property name => prop_all;
 }
 
-__PACKAGE__->PassThroughArgs;
+our %CTOR = (
+    'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args}
+);
 
 sub CTOR {
     my ($this,%args) = @_;
     
-    $this->minOccur(defined $args{minOcuur} ? $args{minOcuur} : 1);
+    $this->minOccur(defined $args{minOccur} ? $args{minOccur} : 1);
     $this->maxOccur(defined $args{maxOccur} ? $args{maxOccur} : 1);
     $this->type($args{type});
+    $this->name($args{name}) or die new IMPL::InvalidArgumentException('Argument is required','name');
 }
 
 sub Validate {
@@ -28,6 +32,8 @@
     
     if (my $schemaType = $this->type ? $this->rootNode->resolveType($this->type) : undef ) {
         return $schemaType->Validate($node);
+    } else {
+        return ();
     }
 }
 
@@ -47,6 +53,6 @@
 
 =head1 DESCRIPTION
 
-Базовый класс для элементов схемы. Содержит в себе базовые методы 
+Базовый класс для элементов схемы.
 
 =cut