| File | /home/tamil/util/marc-moose/lib/MARC/Moose/Parser/MarcxmlSax.pm |
| Statements Executed | 21 |
| Total Time | 0.0006878 seconds |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0s | 0s | MARC::Moose::Parser::MarcxmlSax::BEGIN |
| 0 | 0 | 0 | 0s | 0s | MARC::Moose::Parser::MarcxmlSax::__ANON__[:13] |
| 0 | 0 | 0 | 0s | 0s | MARC::Moose::Parser::MarcxmlSax::__ANON__[:41] |
| Line | Stmts. | Exclusive Time | Avg. | Code |
|---|---|---|---|---|
| 1 | package MARC::Moose::Parser::MarcxmlSax; | |||
| 2 | # ABSTRACT: Parser for MARXML records using SAX parser | |||
| 3 | ||||
| 4 | 3 | 31µs | 10µs | use namespace::autoclean; # spent 65µs making 1 call to namespace::autoclean::import |
| 5 | 3 | 59µs | 20µs | use Moose; # spent 5.79ms making 1 call to Moose::Exporter::__ANON__[/usr/local/lib/perl/5.10.0/Moose/Exporter.pm:425] |
| 6 | ||||
| 7 | 1 | 7µs | 7µs | extends 'MARC::Moose::Parser'; # spent 1.47ms making 1 call to Moose::extends |
| 8 | ||||
| 9 | 3 | 28µs | 9µs | use MARC::Moose::Field::Control; # spent 5µs making 1 call to import |
| 10 | 3 | 27µs | 9µs | use MARC::Moose::Field::Std; # spent 4µs making 1 call to import |
| 11 | 3 | 442µs | 147µs | use XML::Simple; # spent 16µs making 1 call to XML::Simple::import |
| 12 | ||||
| 13 | 1 | 10µs | 10µs | has 'xs' => ( is => 'rw', default => sub { XML::Simple->new() } ); # spent 2.30ms making 1 call to Moose::has |
| 14 | ||||
| 15 | ||||
| 16 | override 'parse' => sub { | |||
| 17 | my ($self, $raw) = @_; | |||
| 18 | ||||
| 19 | return unless $raw; | |||
| 20 | ||||
| 21 | my $ref = eval { $self->xs->XMLin($raw, forcearray => [ 'subfield' ] ) }; | |||
| 22 | return undef if $@; | |||
| 23 | ||||
| 24 | my $record = MARC::Moose::Record->new(); | |||
| 25 | $record->_leader( $ref->{leader} ); | |||
| 26 | my @fields_control = map { | |||
| 27 | MARC::Moose::Field::Control->new( tag => $_->{tag}, value => $_->{content} ); | |||
| 28 | } @{$ref->{controlfield}}; | |||
| 29 | my @fields_std = map { | |||
| 30 | my @sf = map { [ $_->{code}, $_->{content} ] } @{$_->{subfield}}; | |||
| 31 | MARC::Moose::Field::Std->new( | |||
| 32 | tag => $_->{tag}, | |||
| 33 | ind1 => $_->{ind1}, | |||
| 34 | ind2 => $_->{ind2}, | |||
| 35 | subf => \@sf, | |||
| 36 | ); | |||
| 37 | } @{$ref->{datafield}}; | |||
| 38 | $record->fields( [ @fields_control, @fields_std ] ); | |||
| 39 | ||||
| 40 | return $record; | |||
| 41 | 1 | 21µs | 21µs | }; # spent 505µs making 1 call to Moose::override |
| 42 | ||||
| 43 | 1 | 17µs | 17µs | __PACKAGE__->meta->make_immutable; # spent 3.95ms making 1 call to Class::MOP::Class::make_immutable
# spent 24µs making 1 call to MARC::Moose::Parser::MarcxmlSax::meta |
| 44 | ||||
| 45 | 1 | 34µs | 34µs | 1; |
| 46 | ||||
| 47 | =head1 SEE ALSO | |||
| 48 | ||||
| 49 | =for :list | |||
| 50 | * L<MARC::Moose> | |||
| 51 | * L<MARC::Moose::Parser> | |||
| 52 | 1 | 12µs | 12µs | * L<MARC::Moose::Parser::Marcxml> |