-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#550 Added template stub mycoreobject-mods-resolve-his-keys.xsl and d…
…efined transformer mods-resolve-his-keys
- Loading branch information
Showing
5 changed files
with
118 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
common/src/main/java/de/uni_jena/thunibib/common/xml/HISinOneResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package de.uni_jena.thunibib.common.xml; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.jdom2.Element; | ||
import org.jdom2.transform.JDOMSource; | ||
import org.mycore.common.xml.MCRFunctionResolver; | ||
|
||
import javax.xml.transform.Source; | ||
import javax.xml.transform.TransformerException; | ||
import javax.xml.transform.URIResolver; | ||
|
||
public class HISinOneResolver implements URIResolver { | ||
public enum URI_PART { | ||
language | ||
} | ||
|
||
private static Logger LOGGER = LogManager.getLogger(MCRFunctionResolver.class); | ||
|
||
@Override | ||
public Source resolve(String href, String base) throws TransformerException { | ||
LOGGER.info("Resolving '{}'", href); | ||
|
||
String[] parts = href.split(":"); | ||
String entity = parts[1]; | ||
String value = parts[2]; | ||
|
||
try { | ||
switch (URI_PART.valueOf(entity)) { | ||
case language: | ||
return new JDOMSource(new Element("int").setText(String.valueOf(resolveLanguage(value)))); | ||
} | ||
} catch (Exception e) { | ||
throw new TransformerException(e); | ||
} | ||
|
||
throw new TransformerException("Unknown entity: " + entity); | ||
} | ||
|
||
private int resolveLanguage(String rfc5646) { | ||
return 42; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
common/src/main/resources/xsl/mycoreobject-mods-resolve-his-keys.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="3.0" | ||
xmlns:fn="http://www.w3.org/2005/xpath-functions" | ||
xmlns:mods="http://www.loc.gov/mods/v3" | ||
xmlns:mcracl="http://www.mycore.de/xslt/acl" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
exclude-result-prefixes="mcracl fn xsl"> | ||
|
||
<xsl:include href="resource:xsl/functions/acl.xsl"/> | ||
|
||
<xsl:output method="xml" indent="yes"/> | ||
|
||
<xsl:param name="ThUniBib.HISinOne.BaseURL"/> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="mods:language"> | ||
<xsl:variable name="rfc5646" select="mods:languageTerm[@type='code'][@authority='rfc5646']"/> | ||
|
||
<xsl:copy> | ||
<xsl:copy-of select="*|@*"/> | ||
<xsl:variable name="his-key" select="fn:document(concat('HISinOne:language:', $rfc5646))"/> | ||
|
||
<xsl:if test="$his-key"> | ||
<mods:languageTerm authorityURI="{$ThUniBib.HISinOne.BaseURL}" type="code"> | ||
<xsl:value-of select="$his-key"/> | ||
</mods:languageTerm> | ||
</xsl:if> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |