Mercurial > pub > Impl
comparison Lib/IMPL/DOM/Navigator/Builder.pm @ 236:2904da230022
DOM refactoring
author | sergey |
---|---|
date | Mon, 15 Oct 2012 04:23:01 +0400 |
parents | c8fe3f84feba |
children | b8c724f6de36 |
comparison
equal
deleted
inserted
replaced
235:a4d9126edcbb | 236:2904da230022 |
---|---|
1 package IMPL::DOM::Navigator::Builder; | 1 package IMPL::DOM::Navigator::Builder; |
2 use strict; | 2 use strict; |
3 use warnings; | 3 use warnings; |
4 | |
5 use IMPL::Const qw(:prop); | |
4 | 6 |
5 use parent qw(IMPL::DOM::Navigator); | 7 use parent qw(IMPL::DOM::Navigator); |
6 use IMPL::Class::Property; | 8 use IMPL::Class::Property; |
7 use IMPL::Class::Property::Direct; | 9 use IMPL::Class::Property::Direct; |
8 require IMPL::DOM::Navigator::SchemaNavigator; | 10 require IMPL::DOM::Navigator::SchemaNavigator; |
9 require IMPL::DOM::Schema::ValidationError; | 11 require IMPL::DOM::Schema::ValidationError; |
10 use IMPL::DOM::Document; | 12 use IMPL::DOM::Document; |
11 | 13 |
12 BEGIN { | 14 BEGIN { |
13 private _direct property _schemaNavi => prop_all; | 15 private _direct property _schemaNavi => PROP_RW; |
14 private _direct property _docClass => prop_all; | 16 private _direct property _docClass => PROP_RW; |
15 public _direct property BuildErrors => prop_get | prop_list; | 17 public _direct property BuildErrors => PROP_RO | PROP_LIST; |
16 public _direct property Document => prop_get | owner_set; | 18 public _direct property Document => PROP_RO; |
19 public _direct property ignoreUndefined => PROP_RO; | |
17 } | 20 } |
18 | 21 |
19 our %CTOR = ( | 22 our %CTOR = ( |
20 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document->Empty; } | 23 'IMPL::DOM::Navigator' => sub { IMPL::DOM::Document->Empty; } |
21 ); | 24 ); |
22 | 25 |
23 sub CTOR { | 26 sub CTOR { |
24 my ($this,$docClass,$schema) = @_; | 27 my ($this,$docClass,$schema,%opts) = @_; |
25 | 28 |
26 $this->{$_docClass} = $docClass; | 29 $this->{$_docClass} = $docClass; |
27 $this->{$_schemaNavi} = $schema ? IMPL::DOM::Navigator::SchemaNavigator->new($schema) : undef; | 30 $this->{$_schemaNavi} = $schema ? IMPL::DOM::Navigator::SchemaNavigator->new($schema) : undef; |
31 | |
32 $this->{$ignoreUndefined} = $opts{ignoreUndefined} if $opts{ignoreUndefined}; | |
28 } | 33 } |
29 | 34 |
30 sub NavigateCreate { | 35 sub NavigateCreate { |
31 my ($this,$nodeName,%props) = @_; | 36 my ($this,$nodeName,%props) = @_; |
32 | 37 |
52 | 57 |
53 if (@errors) { | 58 if (@errors) { |
54 $this->BuildErrors->Append( | 59 $this->BuildErrors->Append( |
55 map { | 60 map { |
56 IMPL::DOM::Schema::ValidationError->new( | 61 IMPL::DOM::Schema::ValidationError->new( |
57 Node => $node, | 62 node => $node, |
58 Source => $schemaSource, | 63 source => $schemaSource, |
59 Schema => $schemaNode, | 64 schema => $schemaNode, |
60 Message => $schemaNode->messageInflateError, | 65 message => $schemaNode->messageInflateError, |
61 Error => $_ | 66 error => $_ |
62 ) | 67 ) |
63 } @errors | 68 } @errors |
64 ); | 69 ); |
65 } | 70 } |
66 | 71 |
67 return $node; | 72 return $node; |
68 } else { | 73 } else { |
69 die new IMPL::InvalidOperationException("The specified node is undefined", $nodeName); | 74 die new IMPL::InvalidOperationException("The specified node is undefined", $nodeName) |
75 if !$this->ingnoreUndefiend; | |
76 return; | |
70 } | 77 } |
71 } | 78 } |
72 | 79 |
73 sub inflateProperties { | 80 sub inflateProperties { |
74 my ($this,$schemaNode,$refProps) = @_; | 81 my ($this,$schemaNode,$refProps) = @_; |
126 | 133 |
127 $this->{$_schemaNavi}->restoreState; | 134 $this->{$_schemaNavi}->restoreState; |
128 $this->SUPER::restoreState; | 135 $this->SUPER::restoreState; |
129 } | 136 } |
130 | 137 |
138 #compatibility | |
139 sub buildErrors { | |
140 goto &BuildErrors; | |
141 } | |
142 | |
131 1; | 143 1; |
132 | 144 |
133 __END__ | 145 __END__ |
134 | 146 |
135 =pod | 147 =pod |