Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Document.pm @ 171:59e5fcb59d86
Исправления, изменена концепция веб-форм
author | sourcer |
---|---|
date | Mon, 06 Jun 2011 03:30:36 +0400 |
parents | 76515373dac0 |
children | d1676be8afcc |
rev | line source |
---|---|
49 | 1 package IMPL::DOM::Document; |
2 use strict; | |
3 use warnings; | |
4 | |
165 | 5 use parent qw(IMPL::DOM::Node); |
49 | 6 |
7 __PACKAGE__->PassThroughArgs; | |
8 | |
9 sub document { | |
10 return $_[0]; | |
11 } | |
12 | |
13 sub Create { | |
14 my ($this,$nodeName,$class,$refProps) = @_; | |
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 | 22 $refProps ||= {}; |
23 | |
24 delete $refProps->{nodeName}; | |
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 | 27 return $class->new( |
28 nodeName => $nodeName, | |
29 document => $this, | |
30 %$refProps | |
31 ); | |
32 } | |
33 | |
152 | 34 sub save { |
35 my ($this,$writer) = @_; | |
36 | |
37 $writer->xmlDecl(undef,'yes'); | |
38 $this->SUPER::save($writer); | |
39 $writer->end(); | |
40 } | |
41 | |
49 | 42 { |
43 my $empty; | |
44 sub Empty() { | |
45 return $empty ? $empty : $empty = __PACKAGE__->new(nodeName => 'Empty'); | |
46 } | |
47 } | |
48 | |
49 1; | |
50 __END__ | |
51 | |
52 =pod | |
53 | |
77 | 54 =head1 NAME |
55 | |
56 C<IMPL::DOM::Document> DOM . | |
57 | |
49 | 58 =head1 DESCRIPTION |
59 | |
77 | 60 , , |
61 . .. C<IMPL::DOM::Navigator::Builder> | |
62 . | |
63 | |
64 =head1 SYNOPSIS | |
65 | |
66 =begin code | |
67 | |
68 package MyDocument; | |
165 | 69 use parent qw(IMPL::DOM::Document); |
77 | 70 |
71 sub Create { | |
72 my $this = shift; | |
73 my ($name,$class,$hashProps) = @_; | |
74 | |
75 if ($class eq 'Info') { | |
76 return MyInfo->new($name,$hashProps->{date},$hashProps->{description}); | |
77 } else { | |
78 # leave as it is | |
79 return $this->SUPER::Create(@_); | |
80 } | |
81 } | |
82 | |
83 =end code | |
84 | |
49 | 85 =head1 METHODS |
86 | |
87 =over | |
88 | |
77 | 89 =item C< Create($nodeName,$class,$hashProps) > |
90 | |
91 . . | |
92 | |
93 =begin code | |
49 | 94 |
77 | 95 sub Create { |
96 my ($this,$nodeName,$class,$hashProps) = @_; | |
97 | |
98 return $class->new ( | |
99 nodeName => $nodeName, | |
100 document => $this, | |
101 %$hashProps | |
102 ); | |
103 } | |
104 | |
105 =end code | |
49 | 106 |
152 | 107 =item C< save($writer) > |
108 | |
109 XML C<< $writer->end() >>. | |
110 | |
111 =over | |
112 | |
113 =item C<$writer> | |
114 | |
115 C<XML::Writer> | |
116 | |
117 | |
118 =back | |
119 | |
49 | 120 =back |
121 | |
122 =cut |