Hi,
How I could fetch first three character from a string variable.
Say for I fetched a variable message="ABCtest" .... now I want to test that the first three character matches ABD or not .. How I could code to achieve in xslt?
Cheers
Manish
Hi,
How I could fetch first three character from a string variable.
Say for I fetched a variable message="ABCtest" .... now I want to test that the first three character matches ABD or not .. How I could code to achieve in xslt?
Cheers
Manish
Hi,
How I could fetch first three character from a string variable.
Say for I fetched a variable message="ABCtest" .... now I want to test that the first three character matches ABD or not .. How I could code to achieve in xslt?Cheers
Manish
I am giving answer focusing on the bold line (that I've made)....
Let's consider the following example
<?xml version="1.0" encoding="UTF-8"?>
<abc>
<def>
</def>
<ghi>
<jkl>ABCdef</jkl>
</ghi>
<jkl/>
</abc>
I want to print ABCdef if it contain ABC in the first three letters....
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="jkl">
<xsl:if test="substring(.,1,3)='ABC'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Hope you will get the answer.
Regards.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.