annotate Lib/IMPL/DOM/Transform/ObjectToDOM.pm @ 393:69a1f1508696

minor security refactoring
author cin
date Fri, 14 Feb 2014 16:41:12 +0400
parents 2287c72f303a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
1 package IMPL::DOM::Transform::ObjectToDOM;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
2 use strict;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
3
2904da230022 DOM refactoring
sergey
parents:
diff changeset
4 use IMPL::Const qw(:prop :access);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
5 use IMPL::declare {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
6 require => {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
7 PropertyInfo => 'IMPL::Class::PropertyInfo',
2904da230022 DOM refactoring
sergey
parents:
diff changeset
8 Builder => 'IMPL::DOM::Navigator::Builder',
2904da230022 DOM refactoring
sergey
parents:
diff changeset
9 Exception => 'IMPL::Exception',
2904da230022 DOM refactoring
sergey
parents:
diff changeset
10 ArgumentException => '-IMPL::InvalidArgumentException',
2904da230022 DOM refactoring
sergey
parents:
diff changeset
11 OperationException => '-IMPL::InvalidOperationException'
2904da230022 DOM refactoring
sergey
parents:
diff changeset
12 },
2904da230022 DOM refactoring
sergey
parents:
diff changeset
13 base => [
2904da230022 DOM refactoring
sergey
parents:
diff changeset
14 'IMPL::Transform' => sub {
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
15 -plain => 'TransformPlain',
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
16 HASH => 'TransformHash',
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
17 -default => 'TransformDefault'
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
18 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
19 ],
2904da230022 DOM refactoring
sergey
parents:
diff changeset
20 props => [
2904da230022 DOM refactoring
sergey
parents:
diff changeset
21 documentSchema => PROP_RO,
2904da230022 DOM refactoring
sergey
parents:
diff changeset
22 _schema => PROP_RW,
2904da230022 DOM refactoring
sergey
parents:
diff changeset
23 _navi => PROP_RW
2904da230022 DOM refactoring
sergey
parents:
diff changeset
24 ]
2904da230022 DOM refactoring
sergey
parents:
diff changeset
25 };
2904da230022 DOM refactoring
sergey
parents:
diff changeset
26
246
2746a8e5a6c4 Fixed regressions in DOM due previous refactorings
sergey
parents: 237
diff changeset
27 use constant {
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
28 SchemaNode => 'IMPL::DOM::Schema::Node',
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
29 ComplexNode => 'IMPL::DOM::Schema::ComplexNode'
246
2746a8e5a6c4 Fixed regressions in DOM due previous refactorings
sergey
parents: 237
diff changeset
30 };
2746a8e5a6c4 Fixed regressions in DOM due previous refactorings
sergey
parents: 237
diff changeset
31
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
32 sub CTOR {
237
61db68166c37 refactoring QueryToDOM
sergey
parents: 236
diff changeset
33 my ($this,$docName,$docSchema,$transforms) = @_;
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
34
246
2746a8e5a6c4 Fixed regressions in DOM due previous refactorings
sergey
parents: 237
diff changeset
35 my $docNodeSchema = $docSchema->selectSingleNode(sub { $_->isa(SchemaNode) and $_->name eq $docName } )
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
36 or die OperationException->new("Can't find a node schema for the document '$docName'");
2904da230022 DOM refactoring
sergey
parents:
diff changeset
37
2904da230022 DOM refactoring
sergey
parents:
diff changeset
38 my $docClass = ($docNodeSchema->can('nativeType') ? $docNodeSchema->nativeType : undef) || 'IMPL::DOM::Document';
2904da230022 DOM refactoring
sergey
parents:
diff changeset
39
2904da230022 DOM refactoring
sergey
parents:
diff changeset
40 $this->documentSchema($docNodeSchema);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
41
2904da230022 DOM refactoring
sergey
parents:
diff changeset
42 $this->_navi(
2904da230022 DOM refactoring
sergey
parents:
diff changeset
43 Builder->new(
2904da230022 DOM refactoring
sergey
parents:
diff changeset
44 $docClass,
2904da230022 DOM refactoring
sergey
parents:
diff changeset
45 $docSchema,
2904da230022 DOM refactoring
sergey
parents:
diff changeset
46 ignoreUndefined => 1
2904da230022 DOM refactoring
sergey
parents:
diff changeset
47 )
2904da230022 DOM refactoring
sergey
parents:
diff changeset
48 );
2904da230022 DOM refactoring
sergey
parents:
diff changeset
49 $this->_schema($docSchema);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
50
2904da230022 DOM refactoring
sergey
parents:
diff changeset
51 $this->_navi->NavigateCreate($docName);
263
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
52 $this->currentNode->nodeProperty(schemaDocument => $docSchema);
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
53 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
54
2904da230022 DOM refactoring
sergey
parents:
diff changeset
55 sub TransformPlain {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
56 my ($this,$data) = @_;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
57
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
58 $this->_navi->Current->nodeValue( $data );
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
59 return $this->_navi->Current;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
60 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
61
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
62 sub currentNode {
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
63 shift->_navi->Current;
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
64 }
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
65
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
66 sub TransformHash {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
67 my ($this,$data) = @_;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
68
2904da230022 DOM refactoring
sergey
parents:
diff changeset
69 die ArgumentException->new(data => 'A HASH reference is required')
2904da230022 DOM refactoring
sergey
parents:
diff changeset
70 unless ref $data eq 'HASH';
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
71
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
72 return $this->StoreObject($this->currentNode,$data)
387
4cc6cc370fb2 DOM refactoring
sergey
parents: 348
diff changeset
73 if !$this->currentNode->schemaType->isa(ComplexNode);
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
74
2904da230022 DOM refactoring
sergey
parents:
diff changeset
75 KEYLOOP: foreach my $key (keys %$data) {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
76 my $value = $data->{$key};
2904da230022 DOM refactoring
sergey
parents:
diff changeset
77
2904da230022 DOM refactoring
sergey
parents:
diff changeset
78 if (ref $value eq 'ARRAY') {
257
299af584c05f collapse empty array elements in POSTed data
sergey
parents: 250
diff changeset
79 foreach my $subval (grep $_, @$value) {
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
80
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
81 $this->_navi->saveState();
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
82
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
83 my $node = $this->_navi->NavigateCreate($key);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
84
2904da230022 DOM refactoring
sergey
parents:
diff changeset
85 unless(defined $node) {
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
86 #$this->_navi->Back();
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
87 $this->_navi->restoreState();
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
88 next KEYLOOP;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
89 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
90
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
91 $this->_navi->applyState();
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
92
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
93 $this->Transform($subval);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
94
2904da230022 DOM refactoring
sergey
parents:
diff changeset
95 $this->_navi->Back();
2904da230022 DOM refactoring
sergey
parents:
diff changeset
96 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
97 } else {
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
98 $this->_navi->saveState();
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
99 my $node = $this->_navi->NavigateCreate($key);
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
100
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
101 unless(defined $node) {
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
102 #$this->_navi->Back();
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
103 $this->_navi->restoreState();
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
104 next KEYLOOP;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
105 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
106
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
107 $this->_navi->applyState();
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
108
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
109 $this->Transform($value);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
110
2904da230022 DOM refactoring
sergey
parents:
diff changeset
111 $this->_navi->Back();
2904da230022 DOM refactoring
sergey
parents:
diff changeset
112 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
113 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
114 return $this->_navi->Current;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
115 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
116
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
117 # this method handles situatuions when a complex object must be stored in a
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
118 # simple node.
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
119 sub StoreObject {
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
120 my ($this,$node,$data) = @_;
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
121
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
122 $node->nodeValue($data);
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
123
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
124 return $node;
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
125 }
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
126
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
127 sub TransformDefault {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
128 my ($this,$data) = @_;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
129
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
130 return $this->StoreObject($this->currentNode,$data)
391
2287c72f303a code cleanup
cin
parents: 387
diff changeset
131 if !$this->currentNode->schemaType->isa(ComplexNode);
250
129e48bb5afb DOM refactoring
sergey
parents: 246
diff changeset
132
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
133 if ( ref $data and eval { $data->can('GetMeta') } ) {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
134 my %props = map {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
135 $_->name, 1
2904da230022 DOM refactoring
sergey
parents:
diff changeset
136 } $data->GetMeta(PropertyInfo, sub { $_->access == ACCESS_PUBLIC }, 1 );
2904da230022 DOM refactoring
sergey
parents:
diff changeset
137
329
50ff1595bd62 fixed bug when transforming list properties
sergey
parents: 264
diff changeset
138
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
139 my %values = map {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
140 $_,
329
50ff1595bd62 fixed bug when transforming list properties
sergey
parents: 264
diff changeset
141 scalar($data->$_())
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
142 } keys %props;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
143
2904da230022 DOM refactoring
sergey
parents:
diff changeset
144 return $this->Transform(\%values);
2904da230022 DOM refactoring
sergey
parents:
diff changeset
145 } else {
2904da230022 DOM refactoring
sergey
parents:
diff changeset
146 die OperationException->new("Don't know how to transform $data");
2904da230022 DOM refactoring
sergey
parents:
diff changeset
147 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
148
2904da230022 DOM refactoring
sergey
parents:
diff changeset
149 return $this->_navi->Current;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
150 }
2904da230022 DOM refactoring
sergey
parents:
diff changeset
151
2904da230022 DOM refactoring
sergey
parents:
diff changeset
152 1;
2904da230022 DOM refactoring
sergey
parents:
diff changeset
153
2904da230022 DOM refactoring
sergey
parents:
diff changeset
154 __END__
2904da230022 DOM refactoring
sergey
parents:
diff changeset
155
2904da230022 DOM refactoring
sergey
parents:
diff changeset
156 =pod
2904da230022 DOM refactoring
sergey
parents:
diff changeset
157
2904da230022 DOM refactoring
sergey
parents:
diff changeset
158 =head1 NAME
2904da230022 DOM refactoring
sergey
parents:
diff changeset
159
263
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
160 C<IMPL::DOM::Transform::ObjectToDOM> -преобразование объекта в DOM документ.
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
161
2904da230022 DOM refactoring
sergey
parents:
diff changeset
162 =head1 SYNOPSIS
2904da230022 DOM refactoring
sergey
parents:
diff changeset
163
263
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
164 =begin code
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
165
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
166 use IMPL::require {
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
167 Schema => 'IMPL::DOM::Schema',
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
168 Config => 'IMPL::Config'
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
169 }
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
170
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
171 my $data = {
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
172 id => '12313-232',
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
173 name => 'Peter',
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
174 age => 20
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
175 };
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
176
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
177 my $schema = Schema->LoadSchema(Config->AppBase('schemas','person.xml'));
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
178 my $transorm = IMPL::DOM::Transform::ObjectToDOM->new('edit', $schema);
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
179
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
180 my $form = $transform->Transform($data);
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
181
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
182 my @errors;
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
183
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
184 push @errors, $schema->Validate($doc);
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
185
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
186 =end code
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
187
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
188 =head1 DESCRIPTION
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
189
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
190 Наследует C<IMPL::Transform>. Определяет базовые преобразования для хешей и
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
191 объектов, поддерживающих метаданные.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
192
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
193 Результатом выполнения преобразования является DOM документ. При построении
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
194 документа используется навигатор C<IMPL::DOM::Navigator::Builder> для
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
195 сопоставления схемы и свойств преобразуемого объекта. Элементы полученного
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
196 документа имеют ссылки на соответствующие им элементы схемы.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
197
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
198 После того, как документ построен и преобразование будет очищено, не останется
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
199 объектов, которые бы ссылались на документ со схемой, поскольку элементы схемы
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
200 имеют слабые ссылки на саму схему и не могут предотвратить ее удаление.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
201 Для предотвращения очитски документа схемы, ссылка на него сохраняется в
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
202 атрибуте документа C<schemaDocument>, что обеспечит жизнь схемы на протяжении
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
203 жизни документа.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
204
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
205 Преобразование происходит рекурсивно, сначала используется метод
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
206 C<NavigateCreate> для создания элемента соответсвующего свойству объекта,
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
207 затем вызывается метод C<Transform> для преобразования значения свойства, при
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
208 этом C<currentNode> указывает на только что созданный элемент документа.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
209
264
c9c2ec29793f *IMPL::DOM::Transform: updated documentation
sergey
parents: 263
diff changeset
210 Для изменения поведения преобразования можно добавлять новые обработчики, как
c9c2ec29793f *IMPL::DOM::Transform: updated documentation
sergey
parents: 263
diff changeset
211 в случае со стандартным преобразованием, а также можно унаследовать текущий
c9c2ec29793f *IMPL::DOM::Transform: updated documentation
sergey
parents: 263
diff changeset
212 класс для переопределения его некоторых методов.
c9c2ec29793f *IMPL::DOM::Transform: updated documentation
sergey
parents: 263
diff changeset
213
263
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
214 =head1 MEMBERS
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
215
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
216 =head2 C<CTOR($docName,$schema)>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
217
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
218 Создает преобразование, при этом будет создан документ состоящий только из
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
219 корневого элемента с именем C<$docName> и будет найдена подходящий для него
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
220 элемент схемы C<$schema>.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
221
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
222 =over
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
223
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
224 =item * C<$docName>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
225
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
226 Имя корневого узла документа, которое будет использовано для поиска
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
227 соответствующего элемента схемы C<$schema>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
228
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
229 =item * C<$schema>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
230
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
231 Схема, содержащая описание документа. Если в данной схеме нет описания корневого
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
232 элемента с именем C<$docName>, будет вызвано исключение.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
233
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
234 =back
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
235
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
236 =head2 C<[get]documentSchema>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
237
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
238 Элемент схемы C<ComplexNode> соответствующий документу. Определяется в
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
239 конструкторе исходя из имени документа.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
240
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
241 =head2 C<[get]currentNode>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
242
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
243 Текущий элемент документа. После создания преобразования - это сам документ.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
244 Данное свойство использется внутри преобразования для работы с текущим
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
245 элементом.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
246
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
247 =head2 C<[virtual]StoreObject($node,$data)>
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
248
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
249 Метод, который вызывается преобразованием в случае если текущий узел документа
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
250 является простым, а значени которое ему соответсвует является объектом (ссылкой).
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
251
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
252 По-умолчанию будет выполнено присваивание C<< $node->nodeValue($data) >>, однако
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
253 это можно заменить, например, на преобразование в строку.
0f59b2de72af *fixed IMPL::DOM::Schema circular module references
sergey
parents: 257
diff changeset
254
236
2904da230022 DOM refactoring
sergey
parents:
diff changeset
255 =cut