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
DDA
dda-wizard
Commits
35b57780
Commit
35b57780
authored
Nov 24, 2017
by
Gerrit Hübbers
🃏
Browse files
Merge branch 'FEATURE-xslt-xoai-bundles-source'
parents
a351e5b0
8712c257
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/gesis/dda/publishing/domain/impl/XsltTransformerOaiPmhBundlesStreamSourceTest.java
View file @
35b57780
...
...
@@ -923,6 +923,27 @@ public class XsltTransformerOaiPmhBundlesStreamSourceTest {
bss
.
getBundlesStream
().
map
(
Object:
:
toString
).
forEach
(
LOG:
:
info
);
}
@Test
public
void
getRecordsSsoar
()
throws
IOException
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
String
xMetaDissPlusXsltString
=
IOUtils
.
toString
(
getClass
().
getClassLoader
().
getResourceAsStream
(
"xslt/ssoar-xoai-2-xmlbundle.xslt"
),
StandardCharsets
.
UTF_8
);
map
.
put
(
"xoai"
,
xMetaDissPlusXsltString
);
XsltTransformerOaiPmhBundlesStreamSource
bss
=
new
XsltTransformerOaiPmhBundlesStreamSource
(
"http://www.ssoar.info/OAIHandler/request"
,
map
);
Bundle
bundle
=
bss
.
getBundle
(
"oai:gesis.izsoz.de:document/28836"
);
LOG
.
info
(
"{}"
,
bundle
);
Set
<
Metadatum
>
metadata
=
bundle
.
getMetadata
();
metadata
.
stream
().
map
(
Object:
:
toString
).
forEach
(
LOG:
:
info
);
LOG
.
info
(
"-----------------------"
);
// bss.getBundlesStream().map(Object::toString).forEach(LOG::info);
}
@Test
public
void
matchDdcString
()
{
final
String
NOT_DDC_NUMBERS_PATTERN
=
"(\\s?\\D+;?)+"
;
...
...
src/test/resources/xslt/relacionesinternacionales-nlm-2-xmlbundle.xslt
View file @
35b57780
...
...
@@ -298,11 +298,9 @@
<xsl:param
name=
"inputString"
/>
<xsl:choose>
<xsl:when
test=
"matches($inputString, '^\d{4}-\d{4}$')"
>
<xsl:message
terminate=
"no"
>
when 1
</xsl:message>
<xsl:value-of
select=
"$inputString"
/>
</xsl:when>
<xsl:when
test=
"matches($inputString, '^\d{8}$')"
>
<xsl:message
terminate=
"no"
>
when 2
</xsl:message>
<xsl:value-of
select=
"concat( substring($inputString, 1, 4), '-', substring($inputString, 5) )"
/>
</xsl:when>
<xsl:otherwise>
...
...
src/test/resources/xslt/ssoar-xoai-2-xmlbundle.xslt
0 → 100755
View file @
35b57780
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version=
"3.0"
xmlns:cc=
"http://www.d-nb.de/standards/cc/"
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:dcmitype=
"http://purl.org/dc/dcmitype/"
xmlns:dcterms=
"http://purl.org/dc/terms/"
xmlns:ddb=
"http://www.d-nb.de/standards/ddb/"
xmlns:dini=
"http://www.d-nb.de/standards/xmetadissplus/type/"
xmlns:doi=
"http://www.d-nb.de/standards/doi/"
xmlns:hdl=
"http://www.d-nb.de/standards/hdl/"
xmlns:mml=
"http://www.w3.org/1998/Math/MathML"
xmlns:nlm=
"http://dtd.nlm.nih.gov/publishing/2.3"
xmlns:oai=
"http://www.openarchives.org/OAI/2.0/"
xmlns:pc=
"http://www.d-nb.de/standards/pc/"
xmlns:thesis=
"http://www.ndltd.org/standards/metadata/etdms/1.0/"
xmlns:urn=
"http://www.d-nb.de/standards/urn/"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
xmlns:xMetaDiss=
"http://www.d-nb.de/standards/xmetadissplus/"
xmlns:xoai=
"http://www.lyncode.com/xoai"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
xmlns:zoai=
"http://git.gesis.org/dda/zoai"
>
<xsl:output
indent=
"yes"
/>
<xsl:strip-space
elements=
"*"
/>
<!-- <xsl:message terminate="no">here is the tree at the current node <xsl:copy-of select="."/> </xsl:message> -->
<!-- <xsl:message terminate="no">here is some message for stderr, e.g. <xsl:value-of select='text()' /> </xsl:message> -->
<!--
<xsl:for-each select="./*">
<xsl:message terminate="no">a child=<xsl:value-of select="name()"/></xsl:message>
</xsl:for-each>
-->
<!-- override default template -->
<xsl:template
match=
"*"
/>
<xsl:template
match=
"/"
>
<xsl:element
name=
"bundle"
>
<xsl:element
name=
"metadata"
>
<xsl:apply-templates
select=
"oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/xoai:metadata"
/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template
match=
"oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/xoai:metadata"
>
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template
match=
"xoai:element"
>
<xsl:param
name=
"keyHead"
/>
<xsl:apply-templates>
<xsl:with-param
name=
"keyHead"
>
<xsl:choose>
<xsl:when
test=
"$keyHead = ''"
>
<xsl:value-of
select=
"@name"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select=
"concat( $keyHead, '.', @name )"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template
match=
"xoai:field[@name='value']"
>
<xsl:param
name=
"keyHead"
/>
<xsl:variable
name=
"rawLanguage"
>
<xsl:value-of
select=
"tokenize($keyHead,'\.')[last()]"
/>
</xsl:variable>
<xsl:variable
name=
"cleanedLanguage"
>
<xsl:choose>
<xsl:when
test=
"$rawLanguage = 'none'"
>
<xsl:value-of
select=
"null"
/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select=
"$rawLanguage"
/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable
name=
"metadatumKey"
>
<xsl:call-template
name=
"substring-before-last"
>
<xsl:with-param
name=
"haystack"
select=
"$keyHead"
/>
<xsl:with-param
name=
"lastNeedle"
select=
"'.'"
/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template
name=
"new-metadatum"
>
<xsl:with-param
name=
"key"
select=
"$metadatumKey"
/>
<xsl:with-param
name=
"language"
select=
"$cleanedLanguage"
/>
<xsl:with-param
name=
"value"
select=
"text()"
/>
</xsl:call-template>
</xsl:template>
<xsl:template
name=
"new-metadatum"
>
<xsl:param
name=
"key"
/>
<xsl:param
name=
"language"
/>
<xsl:param
name=
"value"
/>
<xsl:element
name=
"metadatum"
>
<xsl:element
name=
"key"
>
<xsl:value-of
select=
"$key"
/>
</xsl:element>
<xsl:if
test=
"$language != ''"
>
<xsl:element
name=
"language"
>
<xsl:value-of
select=
"$language"
/>
</xsl:element>
</xsl:if>
<xsl:element
name=
"value"
>
<xsl:value-of
select=
"$value"
/>
</xsl:element>
</xsl:element>
</xsl:template>
<!-- via https://stackoverflow.com/a/1119666/923560 -->
<xsl:template
name=
"substring-before-last"
>
<xsl:param
name=
"haystack"
select=
"''"
/>
<xsl:param
name=
"lastNeedle"
select=
"''"
/>
<xsl:if
test=
"$haystack != '' and $lastNeedle != ''"
>
<xsl:variable
name=
"head"
select=
"substring-before($haystack, $lastNeedle)"
/>
<xsl:variable
name=
"tail"
select=
"substring-after($haystack, $lastNeedle)"
/>
<xsl:value-of
select=
"$head"
/>
<xsl:if
test=
"contains($tail, $lastNeedle)"
>
<xsl:value-of
select=
"$lastNeedle"
/>
<xsl:call-template
name=
"substring-before-last"
>
<xsl:with-param
name=
"haystack"
select=
"$tail"
/>
<xsl:with-param
name=
"lastNeedle"
select=
"$lastNeedle"
/>
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
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