Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
uri.hab.de
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin de la Iglesia
uri.hab.de
Commits
ac9df7db
Commit
ac9df7db
authored
6 years ago
by
David Maus
Browse files
Options
Downloads
Patches
Plain Diff
RDF/XML für OPAC Normdatensätze
parent
9408baa8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
public/instance/proxy/opac-de-23/index.php
+31
-1
31 additions, 1 deletion
public/instance/proxy/opac-de-23/index.php
src/xslt/pica2skos.xsl
+27
-0
27 additions, 0 deletions
src/xslt/pica2skos.xsl
with
58 additions
and
1 deletion
public/instance/proxy/opac-de-23/index.php
+
31
−
1
View file @
ac9df7db
...
...
@@ -10,6 +10,7 @@ use HAB\Pica\Reader\PicaNormReader;
use
HAB\Pica\Writer\PicaXmlWriter
;
define
(
'PSI_TEMPLATE'
,
'http://opac.lbs-braunschweig.gbv.de/DB=2/PLAIN=Y/CHARSET=UTF8/PLAINTTLCHARSET=UTF8/PPN?PPN=%s'
);
define
(
'PICA_TEMPLATE'
,
'http://uri.hab.de/instance/proxy/opac-de-23/%s.xml'
);
function
terminate
(
Request
$request
,
Response
$response
)
{
$response
->
prepare
(
$request
);
...
...
@@ -26,10 +27,27 @@ function load ($ident) {
}
}
function
transform
(
$sourceUri
,
$templateUri
)
{
$source
=
new
DOMDocument
();
if
(
@
$source
->
load
(
$sourceUri
)
===
false
)
{
return
false
;
}
$xslt
=
new
DOMDocument
();
if
(
@
$xslt
->
load
(
$templateUri
,
LIBXML_NOENT
)
===
false
)
{
return
false
;
}
$proc
=
new
XSLTProcessor
();
if
(
@
$proc
->
importStylesheet
(
$xslt
)
===
false
)
{
return
false
;
}
$result
=
$proc
->
transformToDoc
(
$source
);
return
$result
->
saveXml
(
$result
->
documentElement
);
}
$request
=
Request
::
createFromGlobals
();
$route
=
basename
(
$request
->
server
->
get
(
'REQUEST_URI'
));
if
(
!
preg_match
(
'@^[0-9]{8}[0-9X]\.
xml
@'
,
$route
))
{
if
(
!
preg_match
(
'@^[0-9]{8}[0-9X]\.
[a-z]+
@'
,
$route
))
{
$response
=
new
Response
(
'<h1>400 Bad Request</h1>'
,
400
,
array
(
'Content-Type'
=>
'text/html'
));
terminate
(
$request
,
$response
);
}
...
...
@@ -49,6 +67,18 @@ switch ($format) {
$content
=
$writer
->
write
(
$record
);
$response
=
new
Response
(
$content
,
200
,
array
(
'Content-Type'
=>
'application/xml'
));
break
;
case
'rdf'
:
$type
=
(
string
)
$record
->
getFirstMatchingField
(
'002@/00'
)
->
getNthSubfield
(
0
,
'0'
);
if
(
$type
[
0
]
===
'T'
)
{
$sourceUri
=
sprintf
(
PICA_TEMPLATE
,
$ident
);
$templateUri
=
__DIR__
.
'/../../../../src/xslt/pica2skos.xsl'
;
$content
=
transform
(
$sourceUri
,
$templateUri
);
if
(
$content
)
{
$response
=
new
Response
(
$content
,
200
,
array
(
'Content-Type'
=>
'application/rdf+xml'
));
break
;
}
}
// Fall through
default
:
$response
=
new
Response
(
'<h1>406 Not Acceptable</h1>'
,
406
,
array
(
'Content-Type'
=>
'text/html'
));
}
...
...
This diff is collapsed.
Click to expand it.
src/xslt/pica2skos.xsl
0 → 100644
+
27
−
0
View file @
ac9df7db
<xsl:transform
version=
"1.0"
exclude-result-prefixes=
"rdf pica skos"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:pica=
"info:srw/schema/5/picaXML-v1.0"
xmlns:skos=
"http://www.w3.org/2004/02/skos/core#"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
>
<xsl:output
method=
"xml"
indent=
"yes"
/>
<xsl:template
match=
"pica:record"
>
<xsl:variable
name=
"recordType"
select=
"substring(pica:datafield[@tag = '002@']/pica:subfield[@code = '0'], 2, 1)"
/>
<rdf:RDF>
<skos:Concept
rdf:about=
"http://uri.hab.de/instance/proxy/opac-de-23/{pica:datafield[@tag = '003@']/pica:subfield[@code = '0']}"
>
<xsl:choose>
<xsl:when
test=
"$recordType = 's'"
>
<skos:prefLabel>
<xsl:value-of
select=
"translate(pica:datafield[@tag = '041A']/pica:subfield[@code = 'a'], '@', '')"
/>
</skos:prefLabel>
</xsl:when>
</xsl:choose>
</skos:Concept>
</rdf:RDF>
</xsl:template>
<xsl:template
match=
"text()"
/>
</xsl:transform>
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment