My data model is as follows:
<Club>
<Captain>
<Name></Name>
<DateOfBirth>15-01-1985</DateOfBirth>
</Captain>
<PlayingStaff>
<Player>
<DateOfBirth>14-01-1993</DateOfBirth>
</Player>
<Player>
<DateOfBirth>07-12-1975</DateOfBirth>
</Player>
<Player>
<DateOfBirth>11-11-1991</DateOfBirth>
</Player>
</PlayingStaff>
</Club>
I've tried using the answer given here: XSLT: Getting the latest date but it isnt giving me any value.
I'm trying to get the youngest player to pass to an external function.
I'm doing this in Biztalk so I have to stick to XSLT1
My work so far is as follows:
<xsl:variable name="youngestPlayer">
<xsl:for-each select="$ClubRoot/*[local-name()='PlayingStaff']/*[local-name()='Player']">
<xsl:sort select="./*[local-name()='DateOfBirth']" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="DateOfBirth"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="IsYoungestPlayerUnderAgeLimit" select="externalfunctionreturningboolean">
<xsl:element name="blahhh"><xsl:value-of select="$IsYoungestPlayerUnderAgeLimit"/></xsl:element>
<xsl:element name="blahhh"><xsl:value-of select="$youngestPlayer"/></xsl:element>
This is part of a large template - I can't really change this, but the value of ClubRoot is "<xsl:variable name="ClubRoot" select="/*[1]"/>"
to ensure I can read its child nodes.
I'm always getting
<blahhh>false</blahhh>
<blahhh/>
as my debug values... so i'm not picking up the value I expect
Can someone highlight where I've gone wrong?
From the data above, I'd expect the value of 14-01-1993 in my youngestPlayer variable. But its blank.