49
|
1 package IMPL::DOM::Schema::Node;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use base qw(IMPL::DOM::Node);
|
|
6 use IMPL::Class::Property;
|
|
7 use IMPL::DOM::Property qw(_dom);
|
|
8 use IMPL::Class::Property::Direct;
|
|
9
|
|
10 BEGIN {
|
|
11 public _direct property minOccur => prop_all;
|
|
12 public _direct property maxOccur => prop_all;
|
|
13 public _direct property type => prop_all;
|
|
14 public _direct property name => prop_all;
|
|
15 }
|
|
16
|
|
17 our %CTOR = (
|
|
18 'IMPL::DOM::Node' => sub {my %args = @_; $args{nodeName} ||= 'Node'; %args}
|
|
19 );
|
|
20
|
|
21 sub CTOR {
|
|
22 my ($this,%args) = @_;
|
|
23
|
|
24 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1;
|
|
25 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1;
|
|
26 $this->{$type} = $args{type};
|
|
27 $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name');
|
|
28 }
|
|
29
|
|
30 sub Validate {
|
|
31 my ($this,$node) = @_;
|
|
32
|
|
33 if (my $schemaType = $this->{$type} ? $this->document->resolveType($this->{$type}) : undef ) {
|
|
34 return $schemaType->Validate($node);
|
|
35 } else {
|
|
36 return ();
|
|
37 }
|
|
38 }
|
|
39
|
|
40 sub qname {
|
|
41 $_[0]->nodeName.'[name='.$_[0]->{$name}.']';
|
|
42 }
|
|
43
|
|
44 1;
|
|
45
|
|
46 __END__
|
|
47 =pod
|
|
48
|
|
49 =head1 SYNOPSIS
|
|
50
|
|
51 package Restriction;
|
|
52 use base qw(IMPL::DOM::Schema::Item);
|
|
53
|
|
54 sub Validate {
|
|
55 my ($this,$node) = @_;
|
|
56 }
|
|
57
|
|
58 =head1 DESCRIPTION
|
|
59
|
|
60 Базовый класс для элементов схемы.
|
|
61
|
|
62 =cut
|