Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Schema/ComplexNode.pm @ 7:94d47b388442
Улучшены тесты
Исправлены ошибки
Улучшена документация
Работа над схемой DOM
author | Sergey |
---|---|
date | Mon, 24 Aug 2009 01:05:34 +0400 |
parents | |
children | fffb153be599 |
comparison
equal
deleted
inserted
replaced
6:e2cd73ccc5bd | 7:94d47b388442 |
---|---|
1 package IMPL::DOM::Schema::ComplexNode; | |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::DOM::Schema::Item); | |
6 use IMPL::Class::Property; | |
7 | |
8 BEGIN { | |
9 public property nodeType => prop_all; | |
10 public property content => { | |
11 get => \&_getContent, | |
12 set => \&_setContent | |
13 } | |
14 } | |
15 | |
16 __PACKAGE__->PassThroughArgs; | |
17 | |
18 sub _getContent { | |
19 $_[0]->firstChild; | |
20 } | |
21 | |
22 sub _setContent { | |
23 $_[0]->firstChild($_[1]); | |
24 } | |
25 | |
26 sub Validate { | |
27 my ($this,$node) = @_; | |
28 | |
29 if (my $type = $this->nodeType) { | |
30 my $schemaType = $this->Schema->ResolveType($type); | |
31 return $schemaType->Validate($node); | |
32 } else { | |
33 my @errors; | |
34 push @errors, $_->Validate foreach @{$this->childNodes}; | |
35 | |
36 if (@errors and $this->Message) { | |
37 return { | |
38 Error => 1, | |
39 Message => $this->formatMessage($node), | |
40 InnerErrors => \@errors | |
41 }; | |
42 } else { | |
43 return @errors; | |
44 } | |
45 } | |
46 } | |
47 | |
48 1; | |
49 | |
50 __END__ | |
51 | |
52 =pod | |
53 | |
54 =head1 DESCRIPTION | |
55 | |
56 . , | |
57 . | |
58 | |
59 .. | |
60 , . C<content> | |
61 | |
62 =head2 PROPERTIES | |
63 | |
64 =over | |
65 | |
66 =item C<nodeType> | |
67 | |
68 , . | |
69 C<content> . | |
70 | |
71 =item C<content> | |
72 | |
73 , C<IMPL::DOM::Schema::NodeSet> | |
74 C<IMPL::DOM::Schema::NodeList>, . | |
75 . | |
76 | |
77 =back | |
78 | |
79 =cut |