Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
ExternalAPIs
OAI
Commits
4d2acb41
Commit
4d2acb41
authored
Sep 29, 2020
by
Günter Hipler
Browse files
only a workaround because I cannot load the xslt template as resource
parent
2d873b6d
Pipeline
#14982
passed with stages
in 7 minutes and 26 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/utilities/TemplateCreator.java
View file @
4d2acb41
...
...
@@ -4,6 +4,7 @@ import javax.xml.transform.Transformer;
import
javax.xml.transform.TransformerConfigurationException
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.stream.StreamSource
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -53,9 +54,14 @@ public class TemplateCreator {
Transformer
transformer
=
null
;
//ClassLoader classLoader = TemplateCreator.class.getClassLoader();
ClassLoader
classLoader
=
TemplateCreator
.
class
.
getClassLoader
();
//I have problems to get a ressource as stream because gitlab-ci doesn't create
//a package as I need it (in conjunction with play) - I need more time to analyse it
//try (InputStream is = getClass()
// .getClassLoader().getResourceAsStream(templatePath)) {
try
(
InputStream
is
=
classLoader
.
getResourceAsStream
(
templatePath
))
{
//only a workaround!
try
(
InputStream
is
=
streamFromString
())
{
source
=
new
StreamSource
(
is
);
transformer
=
transformerFactory
.
newTransformer
(
source
);
}
catch
(
TransformerConfigurationException
|
IOException
exc
)
{
...
...
@@ -65,6 +71,12 @@ public class TemplateCreator {
return
transformer
;
}
private
InputStream
streamFromString
()
{
return
new
ByteArrayInputStream
(
XSLTWrapper
.
templatefromString
().
getBytes
());
}
}
app/utilities/XSLTWrapper.scala
View file @
4d2acb41
...
...
@@ -11,4 +11,42 @@ object XSLTWrapper {
new
TemplateCreator
(
TRANSFORMERIMPL
,
EDM_namespace
).
createTransformerFromResource
}
def
templatefromString
:
String
=
"""<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
| xmlns:fn="http://www.w3.org/2005/xpath-functions"
| exclude-result-prefixes="fn">
| <!--xmlns:fn="http://www.w3.org/2005/xpath-functions"> -->
|
| <xsl:output method="xml"
| encoding="UTF-8"
| indent="yes"
| omit-xml-declaration="yes"
| />
|
| <!--
| <xsl:attribute-set name="edm">
| <xsl:attribute name="edm">https://europeana.org/irgendwas</xsl:attribute>
| </xsl:attribute-set>
| -->
| <xsl:template match="record">
|
| <xsl:element namespace="https://europeana.org/irgendwas" name="edm:{local-name()}">
|
|
| <xsl:apply-templates select="@*|node()"/>
| </xsl:element>
|
|
| </xsl:template>
|
|
| <xsl:template match="@*|node()">
| <xsl:copy-of select="."/>
| </xsl:template>
|
|</xsl:stylesheet>
|
|
|"""
.
stripMargin
}
conf/application.conf
View file @
4d2acb41
...
...
@@ -24,6 +24,7 @@ elasticsearch {
//
template_prefix
=
"production"
//
hosts
: [
"sb-ues5.swissbib.unibas.ch:8080"
,
"sb-ues6.swissbib.unibas.ch:8080"
,
"sb-ues7.swissbib.unibas.ch:8080"
,
"sb-ues8.swissbib.unibas.ch:8080"
]
hosts
: [
"mb-es1.memobase.unibas.ch:8080"
]
//
hosts
: [
"localhost:8080"
]
cluster
:
"test-memobase-search-cluster"
# "weywot"
index
:
"documents-v9"
content
:
"application/json; charset=utf-8"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment