Created
September 30, 2011 11:35
-
-
Save dmj/1253503 to your computer and use it in GitHub Desktop.
Translate Pica PSI response to SRU response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:explain="http://explain.z3950.org/dtd/2.0/" | |
xmlns:zs="http://www.loc.gov/zing/srw/" | |
version="1.0"> | |
<xsl:output indent="yes" method="xml"/> | |
<xsl:param name="host" select="''"/> | |
<xsl:param name="port" select="''"/> | |
<xsl:param name="database" select="''"/> | |
<xsl:variable name="downcase" select="'abcdefghijklmnopqrstuvwxyz'" /> | |
<xsl:variable name="upcase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> | |
<xsl:template match="/"> | |
<zs:explainResponse> | |
<zs:version>1.1</zs:version> | |
<zs:record> | |
<zs:recordSchema>http://explain.z3950.org/dtd/2.0/</zs:recordSchema> | |
<zs:recordPacking>xml</zs:recordPacking> | |
<zs:recordData> | |
<explain:explain> | |
<explain:serverInfo protocol="SRU" version="1.1" transport="http" method="GET"> | |
<explain:host><xsl:value-of select="$host"/></explain:host> | |
<explain:port><xsl:value-of select="$port"/></explain:port> | |
<explain:database><xsl:value-of select="$database"/></explain:database> | |
</explain:serverInfo> | |
<explain:indexInfo> | |
<explain:set name="pica" identifier="info:srw/cql-context-set/5/pica-v1.0"/> | |
<xsl:for-each select="/RESULT/IKTLIST/KEY"> | |
<explain:index> | |
<explain:title><xsl:value-of select="@description"/></explain:title> | |
<explain:map> | |
<explain:name set="pica"> | |
<xsl:value-of select="translate(@mnemonic, $upcase, $downcase)"/> | |
</explain:name> | |
</explain:map> | |
</explain:index> | |
</xsl:for-each> | |
</explain:indexInfo> | |
<explain:schemaInfo> | |
<explain:schema name="x-pica-short" identifier="urn:uuid:560e990a-abf9-40f1-9382-56e8cfdb75b6"> | |
<explain:title>PSI Kurztitel</explain:title> | |
</explain:schema> | |
</explain:schemaInfo> | |
</explain:explain> | |
</zs:recordData> | |
</zs:record> | |
</zs:explainResponse> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:zs="http://www.loc.gov/zing/srw/" | |
xmlns:x-pica="urn:uuid:560e990a-abf9-40f1-9382-56e8cfdb75b6" | |
version="1.0"> | |
<xsl:output indent="yes" method="xml"/> | |
<xsl:variable name="downcase" select="'abcdefghijklmnopqrstuvwxyz'" /> | |
<xsl:variable name="upcase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> | |
<xsl:template match="/"> | |
<zs:scanResponse> | |
<zs:version>1.1</zs:version> | |
<zs:terms> | |
<xsl:apply-templates select="/RESULT/SCANLIST/SCANLINE"/> | |
</zs:terms> | |
</zs:scanResponse> | |
</xsl:template> | |
<xsl:template match="/RESULT/SCANLIST/SCANLINE"> | |
<zs:term> | |
<zs:displayTerm><xsl:value-of select="text()"/></zs:displayTerm> | |
<zs:numberOfRecords><xsl:value-of select="@hits"/></zs:numberOfRecords> | |
<zs:value><xsl:value-of select="@description"/></zs:value> | |
<zs:extraTermData> | |
<x-pica:index>pica.<xsl:value-of select="translate(@mnemonic, $upcase, $downcase)"/></x-pica:index> | |
<xsl:if test="/RESULT/SCANPREV/@term = text()"> | |
<x-pica:scanPrev/> | |
</xsl:if> | |
<xsl:if test="/RESULT/SCANNEXT/@term = text()"> | |
<x-pica:scanNext/> | |
</xsl:if> | |
</zs:extraTermData> | |
</zs:term> | |
</xsl:template> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:explain="http://explain.z3950.org/dtd/2.0/" | |
xmlns:zs="http://www.loc.gov/zing/srw/" | |
xmlns:x-pica="urn:uuid:560e990a-abf9-40f1-9382-56e8cfdb75b6" | |
version="1.0"> | |
<xsl:output indent="yes" method="xml"/> | |
<xsl:template match="/"> | |
<zs:searchRetriveResponse> | |
<zs:version>1.1</zs:version> | |
<zs:numberOfRecords> | |
<xsl:value-of select="/RESULT/SET/@hits"/> | |
</zs:numberOfRecords> | |
<zs:resultSetId> | |
<xsl:value-of select="/RESULT/SESSION/SESSIONVAR[@name='SID']"/>/<xsl:value-of select="/RESULT/SESSION/SESSIONVAR[@name='SET']"/> | |
</zs:resultSetId> | |
<zs:records> | |
<xsl:for-each select="/RESULT/SET/SHORTTITLE"> | |
<zs:recordSchema>x-pica-short</zs:recordSchema> | |
<zs:recordPacking>xml</zs:recordPacking> | |
<zs:recordPosition><xsl:value-of select="@nr"/></zs:recordPosition> | |
<zs:recordData> | |
<x-pica:record> | |
<xsl:for-each select="@*"> | |
<xsl:element name="{concat('x-pica:', name())}"> | |
<xsl:value-of select="."/> | |
</xsl:element> | |
</xsl:for-each> | |
<xsl:element name="x-pica:shorttitle"> | |
<xsl:for-each select="text()"> | |
<x-pica:line><xsl:value-of select="."/></x-pica:line> | |
</xsl:for-each> | |
</xsl:element> | |
</x-pica:record> | |
</zs:recordData> | |
</xsl:for-each> | |
</zs:records> | |
</zs:searchRetriveResponse> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment