File Coverage

lib/XML/Schema/Type/List.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition 1 2 50.0
subroutine 6 6 100.0
pod 1 2 50.0
total 35 37 94.5


line stmt bran cond sub pod time code
1             #============================================================= -*-perl-*-
2             #
3             # XML::Schema::Type::List
4             #
5             # DESCRIPTION
6             # Module implementing the XML Schema list datatype.
7             #
8             # AUTHOR
9             # Andy Wardley
10             #
11             # COPYRIGHT
12             # Copyright (C) 2001 Canon Research Centre Europe Ltd.
13             # All Rights Reserved.
14             #
15             # This module is free software; you can redistribute it and/or
16             # modify it under the same terms as Perl itself.
17             #
18             # REVISION
19             # $Id: List.pm,v 1.1.1.1 2001/08/29 14:30:17 abw Exp $
20             #
21             #========================================================================
22              
23             package XML::Schema::Type::List;
24              
25 28     28   142 use strict;
  28         48  
  28         925  
26 28     28   171 use XML::Schema::Type::Simple;
  28         61  
  28         850  
27 28     28   152 use base qw( XML::Schema::Type::Simple );
  28         65  
  28         2666  
28 28     28   146 use vars qw( $VERSION $DEBUG $ERROR @MANDATORY @FACETS );
  28         53  
  28         10946  
29              
30             $VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
31             $DEBUG = 0 unless defined $DEBUG;
32             $ERROR = '';
33              
34             @MANDATORY = qw( itemType );
35             @FACETS = (
36             whiteSpace => 'collapse',
37             sub { $_[1]->split($_[0]) },
38             );
39              
40             sub split {
41 15     15 0 16 my ($self, $instance) = @_;
42             my $base = $self->{ itemType }
43 15   50     37 || return $self->error('list has no itemType');
44 15         17 my $i = 0;
45              
46             $instance->{ value } = [
47 41 100       118 map {
48             $base->instance($_)
49             || return $self->error("list item $i: " . $base->error());
50 37         168 $i++;
51             } split(/\s+/, $instance->{ value })
52 15         58 ];
53              
54 11         50 return 1;
55             }
56              
57             sub init {
58 4     4 1 7 my ($self, $config) = @_;
59 4 100       17 $self->SUPER::init($config)
60             || return;
61 3         6 $self->{ _VARIETY } = 'list';
62 3         15 return $self;
63             }
64              
65              
66             __END__