Last active
April 24, 2023 20:02
-
-
Save sallain/7604ffb0c155294fcfaf to your computer and use it in GitHub Desktop.
MODS Template for Open Refine
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
<!-- For Prefix --> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<modsCollection xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd"> | |
<!-- For Row Template --> | |
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd"> | |
<titleInfo> | |
<title>{{jsonize(cells["Title"].value)}}</title> | |
</titleInfo> | |
<name> | |
<namePart>{{jsonize(cells["Name"].value)}}</namePart> | |
<role> | |
<roleTerm type="text">{{jsonize(cells["Role"].value)}}</roleTerm> | |
</role> | |
</name> | |
<genre>{{jsonize(cells["Genre"].value)}}</genre> | |
<subject> | |
<topic>{{jsonize(cells["Subject"].value)}}</topic> | |
</subject> | |
<note>{{jsonize(cells["Note"].value)}}</note> | |
<originInfo> | |
<publisher>{{jsonize(cells["Publisher"].value)}}</publisher> | |
</originInfo> | |
<originInfo> | |
<dateCreated>{{jsonize(cells["Date"].value)}}</dateCreated> | |
</originInfo> | |
<physicalDescription> | |
<extent>{{jsonize(cells["Size"].value)}}</extent> | |
</physicalDescription> | |
<identifier type="local">{{jsonize(cells["Identifier"].value)}}</identifier> | |
<language> | |
<languageTerm type="text">{{jsonize(cells["Language"].value)}}</languageTerm> | |
</language> | |
<accessCondition>{{jsonize(cells["Rights"].value)}}</accessCondition> | |
</mods> | |
<!-- Don't put anything in Row Separator --> | |
<!-- For Suffix --> | |
</modsCollection> |
A colleague of mine spent some time with her GREL skills, and she came up with this null value solution:
{{if(isBlank(cells["Genre"].value),"","<genre>"+jsonize(cells["Genre"].value).replace('"', '')+"</genre>")}}
Here's a more complicated example for Subject Headings under authority:
{{if(isBlank(cells["subj_auth_2"].value),"","<mods:subject authority="+jsonize(cells["subj_auth_2"].value)+">")}}
{{if(isBlank(cells["subject_2"].value),"","<mods:topic>"+jsonize(cells["subject_2"].value).replace('"', '')+"</mods:topic>
</mods:subject>")}}
Thanks for posting and thanks dmj and psuda1 for the suggestions. I made a template for exporting to an EAD-formatted XML record and used the suggestions for removing the quotes as well as escaping the necessary characters (this is crucial for me as I'm working with metadata with ampersands galore).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Although I, like psuda1 am wondering how to remove null values, i.e. a cell with nothing in it?