I am relatively new to XSLT and have a requirement. Below is my input XML
<Response>
<STF_N>123</STF_N>
<STF_1NM_T>Moon Go</STF_1NM_T>
<STF_SURNM_T>Kimm</STF_SURNM_T>
<STF_FULLNM_T>Kimm Moon Go</STF_FULLNM_T>
<STF_HIRE_D>1990-06-25T00:00:00.000</STF_HIRE_D>
<APPT_ID>A</APPT_ID>
</Response>
<Response>
<STF_N>123</STF_N>
<STF_1NM_T>Moon Go</STF_1NM_T>
<STF_SURNM_T>Kimm</STF_SURNM_T>
<STF_FULLNM_T>Kimm Moon Go</STF_FULLNM_T>
<STF_HIRE_D>2020-06-25T00:00:00.000</STF_HIRE_D>
<APPT_ID>B</APPT_ID>
</Response>
Required output -
<Response>
<STF_N>123</STF_N>
<STF_1NM_T>Moon Go</STF_1NM_T>
<STF_SURNM_T>Kimm</STF_SURNM_T>
<STF_FULLNM_T>Kimm Moon Go</STF_FULLNM_T>
<STF_HIRE_D>1990-06-25T00:00:00.000</STF_HIRE_D>
<APPT_ID>A</APPT_ID>
</Response>
<Response>
<STF_N>123</STF_N>
<STF_1NM_T>Moon Go</STF_1NM_T>
<STF_SURNM_T>Kimm</STF_SURNM_T>
<STF_FULLNM_T>Kimm Moon Go</STF_FULLNM_T>
<STF_HIRE_D>1990-06-25T00:00:00.000</STF_HIRE_D>
<APPT_ID>B</APPT_ID>
</Response>
The STF_HIRE_D should be the same (first value) for all records with the same STF_N.
I used the below XSLT but it is not working as expected -
<xsl:output indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Response/STF_HIRE_D">
<xsl:for-each-group select="Response" group-by="STF_N">
<STF_HIRE_D>
<xsl:value-of select="current-group()[1]/STF_HIRE_D"/>
</STF_HIRE_D>
</xsl:for-each-group>
Any help is much appreciated.
Thank you