Reputation: 331
How can I get only number in a string value? I tried this function but it is not working. What is a possible problem?
Original file:
<?xml version="1.0" encoding="utf-8"?>
<ns0:Request xmlns:ns0="http://ABS.NM.B">
<TRANSACTION>
<LREF>SUBIS 70055593</LREF>
</TRANSACTION>
</ns0:Request>
XSLT:
<xsl:template match="TRANSACTION" >
<Transaction reference="{LREF}" >
<xsl:attribute name="reference">
<xsl:value-of select="replace($input, '.*[^.\d](.*)$', '$1')"/>
</xsl:attribute>
</Transaction>
</xsl:template>
Result:
<Transaction reference="70055593">
</Transaction>
Upvotes: 0
Views: 1862
Reputation: 1278
Your code almost correct, but variable only needs to set as given below.
<xsl:template match="TRANSACTION" >
<xsl:variable name="input" select="LREF"/>
<Transaction reference="{LREF}" >
<xsl:attribute name="reference">
<xsl:value-of select="replace($input, '.*[^.\d](.*)$', '$1')"/>
</xsl:attribute>
</Transaction>
</xsl:template>
Upvotes: 2