Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema.pm @ 383:2f16f13b000c
DOM localization
author | cin |
---|---|
date | Thu, 23 Jan 2014 17:26:34 +0400 |
parents | 99ac2e19c0cc |
children | 5aff94ba842f |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm Thu Jan 23 02:35:28 2014 +0400 +++ b/Lib/IMPL/DOM/Schema.pm Thu Jan 23 17:26:34 2014 +0400 @@ -29,10 +29,10 @@ } ], props => [ - _TypesMap => PROP_RW | PROP_DIRECT, + _typesMap => PROP_RW | PROP_DIRECT, baseDir => PROP_RW | PROP_DIRECT, schemaName => PROP_RW | PROP_DIRECT, - BaseSchemas => PROP_RO | PROP_DIRECT, + baseSchemas => PROP_RO | PROP_LIST | PROP_DIRECT, stringMap => { get => '_getStringMap', direct => 1 @@ -44,7 +44,7 @@ #TODO rename and remove sub resolveType { - $_[0]->{$_TypesMap}->{$_[1]} or die IMPL::KeyNotFoundException->new($_[1]); + goto &ResolveType; } sub CTOR { @@ -55,7 +55,18 @@ # compat sub ResolveType { - goto &resolveType + my ($this,$typeName) = @_; + + my $type = $this->{$_typesMap}{$typeName}; + return $type if $type; + + foreach my $base ($this->baseSchemas) { + last if $type = $base->resolveType($typeName); + } + + die IMPL::KeyNotFoundException->new($typeName) + unless $type; + return $this->{$_typesMap}{$typeName} = $type; } sub Create { @@ -81,13 +92,13 @@ my ($this) = @_; return $this->{$stringMap} - if return $this->{$stringMap}; + if $this->{$stringMap}; my $map = StringMap->new(); if ($this->baseDir and $this->schemaName) { $map->paths( File::Spec->catdir($this->baseDir,'locale') ); - $map->name(schemaName); + $map->name( $this->schemaName ); } return $this->{$stringMap} = $map; @@ -100,7 +111,7 @@ $this->Include($_) foreach map $_->nodeProperty('source'), $this->selectNodes('Include'); # build types map - $this->{$_TypesMap} = { map { $_->type, $_ } $this->selectNodes(sub { $_[0]->nodeName eq 'ComplexType' || $_[0]->nodeName eq 'SimpleType' } ) }; + $this->{$_typesMap} = { map { $_->type, $_ } $this->selectNodes(sub { $_[0]->nodeName eq 'ComplexType' || $_[0]->nodeName eq 'SimpleType' } ) }; } sub Include { @@ -108,7 +119,7 @@ my $schema = $this->LoadSchema(File::Spec->catfile($this->baseDir, $file)); - $this->appendRange( $schema->childNodes ); + $this->baseSchemas->Append( $schema ); } sub LoadSchema {