Thanks for your solution. I'll try it.

Stefan
----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, October 14, 2003 2:55 AM
Subject: Re: XSL: formating date


> 
> I think your question will be resolved by a simple XPath.
> 
> If you transform your xml by XSLT, you can do it with the following
> stylesheet:
> 
> ------------------------------------------------------------------
> <xsl:transform version="1.0"
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >
> <xsl:output method="text"/>
> <xsl:template match="/">
>      <xsl:apply-templates select="//created"/>
> </xsl:template>
> <xsl:template match="created">
>     <xsl:choose>
>         <xsl:when test="number(.) > 20011231235959">
>             <!-- convert "yyyyMMddHHmmss" to "dd.MM.yyyy HH:mm:ss" -->
>             <xsl:value-of select="concat( substring( . , 7 , 2) ,
>                                           '.' ,
>                                           substring( . , 5 , 2) ,
>                                           '.' ,
>                                           substring( . , 1 , 4) ,
>                                           ' ' ,
>                                           substring( . , 9 , 2) ,
>                                           ':' ,
>                                           substring( . , 11 , 2) ,
>                                           ':' ,
>                                           substring( . , 13 , 2) )"/>
>         </xsl:when>
>         <xsl:otherwise>
>             <xsl:message terminate="yes"
> >[EMAIL PROTECTED]'created'] : invalid content of
> &lt;created&gt;</xsl:message>
>         </xsl:otherwise>
>     </xsl:choose>
> </xsl:template>
> 
> </xsl:transform>
> --------------------------------------------------------------
> 
> With this xsl, you will get "03.10.2003 17:38:34" from
> "<created>20031003173834</created>".
> 
> You also achieve the similar transformation by <x:out select="...xpath
> expression..."/>
> where the xpath expression will be the equivalent one to the value of
> select attribute of the following:
>             <xsl:value-of select="concat( substring( . , 7 , 2) ,
>                                           '.' ,
>                                           substring( . , 5 , 2) ,
>                                           '.' ,
>                                           substring( . , 1 , 4) ,
>                                           ' ' ,
>                                           substring( . , 9 , 2) ,
>                                           ':' ,
>                                           substring( . , 11 , 2) ,
>                                           ':' ,
>                                           substring( . , 13 , 2) )"/>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to