[xsl] Simple question? element value last() - element value (first)

Subject: [xsl] Simple question? element value last() - element value (first)
From: j milo taylor <milo@xxxxxxxxxx>
Date: Mon, 04 Aug 2008 14:33:30 +0100
This is, I think, pretty simple, but I'm just not getting it.

I want to output a number value = x

where

x = last <Work_Year> - first <Work_Year>

///

I'm applying

<xsl:template match="artist_works">
<xsl:for-each select="works_details">
<xsl:value-of select="Work_Year[last()] - Work_Year[1]"/>
</xsl:for-each>
</xsl:template>


///

on the following XML

///

<artist_works>

<works_details>
<Work_ID>1</Work_ID>
<Work_Year>1945</Work_Year>
</works_details>

<works_details>
<Work_ID>2</Work_ID>
<Work_Year>1958</Work_Year>
</works_details>

<works_details>
<Work_ID>3</Work_ID>
<Work_Year>1972</Work_Year>
</works_details>

</artist_works>

All I'm getting is "000", where in this example it should be "27" i.e 1972-1945

Can anyone advise?

Best Regards
J Milo Taylor

Current Thread