Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Converting a xml STRING displaying a long date, to dd/mm/yyyy >Thread Next - Re: Converting a xml STRING displaying a long date, to dd/mm/yyyy Re: Converting a xml STRING displaying a long date, to dd/mm/yyyyTo: NULL Date: 12/17/2008 12:40:00 PM All Microsoft stuff is version 1.0. Here's an example for you:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://example.com/dates">
<my:months>
<month index="01" name="January" />
<month index="02" name="February" />
<month index="03" name="March" />
<month index="04" name="April" />
<month index="05" name="May" />
<month index="06" name="June" />
<month index="07" name="July" />
<month index="08" name="August" />
<month index="09" name="September" />
<month index="10" name="October" />
<month index="11" name="November" />
<month index="12" name="December" />
</my:months>
<xsl:template match="/">
<dates>
<xsl:apply-templates select="Coupon/Event/Date" /></dates>
</xsl:template>
<xsl:template match="Date">
GMT: <xsl:value-of select="."/>
UK: <xsl:call-template name="gmtToUkDate">
<xsl:with-param name="gmtDate" select="." />
</xsl:call-template>
</xsl:template>
<!-- coverts date such as Friday 12 December 2008 to 14/12/2008-->
<xsl:template name="gmtToUkDate">
<xsl:param name="gmtDate"/>
<xsl:variable name="date" select="substring-before(substring-after($gmtDate,
' '), ' ')" />
<xsl:variable name="monthName"
select="substring-before(substring-after($gmtDate, concat($date, ' ')), '
')" />
<xsl:variable name="month" select="document('')/*/my:months/month[@name =
$monthName]/@index" />
<xsl:variable name="year" select="substring-after($gmtDate,
concat($monthName, ' '))" />
<xsl:value-of select="concat($date, '/', $month, '/', $year)"/>
</xsl:template>
</xsl:stylesheet>
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"Savvoulidis Iordanis" <SavvoulidisIordanis@d...> wrote
in message news:1FBD81DF-3216-40F1-B18E-D746F5C8A477@m......
> Thanks for the response Joe.
>
> How do I figure out the XSLT version? I use .NET3.5 with VS2008.
>
> I read your recommendations, but I was hoping for a real XSLT example for
> my
> case. As I mentioned , I'm a begginer in XML/XSLT and the things I've done
> with them, are far beyond my expectations for now. Also, time is running
> out
> for my project (as always happens!) and a XSLT research/training is out of
> the question. Sure later, I'll start delving in more depth.
>
> I really liked the other option, about VB.NET. How could I call a VB.NET
> function that does the transformation and inject a "14/12/2008" string, in
> my
> CSV result along with the other column data?
>
> Following, is an excerpt of my XML file.
>
> <?xml version="1.0" encoding="utf-8"?>
> <Coupon type="FOOTBALL">
> <Event code="200">
> <Status>ACTIVE</Status>
> <League>GE2</League>
> <Date>Monday 22 December 2008</Date>
> <Time>19:00</Time>
> <Code>200 </Code>
> <Apodosi1>1,80</Apodosi1>
> <HomeTeamAdvantage />
> <HomeTeam>KOBLENTZ</HomeTeam>
> <ApodosiX>3,15</ApodosiX>
> <AwayTeam>INGOLDSTAD</AwayTeam>
> <AwayTeamAdvantage />
> <Apodosi2>3,50</Apodosi2>
> <Apodosi1X>1,15</Apodosi1X>
> <Apodosi12>1,19</Apodosi12>
> <ApodosiX2>1,66</ApodosiX2>
> <ApodosiHalf1>2,30</ApodosiHalf1>
> <ApodosiHalfX>1,90</ApodosiHalfX>
> <ApodosiHalf2>3,75</ApodosiHalf2>
> <ApodosiUNDER>1,75</ApodosiUNDER>
> <ApodosiOVER>1,70</ApodosiOVER>
> <ApodosiSOG01>3,20</ApodosiSOG01>
> <ApodosiSOG23>1,80</ApodosiSOG23>
> <ApodosiSOG46>3,00</ApodosiSOG46>
> <ApodosiSOG7>15,00</ApodosiSOG7>
> </Event>
> <Event code="201">
> <Status>COMPLETE</Status>
> <League>EN2</League>
> <Date>Friday 12 December 2008</Date>
> <Time>19:00</Time>
> <Code>200 </Code>
> <Apodosi1>1,85</Apodosi1>
> <HomeTeamAdvantage />
> <HomeTeam>WATFORD</HomeTeam>
> <ApodosiX>3,15</ApodosiX>
> <AwayTeam>COVENTRY</AwayTeam>
> <AwayTeamAdvantage />
> <Apodosi2>3,50</Apodosi2>
> <Apodosi1X>1,15</Apodosi1X>
> <Apodosi12>2,19</Apodosi12>
> <ApodosiX2>1,66</ApodosiX2>
> <ApodosiHalf1>2,30</ApodosiHalf1>
> <ApodosiHalfX>3,90</ApodosiHalfX>
> <ApodosiHalf2>3,75</ApodosiHalf2>
> <ApodosiUNDER>1,65</ApodosiUNDER>
> <ApodosiOVER>1,70</ApodosiOVER>
> <ApodosiSOG01>3,20</ApodosiSOG01>
> <ApodosiSOG23>2,80</ApodosiSOG23>
> <ApodosiSOG46>4,00</ApodosiSOG46>
> <ApodosiSOG7>18,00</ApodosiSOG7>
> </Event>
> <Event code="202">
> <Status>ACTIVE</Status>
> <League>EN1</League>
> <Date>Saturday 27 December 2008</Date>
> <Time>19:00</Time>
> <Code>200 </Code>
> <Apodosi1>1,85</Apodosi1>
> <HomeTeamAdvantage />
> <HomeTeam>ARSENAL</HomeTeam>
> <ApodosiX>3,15</ApodosiX>
> <AwayTeam>CARDIFF</AwayTeam>
> <AwayTeamAdvantage />
> <Apodosi2>3,50</Apodosi2>
> <Apodosi1X>1,15</Apodosi1X>
> <Apodosi12>2,19</Apodosi12>
> <ApodosiX2>1,66</ApodosiX2>
> <ApodosiHalf1>2,30</ApodosiHalf1>
> <ApodosiHalfX>3,90</ApodosiHalfX>
> <ApodosiHalf2>3,75</ApodosiHalf2>
> <ApodosiUNDER>1,65</ApodosiUNDER>
> <ApodosiOVER>1,70</ApodosiOVER>
> <ApodosiSOG01>3,20</ApodosiSOG01>
> <ApodosiSOG23>2,80</ApodosiSOG23>
> <ApodosiSOG46>4,00</ApodosiSOG46>
> <ApodosiSOG7>18,00</ApodosiSOG7>
> </Event>
> </Coupon>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
