Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/Node.pm @ 154:eb478083f72b
Url support
author | wizard |
---|---|
date | Thu, 30 Sep 2010 02:13:05 +0400 |
parents | 1e7f03414b65 |
children | 76515373dac0 |
rev | line source |
---|---|
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 { | |
152 | 11 public _dom _direct property minOccur => prop_all; |
12 public _dom _direct property maxOccur => prop_all; | |
13 public _dom _direct property type => prop_all; | |
14 public _dom _direct property name => prop_all; | |
15 public _dom _direct property display => prop_all; | |
16 public _dom _direct property display_no => prop_all; | |
17 public _dom _direct property display_blame => prop_all; | |
49 | 18 } |
19 | |
20 our %CTOR = ( | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
21 'IMPL::DOM::Node' => sub { |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
22 my %args = @_; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
23 delete @args{qw( |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
24 minOccur |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
25 maxOccur |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
26 type |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
27 name |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
28 display |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
29 display_no |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
30 display_blame |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
31 )} ; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
32 $args{nodeName} ||= 'Node'; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
33 %args |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
34 } |
49 | 35 ); |
36 | |
37 sub CTOR { | |
38 my ($this,%args) = @_; | |
39 | |
40 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1; | |
41 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1; | |
42 $this->{$type} = $args{type}; | |
43 $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name'); | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
44 $this->{$display} = $args{display} if $args{display}; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
45 $this->{$display_no} = $args{display_no} if $args{display}; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
46 $this->{$display_blame} = $args{display_blame} if $args{display}; |
49 | 47 } |
48 | |
49 sub Validate { | |
50 my ($this,$node) = @_; | |
51 | |
52 if (my $schemaType = $this->{$type} ? $this->document->resolveType($this->{$type}) : undef ) { | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
53 my @errors = $schemaType->Validate($node,{Source => $this}); |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
54 return @errors; |
49 | 55 } else { |
56 return (); | |
57 } | |
58 } | |
59 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
60 sub inflateValue { |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
61 $_[1]; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
62 } |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
63 |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
64 sub inflator { undef } |
103 | 65 |
49 | 66 sub qname { |
67 $_[0]->nodeName.'[name='.$_[0]->{$name}.']'; | |
68 } | |
69 | |
70 1; | |
71 | |
72 __END__ | |
73 =pod | |
74 | |
75 =head1 SYNOPSIS | |
76 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
77 package SchemaEntity; |
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
78 use base qw(IMPL::DOM::Schema::Node); |
49 | 79 |
80 sub Validate { | |
81 my ($this,$node) = @_; | |
82 } | |
83 | |
84 =head1 DESCRIPTION | |
85 | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
86 Базовый класс для элементов схемы. Также позволяет объявлять узлы определенного типа. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
87 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
88 =head1 MEMBERS |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
89 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
90 =head2 PROPERTIES |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
91 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
92 =over |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
93 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
94 =item C<[get,set] minOccur> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
95 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
96 C<default: 1>. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
97 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
98 Минимальное количество повторений узла. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
99 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
100 =item C<[get,set] maxOccur> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
101 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
102 C<default: 1>. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
103 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
104 Максимальное количество повторений узла |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
105 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
106 =item C<[get,set] type> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
107 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
108 C<default: undef> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
109 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
110 Имя типа из схемы. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
111 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
112 =item C<[get,set] name> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
113 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
114 Имя узла. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
115 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
116 =item C<[get,set] display> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
117 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
118 Имя узла для отображения. |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
119 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
120 =item C<[get,set] display_no> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
121 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
122 Имя узла для отображения (родительный падеж). |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
123 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
124 =item C<[get,set] display_blame> |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
125 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
126 Имя узла для отображения (винительный падеж). |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
127 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
104
diff
changeset
|
128 =back |
49 | 129 |
130 =cut |