Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Document.pm @ 121:92c850d0bdb9
Minor changes
Fixed bug with templates base in the PageFormat module
Added an ability to remove current security context with a specified
author | wizard |
---|---|
date | Tue, 08 Jun 2010 03:38:10 +0400 |
parents | 196bf443b5e1 |
children | e6447ad85cb4 |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Document; |
2 use strict; | |
3 use warnings; | |
4 | |
5 use base qw(IMPL::DOM::Node); | |
6 | |
7 __PACKAGE__->PassThroughArgs; | |
8 | |
9 sub document { | |
10 return $_[0]; | |
11 } | |
12 | |
13 sub Create { | |
14 my ($this,$nodeName,$class,$refProps) = @_; | |
15 | |
16 $refProps ||= {}; | |
17 | |
18 delete $refProps->{nodeName}; | |
19 | |
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
77
diff
changeset
|
20 die new IMPL::Exception("class is not specified") unless $class; |
49 | 21 return $class->new( |
22 nodeName => $nodeName, | |
23 document => $this, | |
24 %$refProps | |
25 ); | |
26 } | |
27 | |
28 { | |
29 my $empty; | |
30 sub Empty() { | |
31 return $empty ? $empty : $empty = __PACKAGE__->new(nodeName => 'Empty'); | |
32 } | |
33 } | |
34 | |
35 1; | |
36 __END__ | |
37 | |
38 =pod | |
39 | |
77 | 40 =head1 NAME |
41 | |
42 C<IMPL::DOM::Document> DOM документ. | |
43 | |
49 | 44 =head1 DESCRIPTION |
45 | |
77 | 46 Документ, позволяет создавать узлы определенных типов, что позволяет абстрагироваться |
47 от механизмов реального создания объектов. Т.о. например C<IMPL::DOM::Navigator::Builder> | |
48 может формировать произвольные документы. | |
49 | |
50 =head1 SYNOPSIS | |
51 | |
52 =begin code | |
53 | |
54 package MyDocument; | |
55 use base qw(IMPL::DOM::Document); | |
56 | |
57 sub Create { | |
58 my $this = shift; | |
59 my ($name,$class,$hashProps) = @_; | |
60 | |
61 if ($class eq 'Info') { | |
62 return MyInfo->new($name,$hashProps->{date},$hashProps->{description}); | |
63 } else { | |
64 # leave as it is | |
65 return $this->SUPER::Create(@_); | |
66 } | |
67 } | |
68 | |
69 =end code | |
70 | |
49 | 71 =head1 METHODS |
72 | |
73 =over | |
74 | |
77 | 75 =item C< Create($nodeName,$class,$hashProps) > |
76 | |
77 Реализация по умолчанию. Создает узел определеннго типа с определенным именем и свойствами. | |
78 | |
79 =begin code | |
49 | 80 |
77 | 81 sub Create { |
82 my ($this,$nodeName,$class,$hashProps) = @_; | |
83 | |
84 return $class->new ( | |
85 nodeName => $nodeName, | |
86 document => $this, | |
87 %$hashProps | |
88 ); | |
89 } | |
90 | |
91 =end code | |
49 | 92 |
93 =back | |
94 | |
95 =cut |