"//mods:mods/mods:titleInfo[mods:title and (\@type='uniform')]",
proper =>
"//mods:mods/mods:titleInfo[mods:title and not (\@type)]",
+ sortkey =>
+ "//mods:mods/mods:titleInfo[mods:title and not (\@type)]",
any =>
"//mods:mods/mods:titleInfo",
},
sub get_field_value {
- my( $self, $mods, $xpath, $type) = @_;
+ my( $self, $mods, $xpath, $class, $type) = @_;
my @string;
my @children = $value->childNodes();
my @child_text;
for my $child (@children) {
+ # Magic for title-sorting special value, skip the nonSort node
+ next if ($class && $class eq 'title' && $type && $type eq 'sortkey' && $child->nodeName =~ m/nonSort/);
+
# MODS strips the punctuation from 245abc, which often
# results in "title subtitle" rather than "title : subtitle";
# this hack gets it back for us
- if ($type && $type eq 'title' && $child->nodeName =~ m/subTitle/) {
+ if ($class && $class eq 'title' && $child->nodeName =~ m/subTitle/) {
push(@child_text, " : ");
}
next unless( $child->nodeType != 3 );
my $class = "title";
$data->{$class} = {};
for my $type(keys %{$xpathset->{$class}}) {
- my @value = $self->get_field_value( $mods, $xpathset->{$class}->{$type}, "title" );
+ my @value = $self->get_field_value( $mods, $xpathset->{$class}->{$type}, "title", $type );
for my $arr (@value) {
if( ref($arr) ) {
$data->{$class}->{$type} = shift @$arr;
my( $self, $modsperl ) = @_;
my $title = "";
+ my $titlesort = "";
my $author = "";
my $subject = [];
my $series = [];
($title = $tmp->{any});
}
+ # Just another title value check, so we can re-use the previous tmp lookup
+ if(!$tmp) { $titlesort = ""; }
+ else {
+ ($titlesort = $tmp->{sortkey}) ||
+ ($titlesort = $title);
+ }
+
$tmp = $modsperl->{author};
if(!$tmp) { $author = ""; }
else {
else { $series = $tmp->{'series'}; }
- return { series => $series, title => $title,
+ return { series => $series, title => $title, titlesort => $titlesort,
author => $author, subject => $subject };
}
#(my $title = $perl->{title}) =~ s/\[.*?\]//og;
#(my $author = $perl->{author}) =~ s/\(.*?\)//og;
my $title = $perl->{title};
+ my $titlesort = $perl->{titlesort};
my $author = $perl->{author};
my @series;
$rtypes = [ keys %hash ];
$record->title($title);
+ $record->titlesort($titlesort);
$record->author($author);
$record->doc_id($perl->{doc_id});