I have the following XML:

```
<data>
    <item group="A">AAA</item>
    <item>DDD</item>
    <item group="B">BBB</item>
    <item>DDD</item>
</data>
<data>
    <item group="C">AAA</item>
    <item>DDD</item>
    <item group="D">BBB</item>
    <item>EEE</item>
</data>

```

I would like a value of "true" returned when the the last "item" element in the second "data" element. In this example, I have only 2 "data" elements, but in reality, the number of data elements were vary.

Here is my XSLT:

```
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="data">
    <xsl:apply-templates select="item[@group]"/>
  </xsl:template>

  <xsl:template match="item">    
    <xsl:attribute name="lastdata">
      <xsl:if test="position() = last()">
        <xsl:value-of select="'true'"/>
      </xsl:if>
    </xsl:attribute>
 </xsl:template>

```

Thanks for your help in advance.