line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::XForms::Generator::Action; |
2
|
|
|
|
|
|
|
###################################################################### |
3
|
|
|
|
|
|
|
## ## |
4
|
|
|
|
|
|
|
## Package: Action.pm ## |
5
|
|
|
|
|
|
|
## Author: D. Hageman ## |
6
|
|
|
|
|
|
|
## ## |
7
|
|
|
|
|
|
|
## Description: ## |
8
|
|
|
|
|
|
|
## ## |
9
|
|
|
|
|
|
|
## Perl object to assist in the generation of XML compliant with ## |
10
|
|
|
|
|
|
|
## the W3's XForms specification. ## |
11
|
|
|
|
|
|
|
## ## |
12
|
|
|
|
|
|
|
###################################################################### |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
##==================================================================## |
15
|
|
|
|
|
|
|
## Libraries and Variables ## |
16
|
|
|
|
|
|
|
##==================================================================## |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
require 5.006; |
19
|
|
|
|
|
|
|
require Exporter; |
20
|
|
|
|
|
|
|
|
21
|
5
|
|
|
5
|
|
4287
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
173
|
|
22
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
573
|
|
23
|
|
|
|
|
|
|
|
24
|
5
|
|
|
5
|
|
56
|
use Carp; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
295
|
|
25
|
5
|
|
|
5
|
|
3275
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use XML::XForms::Generator::Common; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @ISA = qw( Exporter XML::LibXML::Element ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT = qw(); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = "0.70"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
no strict 'refs'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
foreach my $action ( @XFORMS_ACTION ) |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
## We need to temporarily remove the namespace prefix. |
39
|
|
|
|
|
|
|
$action =~ s/^xforms://g; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
## I prefer the below function, but it seems that Exporter |
42
|
|
|
|
|
|
|
## will throw warnings whenever I use it. |
43
|
|
|
|
|
|
|
#Exporter::export_tags( "xforms_$action" ); |
44
|
|
|
|
|
|
|
push( @EXPORT, "xforms_$action" ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
*{ "xforms_$action" } = sub { |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my( $attributes, @children ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $node = XML::XForms::Generator::Action->new( $action ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__xforms_attribute( $node, $attributes ); |
53
|
|
|
|
|
|
|
__xforms_children( $node, @children ); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return( $node ); |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use strict 'refs'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
##==================================================================## |
62
|
|
|
|
|
|
|
## Constructor(s)/Deconstructor(s) ## |
63
|
|
|
|
|
|
|
##==================================================================## |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
##----------------------------------------------## |
66
|
|
|
|
|
|
|
## new ## |
67
|
|
|
|
|
|
|
##----------------------------------------------## |
68
|
|
|
|
|
|
|
## XForms::Action default contstructor. ## |
69
|
|
|
|
|
|
|
##----------------------------------------------## |
70
|
|
|
|
|
|
|
sub new |
71
|
|
|
|
|
|
|
{ |
72
|
|
|
|
|
|
|
## Pull in what type of an object we will be. |
73
|
|
|
|
|
|
|
my $type = shift; |
74
|
|
|
|
|
|
|
## Pull in any arguments provided to the constructor. |
75
|
|
|
|
|
|
|
my %params = @_; |
76
|
|
|
|
|
|
|
## The object we are generating is going to be a child class of |
77
|
|
|
|
|
|
|
## XML::LibXML's DOM objects. |
78
|
|
|
|
|
|
|
my $self = XML::LibXML::Element->new( $params{__type__} ); |
79
|
|
|
|
|
|
|
## We need to clean up the parameter ... |
80
|
|
|
|
|
|
|
delete( $params{__type__} ); |
81
|
|
|
|
|
|
|
## Determine what exact class we will be blessing this instance into. |
82
|
|
|
|
|
|
|
my $class = ref( $type ) || $type; |
83
|
|
|
|
|
|
|
## Bless the class for it is good [tm]. |
84
|
|
|
|
|
|
|
bless( $self, $class ); |
85
|
|
|
|
|
|
|
## We need to set our namespace on our model element and activate it. |
86
|
|
|
|
|
|
|
$self->setNamespace( $XFORMS_NAMESPACE{xforms}, "xforms", 1 ); |
87
|
|
|
|
|
|
|
## Send it back to the caller all happy like. |
88
|
|
|
|
|
|
|
return( $self ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
##----------------------------------------------## |
92
|
|
|
|
|
|
|
## DESTROY ## |
93
|
|
|
|
|
|
|
##----------------------------------------------## |
94
|
|
|
|
|
|
|
## XForms::Action default deconstructor. ## |
95
|
|
|
|
|
|
|
##----------------------------------------------## |
96
|
|
|
|
|
|
|
sub DESTROY |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
## This is mainly a placeholder to keep things like mod_perl happy. |
99
|
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
##==================================================================## |
103
|
|
|
|
|
|
|
## Method(s) ## |
104
|
|
|
|
|
|
|
##==================================================================## |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
no strict 'refs'; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
foreach my $element ( @XFORMS_ACTION ) |
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
## We need to temporarily remove the namespace prefix for our work. |
111
|
|
|
|
|
|
|
$element =~ s/^xforms://g; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
##----------------------------------------------## |
114
|
|
|
|
|
|
|
## appendCHILDENAME ## |
115
|
|
|
|
|
|
|
##----------------------------------------------## |
116
|
|
|
|
|
|
|
## Method generation for the common child ## |
117
|
|
|
|
|
|
|
## elements of controls. ## |
118
|
|
|
|
|
|
|
##----------------------------------------------## |
119
|
|
|
|
|
|
|
*{ "append" . ucfirst( $element ) } = sub { |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my( $self, $attributes, @children ) = @_; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
## We need to determine what type of control we are working with. |
124
|
|
|
|
|
|
|
my $type = $self->nodeName; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
## We set a status bit to false indicating that at the momment we |
127
|
|
|
|
|
|
|
## don't know if this particular control has the potential of |
128
|
|
|
|
|
|
|
## having the child element in question attached to it. |
129
|
|
|
|
|
|
|
my $status = 0; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
## Loop through all the potential child elements looking for it. |
132
|
|
|
|
|
|
|
foreach( @{ $XFORMS_SCHEMA{ $type }->[3] }, |
133
|
|
|
|
|
|
|
@{ $XFORMS_SCHEMA{ $type }->[4] } ) |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
## When we find it, make sure we change our status bit. |
136
|
|
|
|
|
|
|
if( $_ eq "$element" ) |
137
|
|
|
|
|
|
|
{ |
138
|
|
|
|
|
|
|
$status = 1; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
if( $status ) |
143
|
|
|
|
|
|
|
{ |
144
|
|
|
|
|
|
|
## If status is true, then proceed to build and append the |
145
|
|
|
|
|
|
|
## child element. |
146
|
|
|
|
|
|
|
my $node = XML::LibXML::Element->new( $element ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$self->appendChild( $node ); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
$node->setNamespace( $XFORMS_NAMESPACE{xforms}, "xforms", 1 ); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__xforms_attribute( $node, $attributes ); |
153
|
|
|
|
|
|
|
__xforms_children( $node, @children ); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
return( $node ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else |
158
|
|
|
|
|
|
|
{ |
159
|
|
|
|
|
|
|
croak( qq|Error: $type control does not have the ability to have |, |
160
|
|
|
|
|
|
|
qq|a $element child element| ); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
}; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
##----------------------------------------------## |
165
|
|
|
|
|
|
|
## getCHILDENAME ## |
166
|
|
|
|
|
|
|
##----------------------------------------------## |
167
|
|
|
|
|
|
|
## Method for retrieval of the control child ## |
168
|
|
|
|
|
|
|
## elements. ## |
169
|
|
|
|
|
|
|
##----------------------------------------------## |
170
|
|
|
|
|
|
|
*{ "get" . ucfirst( $element ) } = sub { |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $self = shift; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my @nodes = |
175
|
|
|
|
|
|
|
$self->getElementsByTagNameNS( $XFORMS_NAMESPACE{ 'xforms' }, |
176
|
|
|
|
|
|
|
$element ); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
return( @nodes ); |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
use strict 'refs'; |
183
|
|
|
|
|
|
|
##==================================================================## |
184
|
|
|
|
|
|
|
## Function(s) ## |
185
|
|
|
|
|
|
|
##==================================================================## |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
##==================================================================## |
188
|
|
|
|
|
|
|
## Internal Function(s) ## |
189
|
|
|
|
|
|
|
##==================================================================## |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
##==================================================================## |
192
|
|
|
|
|
|
|
## End of Code ## |
193
|
|
|
|
|
|
|
##==================================================================## |
194
|
|
|
|
|
|
|
1; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
##==================================================================## |
197
|
|
|
|
|
|
|
## Plain Old Documentation (POD) ## |
198
|
|
|
|
|
|
|
##==================================================================## |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
__END__ |