I have a xml file who contains multiple elements with same name but differents attributes.
<ns3:ExportMedicines>
<ns3:Jkm code="35897">
<ns3:Data from="2016-10-01" to="2020-07-21">
<ns2:Name>
<Fr>estradiol 1 mg comp + estradiol 1 mg + dydrogestérone 10 mg comp</Fr>
</ns2:Name>
</ns3:Data>
<ns3:Data from="2020-07-22">
<ns2:Name>
<Fr>estradiol 1 mg comp+ estradiol 1 mg + dydrogestérone 10 mg comp</Fr>
</ns2:Name>
</ns3:Data>
</ns3:Jkm>
</ns3:ExportMedicines>
I would like to get the more recent <ns3:data> element.
I'm using xsl 1.0 so as i already read i can't test date attributes.
So i think one way to do is to test if the attribute to doesn't exists.
I can't use a template match because i'm already in a for-each
Here is a snippet from my xsl :
<xsl:for-each select="ns3:jkm">
<xsl:text>INSERT INTO JKM VALUES ('</xsl:text>
<xsl:value-of select="@code" />
<xsl:text>','</xsl:text>
<!--<xsl:if test="not(ns3:Data[@to])">-->
<xsl:value-of select="ns3:Data/@from and ns3:Data[not(@to)]" /> <!--doesn't work-->
<xsl:text>','</xsl:text>
<!--</xsl:if>-->
<xsl:text>','</xsl:text>-->
<xsl:call-template name="escape-apos">
<xsl:with-param name="string" select=".//ns2:Name" />
</xsl:call-template>
<xsl:text>','</xsl:text>
<xsl:text>');</xsl:text>
</xsl:for-each>
Any help will be appreciated!