Skip to content

Commit

Permalink
initial code commit
Browse files Browse the repository at this point in the history
 * bnb/*
 * isbn/* (excluding personal files)
 * tools/showText.php
  • Loading branch information
zuphilip committed Oct 26, 2014
1 parent e8f93ac commit 76cbac4
Show file tree
Hide file tree
Showing 18 changed files with 2,299 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/isbn/conf.php
/isbn/paketinfo.js
/isbn/isbn2MANholdings.php
/isbn/temp
/isbn/jquery*.js
/bnb/BNBDaten/*
119 changes: 119 additions & 0 deletions bnb/bnb.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php
/*
* Source: https://github.com/UB-Mannheim/malibu/bnb
*
* Copyright (C) 2013 Universitaetsbibliothek Mannheim
*
* Author:
* Philipp Zumstein <[email protected]>
*
* This is free software licensed under the terms of the GNU GPL,
* version 3, or (at your option) any later version.
* See <http://www.gnu.org/licenses/> for more details.
*
* GET-Parameter
* @nr : Komma-separierte Liste von BNB weekly Nummern
* @ddc : Komma-separierte Liste von DDC-Stellen
* @forth : yes/no/only
* @noisbn : yes/no/only
*
* Entsprechende Datensaetze werden von den XML-Dateien
* anhand der Einstellungen gefiltert ausgegeben
* (die Darstellung und Sortierung übernimmt aber die bnb.xsl).
*/

header('Content-type: text/xml');

if (isset($_GET['nr'])) {

if (is_string($_GET['nr'])) {
$nrArray = explode(',', $_GET['nr']);
} else {
$nrArray = $_GET['nr'];
}

foreach ($nrArray as $nrElement) {
$xmlArray[$nrElement] = simplexml_load_file('BNBDaten/bnbrdf_N' . trim($nrElement) . '.rdf');
}
} else {
//echo "Bitte eine Nummer als Parameter spezifizieren, z.B. &nr=3231";
}


if (isset($_GET['ddc'])) {
$ddcArray = explode(',', $_GET['ddc']);
$query = "";
foreach ($ddcArray as $ddcElement) {
if ($query == "") {
$query = 'starts-with(., \'' . trim($ddcElement) . '\') ';
} else {
$query .= 'or starts-with(., \'' . trim($ddcElement) . '\') ';
}
}
} else {
$query = 'starts-with(.,"")';
}
//forthInclude ~ include forthcoming publication? - Yes, no, only
if (isset($_GET['forth'])) {//yes, no, only
$forthInclude = $_GET['forth'];
} else {
$forthInclude = "yes";
}
//noisbnInclude ~ include publication without isbn? - Yes, no, only
if (isset($_GET['noisbn'])) {//yes, no, only
$noisbnInclude = $_GET['noisbn'];
} else {
$noisbnInclude = "yes";
}


echo "<?xml version=\"1.0\"?>\n";
echo "<?xml-stylesheet href=\"bnb.xsl\" type=\"text/xsl\"?>\n";
echo "<bnb xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\" xmlns:isbd=\"http://iflastandards.info/ns/isbd/elements/\" xmlns:rda=\"http://rdvocab.info/Elements\" xmlns:skos=\"http://www.w3.org/2004/02/skos/core#\" xmlns:bibo=\"http://purl.org/ontology/bibo/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:owlt=\"http://www.w3.org/2006/time#\" >\n";



foreach ($nrArray as $nrElement) {
$xml = $xmlArray[$nrElement];

//register namespaces for the use in the XPath-Expression for the element xml
//(will not work for xpath-expressions starting from a different node)
$ns = $xml->getNameSpaces(true);
foreach ($ns as $nsName => $nsUri) {
$xml->registerXPathNamespace($nsName, $nsUri);
}

//contains(.,'004.') the current node contains the string 004.
//starts-with(.,'00') the current node starts with 00
//more than one ddc with or in [...]
//z.B. $xpath = $xml->xpath('//rdf:Description/dcterms:subject/rdf:Description/skos:notation[starts-with(., \'004\') or starts-with(., \'005\') or starts-with(., \'006\') ]/../../..');
$xpath = $xml->xpath('//rdf:Description/dcterms:subject/rdf:Description/skos:notation[' . $query . ']/../../..'); //
//var_dump($xpath);


$nFiltered = 0;

foreach ($xpath as $item) {
$itemXML = $item->asXML();
$forthAppear = stristr($itemXML, "Forthcoming publication");
$isbnAppear = stristr($itemXML, "isbn");
if ($forthInclude == "yes" || ($forthInclude == "no" && !$forthAppear) || ($forthInclude == "only" && $forthAppear)) {
if ($noisbnInclude == "yes" || ($noisbnInclude == "no" && $isbnAppear) || ($noisbnInclude == "only" && !$isbnAppear)) {
$nFiltered++;
echo $item->asXML();
//echo '<hr />';
echo "\n";
}
}
}

echo "<query>\n";
echo "<source>bnblist$nrElement</source>\n";
echo "<querystring>DDC $query ; include forthcoming publication: $forthInclude ; include publications without isbn: $noisbnInclude </querystring>\n";
//filter
echo '<nresults>' . $nFiltered . ' (' . count($xpath) . ' ungefiltert) ' . '</nresults>';
echo "\n</query>\n";
}

