Bio-Biblio
view release on metacpan or search on metacpan
lib/Bio/Biblio/IO/pubmedxml.pm view on Meta::CPAN
(
'PubMedPubDate' => 'pubDates',
'History' => 'histories',
);
sub handle_start {
my ($expat, $e, %attrs) = @_;
# &Bio::Biblio::IO::medlinexml::_debug_object_stack ("START", $e);
#
# The #PCDATA elements which have an attribute list must
# be first here - because for them I create entries both on
# the @PCDataStack _and_ on @ObjectStack.
#
if ($e eq 'ArticleId') {
my %p = ();
$p{'idType'} = (defined $attrs{'IdType'} ? $attrs{'IdType'} : 'pubmed');
push (@Bio::Biblio::IO::medlinexml::ObjectStack, \%p);
}
if ($e eq 'URL') {
my %p = ();
$p{'type'} = $attrs{'type'} if $attrs{'type'};
$p{'lang'} = $attrs{'lang'} if $attrs{'lang'};
push (@Bio::Biblio::IO::medlinexml::ObjectStack, \%p);
}
#
# Then we have #PCDATA elements without an attribute list.
# For them I create an entry on @PCDataStack.
#
if (exists $PCDATA_NAMES{$e}) {
push (@Bio::Biblio::IO::medlinexml::PCDataStack, '');
#
# And finally, all non-PCDATA elements go to the objectStack
#
} elsif (exists $SIMPLE_TREATMENT{$e}) {
push (@Bio::Biblio::IO::medlinexml::ObjectStack, {});
} elsif ($e eq 'ArticleIdList') {
;
} elsif ($e eq 'PubMedPubDate') {
my %p = ();
$p{'pubStatus'} = $attrs{'PubStatus'} if $attrs{'PubStatus'};
push (@Bio::Biblio::IO::medlinexml::ObjectStack, \%p);
} else {
&Bio::Biblio::IO::medlinexml::handle_start ($expat, $e, %attrs);
}
}
sub handle_end {
my ($expat, $e) = @_;
#
# First I have to deal with those elements which are both PCDATA
# (and therefore they are on the pcdataStack) and which have an
# attribute list (therefore they are also known as a separate
# p-object on the objectStack.
#
if ($e eq 'ArticleId') {
&Bio::Biblio::IO::medlinexml::_data2obj ('id');
&Bio::Biblio::IO::medlinexml::_add_element ('pubmedArticleIds', pop @Bio::Biblio::IO::medlinexml::ObjectStack);
# &Bio::Biblio::IO::medlinexml::_debug_object_stack ("END", $e);
return;
}
if ($e eq 'URL') {
&Bio::Biblio::IO::medlinexml::_data2obj ('URL');
&Bio::Biblio::IO::medlinexml::_add_element ('pubmedURLs', pop @Bio::Biblio::IO::medlinexml::ObjectStack);
# &Bio::Biblio::IO::medlinexml::_debug_object_stack ("END", $e);
return;
}
#
# both object and pcdata stacks elements mixed here together
#
if (exists $POP_DATA_AND_PEEK_OBJ{$e}) {
&Bio::Biblio::IO::medlinexml::_data2obj ("\l$e");
} elsif (exists $POP_AND_ADD_DATA_ELEMENT{$e}) {
&Bio::Biblio::IO::medlinexml::_add_element ($POP_AND_ADD_DATA_ELEMENT{$e}, pop @Bio::Biblio::IO::medlinexml::ObjectStack);
} elsif ($e eq 'MedlineCitation' ||
$e eq 'NCBIArticle') {
&Bio::Biblio::IO::medlinexml::_obj2obj ('Citation');
} elsif ($e eq 'PubmedData') {
&Bio::Biblio::IO::medlinexml::_obj2obj ('PubmedData');
} elsif ($e eq 'PubMedArticle' ||
$e eq 'PubmedArticle') {
#
# Here we finally have the whole citation ready.
#
&Bio::Biblio::IO::medlinexml::_process_citation (pop @Bio::Biblio::IO::medlinexml::ObjectStack);
} else {
&Bio::Biblio::IO::medlinexml::handle_end ($expat, $e);
}
# &Bio::Biblio::IO::medlinexml::_debug_object_stack ("END", $e);
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Bio::Biblio::IO::pubmedxml - a converter of XML files with PUBMED citations
=head1 VERSION
version 1.70
=head1 SYNOPSIS
Do not use this object directly, it is recommended to access it and use
it through the I<Bio::Biblio::IO> module:
use Bio::Biblio::IO;
my $io = Bio::Biblio::IO->new(-format => 'pubmedxml');
=head1 DESCRIPTION
This object reads bibliographic citations in XML/MEDLINE format and
converts them into I<Bio::Biblio::RefI> objects. It is an
implementation of methods defined in I<Bio::Biblio::IO>.
( run in 1.045 second using v1.01-cache-2.11-cpan-6aa56a78535 )