diff Lib/IMPL/DOM/Schema.pm @ 381:ced5937ff21a

Custom getters/setters support method names in theirs definitions Initial support for localizable labels in DOM schemas
author cin
date Wed, 22 Jan 2014 16:56:10 +0400
parents 4ddb27ff4a0b
children 99ac2e19c0cc
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema.pm	Fri Jan 17 15:58:57 2014 +0400
+++ b/Lib/IMPL/DOM/Schema.pm	Wed Jan 22 16:56:10 2014 +0400
@@ -2,38 +2,44 @@
 use strict;
 use warnings;
 
-use IMPL::require {
-    ComplexNode => 'IMPL::DOM::Schema::ComplexNode',
-    ComplexType => 'IMPL::DOM::Schema::ComplexType',
-    SimpleNode => 'IMPL::DOM::Schema::SimpleNode',
-    SimpleType => 'IMPL::DOM::Schema::SimpleType',
-    Node => 'IMPL::DOM::Schema::Node',
-    AnyNode => 'IMPL::DOM::Schema::AnyNode',
-    NodeList => 'IMPL::DOM::Schema::NodeList',
-    NodeSet => 'IMPL::DOM::Schema::NodeSet',
-    Property => 'IMPL::DOM::Schema::Property',
-    SwitchNode => 'IMPL::DOM::Schema::SwitchNode',
-    Validator => 'IMPL::DOM::Schema::Validator',
-    Builder => 'IMPL::DOM::Navigator::Builder',
-    XMLReader => 'IMPL::DOM::XMLReader', # XMLReader references Schema
-    InflateFactory => 'IMPL::DOM::Schema::InflateFactory',
-    Loader => 'IMPL::Code::Loader'
+use File::Spec;
+use IMPL::Const qw(:prop);
+use IMPL::declare {
+	require => {
+		ComplexNode => 'IMPL::DOM::Schema::ComplexNode',
+	    ComplexType => 'IMPL::DOM::Schema::ComplexType',
+	    SimpleNode => 'IMPL::DOM::Schema::SimpleNode',
+	    SimpleType => 'IMPL::DOM::Schema::SimpleType',
+	    Node => 'IMPL::DOM::Schema::Node',
+	    AnyNode => 'IMPL::DOM::Schema::AnyNode',
+	    NodeList => 'IMPL::DOM::Schema::NodeList',
+	    NodeSet => 'IMPL::DOM::Schema::NodeSet',
+	    Property => 'IMPL::DOM::Schema::Property',
+	    SwitchNode => 'IMPL::DOM::Schema::SwitchNode',
+	    Validator => 'IMPL::DOM::Schema::Validator',
+	    Builder => 'IMPL::DOM::Navigator::Builder',
+	    XMLReader => 'IMPL::DOM::XMLReader', # XMLReader references Schema
+	    InflateFactory => 'IMPL::DOM::Schema::InflateFactory',
+	    Loader => 'IMPL::Code::Loader',
+	    StringMap => 'IMPL::Resources::StringLocaleMap'
+	},
+	base => [
+		'IMPL::DOM::Document' => sub {
+			nodeName => 'schema'
+		}
+	],
+	props => [
+		_TypesMap => PROP_RW | PROP_DIRECT,
+		baseDir => PROP_RW | PROP_DIRECT,
+		schemaName => PROP_RW | PROP_DIRECT,
+		BaseSchemas => PROP_RO | PROP_DIRECT,
+		stringMap => {
+			get => '_getStringMap',
+			direct => 1
+		}
+	]
 };
 
-use parent qw(IMPL::DOM::Document);
-use IMPL::Class::Property;
-use File::Spec;
-
-our %CTOR = (
-    'IMPL::DOM::Document' => sub { nodeName => 'schema' }
-);
-
-BEGIN {
-    private _direct property _TypesMap => prop_all;
-    public _direct property baseDir => prop_all;
-    public _direct property BaseSchemas => prop_get | owner_set;
-}
-
 my $validatorLoader = Loader->new(prefix => Validator, verifyNames => 1);
 
 #TODO rename and remove
@@ -71,6 +77,14 @@
     return $this->SUPER::Create($nodeName,$class,$refArgs);
 }
 
+sub _getStringMap {
+	my ($this) = @_;
+	
+	
+	
+	File::Spec->catdir($this->baseDir,'locale');
+}
+
 sub Process {
     my ($this) = @_;
     
@@ -108,9 +122,12 @@
     
     my $schema = $reader->Navigator->Document;
     
-    my ($vol,$dir) = File::Spec->splitpath($file);
+    my ($vol,$dir,$name) = File::Spec->splitpath($file);
+    
+    $name =~ s/\.xml$//;
     
     $schema->baseDir($dir);
+    $schema->schemaName($name);
     
     my @errors = $class->MetaSchema->Validate($schema);