Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Node.pm @ 148:e6447ad85cb4
DOM objects now have a schema and schemaSource properties
RegExp now can launder data
Improved post to DOM transformation (multiple values a now supported)
Added new axes to navigation queries: ancestor and descendant
minor changes and bug fixes
author | wizard |
---|---|
date | Mon, 16 Aug 2010 08:26:44 +0400 |
parents | e30bdd040fe3 |
children | 1e7f03414b65 |
comparison
equal
deleted
inserted
replaced
147:c2aa10fbb396 | 148:e6447ad85cb4 |
---|---|
15 public _direct property nodeName => prop_get; | 15 public _direct property nodeName => prop_get; |
16 public _direct property document => prop_get; | 16 public _direct property document => prop_get; |
17 public _direct property isComplex => { get => \&_getIsComplex } ; | 17 public _direct property isComplex => { get => \&_getIsComplex } ; |
18 public _direct property nodeValue => prop_all; | 18 public _direct property nodeValue => prop_all; |
19 public _direct property childNodes => { get => \&_getChildNodes }; # prop_list | 19 public _direct property childNodes => { get => \&_getChildNodes }; # prop_list |
20 public _direct property parentNode => prop_get ; | 20 public _direct property parentNode => prop_get | owner_set; |
21 public _direct property schema => prop_get | owner_set; | |
22 public _direct property schemaSource => prop_get | owner_set; | |
21 private _direct property _propertyMap => prop_all ; | 23 private _direct property _propertyMap => prop_all ; |
22 | 24 |
23 __PACKAGE__->class_data(property_bind => {}); | 25 __PACKAGE__->class_data(property_bind => {}); |
24 } | 26 } |
25 | 27 |
26 our %Axes = ( | 28 our %Axes = ( |
27 parent => \&selectParent, | 29 parent => \&selectParent, |
28 siblings => \&selectSiblings, | 30 siblings => \&selectSiblings, |
29 child => \&childNodes, | 31 child => \&childNodes, |
30 document => \&selectDocument | 32 document => \&selectDocument, |
33 ancestor => \&selectAncestors, | |
34 descendant => \&selectDescendant | |
31 ); | 35 ); |
32 | 36 |
33 sub CTOR { | 37 sub CTOR { |
34 my ($this,%args) = @_; | 38 my ($this,%args) = @_; |
35 | 39 |
288 } else { | 292 } else { |
289 return wantarray ? () : []; | 293 return wantarray ? () : []; |
290 } | 294 } |
291 } | 295 } |
292 | 296 |
297 sub selectDescendant { | |
298 wantarray ? | |
299 map $_->selectAll(), $_[0]->childNodes : | |
300 [map $_->selectAll(), $_[0]->childNodes] | |
301 } | |
302 | |
303 sub selectAll { | |
304 map(selectAll($_),@{$_[0]->childNodes}) , $_[0] | |
305 } | |
306 | |
307 sub selectAncestors { | |
308 my $parent = $_[0]->parentNode; | |
309 | |
310 wantarray ? | |
311 ($parent ? ($parent->selectAncestors,$parent) : ()) : | |
312 [$parent ? ($parent->selectAncestors,$parent) : ()] | |
313 } | |
314 | |
293 sub firstChild { | 315 sub firstChild { |
294 @_ >=2 ? $_[0]->replaceNodeAt(0,$_[1]) : $_[0]->childNodes->[0]; | 316 @_ >=2 ? $_[0]->replaceNodeAt(0,$_[1]) : $_[0]->childNodes->[0]; |
295 } | 317 } |
296 | 318 |
297 sub _getIsComplex { | 319 sub _getIsComplex { |
347 sub nodeProperty { | 369 sub nodeProperty { |
348 my $this = shift; | 370 my $this = shift; |
349 my $name = shift; | 371 my $name = shift; |
350 | 372 |
351 if (my $method = $this->can($name)) { | 373 if (my $method = $this->can($name)) { |
352 return &$method($this,@_); | 374 unshift @_,$this; |
353 } | 375 # use goto to preserve calling context |
354 | 376 goto &$method; |
377 } | |
378 # dynamic property | |
355 if (@_) { | 379 if (@_) { |
356 # set | 380 # set |
357 return $this->{$_propertyMap}{$name} = shift; | 381 return $this->{$_propertyMap}{$name} = shift; |
358 } else { | 382 } else { |
359 return $this->{$_propertyMap}{$name}; | 383 return $this->{$_propertyMap}{$name}; |
427 | 451 |
428 =item C<[get] parentNode> | 452 =item C<[get] parentNode> |
429 | 453 |
430 Ссылка на родительский элемент, если таковой имеется. | 454 Ссылка на родительский элемент, если таковой имеется. |
431 | 455 |
456 =item C<[get] schema> | |
457 | |
458 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий схему данных текущего узла. Может быть C<undef>. | |
459 | |
460 =item C<[get] schema> | |
461 | |
462 Ссылка на узел из C<IMPL::DOM::Schema>, представляющий элемент схемы, объявляющий данный узел. Может быть C<undef>. | |
463 | |
464 Отличается от свойства C<schema> тем, что узел в случае ссылки на тип узла, данной свойство будет содержать | |
465 описание ссылки C<IMPL::DOM::Schema::Node>, а свойство C<schema> например будет ссылаться на | |
466 C<IMPL::DOM::Schema::ComplexType>. | |
467 | |
468 =back | |
469 | |
432 =head2 METHODS | 470 =head2 METHODS |
433 | 471 |
434 =cut | 472 =cut |