Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema.pm @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author | cin |
---|---|
date | Tue, 10 Apr 2012 20:08:29 +0400 |
parents | d1676be8afcc |
children | 6d8092d8ce1b |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm Tue Apr 10 08:13:22 2012 +0400 +++ b/Lib/IMPL/DOM/Schema.pm Tue Apr 10 20:08:29 2012 +0400 @@ -37,9 +37,9 @@ } sub CTOR { - my ($this,%args) = @_; - - $this->{$baseDir} = ($args{baseDir} || '.'); + my ($this,%args) = @_; + + $this->{$baseDir} = ($args{baseDir} || '.'); } sub Create { @@ -48,12 +48,12 @@ die new IMPL::Exception('Invalid node class') unless $class->isa('IMPL::DOM::Node'); if ($class->isa('IMPL::DOM::Schema::Validator')) { - $class = "IMPL::DOM::Schema::Validator::$nodeName"; - unless (eval {$class->can('new')}) { - eval "require $class; 1;"; - my $e = $@; - die new IMPL::Exception("Invalid validator",$class,$e) if $e; - } + $class = "IMPL::DOM::Schema::Validator::$nodeName"; + unless (eval {$class->can('new')}) { + eval "require $class; 1;"; + my $e = $@; + die new IMPL::Exception("Invalid validator",$class,$e) if $e; + } } return $this->SUPER::Create($nodeName,$class,$refArgs); @@ -70,43 +70,43 @@ } sub Include { - my ($this,$file) = @_; - - my $schema = $this->LoadSchema(File::Spec->catfile($this->baseDir, $file)); - - $this->appendRange( $schema->childNodes ); + my ($this,$file) = @_; + + my $schema = $this->LoadSchema(File::Spec->catfile($this->baseDir, $file)); + + $this->appendRange( $schema->childNodes ); } sub LoadSchema { - my ($this,$file) = @_; - - $file = File::Spec->rel2abs($file); - - my $class = ref $this || $this; - - my $reader = new IMPL::DOM::XMLReader( - Navigator => new IMPL::DOM::Navigator::Builder( - $class, - $class->MetaSchema - ), - SkipWhitespace => 1 - ); - - $reader->ParseFile($file); - - my $schema = $reader->Navigator->Document; - - my ($vol,$dir) = File::Spec->splitpath($file); - - $schema->baseDir($dir); - - my @errors = $class->MetaSchema->Validate($schema); - - die new IMPL::Exception("Schema is invalid",$file,map( $_->Message, @errors ) ) if @errors; - - $schema->Process; - - return $schema; + my ($this,$file) = @_; + + $file = File::Spec->rel2abs($file); + + my $class = ref $this || $this; + + my $reader = new IMPL::DOM::XMLReader( + Navigator => new IMPL::DOM::Navigator::Builder( + $class, + $class->MetaSchema + ), + SkipWhitespace => 1 + ); + + $reader->ParseFile($file); + + my $schema = $reader->Navigator->Document; + + my ($vol,$dir) = File::Spec->splitpath($file); + + $schema->baseDir($dir); + + my @errors = $class->MetaSchema->Validate($schema); + + die new IMPL::Exception("Schema is invalid",$file,map( $_->Message, @errors ) ) if @errors; + + $schema->Process; + + return $schema; } sub Validate { @@ -191,7 +191,7 @@ ), IMPL::DOM::Schema::ComplexType->new(type => 'SimpleType', nativeType => 'IMPL::DOM::Schema::SimpleType')->appendRange( IMPL::DOM::Schema::NodeList->new()->appendRange( - IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), + 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'), @@ -199,7 +199,7 @@ ), IMPL::DOM::Schema::ComplexType->new(type => 'SimpleNode', nativeType => 'IMPL::DOM::Schema::SimpleNode')->appendRange( IMPL::DOM::Schema::NodeList->new()->appendRange( - IMPL::DOM::Schema::Node->new(name => 'Property', type=>'Property', maxOccur=>'unbounded', minOccur=>0), + 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'), @@ -211,15 +211,15 @@ ) ), 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'), - new IMPL::DOM::Schema::Property(name => 'inflator', optional => 1, inflator => 'IMPL::DOM::Schema::InflateFactory') + IMPL::DOM::Schema::NodeList->new()->appendRange( + IMPL::DOM::Schema::AnyNode->new(maxOccur => 'unbounded', minOccur => 0) + ), + IMPL::DOM::Schema::Property->new(name => 'name'), + new IMPL::DOM::Schema::Property(name => 'inflator', optional => 1, inflator => 'IMPL::DOM::Schema::InflateFactory') ), IMPL::DOM::Schema::SimpleType->new(type => 'Node', nativeType => 'IMPL::DOM::Schema::Node')->appendRange( - IMPL::DOM::Schema::Property->new(name => 'name'), - IMPL::DOM::Schema::Property->new(name => 'type') + IMPL::DOM::Schema::Property->new(name => 'name'), + IMPL::DOM::Schema::Property->new(name => 'type') ), IMPL::DOM::Schema::SimpleType->new(type => 'AnyNode', nativeType => 'IMPL::DOM::Schema::AnyNode') );