Mercurial > pub > Impl
diff Lib/IMPL/DOM/Schema/Property.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 9dd67fa91ee3 |
children | d8dc6cad3f55 |
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Schema/Property.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/IMPL/DOM/Schema/Property.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,54 +1,54 @@ -package IMPL::DOM::Schema::Property; -use strict; -use warnings; - -use base qw(IMPL::DOM::Schema::SimpleNode); -require IMPL::DOM::Schema; -require IMPL::DOM::Node; -use IMPL::Class::Property; - -__PACKAGE__->PassThroughArgs; - -BEGIN { - public property RequiredMessage => prop_all; -} - -our %CTOR = ( - 'IMPL::DOM::Schema::SimpleNode' => sub { - my %args = @_; - - $args{maxOccur} = 1; - $args{minOccur} = delete $args{optional} ? 0 : 1; - $args{nodeName} ||= 'Property'; - - return %args; - } -); - -sub CTOR { - my ($this,%args) = @_; - - $this->RequiredMessage($args{RequiredMessage} || 'A property %Schema.name% is required in the %Node.qname%'); -} - -sub Validate { - my ($this,$node) = @_; - - if ($this->minOccur) { - my $prop = $this->name; - my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => $node->$prop() || $node->nodePropety($prop)); - - if (! $nodeProp->nodeValue) { - return new IMPL::DOM::Schema::ValidationError( - Message => $this->RequiredMessage, - Node => $node, - Schema => $this - ); - } - return $this->SUPER::Validate($nodeProp); - } else { - return (); - } -} - -1; +package IMPL::DOM::Schema::Property; +use strict; +use warnings; + +use base qw(IMPL::DOM::Schema::SimpleNode); +require IMPL::DOM::Schema; +require IMPL::DOM::Node; +use IMPL::Class::Property; + +__PACKAGE__->PassThroughArgs; + +BEGIN { + public property RequiredMessage => prop_all; +} + +our %CTOR = ( + 'IMPL::DOM::Schema::SimpleNode' => sub { + my %args = @_; + + $args{maxOccur} = 1; + $args{minOccur} = delete $args{optional} ? 0 : 1; + $args{nodeName} ||= 'Property'; + + return %args; + } +); + +sub CTOR { + my ($this,%args) = @_; + + $this->RequiredMessage($args{RequiredMessage} || 'A property %Schema.name% is required in the %Node.qname%'); +} + +sub Validate { + my ($this,$node) = @_; + + if ($this->minOccur) { + my $prop = $this->name; + my $nodeProp = new IMPL::DOM::Node(nodeName => '::property', nodeValue => $node->$prop() || $node->nodePropety($prop)); + + if (! $nodeProp->nodeValue) { + return new IMPL::DOM::Schema::ValidationError( + Message => $this->RequiredMessage, + Node => $node, + Schema => $this + ); + } + return $this->SUPER::Validate($nodeProp); + } else { + return (); + } +} + +1;