Hi HC,
I hope you are using XSLT 2.0 (you didn't specify), though it wouldn't
be hard in XSLT 1.0, it is just so much easier 2.0. Here it goes:
<xsl:sequence select="replace(first/date, '(\d+)\.(\d+)\.(\d+)',
'\2/\1/\3') />
hmm, while writing it, looks pretty obfuscated hehe. Perhaps the XSLT
1.0 way with nested substring-before is clearer after all. An
alternative approach would be to convert it into a date and use
format-date() on it.
Thinking of Larry Wall's: there's more than one way to do it. Though
XSLT is not Perl, it can get close. Here's another method (and I'm sure
there're a thousand more!):
<xsl:value-of select="for $i in (2,1,3) return tokenize(first/date,
'\.')[$i]" separator="/" />
if you need some extra explanation on these ones, I am happy to help you
further. Btw, I personally like that last solution, just happened to
come up like that ;)
Cheers,
-- Abel Braaksma
Chaudhary, Harsh wrote:
Hi,
I am sure this has been discussed to death but I have not been able to
find a good source of info on it.
I have an xml:
<first>
<date>31.12.2006</date>
</first>
I would like to convert it to 12/31/2006.
Is there any built in function for this or is string formatting the way
to go?
Thanks,
HC.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--