@ -0,0 +1,152 @@ |
|||
package C4::XSLT; |
|||
# Copyright (C) 2006 LibLime |
|||
# <jmf at liblime dot com> |
|||
# |
|||
# This file is part of Koha. |
|||
# |
|||
# Koha is free software; you can redistribute it and/or modify it under the |
|||
# terms of the GNU General Public License as published by the Free Software |
|||
# Foundation; either version 2 of the License, or (at your option) any later |
|||
# version. |
|||
# |
|||
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
|||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License along with |
|||
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
|||
# Suite 330, Boston, MA 02111-1307 USA |
|||
|
|||
use C4::Context; |
|||
use C4::Branch; |
|||
use C4::Items; |
|||
use C4::Koha; |
|||
use C4::Biblio; |
|||
use XML::LibXML; |
|||
use XML::LibXSLT; |
|||
|
|||
use strict; |
|||
|
|||
use vars qw($VERSION @ISA @EXPORT); |
|||
|
|||
BEGIN { |
|||
require Exporter; |
|||
$VERSION = 0.03; |
|||
@ISA = qw(Exporter); |
|||
@EXPORT = qw( |
|||
&XSLTParse4Display |
|||
); |
|||
} |
|||
|
|||
=head1 NAME |
|||
|
|||
C4::XSLT - Functions for displaying XSLT-generated content |
|||
|
|||
=head1 FUNCTIONS |
|||
|
|||
=head1 transformMARCXML4XSLT |
|||
|
|||
=head2 replaces codes with authorized values in a MARCXML record |
|||
|
|||
=cut |
|||
|
|||
sub transformMARCXML4XSLT { |
|||
my ($biblionumber) = @_; |
|||
my $record = GetMarcBiblio($biblionumber); |
|||
my $biblio = GetBiblioData($biblionumber); |
|||
my $frameworkcode = GetFrameworkCode($biblionumber); |
|||
my $tagslib = &GetMarcStructure(1,$frameworkcode); |
|||
my @fields = $record->fields(); |
|||
my $list_of_authvalues = getAuthorisedValues4MARCSubfields($frameworkcode); |
|||
for my $authvalue (@$list_of_authvalues) { |
|||
for my $field ( $record->field($authvalue->{tagfield}) ) { |
|||
my @newSubfields = (); |
|||
for my $subfield ( $field->subfields() ) { |
|||
my ($code,$data) = @$subfield; |
|||
unless ($code eq $authvalue->{tagsubfield}) { |
|||
push ( @newSubfields, $code, $data ); |
|||
} else { |
|||
my $newvalue = GetAuthorisedValueDesc( $authvalue->{tagfield}, $code, $data, '', $tagslib ); |
|||
push ( @newSubfields, $code, $newvalue ); |
|||
} |
|||
} |
|||
my $newField = MARC::Field->new( |
|||
$authvalue->{tagfield}, |
|||
$field->indicator(1), |
|||
$field->indicator(2), |
|||
$authvalue->{tagsubfield} => @newSubfields |
|||
); |
|||
$field->replace_with($newField); |
|||
} |
|||
} |
|||
return $record; |
|||
} |
|||
|
|||
=head1 getAuthorisedValues4MARCSubfields |
|||
|
|||
=head2 returns an array of hash refs for authorised value tag/subfield combos for a given framework |
|||
|
|||
=cut |
|||
|
|||
sub getAuthorisedValues4MARCSubfields { |
|||
my ($frameworkcode) = @_; |
|||
my @results; |
|||
my $dbh = C4::Context->dbh; |
|||
my $sth = $dbh->prepare("SELECT DISTINCT tagfield,tagsubfield FROM marc_subfield_structure WHERE authorised_value IS NOT NULL AND authorised_value!='' AND frameworkcode=?"); |
|||
$sth->execute($frameworkcode); |
|||
while (my $result = $sth->fetchrow_hashref()) { |
|||
push @results, $result; |
|||
} |
|||
return \@results; |
|||
} |
|||
|
|||
sub XSLTParse4Display { |
|||
my ($biblionumber,$type) = @_; |
|||
# 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('intranetdir')."/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPAC$type.xsl"; |
|||
my $parser = XML::LibXML->new(); |
|||
# don't die when you find &, >, etc |
|||
$parser->recover_silently(1); |
|||
my $xslt = XML::LibXSLT->new(); |
|||
my $source = $parser->parse_string($xmlrecord); |
|||
my $style_doc = $parser->parse_file($xslfile); |
|||
my $stylesheet = $xslt->parse_stylesheet($style_doc); |
|||
my $results = $stylesheet->transform($source); |
|||
my $newxmlrecord = $stylesheet->output_string($results); |
|||
return $newxmlrecord; |
|||
} |
|||
|
|||
sub buildKohaItemsNamespace { |
|||
my ($biblionumber) = @_; |
|||
my @items = C4::Items::GetItemsInfo($biblionumber); |
|||
my $branches = GetBranches(); |
|||
my $itemtypes = GetItemTypes(); |
|||
my $xml; |
|||
for my $item (@items) { |
|||
my $status; |
|||
if ($item->{onloan}) { |
|||
$status = "On loan"; |
|||
} else { |
|||
$status = "available"; |
|||
} |
|||
$xml.="<item><homebranch>".$branches->{$item->{homebranch}}->{'branchname'}."</homebranch>"."<status>$status</status></item>"; |
|||
} |
|||
return "<items xmlns='http://www.koha.org/items'>".$xml."</items>"; |
|||
} |
|||
|
|||
|
|||
|
|||
1; |
|||
__END__ |
|||
|
|||
=head1 NOTES |
|||
|
|||
=head1 AUTHOR |
|||
|
|||
Joshua Ferraro <jmf@liblime.com> |
|||
|
|||
=cut |
@ -0,0 +1,393 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ --> |
|||
<xsl:stylesheet version="1.0" |
|||
xmlns:marc="http://www.loc.gov/MARC21/slim" |
|||
xmlns:items="http://www.koha.org/items" |
|||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|||
exclude-result-prefixes="marc items"> |
|||
<xsl:import href="MARC21slimUtils.xsl"/> |
|||
<xsl:output method="html" indent="yes"/> |
|||
|
|||
<xsl:template match="/"> |
|||
<xsl:apply-templates/> |
|||
</xsl:template> |
|||
|
|||
<xsl:template match="marc:record"> |
|||
<xsl:variable name="leader" select="marc:leader"/> |
|||
<xsl:variable name="leader6" select="substring($leader,7,1)"/> |
|||
<xsl:variable name="leader7" select="substring($leader,8,1)"/> |
|||
<xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/> |
|||
<xsl:variable name="materialTypeCode"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader6='a'"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when> |
|||
<xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:when> |
|||
<xsl:when test="$leader6='t'">BK</xsl:when> |
|||
<xsl:when test="$leader6='p'">MM</xsl:when> |
|||
<xsl:when test="$leader6='m'">CF</xsl:when> |
|||
<xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when> |
|||
<xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when> |
|||
<xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:variable> |
|||
<xsl:variable name="materialTypeLabel"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader6='a'"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when> |
|||
<xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">Serial</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:when> |
|||
<xsl:when test="$leader6='t'">Book</xsl:when> |
|||
<xsl:when test="$leader6='p'">Mixed Materials</xsl:when> |
|||
<xsl:when test="$leader6='m'">Computer File</xsl:when> |
|||
<xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when> |
|||
<xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">Visual Material</xsl:when> |
|||
<xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">Music</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:variable> |
|||
|
|||
<!-- Title Statement --> |
|||
<style type="text/css"> |
|||
.label { |
|||
font-size: 80%; |
|||
color: grey; |
|||
} |
|||
</style> |
|||
<div id="views"> |
|||
<xsl:if test="marc:datafield[@tag=245]"> |
|||
<h1> |
|||
<xsl:for-each select="marc:datafield[@tag=245]"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">abfghk</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
</h1> |
|||
</xsl:if> |
|||
|
|||
<span class="views"><span id="Normalview">Normal View</span> <a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">MARC View</a> <a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">Card View (ISBD)</a></span> |
|||
</div> |
|||
|
|||
<xsl:choose> |
|||
<xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]"> |
|||
|
|||
<h5 class="author">by |
|||
<xsl:for-each select="marc:datafield[@tag=100 or @tag=700]"> |
|||
<a> |
|||
<xsl:choose> |
|||
<xsl:when test="marc:subfield[@code=9]"> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?authid=<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute> |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute> |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
<xsl:call-template name="nameABCDQ"/></a> |
|||
<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:for-each select="marc:datafield[@tag=110 or @tag=710]"> |
|||
<a> |
|||
<xsl:choose> |
|||
<xsl:when test="marc:subfield[@code=9]"> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?authid=<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute> |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute> |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
<xsl:call-template name="nameABCDN"/></a> |
|||
<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:for-each select="marc:datafield[@tag=111 or @tag=711]"> |
|||
<a> |
|||
<xsl:choose> |
|||
<xsl:when test="marc:subfield[@code=9]"> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?authid=<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute> |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute> |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
<xsl:call-template name="nameACDEQ"/></a> |
|||
<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> |
|||
</h5> |
|||
</xsl:when> |
|||
</xsl:choose> |
|||
|
|||
<div class="summary"> |
|||
|
|||
<xsl:if test="$materialTypeCode"> |
|||
<p><span class="label">Type: </span> |
|||
<img src="/opac-tmpl/prog/famfamfam/{$materialTypeCode}.png"/><xsl:value-of select="$materialTypeLabel"/> |
|||
</p> |
|||
</xsl:if> |
|||
<xsl:if test="marc:datafield[@tag=440 or @tag=490]"> |
|||
<p><span class="label">Series: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=440]"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">av</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
<xsl:call-template name="part"/> |
|||
<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:for-each select="marc:datafield[@tag=490][@ind1=0]"> |
|||
<a href="/cgi-bin/koha/opac-search.pl?se:{marc:subfield[@code='a']}"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">av</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</a> |
|||
<xsl:call-template name="part"/> |
|||
<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> |
|||
</xsl:if> |
|||
<xsl:if test="marc:datafield[@tag=260]"> |
|||
<p><span class="label">Publisher: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=260]"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">bcg</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
<xsl:if test="marc:datafield[@tag=020]"> |
|||
<p><span class="label">ISBN: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=020]"> |
|||
<xsl:value-of select="marc:subfield[@code='a']"/> |
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
|
|||
<xsl:if test="marc:datafield[@tag=022]"> |
|||
<p><span class="label">ISSN: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=022]"> |
|||
<xsl:value-of select="marc:subfield[@code='a']"/> |
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
|
|||
<xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]"> |
|||
<p><span class="label">Uniform titles: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]"> |
|||
<xsl:variable name="str"> |
|||
<xsl:for-each select="marc:subfield"> |
|||
<xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))"> |
|||
<xsl:value-of select="text()"/> |
|||
<xsl:text> </xsl:text> |
|||
</xsl:if> |
|||
</xsl:for-each> |
|||
</xsl:variable> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:value-of select="substring($str,1,string-length($str)-1)"/> |
|||
|
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
|
|||
<xsl:if test="marc:datafield[@tag=650]"> |
|||
<p><span class="label">Related Subjects: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=650]"> |
|||
<a> |
|||
<xsl:choose> |
|||
<xsl:when test="marc:subfield[@code=9]"> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?authid=<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute> |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute> |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">abcdvxyz</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</a> |
|||
<xsl:choose> |
|||
<xsl:when test="position()=last()"></xsl:when> |
|||
<xsl:otherwise> | </xsl:otherwise> |
|||
</xsl:choose> |
|||
|
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
|
|||
<xsl:if test="marc:datafield[@tag=856]"> |
|||
<p><span class="label">Online Resources: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=856]"> |
|||
<a><xsl:attribute name="href"> <xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute> |
|||
<xsl:if test="marc:subfield[@code='y' or @code='3' or @code='z']"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">y3z</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if></a> |
|||
<xsl:choose> |
|||
<xsl:when test="position()=last()"></xsl:when> |
|||
<xsl:otherwise> | </xsl:otherwise> |
|||
</xsl:choose> |
|||
|
|||
</xsl:for-each> |
|||
</p> |
|||
</xsl:if> |
|||
|
|||
<!-- 780 --> |
|||
<xsl:if test="marc:datafield[@tag=780]/marc:subfield[@code='a']"> |
|||
<xsl:for-each select="marc:datafield[@tag=780]"> |
|||
<p><span class="label"> |
|||
<xsl:choose> |
|||
<xsl:when test="@ind2=0"> |
|||
Continues: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=1"> |
|||
Continues in part: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=2"> |
|||
Supersedes: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=3"> |
|||
Supersedes in part: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=4"> |
|||
Formed by the union: ... and: ... |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=5"> |
|||
Absorbed: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=6"> |
|||
Absorbed in part: |
|||
</xsl:when> |
|||
<xsl:when test="@ind2=7"> |
|||
Separated from: |
|||
</xsl:when> |
|||
</xsl:choose> |
|||
</span> |
|||
<a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="marc:subfield[@code='t']"/></xsl:attribute> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">atxwg</xsl:with-param> |
|||
</xsl:call-template> |
|||
</a> |
|||
</p> |
|||
<xsl:choose> |
|||
<xsl:when test="@ind1=0"> |
|||
<p><xsl:value-of select="marc:subfield[@code='n']"/></p> |
|||
</xsl:when> |
|||
</xsl:choose> |
|||
|
|||
</xsl:for-each> |
|||
</xsl:if> |
|||
|
|||
</div> |
|||
|
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameABCDQ"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">aq</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
<xsl:with-param name="punctuation"> |
|||
<xsl:text>:,;/ </xsl:text> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
<xsl:call-template name="termsOfAddress"/> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameABCDN"> |
|||
<xsl:for-each select="marc:subfield[@code='a']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="."/> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
<xsl:for-each select="marc:subfield[@code='b']"> |
|||
<xsl:value-of select="."/> |
|||
</xsl:for-each> |
|||
<xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">cdn</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameACDEQ"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">acdeq</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:template> |
|||
<xsl:template name="termsOfAddress"> |
|||
<xsl:if test="marc:subfield[@code='b' or @code='c']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">bc</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="part"> |
|||
<xsl:variable name="partNumber"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">n</xsl:with-param> |
|||
<xsl:with-param name="anyCodes">n</xsl:with-param> |
|||
<xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:variable> |
|||
<xsl:variable name="partName"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">p</xsl:with-param> |
|||
<xsl:with-param name="anyCodes">p</xsl:with-param> |
|||
<xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:variable> |
|||
<xsl:if test="string-length(normalize-space($partNumber))"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="$partNumber"/> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
<xsl:if test="string-length(normalize-space($partName))"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="$partName"/> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="specialSubfieldSelect"> |
|||
<xsl:param name="anyCodes"/> |
|||
<xsl:param name="axis"/> |
|||
<xsl:param name="beforeCodes"/> |
|||
<xsl:param name="afterCodes"/> |
|||
<xsl:variable name="str"> |
|||
<xsl:for-each select="marc:subfield"> |
|||
<xsl:if test="contains($anyCodes, @code) or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis]) or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])"> |
|||
<xsl:value-of select="text()"/> |
|||
<xsl:text> </xsl:text> |
|||
</xsl:if> |
|||
</xsl:for-each> |
|||
</xsl:variable> |
|||
<xsl:value-of select="substring($str,1,string-length($str)-1)"/> |
|||
</xsl:template> |
|||
</xsl:stylesheet> |
@ -0,0 +1,318 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ --> |
|||
<xsl:stylesheet version="1.0" |
|||
xmlns:marc="http://www.loc.gov/MARC21/slim" |
|||
xmlns:items="http://www.koha.org/items" |
|||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|||
exclude-result-prefixes="marc items"> |
|||
<xsl:import href="MARC21slimUtils.xsl"/> |
|||
<xsl:output method="html" indent="yes"/> |
|||
<xsl:key name="item-by-status" match="items:item" use="items:status"/> |
|||
<xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/> |
|||
|
|||
<xsl:template match="/"> |
|||
<xsl:apply-templates/> |
|||
</xsl:template> |
|||
<xsl:template match="marc:record"> |
|||
<xsl:variable name="leader" select="marc:leader"/> |
|||
<xsl:variable name="leader6" select="substring($leader,7,1)"/> |
|||
<xsl:variable name="leader7" select="substring($leader,8,1)"/> |
|||
<xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/> |
|||
<xsl:variable name="materialTypeCode"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader6='a'"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when> |
|||
<xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:when> |
|||
<xsl:when test="$leader6='t'">BK</xsl:when> |
|||
<xsl:when test="$leader6='p'">MM</xsl:when> |
|||
<xsl:when test="$leader6='m'">CF</xsl:when> |
|||
<xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when> |
|||
<xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when> |
|||
<xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:variable> |
|||
<xsl:variable name="materialTypeLabel"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader6='a'"> |
|||
<xsl:choose> |
|||
<xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when> |
|||
<xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">Serial</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:when> |
|||
<xsl:when test="$leader6='t'">Book</xsl:when> |
|||
<xsl:when test="$leader6='p'">Mixed Materials</xsl:when> |
|||
<xsl:when test="$leader6='m'">Computer File</xsl:when> |
|||
<xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when> |
|||
<xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">Visual Material</xsl:when> |
|||
<xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">Music</xsl:when> |
|||
</xsl:choose> |
|||
</xsl:variable> |
|||
|
|||
<style type="text/css"> |
|||
.results_summary { |
|||
font-size: 80%; |
|||
color: grey; |
|||
} |
|||
.select { |
|||
border-bottom: 1px solid #ddd; padding: 6px 5px; vertical-align: top; |
|||
} |
|||
.holdings_summary { |
|||
font-size: 90%; |
|||
} |
|||
</style> |
|||
|
|||
<td class="select"> |
|||
<input type="checkbox" id="bib{marc:datafield[@tag=999]/marc:subfield[@code='c']}" name="biblionumber" value="{marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="Click to add to cart" /> <label for="bib{marc:datafield[@tag=999]/marc:subfield[@code='c']}"></label> |
|||
</td> |
|||
<td> |
|||
<a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/></xsl:attribute> |
|||
|
|||
<xsl:if test="marc:datafield[@tag=245]"> |
|||
<xsl:for-each select="marc:datafield[@tag=245]"> |
|||
<xsl:variable name="title"> |
|||
<xsl:choose> |
|||
<xsl:when test="marc:subfield[@code='b']"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">b</xsl:with-param> |
|||
<xsl:with-param name="beforeCodes">afghk</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">abfgk</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
</xsl:variable> |
|||
<xsl:variable name="titleChop"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:value-of select="$title"/> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:variable> |
|||
<xsl:value-of select="$titleChop"/> |
|||
<xsl:if test="marc:subfield[@code='b']"> |
|||
<xsl:text> : </xsl:text> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">b</xsl:with-param> |
|||
<xsl:with-param name="anyCodes">b</xsl:with-param> |
|||
<xsl:with-param name="afterCodes">afghk</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
<xsl:call-template name="part"/> |
|||
</xsl:for-each>. |
|||
</xsl:if> |
|||
</a> |
|||
<p> |
|||
|
|||
<xsl:choose> |
|||
<xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]"> |
|||
|
|||
by |
|||
<xsl:for-each select="marc:datafield[@tag=100 or @tag=700]"> |
|||
<xsl:choose> |
|||
<xsl:when test="position()=last()"> |
|||
<xsl:call-template name="nameABCDQ"/>. |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:call-template name="nameABCDQ"/>; |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
</xsl:for-each> |
|||
|
|||
<xsl:for-each select="marc:datafield[@tag=110 or @tag=710]"> |
|||
<xsl:choose> |
|||
<xsl:when test="position()=last()"> |
|||
<xsl:call-template name="nameABCDN"/>. |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:call-template name="nameABCDN"/>; |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
</xsl:for-each> |
|||
|
|||
<xsl:for-each select="marc:datafield[@tag=111 or @tag=711]"> |
|||
<xsl:choose> |
|||
<xsl:when test="position()=last()"> |
|||
<xsl:call-template name="nameACDEQ"/>. |
|||
</xsl:when> |
|||
<xsl:otherwise> |
|||
<xsl:call-template name="nameACDEQ"/>; |
|||
</xsl:otherwise> |
|||
</xsl:choose> |
|||
</xsl:for-each> |
|||
|
|||
</xsl:when> |
|||
</xsl:choose> |
|||
</p> |
|||
<span class="results_summary"> |
|||
<xsl:if test="$materialTypeCode"> |
|||
<span class="label">Type: </span> |
|||
<img src="/opac-tmpl/prog/famfamfam/{$materialTypeCode}.png"/><xsl:value-of select="$materialTypeLabel"/><br/> |
|||
</xsl:if> |
|||
<xsl:if test="marc:datafield[@tag=260]"> |
|||
<span class="label">Publisher: </span> |
|||
<xsl:for-each select="marc:datafield[@tag=260]"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">bcg</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
|
|||
</xsl:if> |
|||
</span> |
|||
<div class="holdings_summary"> |
|||
<xsl:if test="count(key('item-by-status', 'available'))>0"> |
|||
<span class="available"> |
|||
<xsl:text>Copies available at: </xsl:text> |
|||
<xsl:variable name="available_items" |
|||
select="key('item-by-status', 'available')"/> |
|||
<xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]"> |
|||
<xsl:value-of select="items:homebranch"/> |
|||
<xsl:text> (</xsl:text> |
|||
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/> |
|||
<xsl:text>) </xsl:text> |
|||
</xsl:for-each> |
|||
</span> |
|||
</xsl:if> |
|||
<xsl:if test="count(key('item-by-status', 'On loan'))>0"> |
|||
<span class="unavailable"> |
|||
<xsl:text>On loan (</xsl:text> |
|||
<xsl:value-of select="count(key('item-by-status', 'On loan'))"/> |
|||
<xsl:text>)</xsl:text> |
|||
</span> |
|||
</xsl:if> |
|||
</div> |
|||
</td> |
|||
</xsl:template> |
|||
<xsl:template name="nameABCDQ"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">aq</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
<xsl:with-param name="punctuation"> |
|||
<xsl:text>:,;/ </xsl:text> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
<xsl:call-template name="termsOfAddress"/> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameABCDN"> |
|||
<xsl:for-each select="marc:subfield[@code='a']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="."/> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
<xsl:for-each select="marc:subfield[@code='b']"> |
|||
<xsl:value-of select="."/> |
|||
</xsl:for-each> |
|||
<xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">cdn</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameACDEQ"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">acdeq</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="termsOfAddress"> |
|||
<xsl:if test="marc:subfield[@code='b' or @code='c']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">bc</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="nameDate"> |
|||
<xsl:for-each select="marc:subfield[@code='d']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="."/> |
|||
</xsl:call-template> |
|||
</xsl:for-each> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="role"> |
|||
<xsl:for-each select="marc:subfield[@code='e']"> |
|||
<xsl:value-of select="."/> |
|||
</xsl:for-each> |
|||
<xsl:for-each select="marc:subfield[@code='4']"> |
|||
<xsl:value-of select="."/> |
|||
</xsl:for-each> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="specialSubfieldSelect"> |
|||
<xsl:param name="anyCodes"/> |
|||
<xsl:param name="axis"/> |
|||
<xsl:param name="beforeCodes"/> |
|||
<xsl:param name="afterCodes"/> |
|||
<xsl:variable name="str"> |
|||
<xsl:for-each select="marc:subfield"> |
|||
<xsl:if test="contains($anyCodes, @code) or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis]) or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])"> |
|||
<xsl:value-of select="text()"/> |
|||
<xsl:text> </xsl:text> |
|||
</xsl:if> |
|||
</xsl:for-each> |
|||
</xsl:variable> |
|||
<xsl:value-of select="substring($str,1,string-length($str)-1)"/> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="subtitle"> |
|||
<xsl:if test="marc:subfield[@code='b']"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString"> |
|||
<xsl:value-of select="marc:subfield[@code='b']"/> |
|||
|
|||
<!--<xsl:call-template name="subfieldSelect"> |
|||
<xsl:with-param name="codes">b</xsl:with-param> |
|||
</xsl:call-template>--> |
|||
</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="part"> |
|||
<xsl:variable name="partNumber"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">n</xsl:with-param> |
|||
<xsl:with-param name="anyCodes">n</xsl:with-param> |
|||
<xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:variable> |
|||
<xsl:variable name="partName"> |
|||
<xsl:call-template name="specialSubfieldSelect"> |
|||
<xsl:with-param name="axis">p</xsl:with-param> |
|||
<xsl:with-param name="anyCodes">p</xsl:with-param> |
|||
<xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param> |
|||
</xsl:call-template> |
|||
</xsl:variable> |
|||
<xsl:if test="string-length(normalize-space($partNumber))"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="$partNumber"/> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
<xsl:if test="string-length(normalize-space($partName))"> |
|||
<xsl:if test="string-length(normalize-space($partName))"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="$partName"/> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
</xsl:stylesheet> |
@ -0,0 +1,65 @@ |
|||
<?xml version='1.0'?> |
|||
<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
|||
<xsl:template name="datafield"> |
|||
<xsl:param name="tag"/> |
|||
<xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param> |
|||
<xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param> |
|||
<xsl:param name="subfields"/> |
|||
<xsl:element name="datafield"> |
|||
<xsl:attribute name="tag"> |
|||
<xsl:value-of select="$tag"/> |
|||
</xsl:attribute> |
|||
<xsl:attribute name="ind1"> |
|||
<xsl:value-of select="$ind1"/> |
|||
</xsl:attribute> |
|||
<xsl:attribute name="ind2"> |
|||
<xsl:value-of select="$ind2"/> |
|||
</xsl:attribute> |
|||
<xsl:copy-of select="$subfields"/> |
|||
</xsl:element> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="subfieldSelect"> |
|||
<xsl:param name="codes"/> |
|||
<xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param> |
|||
<xsl:variable name="str"> |
|||
<xsl:for-each select="marc:subfield"> |
|||
<xsl:if test="contains($codes, @code)"> |
|||
<xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/> |
|||
</xsl:if> |
|||
</xsl:for-each> |
|||
</xsl:variable> |
|||
<xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="buildSpaces"> |
|||
<xsl:param name="spaces"/> |
|||
<xsl:param name="char"><xsl:text> </xsl:text></xsl:param> |
|||
<xsl:if test="$spaces>0"> |
|||
<xsl:value-of select="$char"/> |
|||
<xsl:call-template name="buildSpaces"> |
|||
<xsl:with-param name="spaces" select="$spaces - 1"/> |
|||
<xsl:with-param name="char" select="$char"/> |
|||
</xsl:call-template> |
|||
</xsl:if> |
|||
</xsl:template> |
|||
|
|||
<xsl:template name="chopPunctuation"> |
|||
<xsl:param name="chopString"/> |
|||
<xsl:variable name="length" select="string-length($chopString)"/> |
|||
<xsl:choose> |
|||
<xsl:when test="$length=0"/> |
|||
<xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))"> |
|||
<xsl:call-template name="chopPunctuation"> |
|||
<xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/> |
|||
</xsl:call-template> |
|||
</xsl:when> |
|||
<xsl:when test="not($chopString)"/> |
|||
<xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise> |
|||
</xsl:choose> |
|||
</xsl:template> |
|||
</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp. |
|||
<metaInformation> |
|||
<scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/> |
|||
</metaInformation> |
|||
--> |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 620 B |
After Width: | Height: | Size: 760 B |
After Width: | Height: | Size: 804 B |
After Width: | Height: | Size: 385 B |
After Width: | Height: | Size: 658 B |
After Width: | Height: | Size: 653 B |