The XSLT was tested with The XSLT C library for Gnome's xsltproc. This should be installed already if you are using gnome as your desktop; alternatively it is easy to install. The XSLT should work with any XSLT processor. xsltproc will look for MOA2.DTD unless you give if the --novalid flag.
Date/time reformatting requires http://www.exslt.org/date/functions/parse-date/date.parse-date.template.xsl
xsltproc -o brk00010.00000004.mets.xml moa2mets.xsl brk00010.00000004.xml
Take for example, 48.xml. This MOA2 has dates that look like "12/3/1998" and "3/1/1998". moa2mets.date.xsl will convert dates in this format.
xsltproc -o 48.mets.xml moa2mets.date.xsl 48.xml
Examine the difference between moa2mets.xsl and moa2mets.date.xsl
diff moa2mets.xsl
moa2mets.date.xsl
5c5,12
<
version="1.0">
---
>
version="1.0"
> xmlns:date="http://exslt.org/dates-and-times"
> extension-element-prefixes="date">
>
> <xsl:import href="date.parse-date.template.xsl" />
>
>
>
168,170c175,186
<
<xsl:attribute name="CREATED"><xsl:value-of
<
select="substring(.,1,10)"/>T<xsl:value-of
<
select="substring(.,12)"/>
---
> <xsl:variable name="date"><xsl:value-of select="."/></xsl:variable>
>
<xsl:attribute name="CREATED">
> <xsl:call-template name="date:parse-date">
> <xsl:with-param name="date-time"
select="$date" />
> <xsl:with-param name="format"
select="'M/d/yyyy'" />
> <xsl:with-param name="hour"
select="0" />
> </xsl:call-template>
> <xsl:call-template name="date:parse-date">
> <xsl:with-param name="date-time"
select="$date" />
> <xsl:with-param name="format"
select="'MM/d/yyyy'" />
> <xsl:with-param name="hour"
select="0" />
> </xsl:call-template>
189,193c205,218
<
<xsl:attribute name="VERSDATE"><xsl:value-of
<
select="substring(.,1,10)"/>T<xsl:value-of
<
select="substring(.,12)"/>
<
</xsl:attribute>
< </xsl:when>
---
> <xsl:variable name="date"><xsl:value-of select="."/></xsl:variable>
> <xsl:attribute
name="VERDATE">
> <xsl:call-template name="date:parse-date">
> <xsl:with-param name="date-time"
select="$date" />
> <xsl:with-param name="format"
select="'M/d/yyyy'" />
> <xsl:with-param name="hour"
select="0" />
> </xsl:call-template>
> <xsl:call-template name="date:parse-date">
> <xsl:with-param name="date-time"
select="$date" />
> <xsl:with-param name="format"
select="'MM/d/yyyy'" />
> <xsl:with-param name="hour"
select="0" />
> </xsl:call-template>
> </xsl:attribute>
> </xsl:when>
Edit the XSLT call-template parameters to match your data. Please see EXSLT - date:parse-date for more information on turning arbitrary date encodings into valid xs:dateTime with XSLT.