Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema.pm @ 232:5c82eec23bb6
Fixed degradations due refactoring
author | sergey |
---|---|
date | Tue, 09 Oct 2012 20:12:47 +0400 |
parents | 6d8092d8ce1b |
children | 7c517134c42f |
comparison
equal
deleted
inserted
replaced
231:ff1e8fa932f2 | 232:5c82eec23bb6 |
---|---|
15 SwitchNode => 'IMPL::DOM::Schema::SwitchNode', | 15 SwitchNode => 'IMPL::DOM::Schema::SwitchNode', |
16 Validator => 'IMPL::DOM::Schema::Validator', | 16 Validator => 'IMPL::DOM::Schema::Validator', |
17 Builder => 'IMPL::DOM::Navigator::Builder', | 17 Builder => 'IMPL::DOM::Navigator::Builder', |
18 XMLReader => 'IMPL::DOM::XMLReader', | 18 XMLReader => 'IMPL::DOM::XMLReader', |
19 InflateFactory => 'IMPL::DOM::Schema::InflateFactory', | 19 InflateFactory => 'IMPL::DOM::Schema::InflateFactory', |
20 Loader => 'Code::Loader' | 20 Loader => 'IMPL::Code::Loader' |
21 }; | 21 }; |
22 | 22 |
23 use parent qw(IMPL::DOM::Document); | 23 use parent qw(IMPL::DOM::Document); |
24 use IMPL::Class::Property; | 24 use IMPL::Class::Property; |
25 use IMPL::Class::Property::Direct; | 25 use IMPL::Class::Property::Direct; |
53 die new IMPL::Exception('Invalid node class') unless $class->isa('IMPL::DOM::Node'); | 53 die new IMPL::Exception('Invalid node class') unless $class->isa('IMPL::DOM::Node'); |
54 | 54 |
55 if ($class->isa('IMPL::DOM::Schema::Validator')) { | 55 if ($class->isa('IMPL::DOM::Schema::Validator')) { |
56 $class = $validatorLoader->GetFullName($nodeName); | 56 $class = $validatorLoader->GetFullName($nodeName); |
57 unless (eval {$class->can('new')}) { | 57 unless (eval {$class->can('new')}) { |
58 $validatorLoader->Require($nodeName); | 58 eval { |
59 $validatorLoader->Require($nodeName); | |
60 }; | |
61 my $e = $@; | |
59 die new IMPL::Exception("Invalid validator",$class,$e) if $e; | 62 die new IMPL::Exception("Invalid validator",$class,$e) if $e; |
60 } | 63 } |
61 } | 64 } |
62 | 65 |
63 return $this->SUPER::Create($nodeName,$class,$refArgs); | 66 return $this->SUPER::Create($nodeName,$class,$refArgs); |
86 | 89 |
87 $file = File::Spec->rel2abs($file); | 90 $file = File::Spec->rel2abs($file); |
88 | 91 |
89 my $class = ref $this || $this; | 92 my $class = ref $this || $this; |
90 | 93 |
91 my $reader = Reader->( | 94 my $reader = XMLReader->new( |
92 Navigator => Builder->new( | 95 Navigator => Builder->new( |
93 $class, | 96 $class, |
94 $class->MetaSchema | 97 $class->MetaSchema |
95 ), | 98 ), |
96 SkipWhitespace => 1 | 99 SkipWhitespace => 1 |
127 | 130 |
128 sub MetaSchema { | 131 sub MetaSchema { |
129 | 132 |
130 return $schema if $schema; | 133 return $schema if $schema; |
131 | 134 |
132 $schema = Schema->new(); | 135 $schema = __PACKAGE__->new(); |
133 | 136 |
134 $schema->appendRange( | 137 $schema->appendRange( |
135 ComplexNode->new(name => 'schema')->appendRange( | 138 ComplexNode->new(name => 'schema')->appendRange( |
136 NodeSet->new()->appendRange( | 139 NodeSet->new()->appendRange( |
137 Node->new(name => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), | 140 Node->new(name => 'ComplexNode', type => 'ComplexNode', minOccur => 0, maxOccur=>'unbounded'), |
197 NodeList->new()->appendRange( | 200 NodeList->new()->appendRange( |
198 Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), | 201 Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), |
199 AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') | 202 AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') |
200 ), | 203 ), |
201 Property->new(name => 'type'), | 204 Property->new(name => 'type'), |
202 Property->(name => 'inflator', optional => 1, inflator => 'IMPL::DOM::Schema::InflateFactory') | 205 Property->new(name => 'inflator', optional => 1, inflator => 'IMPL::DOM::Schema::InflateFactory') |
203 ), | 206 ), |
204 ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange( | 207 ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange( |
205 NodeList->new()->appendRange( | 208 NodeList->new()->appendRange( |
206 Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), | 209 Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), |
207 AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') | 210 AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') |