Adding unitid elements to did elements

This posting outlines how I believe I will add unitid elements to did elements of EAD files.

The problem

As the CRRA matures, I expect a greater amount of the metadata ingested into the “portal” will come from EAD files. In order to index EAD files meaningfully, I need to extract unique identifiers from each container-level element, a human-readable description of the container, and a location code. The identifier and human-readable description can easily come from unitid and unititle elements of did elements.

Unfortunately, unitid (and maybe unititle) are not required elements of did elements. While the CRRA could mandate the creation of such elements, it turns out to be almost just as easy to create them on-the-fly.

The solution

The good folks apart of the XML4Lib provided me with my solution — an XSLT stylesheet, below:


  <!-- match everything and copy it -->
  <xsl:template match="node()|@*">
    <xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>

  <!-- special case; match dids with no unitid -->
  <xsl:template match="//did[not(unitid)]">
      <!-- add a unit id -->
      <unitid><xsl:value-of select="generate-id()"/></unitid>
      <!-- continue copying -->
      <xsl:apply-templates select="@*|node()" />


While not perfect, it certainly is a step in the right direction. Short and elegant. The next step will be to include some sort of parameter as input or to generate some EAD-specific identifier so each unitid value is unique across the corpus. (Actually, that is another issue I need to address.)

Thanks go to MJ Suhonos for the cool //did[not(unitid)] expression, Tod Olson for the idea of identity transformation (copying), and Stefan Krause for the use of generate-id.

Author: Eric Lease Morgan

I am a librarian first and a computer user second. My professional goal is to discover new ways to use computers to provide better library services. I use much of my time here at the University of Notre Dame developing and providing technical support for the Catholic Research Resources Alliance -- the "Catholic Portal".