I have an XML I need to match one text node (my XSLT my xslt already does that), and then if the last 4 characters of the the attribute value is equal to something I need to add a new attribute into the tag.
This the XML that I have
<LT>
<identifications>
<identification title="Delivery1">
<Direction name="DFD_45_FLO">
<ready>yes</ready>
<indice>1</indice>
</Direction>
</identification>
<identification title="Delivery2">
<Direction name="KJI_45_PTS">
<ready>yes</ready>
<indice>0</indice>
</Direction>
</identification>
<identification title="Delivery3">
<Direction name="DFASDF_552_FLO">
<ready>yes</ready>
<indice>0</indice>
</Direction>
</identification>
</identifications>
</LT>
And I want to match yes and after that if the last characters of the attribute name is FLO_ then copy the entire node an add the attribute paid="check" to the tag direction, in that way I would have an output like :
<LT>
<identifications>
<identification title="Delivery1">
<Direction name="DFD_45_FLO" paid="check">
<ready>yes</ready>
<indice>1</indice>
</Direction>
</identification>
<identification title="Delivery3">
<Direction name="DFASDF_552_FLO" paid="check">
<ready>yes</ready>
<indice>0</indice>
</Direction>
</identification>
</identifications>
</LT>
I have this XSLT, and it already do the first part but I dont know how to match the last characters with the if.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='Direction[ready/text()="yes"]'>
<xsl:if test="@name='last characters = FLO'"> THIS IS THE LINE I DONT KNOW HOW TO WRITE
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="paid">check</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>