Reputation: 3
From <xsl:value-of select="$CashFlowAttach" />
it will come XML Code contain data, from that value i need extract the filename from that {For eg: value could be <p xmlns:Utils="cim:Utils"><a href="resources/Attachment/spend plan.123"><image border="0" width="89px" height="47px" src="resources/Content/images/CIMtrek_spend_plan_123.gif"></image></a></p>
} I need the Value is File name = spend plan.123 at last . Any condition is there to check like that in XSL Form
<xsl:choose>
<xsl:when test="string-length($CashFlowAttach)!=0">
<xsl:if test="not(contains($CashFlowAttach,'<p xmlns:Utils="cim:Utils">'))">
<a>
<xsl:attribute name="onclick">ajaxcallingForFileDownload('<xsl:value-of select="$CashFlowAttach" />')
</xsl:attribute>
<xsl:value-of select="$CashFlowAttach" />
</a>
</xsl:if>
</xsl:when>
</xsl:choose>
Upvotes: 0
Views: 1047
Reputation: 101748
I'd suggest adding this template to your XSLT:
<xsl:template name="GetFileName">
<xsl:param name="path" />
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="GetFileName">
<xsl:with-param name="path"
select="substring-after($path, '/')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This template can be used to get the filename at the end of a path. Then you would call it using something like this:
<xsl:variable name="fileName">
<xsl:call-template name="GetFileName">
<xsl:with-param name="path"
select="substring-before(substring-after($CashFlowAttach, 'a href="'),
'"')" />
</xsl:call-template>
</xsl:variable>
Upvotes: 2