Bio-Biblio
view release on metacpan or search on metacpan
lib/Bio/Biblio/IO/medlinexml.pm view on Meta::CPAN
# Then we have #PCDATA elements without an attribute list.
# For them I create an entry on @PCDataStack.
#
if (exists $PCDATA_NAMES{$e}) {
push (@PCDataStack, '');
#
# And finally, all non-PCDATA elements go to the objectStack
#
} elsif (exists $SIMPLE_TREATMENT{$e}) {
push (@ObjectStack, {});
} elsif ($e eq 'PersonalNameSubject') {
push (@ObjectStack, {'type' => 'PersonalName'});
} elsif ($e eq 'DescriptorName' or
$e eq 'Descriptor') {
if (&_eq_hash_elem (\%attrs, 'MajorTopicYN', "Y")) {
my $peek = $ObjectStack[$#ObjectStack];
$$peek{'descriptorMajorTopic'} = "Y";
}
} elsif ($e eq 'MedlineCitation' ||
$e eq 'NCBIArticle') {
my %p = ( 'type' => 'MedlineCitation' );
$p{'owner'} = $attrs{'Owner'} if $attrs{'Owner'};
$p{'status'} = $attrs{'Status'} if $attrs{'Status'};
push (@ObjectStack, \%p);
} elsif ($e eq 'GrantList') {
if (&_eq_hash_elem (\%attrs, 'CompleteYN', "N")) {
my $peek = $ObjectStack[$#ObjectStack];
$$peek{'grantListComplete'} = "N";
}
} elsif ($e eq 'DataBankList') {
if (&_eq_hash_elem (\%attrs, 'CompleteYN', "N")) {
my $peek = $ObjectStack[$#ObjectStack];
$$peek{'dataBankListComplete'} = "N";
}
} elsif ($e eq 'AuthorList') {
if (&_eq_hash_elem (\%attrs, 'CompleteYN', "N")) {
my $peek = $ObjectStack[$#ObjectStack];
$$peek{'authorListComplete'} = "N";
}
} elsif ($e eq 'OtherAbstract') {
my %p = ();
$p{'type'} = $attrs{'Type'} if $attrs{'Type'};
push (@ObjectStack, \%p);
# push (@ObjectStack, { 'type' => 'Abstract' });
}
}
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 'QualifierName' or
$e eq 'SubHeading') {
my $p = pop @ObjectStack; # pSubHeading
$$p{'subHeading'} = pop @PCDataStack;
&_add_element ('subHeadings', $p); # adding to pMeshHeadings
# &_debug_object_stack ("END", $e);
return;
} elsif ($e eq 'GeneralNote') {
my $p = pop @ObjectStack; # pGeneralNote
$$p{'generalNote'} = pop @PCDataStack;
&_add_element ('generalNotes', $p); # adding to pMedlineCitation
# &_debug_object_stack ("END", $e);
return;
} elsif ($e eq 'OtherID') {
my $p = pop @ObjectStack; # pOtherID
$$p{'otherID'} = pop @PCDataStack;
&_add_element ('otherIDs', $p); # adding to pMedlineCitation
# &_debug_object_stack ("END", $e);
return;
}
#
# both object and pcdata stacks elements mixed here together
# (the element names appear in the order of frequency in the
# medline data set)
#
if (exists $POP_DATA_AND_PEEK_OBJ{$e}) {
&_data2obj ("\l$e");
} elsif (exists $POP_OBJ_AND_PEEK_OBJ{$e}) {
&_obj2obj ("\l$e");
} elsif (exists $POP_AND_ADD_ELEMENT{$e}) {
&_add_element ($POP_AND_ADD_ELEMENT{$e}, pop @ObjectStack);
} elsif (exists $POP_AND_ADD_DATA_ELEMENT{$e}) {
&_add_element ($POP_AND_ADD_DATA_ELEMENT{$e});
} elsif ($e eq 'Author' or
$e eq 'Investigator') {
my $pAuthor;
my $p = pop @ObjectStack; # pPersonalName or pAuthor
if (&_eq_hash_elem ($p, 'type', 'PersonalName')) {
$pAuthor = pop @ObjectStack;
$$pAuthor{'personalName'} = $p;
} else {
$pAuthor = $p;
}
my $peek = $ObjectStack[$#ObjectStack]; # pMedlineCitation, pArticle or pBook
if (&_eq_hash_elem ($peek, 'type', 'MedlineCitation')) {
&_add_element ('investigators', $pAuthor);
} else {
&_add_element ('authors', $pAuthor);
}
} elsif ($e eq 'MedlineJournalInfo') {
&_obj2obj ('journalInfo');
} elsif ($e eq 'PMID') {
my $peek = $ObjectStack[$#ObjectStack]; # pMedlineCitation, pReference or pDeleteCitation
if (&_eq_hash_elem ($peek, 'type', 'DeleteCitation')) {
&_add_element ('PMIDs');
} else {
$$peek{'PMID'} = pop @PCDataStack;
}
} elsif ($e eq 'MedlineID') {
my $peek = $ObjectStack[$#ObjectStack]; # pMedlineCitation, pReference or pDeleteCitation
if (&_eq_hash_elem ($peek, 'type', 'DeleteCitation')) {
&_add_element ('MedlineIDs');
} else {
$$peek{'medlineID'} = pop @PCDataStack;
}
# } elsif ($e eq 'OtherAbstract') {
# my $pAbstract = pop @ObjectStack;
# my $pOtherAbstract = pop @ObjectStack;
# $$pOtherAbstract{'abstract'} = $pAbstract
# &_add_element ('otherAbstracts', $pOtherAbstract);
} elsif ($e eq 'Affiliation') {
my $peek = $ObjectStack[$#ObjectStack];
( run in 1.568 second using v1.01-cache-2.11-cpan-6aa56a78535 )