Skip to content

Metadata manipulator: AddUuidToTemplated

Mark Jordan edited this page Feb 20, 2018 · 2 revisions

Overview

This metadata manipulator adds a UUID v4 to XML metadata generated by the Templated metadata parser.

Toolchains

Can be used within any CSV or CONTENTdm toolchain that uses a Templated Metadata Parser.

Configuration

To register this manipulator in your toolchain, add the following line to the "[MANIPULATORS]" section of your .ini file:

metadatamanipulators[] = "AddUuidToTemplated|/tmp/twigtemplates/mytemplate.xml"

Parameters

The only parameter is the full or relative path to the Twig template that will render the XML containing the UUID.

Functionality

The only parameter is the full or relative path to the Twig template that will render the XML containing the UUID, e.g., if the Templated metadata parser generates MODS XML like this:

<?xml version="1.0"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
  <titleInfo>
     <title>Small boats in Havana Harbour on a sunny day</title>
  </titleInfo>
</mods>

enabling this metadata manipulator using this template:

<identifier type="uuid">{{ UUID }}</identifier>

will result in MODS like this:

<?xml version="1.0"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
  <titleInfo>
     <title>Small boats in Havana Harbour on a sunny day</title>
  </titleInfo>
<identifier type="uuid">fb677095-2eb5-4acf-b310-ad8c3d0491cd</identifier>
</mods>

Note that:

  • The Twig template must contain the variable UUID.
  • This metadata manipulator does not check to see if an element containing a UUID already exists in the XML.
Clone this wiki locally