blib/lib/XML/DOMBacked.pm

filter: Statementstmt 95.3% 287 / 301 Branchbran 76.4% 52 / 68 Conditioncond 62.5% 5 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 51 / 51 Podpod 30.4% 7 / 23 totaltotal 88.1% 402 / 456 CC 46 SCAR 10.2
CC
46
Cov
91%
lookup_namespace
7.2
get_property_object
5.0
set_dom_attribute
4.0
CRAP 2.8
↑ Summary
1 package XML::DOMBacked;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '1.00';
11 2 our $NSMAP = {};
12  
13 use overload
14 2 ▶ 'eq' => 'check_equality',
Subroutine BEGIN: called CC=1 SCAR=0.0
15 '==' => 'check_equality',
16 2 fallback => 1;
17  
18 3 ▶sub check_equality {
Subroutine check_equality: called CC=1 SCAR=0.0
Pod undocumented
19 3 my $lhs = shift;
20 3 my $rhs = shift;
21 3 $lhs->dom->isSameNode( $rhs->dom );
22 }
23  
24 7 ▶sub new {
Subroutine new: called CC=3 SCAR=13.6
Pod documented
25 7 my $class = shift;
26 7 my $self = {};
27 7 bless $self => $class;
28 7 my $init = eval { $self->init( @_ ) };
29 7 ▶ if (!$init) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($init) 0 7 7
30 0 my $mesg = "could not initialise object";
31 0 ▶ if ( $@ ) { $mesg .= ': ' . $@ }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
32 0 die $mesg;
33 }
34 7 return $self;
35 }
36  
37 1 ▶sub from_uri {
Subroutine from_uri: called CC=3 SCAR=11.7
Pod documented
38 1 my $class = shift;
39 1 my $uri = shift;
40 1 ▶ if (!$uri) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uri) 0 1 1
41 0 die "need to have URI to load";
42 }
43 1 my $ua = LWP::UserAgent->new;
44 1 my $r = $ua->get( $uri );
45 1 ▶ if ( !$r->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($r->is_success) 0 1 1
46 0 die "load failed: " . $r->status_line;
47 }
48 1 my $doc = XML::LibXML->new->parse_string( $r->content );
49 1 $class->new->dom( $doc->documentElement );
50 }
51  
52  
53 7 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
54 7 my $self = shift;
55 7 $self->dom( XML::LibXML::Element->new( $self->nodename ) );
56 7 XML::LibXML::Document->new('1.0','UTF-8')->addChild( $self->dom );
57 7 return "init_call_passed";
58 }
59  
60 4 ▶sub nodename {
Subroutine nodename: called CC=3 SCAR=11.8
Pod undocumented
61 4 my $self = shift;
62 4 ▶ my $class = ref( $self ) || $self;
Condition66%2/3
ref $self || $self
l!l&&r!l&&!r
220
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table66%2/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
63 4 ▶ if ( $class =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class =~ /:/) 0 4 4
64 ## we just want to xmlify the last bit
65 0 return lc( substr($class, rindex( $class, ':') + 1 ) );
66 }
67 4 return lc( $class );
68 }
69  
70 110 ▶sub dom {
Subroutine dom: called CC=2 SCAR=6.9
Pod undocumented
71 110 my $self = shift;
72 110 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 8 102 110
73 8 $self->{ dom } = shift;
74 8 return $self;
75 }
76 102 return $self->{ dom };
77 }
78  
79 1 ▶sub has_many {
Subroutine has_many: called CC=3 SCAR=11.0
Pod documented
80 1 my $class = shift;
81 1 my $pairs = { @_ };
82 1 foreach my $key ( keys %$pairs ) {
83 2 ▶ if ( ref( $pairs->{ $key } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pairs->{$key}) { } 1 1 2
84 ## this is a complicated multivalue thing
85 1 $class->setup_has_many_complex( $key, $pairs->{ $key }->{class} );
86 } else {
87 ## this is a simple multivalue thing.
88 ## What am I talking about they're _all_ complicated multivalue things!
89 1 $class->setup_has_many_simple( $key, $pairs->{ $key } );
90 }
91 }
92 }
93  
94 1 ▶sub setup_has_many_complex {
Subroutine setup_has_many_complex: called CC=2 SCAR=6.9
Pod undocumented
95 1 my $class = shift;
96 1 my $key = shift;
97 1 my $val = shift;
98 1 my $name = $val->nodename;
99 1 ▶ if ( $name =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /:/) 1 0 1
100 1 my ($ns, $attr) = split(/:/, $name);
101 1 $name = $attr;
102 }
103 # print "Creating thing: $name\n";
104 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
105 1 ▶ *{$class.'::add_'.$name} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
106 2 my $self = shift;
107 2 my $obj = shift;
108 2 $self->dom->addChild( $obj->dom );
109 1 };
110 1 ▶ *{$class.'::'.$key} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
111 2 my $self = shift;
112 2 map { bless( { dom => $_ }, $val ) } $self->dom->getChildrenByTagName( $val->nodename )
113 1 };
114 1 ▶ *{$class.'::remove_'.$name} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
115 2 my $self = shift;
116 2 my $obj = shift;
117 2 $self->dom->removeChild( $obj->dom );
118 }
119 1 }
120  
121 1 ▶sub setup_has_many_simple {
Subroutine setup_has_many_simple: called CC=3 SCAR=11.0
Pod undocumented
122 1 my $class = shift;
123 1 my $key = shift;
124 1 my $val = shift;
125 1 my $name = $val;
126 1 ▶ if ( $val =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /:/) 1 0 1
127 1 my ($ns, $attr) = split(/:/, $val);
128 1 ▶ if (!$class->lookup_namespace( $ns )) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class->lookup_namespace($ns)) 0 1 1
129 0 die "can't create a property with unknown namespace ($ns)";
130 }
131 1 $name = $attr;
132 }
133 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
134 1 ▶ *{$class .'::add_'. $name} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
135 2 my $self = shift;
136 2 my $data = shift;
137 2 my $elem = XML::LibXML::Element->new( $val );
138 2 $elem->appendText( $data );
139 2 $self->dom->addChild( $elem );
140 1 };
141 1 ▶ *{$class .'::'.$key} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
142 2 my $self = shift;
143 2 map { $_->findvalue('.') } $self->dom->getChildrenByTagName($val);
144 1 };
145 1 ▶ *{$class .'::remove_'.$name} = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
146 1 my $self = shift;
147 1 my $data = shift;
148 1 my @list = grep { $_->findvalue('.') eq $data } $self->dom->getChildrenByTagName( $val );
149 1 $self->dom->removeChild( $_ ) for @list;
150 1 1;
151 1 };
152 }
153  
154 1 ▶sub has_a {
Subroutine has_a: called CC=4 SCAR=13.9
Pod documented
155 1 my $class = shift;
156 1 foreach my $key ( @_ ) {
157 2 ▶ if ( $key->nodename =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key->nodename =~ /:/) { } 1 1 2
158 ## we're in magic namespace land
159 1 my ($ns, $rkey) = split(/:/, $key->nodename);
160 1 my $uri = $class->lookup_namespace( $ns );
161 1 ▶ if (!$uri) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uri) 0 1 1
162 0 die "can't create a property in an unknown namespace( $ns )";
163 }
164 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
165 1 ▶ *{ $class . '::' . $rkey } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
166 2 my $self = shift;
167 2 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
168 1 $self->set_dom_object( $key, @_ );
169 1 return $self;
170 }
171 1 return $self->get_dom_object( $key );
172 1 };
173 } else {
174 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
175 # print "Creating in class $key\n";
176 1 ▶ *{ $class . '::' . $key } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
177 2 my $self = shift;
178 2 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
179 1 $self->set_dom_object( $key, @_ );
180 1 return $self;
181 }
182 1 return $self->get_dom_object( $key );
183 1 };
184 }
185 }
186 }
187  
188 2 ▶sub get_dom_object {
Subroutine get_dom_object: called CC=1 SCAR=0.0
Pod undocumented
189 2 my $self = shift;
190 2 my $prop = shift;
191 2 my $elem = $self->get_property_object( $prop->nodename );
192 2 my $thing = bless( { dom => $elem }, $prop );
193 2 return $thing;
194 }
195  
196 2 ▶sub set_dom_object {
Subroutine set_dom_object: called CC=2 SCAR=6.9
Pod undocumented
197 2 my $self = shift;
198 2 my $prop = shift;
199 2 my $val = shift;
200  
201 # print "Setting dom object\n";
202 # print $val->as_string;
203  
204 2 foreach my $ns ( $val->dom->getNamespaces ) {
205 2 my $prefix = $ns->name;
206 2 my $uri = $ns->getNamespaceURI;
207 2 $self->dom->setNamespace( $uri, $prefix, 0 );
208 }
209 2 $self->dom->addChild( $val->dom );
210 }
211  
212 2 ▶sub has_attributes {
Subroutine has_attributes: called CC=3 SCAR=11.0
Pod documented
213 2 my $class = shift;
214 2 foreach my $attribute ( @_ ) {
215 3 ▶ if ( $attribute =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribute =~ /:/) { } 2 1 3
216 ## has a namespace attached
217 2 my ($ns,$rattr) = split(/:/, $attribute);
218 2 my $uri = $class->lookup_namespace( $ns );
219 # if (! $uri ) {
220 # die "can't create an attribute for an unknown namespace ($ns)";
221 # }
222 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
223 2 ▶ *{ $class . '::' . $rattr } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
224 5 my $self = shift;
225 5 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 3 5
226 2 $self->set_dom_attribute( $attribute, @_ );
227 2 return $self;
228 }
229 3 return $self->get_dom_attribute( $attribute );
230 2 };
231 } else {
232 ## straightforward attribute.
233 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
234 1 ▶ *{ $class . '::' . $attribute } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
235 2 my $self = shift;
236 2 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
237 1 $self->set_dom_attribute( $attribute, @_ );
238 1 return $self;
239 }
240 1 return $self->get_dom_attribute( $attribute );
241 }
242 1 }
243 }
244 }
245  
246 3 ▶sub has_properties {
Subroutine has_properties: called CC=4 SCAR=13.9
Pod documented
247 3 my $class = shift;
248 3 foreach my $property ( @_ ) {
249 6 ▶ if ( $property =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property =~ /:/) { } 5 1 6
250 ## this has a namespace attached
251 5 my ($ns, $realprop) = split(/:/, $property);
252 5 my $uri = $class->lookup_namespace( $ns );
253 5 ▶ if ( ! $uri ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($uri) 0 5 5
254 0 die "can't create a property for an unknown namespace";
255 }
256 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
257 5 ▶ *{ $class . '::' . $realprop } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
258 13 my $self = shift;
259 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 7 13
260 6 $self->set_dom_property( $property, @_ );
261 6 return $self;
262 }
263 7 return $self->get_dom_property( $property );
264 5 };
265 } else {
266 ## this is in the default namespace
267 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
268 1 ▶ *{ $class . '::' . $property } = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
269 4 my $self = shift;
270 4 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 1 4
271 3 $self->set_dom_property( $property, @_ );
272 3 return $self;
273 }
274 1 return $self->get_dom_property( $property );
275 1 };
276 }
277 }
278 }
279  
280 3 ▶sub set_dom_attribute {
Subroutine set_dom_attribute: called CC=4 SCAR=13.9
Pod undocumented
281 3 my $self = shift;
282 3 my $prop = shift;
283 3 my $val = shift;
284 3 ▶ if ( $prop =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prop =~ /:/) { } 2 1 3
285 2 my ($ns, $realprop) = split(/:/, $prop);
286 2 ▶ my $uri = $self->lookup_namespace( $ns ) || '';
Condition50%1/2
$self->lookup_namespace($ns) || ''
l!l
20
MC/DC0%0/1
$self->lookup_namespace($ns) || ''
$self->lookup_namespace($ns)
Truth table50%1/2
A
A= $self->lookup_namespace($ns)
Aresult
11
00
287 2 ▶ if ( !$self->dom->lookupNamespaceURI( $ns ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->dom->lookupNamespaceURI($ns)) { } 1 1 2
288 1 $self->dom->setNamespace( $uri, $ns, 0 );
289 } else {
290 1 $uri = $self->dom->lookupNamespaceURI( $ns );
291 }
292 2 $self->dom->setAttributeNS( $uri, $realprop, $val );
293 } else {
294 1 $self->dom->setAttribute( $prop, $val );
295 }
296 }
297  
298 4 ▶sub get_dom_attribute {
Subroutine get_dom_attribute: called CC=3 SCAR=11.1
Pod undocumented
299 4 my $self = shift;
300 4 my $prop = shift;
301 4 ▶ if ( $prop =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prop =~ /:/) { } 3 1 4
302 3 my ($ns, $propname) = split(/:/, $prop);
303 3 my $uri = $self->lookup_namespace( $ns );
304 3 ▶ if ( $self->dom->hasAttributeNS( $self->lookup_namespace( $ns ), $propname ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dom->hasAttributeNS($self->lookup_namespace($ns), $propname)) { } 3 0 3
305 3 my $val = $self->dom->getAttributeNS( $uri, $propname );
306 3 return $val
307 } else {
308 0 die "no such property $prop";
309 }
310 } else {
311 1 return $self->dom->getAttribute( $prop );
312 }
313 }
314  
315 8 ▶sub get_dom_property {
Subroutine get_dom_property: called CC=1 SCAR=0.0
Pod undocumented
316 8 my $self = shift;
317 8 my $prop = shift;
318 8 my $elem = $self->get_property_object( $prop );
319 8 return $elem->findvalue( '.' );
320 }
321  
322 9 ▶sub set_dom_property {
Subroutine set_dom_property: called CC=2 SCAR=7.1
Pod undocumented
323 9 my $self = shift;
324 9 my $prop = shift;
325 9 my $data = shift;
326 9 my $elem = $self->get_property_object( $prop );
327 9 my $text = XML::LibXML::Text->new( $data );
328 9 ▶ if ( $elem->hasChildNodes() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->hasChildNodes) 0 9 9
329 0 $elem->removeChild( $elem->firstChild );
330 }
331 9 $elem->addChild( $text );
332 }
333  
334 19 ▶sub get_property_object {
Subroutine get_property_object: called CC=5 SCAR=16.1
Pod undocumented
335 19 my $self = shift;
336 19 my $prop = shift;
337  
338 19 ▶ if ( $prop =~ /:/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prop =~ /:/) { } 14 5 19
339 14 my ($ns, $rprop) = split(/:/, $prop);
340 14 my $uri = $self->lookup_namespace( $ns );
341 14 ▶ if ( !$self->dom->lookupNamespacePrefix( $uri ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dom->lookupNamespacePrefix($uri)) 5 9 14
342 5 $self->dom->setNamespace( $uri, $ns, 1 );
343 }
344 14 my $node = ($self->dom->getChildrenByTagNameNS( $uri, $rprop ))[0];
345 14 ▶ if (!$node) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node) 6 8 14
346 6 $node = $self->dom->addNewChild( $uri, $rprop );
347 }
348 14 return $node;
349  
350 } else {
351 5 my $node = ($self->dom->getChildrenByTagName($prop))[0];
352 5 ▶ if (! $node ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node) 3 2 5
353 3 $node = XML::LibXML::Element->new( $prop );
354 3 $self->dom->addChild( $node );
355 }
356 5 return $node;
357  
358 }
359 }
360  
361 36 ▶sub lookup_namespace {
Subroutine lookup_namespace: called CC=7 SCAR=19.8
Pod undocumented
362 36 my $self = shift;
363 36 my $ns = shift;
364 36 ▶ if (!$ns) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ns) 0 36 36
365 0 die "need an namespace parameter";
366 }
367 36 ▶ my $class = ref( $self ) || $self;
Condition66%2/3
ref $self || $self
l!l&&r!l&&!r
25110
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table66%2/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
368 36 ▶ if ( exists $NSMAP->{ $class }->{namespaces}->{ $ns } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $XML::DOMBacked::NSMAP->{$class}{'namespaces'}{$ns}) { } 35 1 36
369 ## it belongs to this class, which makes life eeee-zeee!
370 35 return $NSMAP->{$class}->{namespaces}->{ $ns };
371 } else {
372 ## we're in the land of recursion, la la la la lah!
373 ## first we get the IS-A var.
374 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
375 1 my @isa = @{ $class . '::ISA' };
376 2 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
377 1 my $uri;
378  
379 ## loop through it until we get an answer
380 1 foreach my $isa ( @isa ) {
381 1 my $result = eval { $isa->lookup_namespace( $ns ) };
382 1 ▶ if ( $result ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 1 0 1
383 1 $uri = $result;
384 1 last;
385 }
386 }
387  
388 1 ▶ if ( !exists $NSMAP->{ $class }->{ namespaces }->{ $ns } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $XML::DOMBacked::NSMAP->{$class}{"namespaces"}{$ns}) 1 0 1
389 1 $NSMAP->{ $class }->{ namespaces }->{ $ns } = $uri;
390 }
391  
392 1 return $uri;
393 }
394 0 return 0;
395 }
396  
397 6 ▶sub uses_namespace {
Subroutine uses_namespace: called CC=2 SCAR=6.9
Pod documented
398 6 my $class = shift;
399 6 my $pairs = { @_ };
400 6 foreach my $key (keys %$pairs) {
401 6 my $ns = $key;
402 6 my $uri = $pairs->{$key};
403 6 $NSMAP->{$class}->{ namespaces }->{ $ns } = $uri;
404 }
405 }
406  
407 2 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
408 2 my $self = shift;
409 2 return $self->dom->toString( 1 );
410 }
411  
412 2 ▶sub as_xml {
Subroutine as_xml: called CC=1 SCAR=0.0
Pod undocumented
413 2 my $self = shift;
414 2 my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
415 2 $doc->setDocumentElement( $self->dom );
416 2 return $doc->toString( 1 );
417 }
418  
419 2 1;
420  
421 =head1 NAME
422  
423 XML::DOMBacked - objects backed by a DOM
424  
425 =head1 SYNOPSIS
426  
427 package Person;
428  
429 use base 'XML::DOMBacked';
430  
431 Person->uses_namespace(
432 'foaf' => 'http://xmlns.com/foaf/0.1/',
433 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
434 );
435 Person->has_properties( 'foaf:name','foaf:title','foaf:nick' );
436 Person->has_attributes( 'rdf:nodeID' );
437 Person->has_a( 'Person::Knows' );
438  
439 sub nodename { "foaf:Person" }
440  
441 package Person::Knows;
442  
443 use base 'XML::DOMBacked';
444  
445 Person::Knows->has_many( people => { class => 'Person' } );
446  
447 package main;
448  
449 my $p = Person->new;
450 $p->nodeID("me");
451 $p->name('A. N. Other');
452 $p->title('Mr');
453 $p->nick('another');
454  
455 my $a = Person->new;
456 $a->name('Yet Another');
457  
458 $p->Knows->add_Person( $a );
459 print $p->as_xml;
460  
461 $p = Person->from_uri( 'file:person.xml' );
462  
463 =head1 DESCRIPTION
464  
465 The C<XML::DOMBacked> class lets you back an object on an XML DOM. Think of it as Class::DBI
466 for XML files. You can specifiy things you want to be properties (nodes), attributes, and
467 other objects. XML::DOMBacked takes care of the heavy lifting so that you don't have to.
468  
469 =head1 CONSTRUCTORS
470  
471 =over 4
472  
473 =item new()
474  
475 Constructs a new object.
476  
477 =item from_uri()
478  
479 Loads an object from a URI. Expects XML at the other end.
480  
481 =back
482  
483 =head1 METHODS
484  
485 =over 4
486  
487 =item uses_namespace( prefix => uri )
488  
489 Adds an XML namespace to the object.
490  
491 =item has_properties( ARRAY )
492  
493 Adds XML Elements to the object. These become accessors.
494  
495 =item has_attributes( ARRAY )
496  
497 Adds XML Attributes to the object. These become accessors.
498  
499 =item has_a( ARRAY )
500  
501 Adds 1..1 relationships with other classes to the object. The other classes
502 must also inherit from XML::DOMBacked.
503  
504 =item has_many( PLURAL => SINGULAR )
505  
506 Adds add_SINGULAR, remove_SINGLUAR and PLURAL methods to the class.
507  
508 =item has_many( PLURAL => { class => CLASS } )
509  
510 Looks up the NODENAME for the class, then creates add_NODENAME, remove_NODENAME, and PLURAL methods to the class.
511  
512 =back
513  
514 =head1 BUGS
515  
516 Probably loads. This is really funky, crazy code. I'd be surprised if there aren't bugs.
517  
518 =head1 AUTHOR
519  
520 James A. Duncan <jduncan@fotango.com>
521  
522 =head1 COPYRIGHT
523  
524 Copyright 2005 Fotango Ltd. All Rights Reserved.
525  
526 =cut
↑ Summary