Skip to content

Instantly share code, notes, and snippets.

@kimpham54
Created October 15, 2014 14:52
Show Gist options
  • Save kimpham54/0c76e0b99cca9a08e1cb to your computer and use it in GitHub Desktop.
Save kimpham54/0c76e0b99cca9a08e1cb to your computer and use it in GitHub Desktop.
declare namespace mods="http://www.loc.gov/mods/v3";
declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance";
declare namespace xlink="http://www.w3.org/1999/xlink";
declare namespace schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd";
declare default element namespace "http://www.loc.gov/mods/v3";
copy $xml := .
modify (
let $topic := $xml/mods/subject/topic
return replace node $topic with
for $token in tokenize($topic, '; ')
return <topic>{ $token }</topic>
)
return $xml
@kimpham54
Copy link
Author

turns

<mods><subject>
<topic>lion; bird; cat; dog</topic>
</subject></mods>

into

<mods><subject>
<topic>lion</topic>
<topic>bird</topic>
<topic>cat</topic>
<topic>dog</topic>
</subject></mods>

stick this into your islandora xquery module and it'll sit pretty. guess what anything with $ prefix is a variable, it can be named anything as long it's consistent

namespace declarations may differe based on the structure of your metadata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment