Hello all,
I am trying to write a bit of XSL that will display the most recent revision
date, as encoded at ead/eadheader/revisiondesc/change/date. I'm
anticipating a situation in which there will be multiple <change> elements,
and I only want to display the most recent revision date.
My original idea was to use the sort function. The sort worked fine, but I
ended up with all the dates, rather than the most recent. Here's the xsl:
<xsl:if test="ead/eadheader/revisiondesc[string-length(text()|*)!=0]">
<xsl:for-each select="ead/eadheader/revisiondesc/change">
<xsl:sort select="date/@normal"/>
<br />
<xsl:text>Revised </xsl:text><xsl:apply-templates select="date[1]"/>
</xsl:for-each>
</xsl:if>
The problem is that the sort function is sorting the change elements by
date. What my <xsl:apply-templates select="date[1]"/> asks for is the first
date within each <change> element. How would I write an xpath expression
that would select the <date> from the first <change> element?
Thanks,
Mike
ps: I've managed to come up with a workaround. As long as the <change>
elements are listed most to least recent, the following bit of xsl will
reliably display the most recent date. I'm just convinced that XSL should
be able to remove the chance of error because someone ignores the encoding
guidelines.
<xsl:if test="ead/eadheader/revisiondesc[string-length(text()|*)!=0]">
<br />
<xsl:text>Revised </xsl:text><xsl:apply-templates
select="ead/eadheader/revisiondesc/change[1]/date"/>
</xsl:if>
____________________________________
Michael Rush - Manuscript Processor
Massachusetts Historical Society
[log in to unmask] - (617)646-0553
|