xslt with substring .i am failing in getting correct ouput



I have return XSLT for getting output. Please correct this xslt if any thing is wrong



<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:template match="/">
<item>
<itemSale>
<xsl:if test="itemSale='abed' and itemsearch='bra'">
<xsl:value-of select="substring(itemSale,1,2)">
</xsl:value-of>
</xsl:if>
</itemSale>
</item>
</xsl:template>
</xsl:stylesheet>


Output xml I want is



<?xml version="1.0" encoding="UTF-8"?>
<item>
<itemSale>ab</itemSale>
</item>


Input xml for testing



<?xml version="1.0"?>
<item>
<itemSale>abed</itemSale>
<itemsearch>bra</itemsearch>
</item>


but I am getting Output xml as



<?xml version="1.0" encoding="UTF-8"?>
<item>
<itemSale></itemSale>
</item>

No comments:

Post a Comment