Partial fixes to enable unapi for non-zebra and non-public-facing sru

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Joshua Ferraro 2008-04-08 09:15:24 -04:00
parent cdddac6c9b
commit 4d3519dffd
6 changed files with 29 additions and 7 deletions

View file

@ -1490,7 +1490,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
# XSLT processing of some stuff
if (C4::Context->preference("XSLTResultsDisplay") ) {
my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},'Results');
my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
$oldbiblio->{XSLTResultsRecord} = $newxmlrecord;
}

View file

@ -101,13 +101,12 @@ sub getAuthorisedValues4MARCSubfields {
}
sub XSLTParse4Display {
my ($biblionumber,$type) = @_;
my ($biblionumber,$xslfile) = @_;
# grab the XML, run it through our stylesheet, push it out to the browser
my $record = transformMARCXML4XSLT($biblionumber);
my $itemsxml = buildKohaItemsNamespace($biblionumber);
my $xmlrecord = $record->as_xml();
$xmlrecord =~ s/\<\/record\>/$itemsxml\<\/record\>/;
my $xslfile = C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPAC$type.xsl";
my $parser = XML::LibXML->new();
# don't die when you find &, >, etc
$parser->recover_silently(1);

View file

@ -54,6 +54,7 @@
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">ab</xsl:with-param>
</xsl:call-template>
<xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
</xsl:for-each>
</xsl:variable>
@ -139,7 +140,7 @@
<img src="/opac-tmpl/prog/famfamfam/{$materialTypeCode}.png"/><xsl:value-of select="$materialTypeLabel"/>
</p>
</xsl:if>
<xsl:if test="$lcc">
<xsl:if test="marc:datafield[@tag=050]">
<p><span class="label">Library of Congress Classification: </span>
<xsl:value-of select="$lcc"/>
</p>
@ -185,8 +186,10 @@
</xsl:if>
<xsl:if test="marc:datafield[@tag=020]">
<p><span class="label">ISBN: </span>
<!-- unAPI <abbr/> tag -->
<xsl:for-each select="marc:datafield[@tag=020]">
<xsl:value-of select="marc:subfield[@code='a']"/>
<xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
<abbr class="unapi-id" title="koha:isbn:{$isbn}"><xsl:value-of select="marc:subfield[@code='a']"/></abbr>
<xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
</xsl:for-each>
</p>

View file

@ -377,6 +377,7 @@
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">ab</xsl:with-param>
</xsl:call-template>
<xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
</xsl:for-each>
</xsl:variable>
<td style="vertical-align:top;">

View file

@ -51,7 +51,7 @@ my $biblionumber = $query->param('biblionumber') || $query->param('bib');
$template->param( biblionumber => $biblionumber );
# XSLT processing of some stuff
if (C4::Context->preference("XSLTResultsDisplay") ) {
my $newxmlrecord = XSLTParse4Display($biblionumber,'Detail');
my $newxmlrecord = XSLTParse4Display($biblionumber,C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACDetail.xsl");
$template->param('XSLTBloc' => $newxmlrecord);
}

View file

@ -17,11 +17,30 @@ warn "Warning: OPACBaseURL not set in system preferences" unless $baseurl;
my $id = $cgi->param('id');
my $format = $cgi->param('format');
if ($id && $format) {
# koha:isbn:0152018484
if ($id =~ /isbn/) {
$id =~ s/koha:isbn://;
# two ways to do this, one via the SRU Zebra server (fast)
my $url = "http://$baseurl:9998/biblios?version=1.1&operation=searchRetrieve&query=$id&startRecord=1&maximumRecords=20&recordSchema=$format";
my $content = get($url);
my $content= get($url);
# the other via XSL parsing (not as fast)
unless ($content) {
eval {
my $conn = C4::Context->Zconn('biblioserver');
$conn->option(preferredRecordSyntax => $format);
my $rs = $conn->search_pqf('@attr 1=7 '.$id);
my $n = $rs->size();
$content = $rs->record(0)->raw();
};
if ($@) {
print "Error ", $@->code(), ": ", $@->message(), "\n";
}
}
print $cgi->header( -type =>'application/xml' );
print $content;
}