Newbie: XSLT substring or date format

Discussion in 'XML' started by David Bertolo, Feb 19, 2004.

  1. Hi

    I'm currently using an existing xsl file to display an XML file.
    But I would like change the date format from 2004/02/18-17:26 to 2004/02/18.
    I'm trying to find some examples with format date or substring function but
    it doesn't work.
    There are in comment the two things that I have tried.

    My xsl file is:
    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <html>
    <body>
    <table border="1" cellpadding="8" cellspacing="0">
    <tr>
    <td bgcolor="#88CCAA"><center><i><b>Name</b></i></center></td>
    <td bgcolor="#88CCAA"><center><i><b>Date</b></i></center></td>
    <td bgcolor="#88CCAA"><center><i><b>Size</b></i></center></td>
    </tr>
    <xsl:for-each select="Elements/Element">
    <tr>
    <td bgcolor="#EEDDFF"><xsl:value-of select="@Name"/></td>
    <td bgcolor="#EEDDFF"><xsl:value-of select="@Date"/></td>
    <!--<td bgcolor="#EEDDFF"><xsl:value-of
    select="substring(@Date,1,10)"/></td> -->
    <!--<td bgcolor="#EEDDFF"><xsl:value-of
    select="substring-before(@Date,'-')"/></td>-->
    <td bgcolor="#EEDDFF"><xsl:value-of select="@size"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    Thank you in advance

    David
    David Bertolo, Feb 19, 2004
    #1
    1. Advertising

  2. I solved my problem by replacing this line:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    by this line:
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    Bye

    David

    "David Bertolo" <> wrote in message
    news:40349ca0$0$21655$...
    > Hi
    >
    > I'm currently using an existing xsl file to display an XML file.
    > But I would like change the date format from 2004/02/18-17:26 to

    2004/02/18.
    > I'm trying to find some examples with format date or substring function

    but
    > it doesn't work.
    > There are in comment the two things that I have tried.
    >
    > My xsl file is:
    > <?xml version="1.0" encoding="UTF-16"?>
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    > <xsl:template match="/">
    > <html>
    > <body>
    > <table border="1" cellpadding="8" cellspacing="0">
    > <tr>
    > <td bgcolor="#88CCAA"><center><i><b>Name</b></i></center></td>
    > <td bgcolor="#88CCAA"><center><i><b>Date</b></i></center></td>
    > <td bgcolor="#88CCAA"><center><i><b>Size</b></i></center></td>
    > </tr>
    > <xsl:for-each select="Elements/Element">
    > <tr>
    > <td bgcolor="#EEDDFF"><xsl:value-of select="@Name"/></td>
    > <td bgcolor="#EEDDFF"><xsl:value-of select="@Date"/></td>
    > <!--<td bgcolor="#EEDDFF"><xsl:value-of
    > select="substring(@Date,1,10)"/></td> -->
    > <!--<td bgcolor="#EEDDFF"><xsl:value-of
    > select="substring-before(@Date,'-')"/></td>-->
    > <td bgcolor="#EEDDFF"><xsl:value-of select="@size"/></td>
    > </tr>
    > </xsl:for-each>
    > </table>
    > </body>
    > </html>
    > </xsl:template>
    > </xsl:stylesheet>
    >
    > Thank you in advance
    >
    > David
    >
    >
    David Bertolo, Feb 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,150
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    2,995
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,231
    Michael Borgwardt
    May 30, 2004
  4. Chu
    Replies:
    3
    Views:
    4,176
    Shawn
    Aug 15, 2006
  5. Replies:
    3
    Views:
    191
    Sherm Pendley
    Aug 3, 2005
Loading...

Share This Page