From 5b1af2fedaf95a62514271fa5f237c768a495a22 Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Thu, 28 Sep 2017 15:34:28 +0200 Subject: [PATCH] Add XLST output transformation --- oai2transform.xsl | 446 ++++++++++++++++++++++++++++++++++++++++++++++ oai2xml.php | 3 + 2 files changed, 449 insertions(+) create mode 100644 oai2transform.xsl diff --git a/oai2transform.xsl b/oai2transform.xsl new file mode 100644 index 0000000..570bd95 --- /dev/null +++ b/oai2transform.xsl @@ -0,0 +1,446 @@ + + + + + + + +td.value { + vertical-align: top; + padding-left: 1em; + padding: 3px; +} +td.key { + background-color: #e0e0ff; + padding: 3px; + text-align: right; + border: 1px solid #c0c0c0; + white-space: nowrap; + font-weight: bold; + vertical-align: top; +} +.dcdata td.key { + background-color: #ffffe0; +} +body { + margin: 1em 2em 1em 2em; +} +h1, +h2, +h3 { + font-family: sans-serif; + clear: left; +} +h1 { + padding-bottom: 4px; + margin-bottom: 0px; +} +h2 { + margin-bottom: 0.5em; +} +h3 { + margin-bottom: 0.3em; + font-size: medium; +} +.link { + border: 1px outset #88f; + background-color: #c0c0ff; + padding: 1px 4px 1px 4px; + font-size: 80%; + text-decoration: none; + font-weight: bold; + font-family: sans-serif; + color: black; +} +.link:hover { + color: red; +} +.link:active { + color: red; + border: 1px inset #88f; + background-color: #a0a0df; +} +.oaiRecord, +.oaiRecordTitle { + background-color: #f0f0ff; + border-style: solid; + border-color: #d0d0d0; +} +h2.oaiRecordTitle { + background-color: #e0e0ff; + font-size: medium; + font-weight: bold; + padding: 10px; + border-width: 2px 2px 0px 2px; + margin: 0px; +} +.oaiRecord { + margin-bottom: 3em; + border-width: 2px; + padding: 10px; +} + +.results { + margin-bottom: 1.5em; +} +ul.quicklinks { + margin-top: 2px; + padding: 4px; + text-align: left; + border-bottom: 2px solid #ccc; + border-top: 2px solid #ccc; + clear: left; +} +ul.quicklinks li { + font-size: 80%; + display: inline; + list-style: none; + font-family: sans-serif; +} +p.intro { + font-size: 80%; +} + + + + +.xmlSource { + font-size: 70%; + border: solid #c0c0a0 1px; + background-color: #ffffe0; + padding: 2em 2em 2em 0em; +} +.xmlBlock { + padding-left: 2em; +} +.xmlTagName { + color: #800000; + font-weight: bold; +} +.xmlAttrName { + font-weight: bold; +} +.xmlAttrValue { + color: #0000c0; +} + + + + + + + + OAI 2.0 Request Results + + + +

OAI 2.0 Request Results

+ +

You are viewing an HTML version of the XML OAI response. To see the underlying XML as it appears to any OAI harvester use your web browser's view source option or disable XSLT processing.

+ + + + +
+ + + + + + + + + + + +
Datestamp of Response
Request URL
+ + +

OAI Error

+

The request could not be completed due to the following error.

+
+ +
+
+ +

Request was of type .

+
+ + + + + +
+
+
+
+ + + + + + +
Error Code
+

+
+ + + +

Repository

+ + + + + + + + + + + + + + +
Name
Base URL
Protocol Version
Earliest Datestamp
Deleted Record Policy
Granularity
+
+ + + Admin Email + + + + + + + + + + + + + + + + + + + + + + + + +

This is a list of metadata formats available for the record "". Use these links to view the metadata:

+
+ +

This is a list of metadata formats available from this repository. Click on a format's prefix to get all available records' identifier.

+
+
+ +
+ + + +

Metadata Format

+ + + + + + + +
Prefix
Namespace
Schema
+
+ + + + + + + +

OAI Record:

+
+ + +
+
+ + +

OAI Record Header

+ + + + + +
OAI Identifier + + available formats +
Datestamp
+ +

This record has been deleted.

+
+
+ + +   + + + + + +

There are more results.

+ + + + + + + + + +
Submitted Records
Total Records
Expiration Datestamp
Resumption Token + + Resume
+
+ + + +

Unknown Metadata Format

+
+ +
+
+ + + +
+

DublinCore Metadata

+ + +
+
+
+ + +Title + + +Author or Creator + + +Subject and Keywords + + +Description + + +Publisher + + +Other Contributor + + +Date + + +Resource Type + + +Format + + +Resource Identifier + + +Source + + +Language + + +Relation + + + + + URL + URL not shown as it is very long. + + + + + + + + + + + + + + +Coverage + + +Rights Management + + + +
+ <></> +
+
+ + + + + ="" + + +
diff --git a/oai2xml.php b/oai2xml.php index ed857e4..1f13789 100644 --- a/oai2xml.php +++ b/oai2xml.php @@ -26,7 +26,10 @@ class OAI2XMLResponse { public function __construct($uri, $verb, $request_args) { $this->verb = $verb; + $stylesheet = $_SERVER['HTTP_HOST'].pathinfo(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), PATHINFO_DIRNAME).'/oai2transform.xsl'; + $stylesheet = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https://'.$stylesheet : 'http://'.$stylesheet; $this->doc = new DOMDocument('1.0', 'UTF-8'); + $this->doc->appendChild($this->doc->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="'.$stylesheet.'"')); $oai_node = $this->doc->createElement('OAI-PMH'); $oai_node->setAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/'); $oai_node->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');