PRANG/Graph/Element.pm

filter: Statementstmt 21.2% 35 / 165 Branchbran 0.0% 0 / 90 Conditioncond 0.0% 0 / 61 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 68.7% 11 / 16 Podpod n/a totaltotal 12.6% 46 / 365 CC 71 SCAR 63.6
CC
71
Cov
11%
__ANON__
1163.5
__ANON__
326.3
__ANON__
260.9
CRAP 579.6
« PRANG/Graph/Meta/Element.pm ↑ Summary PRANG/Graph/Choice.pm »
1  
2 package PRANG::Graph::Element;
3  
4 9 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use MooseX::Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 BEGIN {
11 9 ▶ class_type "XML::LibXML::Node";
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 class_type "XML::LibXML::Element";
13 }
14  
15 9 has 'xmlns' =>
16 is => "ro",
17 isa => "Str",
18 predicate => "has_xmlns",
19 ;
20  
21 9 has 'nodeName' =>
22 is => "ro",
23 isa => "Str",
24 required => 1,
25 ;
26  
27 9 has 'nodeClass' =>
28 is => "ro",
29 isa => "Str",
30 predicate => "has_nodeClass",
31 ;
32  
33 9 has 'nodeName_attr' =>
34 is => "rw",
35 isa => "Str",
36 predicate => "has_nodeName_attr",
37 ;
38  
39 9 has 'xmlns_attr' =>
40 is => "rw",
41 isa => "Str",
42 predicate => "has_xmlns_attr",
43 ;
44  
45 9 has 'attrName' =>
46 is => "ro",
47 isa => "Str",
48 required => 1,
49 ;
50  
51 9 has 'contents' =>
52 is => "rw",
53 isa => "PRANG::Graph::Node",
54 predicate => "has_contents",
55 ;
56  
57 9 ▶method node_ok( XML::LibXML::Node $node, PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=18 SCAR=57.9
58 0 ▶ return unless $node->nodeType == XML_ELEMENT_NODE;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->nodeType == 1 0 0 0
59 0 my $got_xmlns;
60  
61 0 ▶ if ( $self->has_xmlns or
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")) 0 0 0
Condition0%0/7
$self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")
l!l&&r!l&&!r
000
$node->prefix || ''
l!l
00
$ctx->prefix || ''
l!l
00
MC/DC0%0/2
$self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")
$self->has_xmlns $node->prefix
MC/DC0%0/1
$ctx->prefix || ''
$ctx->prefix
Truth table0%0/3
A or B
A= $self->has_xmlnsB= $node->prefix
ABresult
1X1
011
000
Truth table0%0/2
A
A= $ctx->prefix
Aresult
11
00
62 ($node->prefix||"") ne ($ctx->prefix||"") ) {
63 0 ▶ my $prefix = $node->prefix//"";
Condition0%0/2
$node->prefix // ""
l!l
00
MC/DC0%0/1
$node->prefix // ""
$node->prefix
Truth table0%0/2
A
A= $node->prefix
Aresult
11
00
64 0 $got_xmlns = $ctx->xsi->{$prefix};
65 0 ▶ if ( !defined $got_xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $got_xmlns) 0 0 0
66 0 ▶ $got_xmlns = $node->getAttribute("xmlns".(length $prefix?":$prefix":""));
Branch: 1 branch
BranchTrueFalseTotal
length $prefix ? : 0 0 0
67 }
68 0 ▶ my $wanted_xmlns = ($self->xmlns||"");
Condition0%0/2
$self->xmlns || ''
l!l
00
MC/DC0%0/1
$self->xmlns || ''
$self->xmlns
Truth table0%0/2
A
A= $self->xmlns
Aresult
11
00
69 0 ▶ if ( $got_xmlns and $wanted_xmlns ne "*" and
Branch: 1 branch
BranchTrueFalseTotal
if ($got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns) 0 0 0
Condition0%0/6
$got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns
!ll&&!rl&&r
000
$got_xmlns and $wanted_xmlns ne "*"
!ll&&!rl&&r
000
MC/DC0%0/3
$got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns
$got_xmlns $wanted_xmlns ne "*" $got_xmlns ne $wanted_xmlns
Truth table0%0/4
A and B and C
A= $got_xmlnsB= $wanted_xmlns ne "*"C= $got_xmlns ne $wanted_xmlns
ABCresult
0XX0
10X0
1100
1111
70 $got_xmlns ne $wanted_xmlns ) {
71 0 return;
72 }
73 }
74 0 my ($ret_nodeName, $ret_xmlns) = ("", "");
75 0 my $wanted_nodeName = $self->nodeName;
76 0 ▶ if ( $wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname) 0 0 0
Condition0%0/3
$wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname
!ll&&!rl&&r
000
MC/DC0%0/2
$wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname
$wanted_nodeName ne "*" $wanted_nodeName ne $node->localname
Truth table0%0/3
A and B
A= $wanted_nodeName ne "*"B= $wanted_nodeName ne $node->localname
ABresult
0X0
100
111
77 0 return;
78 }
79 0 ▶ if ( $self->has_nodeName_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeName_attr) 0 0 0
80 0 $ret_nodeName = $node->localname;
81 }
82 0 ▶ if ( $self->has_xmlns_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns_attr) 0 0 0
83 0 $ret_xmlns = $got_xmlns;
84 }
85 0 ▶ if ( wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
86 0 return ($ret_nodeName, $ret_xmlns);
87 }
88 else {
89 0 return $ret_nodeName;
90 }
91 9 }
92  
93 9 ▶method accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=16 SCAR=55.6
94 0 my ($ret_nodeName, $xmlns) = $self->node_ok($node, $ctx);
95 0 ▶ if ( !defined $ret_nodeName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret_nodeName) 0 0 0
96  
97 # ok, not right, so figure out what we did want, in
98 # the context of the incoming document.
99 0 ▶ my $wanted_xmlns = ($self->xmlns||"");
Condition0%0/2
$self->xmlns || ''
l!l
00
MC/DC0%0/1
$self->xmlns || ''
$self->xmlns
Truth table0%0/2
A
A= $self->xmlns
Aresult
11
00
100 0 my $wanted_prefix = $ctx->get_prefix($wanted_xmlns);
101  
102 0 my $nodeName = $self->nodeName;
103 0 ▶ if ( $wanted_prefix ne "" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_prefix ne "") 0 0 0
104 0 $nodeName = "$wanted_prefix:$nodeName";
105 0 ▶ if ( $ctx->prefix_new($wanted_prefix) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->prefix_new($wanted_prefix)) 0 0 0
106 0 $nodeName .= " xmlns:$wanted_prefix="
107 ."\"$wanted_xmlns\"";
108 }
109 }
110 $ctx->exception(
111 0 "invalid element; expected '$nodeName'",
112 $node, 1,
113 );
114 }
115 0 ▶ undef($ret_nodeName) if !length($ret_nodeName);
Branch: 1 branch
BranchTrueFalseTotal
unless length $ret_nodeName 0 0 0
116 0 ▶ if ( $self->has_nodeClass ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeClass) { } 0 0 0
117 # general nested XML support
118 0 my $marshaller = $ctx->base->get($self->nodeClass);
119 0 ▶ my $value = ( $marshaller ? $marshaller->marshall_in_element(
Branch: 1 branch
BranchTrueFalseTotal
$marshaller ? : 0 0 0
120 $node,
121 $ctx,
122 )
123 : $node );
124 0 $ctx->element_ok(1);
125 0 return ($self->attrName => $value, $ret_nodeName, $xmlns);
126 }
127 else {
128 # XML data types
129 0 ▶ my $type = $self->has_contents ?
Branch: 1 branch
BranchTrueFalseTotal
$self->has_contents ? : 0 0 0
130 "XML data" : "presence-only";
131 0 ▶ if ($node->hasAttributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasAttributes) 0 0 0
132 0 $ctx->exception(
133 "Superfluous attributes on $type node",
134 $node);
135 }
136 0 ▶ if ( $self->has_contents ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_contents) { } 0 0 0
137 # simple types, eg Int, Str
138 my (@childNodes) = grep {
139 0 ▶ !($_->isa("XML::LibXML::Comment") or
Condition0%0/6
$_->isa('XML::LibXML::Comment') || $_->isa('XML::LibXML::Text') && $_->data =~ /\A\s+\Z/
l!l&&r!l&&!r
000
$_->isa("XML::LibXML::Text") and $_->data =~ /\A\s+\Z/
!ll&&!rl&&r
000
MC/DC0%0/3
$_->isa('XML::LibXML::Comment') || $_->isa('XML::LibXML::Text') && $_->data =~ /\A\s+\Z/
$_->isa('XML::LibXML::Comment') $_->isa("XML::LibXML::Text") $_->data =~ /\A\s+\Z/
Truth table0%0/4
A || B and C
A= $_->isa('XML::LibXML::Comment')B= $_->isa("XML::LibXML::Text")C= $_->data =~ /\A\s+\Z/
ABCresult
1XX1
0111
00X0
0100
140 $_->isa("XML::LibXML::Text") and $_->data =~ /\A\s+\Z/)
141 } $node->childNodes;
142  
143 0 ▶ if ( @childNodes > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@childNodes > 1) 0 0 0
144 # we could maybe merge CDATA nodes...
145 0 $ctx->exception(
146 "Too many child nodes for $type node",
147 $node,
148 );
149 }
150 0 my $value;
151 0 ▶ if ( !@childNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @childNodes) { } 0 0 0
152 0 $value = "";
153 } else {
154 0 (undef, $value) = $self->contents->accept(
155 $childNodes[0],
156 $ctx,
157 );
158 }
159 0 $ctx->element_ok(1);
160 0 return ($self->attrName => $value, $ret_nodeName, $xmlns);
161 }
162 else {
163 # boolean
164 0 ▶ if ( $node->hasChildNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasChildNodes) 0 0 0
165 0 $ctx->exception(
166 "Superfluous child nodes on $type node",
167 $node,
168 );
169 }
170 0 $ctx->element_ok(1);
171 0 return ($self->attrName => 1, $ret_nodeName, $xmlns);
172 }
173 }
174 9 }
175  
176 9 ▶method complete( PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=2.6
177 0 $ctx->element_ok;
178 9 }
179  
180 9 ▶method expected( PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=6 SCAR=36.3
181 0 my $prefix = "";
182 0 my $nodename = $self->nodeName;
183 0 ▶ if ( $self->has_xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns) 0 0 0
184 0 ▶ my $xmlns = eval { $self->nodeClass->xmlns } ||
Condition0%0/3
eval { || $self->xmlns
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $self->nodeClass->xmlns } } || $self->xmlns
eval { do { $self->nodeClass->xmlns } } $self->xmlns
Truth table0%0/3
A || B
A= eval { do { $self->nodeClass->xmlns } }B= $self->xmlns
ABresult
1X1
011
000
185 $self->xmlns;
186 0 ▶ if ( $prefix = $ctx->rxsi->{$xmlns} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix = $ctx->rxsi->{$xmlns}) { } 0 0 0
187 0 $prefix .= ":";
188 }
189 else {
190 0 $prefix = $ctx->get_prefix($xmlns);
191 0 $nodename .= " xmlns:$prefix='$xmlns'";
192 0 $prefix .= ":";
193 }
194 }
195 0 ▶ return "<$prefix$nodename".($self->has_nodeClass?"...":
Branch: 2 branches
BranchTrueFalseTotal
$self->has_nodeClass ? : 0 0 0
$self->has_contents ? : 0 0 0
196 $self->has_contents?"":"/")
197 .">";
198 9 }
199  
200 9 ▶method output ( Object $item, XML::LibXML::Element $node, PRANG::Graph::Context $ctx, Item :$value, Int :$slot, Str :$name, Str :$xmlns ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=34 SCAR=70.6
201 0 ▶ $value //= do {
Condition0%0/3
$value //= do {
l!l&&r!l&&!r
000
MC/DC0%0/2
$value //= do { my $accessor = $self->attrName; $item->$accessor }
$value do { my $accessor = $self->attrName; $item->$accessor }
Truth table0%0/3
A //= B
A= $valueB= do { my $accessor = $self->attrName; $item->$accessor }
ABresult
1X1
011
000
202 0 my $accessor = $self->attrName;
203 0 $item->$accessor;
204 };
205 0 ▶ if ( ref $value and ref $value eq "ARRAY" and defined $slot ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value and ref $value eq "ARRAY" and defined $slot) 0 0 0
Condition0%0/6
ref $value and ref $value eq "ARRAY" and defined $slot
!ll&&!rl&&r
000
ref $value and ref $value eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
ref $value and ref $value eq "ARRAY" and defined $slot
ref $value ref $value eq "ARRAY" defined $slot
Truth table0%0/4
A and B and C
A= ref $valueB= ref $value eq "ARRAY"C= defined $slot
ABCresult
0XX0
10X0
1100
1111
206 0 $value = $value->[$slot];
207 }
208 0 ▶ $name //= do {
Condition0%0/3
$name //= do {
l!l&&r!l&&!r
000
MC/DC0%0/2
$name //= do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
$name do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
Truth table0%0/3
A //= B
A= $nameB= do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
ABresult
1X1
011
000
209 0 ▶ if ( $self->has_nodeName_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeName_attr) { } 0 0 0
210 0 my $attr = $self->nodeName_attr;
211 0 $item->$attr;
212 }
213 else {
214 0 $self->nodeName;
215 }
216 };
217 0 ▶ $xmlns //= do {
Condition0%0/3
$xmlns //= do {
l!l&&r!l&&!r
000
MC/DC0%0/2
$xmlns //= do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
$xmlns do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
Truth table0%0/3
A //= B
A= $xmlnsB= do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
ABresult
1X1
011
000
218 0 ▶ if ( $self->has_xmlns_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns_attr) { } 0 0 0
219 0 my $attr = $self->xmlns_attr;
220 0 $item->$attr;
221 }
222 else {
223 0 ▶ $self->xmlns // "";
Condition0%0/2
$self->xmlns // ""
l!l
00
MC/DC0%0/1
$self->xmlns // ""
$self->xmlns
Truth table0%0/2
A
A= $self->xmlns
Aresult
11
00
224 }
225 };
226 0 ▶ if ( ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name) 0 0 0
227 0 $name = $name->[$slot];
228 }
229 0 ▶ if ( ref $xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $xmlns) 0 0 0
230 0 $xmlns = $xmlns->[$slot];
231 }
232  
233 0 my $nn;
234 0 my $doc = $node->ownerDocument;
235 0 my $newctx;
236 0 ▶ if ( length $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $name) { } 0 0 0
237 0 my ($prefix, $new_prefix);
238 0 $ctx = $ctx->next_ctx( $xmlns, $name, $value );
239 0 $prefix = $ctx->prefix;
240 0 ▶ my $new_nodeName = ($prefix ? "$prefix:" : "") . $name;
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 0 0 0
241 0 $nn = $doc->createElement( $new_nodeName );
242 0 ▶ if ( $ctx->prefix_new($prefix) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->prefix_new($prefix)) 0 0 0
243 0 ▶ $nn->setAttribute(
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 0 0 0
244 "xmlns".($prefix?":$prefix":""),
245 $xmlns,
246 );
247 }
248 0 $node->appendChild($nn);
249 # now proceed with contents...
250 0 ▶ if ( my $class = $self->nodeClass ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $class = $self->nodeClass) { } 0 0 0
elsif ($self->has_contents and defined $value) { } 0 0 0
251 0 my $m;
252 0 ▶ if ( !defined $value ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (eval { do { $value->isa($class) } }) { } 0 0 0
elsif (eval { do { $value->isa('XML::LibXML::Element') } }) { } 0 0 0
elsif (builtin::blessed($value)) { } 0 0 0
253 0 $ctx->exception("required element not set");
254 }
255 0 elsif ( eval { $value->isa($class) }) {
256 0 $m = $ctx->base->get($class);
257 }
258 0 elsif ( eval{$value->isa("XML::LibXML::Element")} ) {
259 0 ▶ if ( $value->localname eq $nn->localname and
Branch: 1 branch
BranchTrueFalseTotal
if ($value->localname eq $nn->localname and ($value->namespaceURI || '') eq ($xmlns || '')) { } 0 0 0
Condition0%0/7
$value->localname eq $nn->localname and ($value->namespaceURI || "") eq ($xmlns || "")
!ll&&!rl&&r
000
$value->namespaceURI || ''
l!l
00
$xmlns || ''
l!l
00
MC/DC0%0/2
$value->localname eq $nn->localname and ($value->namespaceURI || "") eq ($xmlns || "")
$value->localname eq $nn->localname $value->namespaceURI
MC/DC0%0/1
$xmlns || ''
$xmlns
Truth table0%0/3
A and B
A= $value->localname eq $nn->localnameB= $value->namespaceURI
ABresult
0X0
100
111
Truth table0%0/2
A
A= $xmlns
Aresult
11
00
260 ($value->namespaceURI||"") eq
261 ($xmlns||"")
262 ) {
263 0 my $nn2 = $value->cloneNode(1);
264 0 $node->appendChild($nn2);
265 0 $node->removeChild($nn);
266 }
267 else {
268 # it's just not safe to set
269 # the nodeName after the fact,
270 # so copy the children across.
271 0 for my $att ( $value->attributes ) {
272 0 ▶ next if $att->isa("XML::LibXML::Namespace");
Branch: 1 branch
BranchTrueFalseTotal
if $att->isa("XML::LibXML::Namespace") 0 0 0
273 0 $nn->setAttribute(
274 $att->localname,
275 $att->value,
276 );
277 }
278 0 for my $child ( $value->childNodes ) {
279 0 my $nn2 = $child->cloneNode(1);
280 0 $nn->appendChild($nn2);
281 }
282 }
283 0 $m = "ok";
284 }
285 elsif ( blessed $value ) {
286 # this actually indicates a type
287 # error. currently it is required for
288 # the Whatever mapping.
289 0 $m = PRANG::Marshaller->get(ref $value);
290 }
291  
292 0 ▶ if ( $m and blessed $m ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m and builtin::blessed($m)) { } 0 0 0
elsif ($m) { } 0 0 0
Condition0%0/3
$m and builtin::blessed($m)
!ll&&!rl&&r
000
MC/DC0%0/2
$m and builtin::blessed($m)
$m builtin::blessed($m)
Truth table0%0/3
A and B
A= $mB= builtin::blessed($m)
ABresult
0X0
100
111
293 0 ▶ $ctx->exception("tried to serialize unblessed value $value")
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 0 0 0
294 if !blessed $value;
295 0 $m->to_libxml($value, $nn, $ctx);
296 }
297 elsif ( $m ) {
298 # allow value-based code above to drop through
299 }
300 else {
301 0 $ctx->exception("no marshaller for '$value'");
302 }
303 }
304 ▶ elsif ( $self->has_contents and defined $value ) {
Condition0%0/3
$self->has_contents and defined $value
!ll&&!rl&&r
000
MC/DC0%0/2
$self->has_contents and defined $value
$self->has_contents defined $value
Truth table0%0/3
A and B
A= $self->has_contentsB= defined $value
ABresult
0X0
100
111
305 0 my $tn = $doc->createTextNode($value);
306 0 $nn->appendChild($tn);
307 }
308 }
309 else {
310 0 $nn = $doc->createTextNode($value);
311 0 $node->appendChild($nn);
312 }
313 9 };
314  
315 9 with 'PRANG::Graph::Node';
316  
317 9 1;
318  
319 __END__
320  
321 =head1 NAME
322  
323 PRANG::Graph::Element - accept a particular type of element
324  
325 =head1 SYNOPSIS
326  
327 See L<PRANG::Graph::Meta::Element> source and
328 L<PRANG::Graph::Node> for examples and information.
329  
330 =head1 DESCRIPTION
331  
332 This graph node specifies that the XML graph at this point must accept
333 a particular type of element.
334  
335 If the element only has only simple types (eg Str, Bool), it will not
336 have one of these objects in its graph.
337  
338 Along with L<PRANG::Graph::Text>, this graph node is the only type
339 which may actually consume input XML nodes or emit them on output.
340 The other node types merely change the state in the
341 L<PRANG::Graph::Context> object.
342  
343 =head1 ATTRIBUTES
344  
345 =over
346  
347 =item B<Str xmlns>
348  
349 If set, then the XML namespace of this element is expected to be the
350 value passed (or absent). This is generally not set if the namespace
351 of this portion of the graph is the same as the parent class.
352  
353 =item B<nodeName>
354  
355 This map is used for emitting and generating error messages. Also, if
356 set to C<*> it has special meaning when parsing. Specifies the name
357 of the node.
358  
359 =item B<nodeName_attr>
360  
361 If set, instances have an attribute which stores the name of the XML
362 element.
363  
364 =item B<Str nodeClass>
365  
366 This specifies the next type of element; during parsing and emitting,
367 recursion to the meta-object of this class occurs.
368  
369 This will be undefined if the attribute has C<Bool> type; node
370 presence is true and absence is false.
371  
372 =item B<attrName>
373  
374 Used when emitting; specifies the method to call to retrieve the item
375 to be output. Also used when parsing, to return the Moose attribute
376 slot for construction.
377  
378 =back
379  
380 =head1 SEE ALSO
381  
382 L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Element>,
383 L<PRANG::Graph::Context>, L<PRANG::Graph::Node>
384  
385 =head1 AUTHOR AND LICENCE
386  
387 Development commissioned by NZ Registry Services, and carried out by
388 Catalyst IT - L<http://www.catalyst.net.nz/>
389  
390 Copyright 2009, 2010, NZ Registry Services. This module is licensed
391 under the Artistic License v2.0, which permits relicensing under other
392 Free Software licenses.
393  
394 =cut
395  
« PRANG/Graph/Meta/Element.pm ↑ Summary PRANG/Graph/Choice.pm »