=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 SYNOPSIS
C<xml_file> defines path to normalize XML.
+C<tags> define additional tags that can be forced (and an be array).
+
=cut
sub open {
$self->{'import_xml_file'} = $xml_file;
+ my @force_array = [ $self->{'tag'}, 'config', 'format' ];
+ push @force_array, $self->{'tags'} if ($self->{'tags'});
+
$self->{'import_xml'} = XMLin($xml_file,
- ForceArray => [ $self->{'tag'}, $self->{'tags'}, 'config', 'format' ],
+ ForceArray => @force_array,
ForceContent => 1,
);
my ($name,$join) = @_;
die "no data array" unless ($data->{'data'} && ref($data->{'data'}) eq 'ARRAY');
+ # Hm? Should we die here?
+ return unless ($name);
my $item = first { $_->{'name'} eq $name } @{ $data->{'data'} };
use Cwd qw/abs_path/;
use blib;
use strict;
+use Data::Dumper;
BEGIN {
use_ok( 'WebPAC::Normalize::XML' );
throws_ok { $n->open() } qr/tag/, "open without tag";
throws_ok { $n->open( tag => 'isis' ) } qr/xml_file/, "open without xml_file";
-throws_ok { $n->open( tag => 'isis', xml_file => 'foo' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
+throws_ok { $n->open( tag => 'isis', xml_file => '/foo/bar/baz' ) } qr/file.*doesn't exist/, "open with invalid xml_file";
ok( $n->open(
tag => 'isis',
xml_file => "$abs_path../conf/normalize/isis.xml",
ok(my @ds = $n->data_structure( $rec ), "data_structure");
+#diag Dumper(@ds);