Created
October 8, 2019 19:53
-
-
Save phette23/002a136fb92c22d0093ffb245937d2e6 to your computer and use it in GitHub Desktop.
Complete MODS => OAI DC transformation
This file contains hidden or 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
<?xml version="1.0"?> | |
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"> | |
<dc:title>Do Re Mi</dc:title> | |
</oai_dc:dc> |
This file contains hidden or 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
<xml> | |
<mods> | |
<titleInfo> | |
<title>Do Re Mi</title> | |
</titleInfo> | |
</mods> | |
</xml> |
This file contains hidden or 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
#!/usr/bin/env bash | |
# to actually transform the file you need some kind of program that can interpret an XSLT | |
# transform & `xsltproc` is available on Mac/Linux for this purpose, this is a shell script | |
# you could run on the command line to accomplish the transformation | |
xsltproc transform.xsl mods.xml > dublincore.xml |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="xml" indent="yes" /> | |
<xsl:template match="/xml"> | |
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/"> | |
<xsl:for-each select="mods/titleInfo/title"> | |
<dc:title> | |
<xsl:value-of select="mods/titleInfo/title" /> | |
</dc:title> | |
</xsl:for-each> | |
</oai_dc:dc> | |
</xsl:template> | |
</xsl:transform> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment