diff Lib/IMPL/DOM/Schema.pm @ 19:1ca530e5c9c5

DOM схема, требует переработки в части схемы для описания схем. Автоверификация не проходит
author Sergey
date Fri, 11 Sep 2009 16:30:39 +0400
parents 818c74b038ae
children 267460284fb3
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm	Thu Sep 10 17:42:47 2009 +0400
+++ b/Lib/IMPL/DOM/Schema.pm	Fri Sep 11 16:30:39 2009 +0400
@@ -2,6 +2,15 @@
 use strict;
 use warnings;
 
+require IMPL::DOM::Schema::ComplexNode;
+require IMPL::DOM::Schema::ComplexType;
+require IMPL::DOM::Schema::SimpleNode;
+require IMPL::DOM::Schema::SimpleType;
+require IMPL::DOM::Schema::Node;
+require IMPL::DOM::Schema::AnyNode;
+require IMPL::DOM::Schema::NodeList;
+require IMPL::DOM::Schema::NodeSet;
+
 use base qw(IMPL::DOM::Document);
 use IMPL::Class::Property;
 use IMPL::Class::Property::Direct;
@@ -12,7 +21,7 @@
     private _direct property _TypesMap => prop_all;
 }
 
-sub ResoveType {
+sub resolveType {
     $_[0]->{$_TypesMap}->{$_[1]};
 }
 
@@ -22,8 +31,19 @@
     $this->{$_TypesMap} = { map { $_->type, $_ } grep {$_->isa('IMPL::DOM::Schema::Type')} @{$this->childNodes} };
 }
 
+sub Validate {
+    my ($this,$node) = @_;
+    
+    #return IMPL::DOM::Schema::NodeSet->new()->appendRange(@{$this->childNodes})->Validate($node);
+}
+
+my $schema;
+
 sub MetaSchema {
-    my $schema = new IMPL::DOM::Schema(nodeName => 'schema');
+    
+    return $schema if $schema;
+    
+    $schema = new IMPL::DOM::Schema(nodeName => 'schema');
     
     $schema->appendRange(
         IMPL::DOM::Schema::ComplexNode->new(nodeName => 'schema')->appendRange(
@@ -34,44 +54,44 @@
                 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleType', type => 'SimpleType', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Include', minOccur => 0, maxOccur=>'unbounded')
-            )
+            ),
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'NodeSet', native => 'IMPL::DOM::Schema::NodeSet')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'NodeSet', nativeType => 'IMPL::DOM::Schema::NodeSet')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
                 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
             )
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'NodeList', native => 'IMPL::DOM::Schema::NodeList')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'NodeList', nativeType => 'IMPL::DOM::Schema::NodeList')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
                 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
             )
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'ComplexType', native => 'IMPL::DOM::Schema::ComplexType')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'ComplexType', nativeType => 'IMPL::DOM::Schema::ComplexType')->appendRange(
             IMPL::DOM::Schema::NodeList->new()->appendRange(
                 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'),
                 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded')
             )
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'ComplexNode', native => 'IMPL::DOM::Schema::ComplexNode')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'ComplexNode', nativeType => 'IMPL::DOM::Schema::ComplexNode')->appendRange(
             IMPL::DOM::Schema::NodeList->new()->appendRange(
                 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'),
                 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'),
                 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded')
             )
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', native => 'IMPL::DOM::Schema::SimpleType')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', nativeType => 'IMPL::DOM::Schema::SimpleType')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
-                IMPL::DOM::Schema::AnyNode(maxOccur => 'unbounded', minOccur => 0)
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
             )
         ),
-        IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', native => 'IMPL::DOM::Schema::SimpleNode')->appendRange(
+        IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
-                IMPL::DOM::Schema::AnyNode(maxOccur => 'unbounded', minOccur => 0)
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
             )
         )
     );