Dear Community! I'm having some XSLT trouble... I have some OAI-PMH records available here: http://sksk.bibkat.no/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=marcxml The National Library of Norway wants to harvest these records, but they have some very specific requirements, namely that the code for the owning library should be in 850 and that 001 should match the record identifier used in the OAI records identifier. To achieve this, I'm taking advantage of the OAI-PMH:ConfFile syspref, to specify an XSLT stylesheet to transform the records on the fly. Here is the relevant part of the ConfFile: format: biblioteksok: metadataPrefix: biblioteksok metadataNamespace: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim schema: http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd xsl_file: /home/magnus/koha/biblioteksok.xslt and here is the stylesheet in /home/magnus/koha/biblioteksok.xslt: <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:items="http://www.koha-community.org/items" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:package="info:srw/extension/13/package-v1.0" > <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="marc:controlfield[@tag=001]"/> <xsl:template match="marc:datafield[@tag=850]"/> <xsl:template match="marc:leader"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <!-- Make sure the biblionumber is in the 001 field --> <xsl:if test="not(marc:controlfield[@tag=001])"> <xsl:text> </xsl:text><xsl:element name="controlfield"> <xsl:attribute name="tag">001</xsl:attribute> <xsl:value-of select="//marc:datafield[@tag=999]/marc:subfield[@code='c']/text()"/> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="marc:datafield[@tag=999]"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <!-- Put the correct string in 850a --> <xsl:if test="not(marc:controlfield[@tag=850])"> <xsl:text> </xsl:text> <xsl:element name="datafield"> <xsl:attribute name="ind1"><xsl:text> </xsl:text></xsl:attribute> <xsl:attribute name="ind2"><xsl:text> </xsl:text></xsl:attribute> <xsl:attribute name="tag">850</xsl:attribute> <xsl:element name="subfield"> <xsl:attribute name="code">a</xsl:attribute> <xsl:text>NO-1120127</xsl:text> </xsl:element> </xsl:element> </xsl:if> </xsl:template> </xsl:stylesheet> And here is the result of applying the stylesheet: http://sksk.bibkat.no/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=biblioteksok I was quite pleased with the result myself, but now the National library is complaining that the transformed records do not validate against http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd and that the empty "xmlns" attribute should be removed from the following elements: <controlfield xmlns="" tag="001">93</controlfield> <datafield xmlns="" ind1=" " ind2=" " tag="850"> I have no idea how to achieve that. Does anyone else have a clue? Best regards, Magnus Enger libriotech.no
and here is the stylesheet in /home/magnus/koha/biblioteksok.xslt:
Try this: Suppress: <xsl:template match="marc:controlfield[@tag=001]"/> <xsl:template match="marc:datafield[@tag=850]"/> and replace: <xsl:template match="marc:leader"> with: <xsl:template match="marc:record">
On 18 January 2013 09:20, Frédéric Demians <frederic@tamil.fr> wrote:
and here is the stylesheet in /home/magnus/koha/biblioteksok.xslt:
Try this:
Suppress:
<xsl:template match="marc:controlfield[@tag=001]"/> <xsl:template match="marc:datafield[@tag=850]"/>
That did not work, when I left these out the old elements were not removed.
and replace:
<xsl:template match="marc:leader">
with:
<xsl:template match="marc:record">
Ah, that helped! What I ended up using was this: https://gist.github.com/1918264#file-biblioteksok-xslt The clue was including an xmlns-definition on the xsl:element: <xsl:element name="datafield" xmlns="http://www.loc.gov/MARC21/slim"> Thanks for your help Frédéric! Best regards, Magnus
participants (2)
-
Frédéric Demians -
Magnus Enger