Re: [xsl] Extract only numeric value

Subject: Re: [xsl] Extract only numeric value
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Thu, 24 May 2007 13:40:08 +0530
Please try the following XSLT 2.0 solution:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">

<xsl:output method="xml" indent="yes" />

 <xsl:template match="x">
    <year><xsl:value-of select="replace(year, '[a-zA-Z]', '')" /></year>
 </xsl:template>

</xsl:stylesheet>

When this is applied to input XML:

<x>
<year>X2A007a</year>
</x>

The output produced is:

<year>2007</year>

Any alphabetic characters anywhere, are replaced by an empty string ('').

On 5/24/07, J. S. Rawat <jrawat@xxxxxxxxxxxxxx> wrote:
Dear All,
I would like a help about to extract numeric value.

Input
<year>2007a</year>
Output
<year>2007</year>

Thanks in advance for your kind help.
...JSR

-- Regards, Mukul Gandhi

Current Thread