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

DOM схема, требует переработки в части схемы для описания схем. Автоверификация не проходит
author Sergey
date Fri, 11 Sep 2009 16:30:39 +0400
parents 818c74b038ae
children 267460284fb3
comparison
equal deleted inserted replaced
18:818c74b038ae 19:1ca530e5c9c5
1 package IMPL::DOM::Schema; 1 package IMPL::DOM::Schema;
2 use strict; 2 use strict;
3 use warnings; 3 use warnings;
4
5 require IMPL::DOM::Schema::ComplexNode;
6 require IMPL::DOM::Schema::ComplexType;
7 require IMPL::DOM::Schema::SimpleNode;
8 require IMPL::DOM::Schema::SimpleType;
9 require IMPL::DOM::Schema::Node;
10 require IMPL::DOM::Schema::AnyNode;
11 require IMPL::DOM::Schema::NodeList;
12 require IMPL::DOM::Schema::NodeSet;
4 13
5 use base qw(IMPL::DOM::Document); 14 use base qw(IMPL::DOM::Document);
6 use IMPL::Class::Property; 15 use IMPL::Class::Property;
7 use IMPL::Class::Property::Direct; 16 use IMPL::Class::Property::Direct;
8 17
10 19
11 BEGIN { 20 BEGIN {
12 private _direct property _TypesMap => prop_all; 21 private _direct property _TypesMap => prop_all;
13 } 22 }
14 23
15 sub ResoveType { 24 sub resolveType {
16 $_[0]->{$_TypesMap}->{$_[1]}; 25 $_[0]->{$_TypesMap}->{$_[1]};
17 } 26 }
18 27
19 sub Process { 28 sub Process {
20 my ($this) = @_; 29 my ($this) = @_;
21 30
22 $this->{$_TypesMap} = { map { $_->type, $_ } grep {$_->isa('IMPL::DOM::Schema::Type')} @{$this->childNodes} }; 31 $this->{$_TypesMap} = { map { $_->type, $_ } grep {$_->isa('IMPL::DOM::Schema::Type')} @{$this->childNodes} };
23 } 32 }
24 33
34 sub Validate {
35 my ($this,$node) = @_;
36
37 #return IMPL::DOM::Schema::NodeSet->new()->appendRange(@{$this->childNodes})->Validate($node);
38 }
39
40 my $schema;
41
25 sub MetaSchema { 42 sub MetaSchema {
26 my $schema = new IMPL::DOM::Schema(nodeName => 'schema'); 43
44 return $schema if $schema;
45
46 $schema = new IMPL::DOM::Schema(nodeName => 'schema');
27 47
28 $schema->appendRange( 48 $schema->appendRange(
29 IMPL::DOM::Schema::ComplexNode->new(nodeName => 'schema')->appendRange( 49 IMPL::DOM::Schema::ComplexNode->new(nodeName => 'schema')->appendRange(
30 IMPL::DOM::Schema::NodeSet->new()->appendRange( 50 IMPL::DOM::Schema::NodeSet->new()->appendRange(
31 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), 51 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'),
32 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexType', type => 'ComplexType', minOccur => 0, maxOccur=>'unbounded'), 52 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexType', type => 'ComplexType', minOccur => 0, maxOccur=>'unbounded'),
33 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'), 53 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'),
34 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleType', type => 'SimpleType', minOccur => 0, maxOccur=>'unbounded'), 54 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleType', type => 'SimpleType', minOccur => 0, maxOccur=>'unbounded'),
35 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'), 55 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
36 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Include', minOccur => 0, maxOccur=>'unbounded') 56 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Include', minOccur => 0, maxOccur=>'unbounded')
37 ) 57 ),
38 ), 58 ),
39 IMPL::DOM::Schema::ComplexType->new(type => 'NodeSet', native => 'IMPL::DOM::Schema::NodeSet')->appendRange( 59 IMPL::DOM::Schema::ComplexType->new(type => 'NodeSet', nativeType => 'IMPL::DOM::Schema::NodeSet')->appendRange(
40 IMPL::DOM::Schema::NodeSet->new()->appendRange( 60 IMPL::DOM::Schema::NodeSet->new()->appendRange(
41 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), 61 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'),
42 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'), 62 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'),
43 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'), 63 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
44 ) 64 )
45 ), 65 ),
46 IMPL::DOM::Schema::ComplexType->new(type => 'NodeList', native => 'IMPL::DOM::Schema::NodeList')->appendRange( 66 IMPL::DOM::Schema::ComplexType->new(type => 'NodeList', nativeType => 'IMPL::DOM::Schema::NodeList')->appendRange(
47 IMPL::DOM::Schema::NodeSet->new()->appendRange( 67 IMPL::DOM::Schema::NodeSet->new()->appendRange(
48 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), 68 IMPL::DOM::Schema::Node->new(nodeName => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'),
49 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'), 69 IMPL::DOM::Schema::Node->new(nodeName => 'SimpleNode', type => 'SimpleNode', minOccur => 0, maxOccur=>'unbounded'),
50 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'), 70 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur=>'unbounded'),
51 ) 71 )
52 ), 72 ),
53 IMPL::DOM::Schema::ComplexType->new(type => 'ComplexType', native => 'IMPL::DOM::Schema::ComplexType')->appendRange( 73 IMPL::DOM::Schema::ComplexType->new(type => 'ComplexType', nativeType => 'IMPL::DOM::Schema::ComplexType')->appendRange(
54 IMPL::DOM::Schema::NodeList->new()->appendRange( 74 IMPL::DOM::Schema::NodeList->new()->appendRange(
55 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'), 75 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'),
56 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'), 76 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'),
57 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded') 77 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded')
58 ) 78 )
59 ), 79 ),
60 IMPL::DOM::Schema::ComplexType->new(type => 'ComplexNode', native => 'IMPL::DOM::Schema::ComplexNode')->appendRange( 80 IMPL::DOM::Schema::ComplexType->new(type => 'ComplexNode', nativeType => 'IMPL::DOM::Schema::ComplexNode')->appendRange(
61 IMPL::DOM::Schema::NodeList->new()->appendRange( 81 IMPL::DOM::Schema::NodeList->new()->appendRange(
62 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'), 82 IMPL::DOM::Schema::Node->new(nodeName => 'NodeSet', minOccur => 0, type => 'NodeSet'),
63 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'), 83 IMPL::DOM::Schema::Node->new(nodeName => 'NodeList', minOccur => 0, type => 'NodeSet'),
64 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded') 84 IMPL::DOM::Schema::SimpleNode->new(nodeName => 'Node', minOccur => 0, maxOccur => 'unbounded')
65 ) 85 )
66 ), 86 ),
67 IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', native => 'IMPL::DOM::Schema::SimpleType')->appendRange( 87 IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', nativeType => 'IMPL::DOM::Schema::SimpleType')->appendRange(
68 IMPL::DOM::Schema::NodeSet->new()->appendRange( 88 IMPL::DOM::Schema::NodeSet->new()->appendRange(
69 IMPL::DOM::Schema::AnyNode(maxOccur => 'unbounded', minOccur => 0) 89 IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
70 ) 90 )
71 ), 91 ),
72 IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', native => 'IMPL::DOM::Schema::SimpleNode')->appendRange( 92 IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange(
73 IMPL::DOM::Schema::NodeSet->new()->appendRange( 93 IMPL::DOM::Schema::NodeSet->new()->appendRange(
74 IMPL::DOM::Schema::AnyNode(maxOccur => 'unbounded', minOccur => 0) 94 IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0)
75 ) 95 )
76 ) 96 )
77 ); 97 );
78 98
79 $schema->Process; 99 $schema->Process;