echo "</bnb>";
?>
97 changes: 97 additions & 0 deletions bnb/bnb.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:isbd="http://iflastandards.info/ns/isbd/elements/" xmlns:owlt="http://www.w3.org/2006/time#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:bibo="http://purl.org/ontology/bibo/" xmlns:rda="http://rdvocab.info/Elements" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">

<!--
Source: https://github.com/UB-Mannheim/malibu/bnb
Copyright (C) 2013 Universitaetsbibliothek Mannheim
Author:
Philipp Zumstein <[email protected]>
This is free software licensed under the terms of the GNU GPL,
version 3, or (at your option) any later version.
See <http://www.gnu.org/licenses/> for more details.
Beschreibung: Diese XSL Datei wandelt die RDF-Dateien
der BNB weekly in eine einfache HTML-Darstellung, wobei
* nur Titel, die den DDC-Stellen entsprechen, herausgefiltert werden
(die anderen Titel werden nicht angezeigt)
* Die Sortierung alphabetisch nach Verlagsnamen passiert.
-->


<xsl:template match="/bnb">
<html>
<head>
<title>Recherche-Resultat (BNB)</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
body { font-family: Arial, Verdana, sans-serif; }
</style>
</head>
<body>

<hr/><hr/>
<xsl:for-each select="query">
Quelle: <xsl:value-of select="source" /> ;
Abfrage: <xsl:value-of select="querystring" /> ;
Anzahl Suchergebnisse: <b><xsl:value-of select="nresults" /></b> <br/>
</xsl:for-each>
<hr/><hr/>

<xsl:for-each select="rdf:Description">
<xsl:sort select="dcterms:publisher/rdf:Description/rdfs:label" />
<b><xsl:value-of select="dcterms:title"/></b><br/>

<xsl:for-each select="dcterms:creator">
<xsl:value-of select="rdf:Description/rdfs:label"/>
</xsl:for-each>
[ <xsl:for-each select="dcterms:contributor">
<xsl:value-of select="rdf:Description/rdfs:label"/>
</xsl:for-each> ]<br/>

<xsl:if test="isbd:P1008">
<i><xsl:value-of select="isbd:P1008"/></i><br/>
</xsl:if>

<xsl:value-of select="isbd:P1016/rdf:Description/rdfs:label" /> : <xsl:value-of select="dcterms:publisher/rdf:Description/rdfs:label" />, <xsl:value-of select="dcterms:issued" /> <br/>

<xsl:for-each select="dcterms:type">
<xsl:value-of select="rdf:Description/rdfs:label"/> ;
</xsl:for-each>
<xsl:value-of select="dcterms:language/rdf:Description/rdfs:label" /> ;
<xsl:value-of select="dcterms:extent/rdf:Description/rdfs:label" /><br/>

<!-- TOC <xsl:value-of select="dcterms:tableOfContents" /><br/> -->

<xsl:for-each select="dcterms:subject">
<xsl:value-of select="rdf:Description/rdfs:label" /> ;
</xsl:for-each><br/>

<a target="blank">
<xsl:attribute name="href">http://dewey.info/class/<xsl:value-of select="dcterms:subject/rdf:Description/skos:notation" />/</xsl:attribute>
<xsl:value-of select="dcterms:subject/rdf:Description/skos:notation" />
</a><br/>

<xsl:if test="dcterms:identifier[starts-with(.,'GBB')]">
<xsl:value-of select="dcterms:identifier[starts-with(.,'GBB')]" />
</xsl:if>
; <span>ISBN <xsl:value-of select="bibo:isbn13" /></span> ; <span><xsl:value-of select="bibo:isbn10" /> </span>; <xsl:value-of select="rda:termsOfAvailability" /><br/>

<xsl:if test="dcterms:isPartOf">
( <xsl:value-of select="dcterms:isPartOf/rdf:Description/rdfs:label" /> ) <br/>
</xsl:if>

<xsl:for-each select="dcterms:description">
<i><xsl:value-of select="." /></i><br/>
</xsl:for-each>


<hr/>
</xsl:for-each>
</body>
</html>
</xsl:template>


</xsl:stylesheet>
11 changes: 11 additions & 0 deletions bnb/getBNBData.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd /var/www/Tools/BNBDaten

wget -r -np -l 1 -A zip http://www.bl.uk/bibliographic/bnbrdfxml.html

for f in /var/www/Tools/BNBDaten/www.bl.uk/bibliographic/bnbrdf/*.zip
do
unzip -o $f
rm $f
done
Loading

0 comments on commit 76cbac4

Please sign in to comment.