diff Lib/IMPL/DOM/Schema.pm @ 34:a8086f85a571

Dom Builder
author Sergey
date Mon, 16 Nov 2009 18:39:25 +0300
parents 7f00786f8210
children c2e7f7c96bcd
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm	Mon Nov 09 16:49:39 2009 +0300
+++ b/Lib/IMPL/DOM/Schema.pm	Mon Nov 16 18:39:25 2009 +0300
@@ -23,12 +23,20 @@
 
 BEGIN {
     private _direct property _TypesMap => prop_all;
+    public _direct property BaseSchemas => prop_get | owner_set;
+    private _direct property _Validators => prop_all;
 }
 
 sub resolveType {
     $_[0]->{$_TypesMap}->{$_[1]};
 }
 
+#sub Create {
+#    my ($this,$nodeName,$class,$refArgs) = @_;
+    
+#    goto &SUPER::Create unless $class eq 'IMPL::DOM::Schema::Validator'
+#}
+
 sub Process {
     my ($this) = @_;
     
@@ -41,7 +49,7 @@
     if ( my ($schemaNode) = $this->selectNodes(sub { $_[0]->name eq $node->nodeName })) {
         $schemaNode->Validate($node);
     } else {
-        return IMPL::DOM::Schema::ValidationError(Message=> "A specified document doesn't match the schema");
+        return new IMPL::DOM::Schema::ValidationError(Message=> "A specified document doesn't match the schema");
     }
 }
 
@@ -99,7 +107,7 @@
                     IMPL::DOM::Schema::Node->new(name => 'NodeSet', type => 'NodeSet'),
                     IMPL::DOM::Schema::Node->new(name => 'NodeList',type => 'NodeList'),
                 ),
-                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator')
             ),
             new IMPL::DOM::Schema::Property(name => 'type')
         ),
@@ -109,18 +117,24 @@
                     IMPL::DOM::Schema::Node->new(name => 'NodeSet', type => 'NodeSet'),
                     IMPL::DOM::Schema::Node->new(name => 'NodeList',type => 'NodeList'),
                 ),
-                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator')
             ),
             new IMPL::DOM::Schema::Property(name => 'name')
         ),
         IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', nativeType => 'IMPL::DOM::Schema::SimpleType')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
-                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator')
             ),
             new IMPL::DOM::Schema::Property(name => 'type')
         ),
         IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange(
             IMPL::DOM::Schema::NodeSet->new()->appendRange(
+                IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator')
+            ),
+            new IMPL::DOM::Schema::Property(name => 'name')
+        ),
+        IMPL::DOM::Schema::ComplexType->new(type => 'Validator', nativeType => 'IMPL::DOM::Schema::Validator')->appendRange(
+            IMPL::DOM::Schema::NodeList->new()->appendRange(
                 IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
             ),
             new IMPL::DOM::Schema::Property(name => 'name')
@@ -185,12 +199,11 @@
         </NodeSet>
     </ComplexType>
     
-    
     <ComplexType type="ComplexType">
         <NodeList>
             <Node name="NodeSet" type="NodeContainer" minOcuur=0/>
             <Node name="NodeList" type="NodeContainer" minOccur=0/>
-            <AnyNode minOccur="0" maxOccur="unbounded"/>
+            <AnyNode minOccur="0" maxOccur="unbounded"  type="Validator"/>
         </NodeList>
     </ComplexType>
     
@@ -198,18 +211,24 @@
         <NodeList>
             <Node name="NodeSet" type="NodeContainer" minOcuur=0/>
             <Node name="NodeList" type="NodeContainer" minOccur=0/>
-            <AnyNode minOccur="0" maxOccur="unbounded"/>
+            <AnyNode minOccur="0" maxOccur="unbounded"  type="Validator"/>
         </NodeList>
     </ComplexType>
     
     <ComplexType type="SimpleNode">
         <NodeSet>
-            <AnyNode minOccur=0 maxOccur="unbounded"/>
+            <AnyNode minOccur=0 maxOccur="unbounded" type="Validator"/>
         </NodeSet>
     </ComplexType>
     
     <ComplexType type="SimpleType">
         <NodeSet>
+            <AnyNode minOccur=0 maxOccur="unbounded" type="Validator"/>
+        </NodeSet>
+    </ComplexType>
+    
+    <ComplexType type="Validator">
+        <NodeSet>
             <AnyNode minOccur=0 maxOccur="unbounded"/>
         </NodeSet>
     </ComplexType>