annotate lib/IMPL/DOM/Transform/ObjectToDOM.pm @ 417:3ed0c58e9da3 ref20150831

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