Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema.pm @ 102:cf3b6ef2be22
Schema beta version
author | wizard |
---|---|
date | Fri, 07 May 2010 08:05:23 +0400 |
parents | d8dc6cad3f55 |
children | c289ed9662ca |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm Thu May 06 17:55:59 2010 +0400 +++ b/Lib/IMPL/DOM/Schema.pm Fri May 07 08:05:23 2010 +0400 @@ -36,6 +36,12 @@ $_[0]->{$_TypesMap}->{$_[1]}; } +sub CTOR { + my ($this,%args) = @_; + + $this->{$baseDir} = ($args{baseDir} || '.'); +} + sub Create { my ($this,$nodeName,$class,$refArgs) = @_; @@ -43,7 +49,6 @@ if ($class->isa('IMPL::DOM::Schema::Validator')) { $class = "IMPL::DOM::Schema::Validator::$nodeName"; - local $@; unless (eval {$class->can('new')}) { eval "require $class; 1;"; my $e = $@; @@ -67,13 +72,15 @@ sub Include { my ($this,$file) = @_; - my $schema = $this->LoadSchema($file); + my $schema = $this->LoadSchema(File::Spec->catfile($this->baseDir, $file)); $this->appendRange( $schema->childNodes ); } sub LoadSchema { - my ($this,$file,$base) = @_; + my ($this,$file) = @_; + + $file = File::Spec->rel2abs($file); my $class = ref $this || $this; @@ -84,7 +91,7 @@ ) ); - $reader->ParseFile($file) or die new IMPL::Exception("Failed to load a schema",$file); + $reader->ParseFile($file); my $schema = $reader->Navigator->Document; @@ -165,6 +172,7 @@ IMPL::DOM::Schema::Node->new(name => 'NodeSet', type => 'NodeSet'), IMPL::DOM::Schema::Node->new(name => 'NodeList',type => 'NodeList'), ), + IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') ), new IMPL::DOM::Schema::Property(name => 'type') @@ -175,18 +183,21 @@ IMPL::DOM::Schema::Node->new(name => 'NodeSet', type => 'NodeSet'), IMPL::DOM::Schema::Node->new(name => 'NodeList',type => 'NodeList'), ), + IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', 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::NodeList->new()->appendRange( + IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', 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::NodeList->new()->appendRange( + IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0, type=>'Validator') ), new IMPL::DOM::Schema::Property(name => 'name') @@ -195,6 +206,12 @@ IMPL::DOM::Schema::NodeList->new()->appendRange( IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0) ) + ), + IMPL::DOM::Schema::ComplexType->new(type => 'Property', nativeType => 'IMPL::DOM::Schema::Property' )->appendRange( + IMPL::DOM::Schema::NodeList->new()->appendRange( + IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0) + ), + IMPL::DOM::Schema::Property->new(name => 'name') ) );