2013-05-31 10 views

risposta

10

Come Tomalak detto, è possibile utilizzare substring() e concat() per costruire una stringa si può lanciare come un xs:date()

Esempio (Non suona come si desidera una dateTime.):

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xsl:output method="text"/> 
    <xsl:strip-space elements="*"/> 

    <xsl:variable name="in" select="'30042013'"/> 

    <xsl:template match="/"> 
     <xsl:variable name="date" select="xs:date(concat(
      substring($in,5,4),'-', 
      substring($in,3,2),'-', 
      substring($in,1,2)))"/> 
     <xsl:value-of select="format-date($date,'[MNn] [D], [Y]')"/> 
    </xsl:template> 

</xsl:stylesheet> 

produce (con qualsiasi input XML)

April 30, 2013