annotate Lib/IMPL/DOM/Document.pm @ 157:c7652cf29a80

Fixed PostToDom with empty fields issue. Fixed the includes search order for TT::Document.
author wizard
date Wed, 20 Oct 2010 18:02:47 +0400
parents 1e7f03414b65
children 76515373dac0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
1 package IMPL::DOM::Document;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
5 use base qw(IMPL::DOM::Node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
7 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
9 sub document {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
10 return $_[0];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
11 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
13 sub Create {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
14 my ($this,$nodeName,$class,$refProps) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
15
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
16 if ( ref $class eq 'HASH' ) {
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
17 $refProps = $class;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
18 $class = undef;
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
19 }
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
20
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
21 $class ||= typeof IMPL::DOM::Node;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
22 $refProps ||= {};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
24 delete $refProps->{nodeName};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
25
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 77
diff changeset
26 die new IMPL::Exception("class is not specified") unless $class;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
27 return $class->new(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
28 nodeName => $nodeName,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
29 document => $this,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
30 %$refProps
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
31 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
32 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
33
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
34 sub save {
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
35 my ($this,$writer) = @_;
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
36
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
37 $writer->xmlDecl(undef,'yes');
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
38 $this->SUPER::save($writer);
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
39 $writer->end();
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
40 }
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
41
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
42 {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
43 my $empty;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
44 sub Empty() {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
45 return $empty ? $empty : $empty = __PACKAGE__->new(nodeName => 'Empty');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
47 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
48
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
49 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
50 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
51
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
52 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
53
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
54 =head1 NAME
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
55
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
56 C<IMPL::DOM::Document> DOM документ.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
57
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
58 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
59
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
60 Документ, позволяет создавать узлы определенных типов, что позволяет абстрагироваться
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
61 от механизмов реального создания объектов. Т.о. например C<IMPL::DOM::Navigator::Builder>
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
62 может формировать произвольные документы.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
63
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
64 =head1 SYNOPSIS
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
65
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
66 =begin code
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
67
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
68 package MyDocument;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
69 use base qw(IMPL::DOM::Document);
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
70
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
71 sub Create {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
72 my $this = shift;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
73 my ($name,$class,$hashProps) = @_;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
74
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
75 if ($class eq 'Info') {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
76 return MyInfo->new($name,$hashProps->{date},$hashProps->{description});
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
77 } else {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
78 # leave as it is
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
79 return $this->SUPER::Create(@_);
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
80 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
81 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
82
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
83 =end code
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
84
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
85 =head1 METHODS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
86
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
87 =over
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
88
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
89 =item C< Create($nodeName,$class,$hashProps) >
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
90
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
91 Реализация по умолчанию. Создает узел определеннго типа с определенным именем и свойствами.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
92
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
93 =begin code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
94
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
95 sub Create {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
96 my ($this,$nodeName,$class,$hashProps) = @_;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
97
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
98 return $class->new (
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
99 nodeName => $nodeName,
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
100 document => $this,
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
101 %$hashProps
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
102 );
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
103 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
104
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
105 =end code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
106
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
107 =item C< save($writer) >
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
108
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
109 Сохраняет документ в виде XML узла и вызывает C<< $writer->end() >>.
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
110
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
111 =over
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
112
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
113 =item C<$writer>
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
114
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
115 Объект с интерфейсом C<XML::Writer> который будет использован для записи
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
116 содержимого документа
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
117
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
118 =back
1e7f03414b65 DOM: schema improvements
wizard
parents: 148
diff changeset
119
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
120 =back
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
121
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
122 =cut