Bug 3326: Work around Zebra's handling of & entities

When using XSLT mode, the OPAC results display will show "&" instead of "&"
when Zebra is indexing in XML mode. This patch works around this by replacing
"&" with "&" and then extends the previous fix to apply to all occurrences
of "& " instead of just the first.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Jared Camins-Esakov 2011-03-14 22:14:19 -04:00 committed by Chris Cormack
parent 74c37aeeb6
commit d52f3680f4
2 changed files with 8 additions and 3 deletions

View file

@ -1687,7 +1687,9 @@ sub searchResults {
# FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search results)
# is not implemented yet
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
$search_context);
$search_context, 1);
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
}
# last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items

View file

@ -120,7 +120,7 @@ sub getAuthorisedValues4MARCSubfields {
my $stylesheet;
sub XSLTParse4Display {
my ( $biblionumber, $orig_record, $xsl_suffix, $interface ) = @_;
my ( $biblionumber, $orig_record, $xsl_suffix, $interface, $fixamps ) = @_;
$interface = 'opac' unless $interface;
# grab the XML, run it through our stylesheet, push it out to the browser
my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
@ -139,8 +139,11 @@ sub XSLTParse4Display {
}
$sysxml .= "</sysprefs>\n";
$xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
$xmlrecord =~ s/\&amp;/\&/g;
}
$xmlrecord =~ s/\& /\&amp\; /;
$xmlrecord=~ s/\&amp\;amp\; /\&amp\; /;
$xmlrecord =~ s/\&amp\;amp\; /\&amp\; /;
my $parser = XML::LibXML->new();
# don't die when you find &, >, etc