Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2008, 07:16 AM
Authorized User
 
Join Date: Jul 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vsempoux
Default transform date

Hello all,

I'm new at the whole xslt thingy :)

I'm creating an xslt to format a customer's xml into a new xml format.
In the customer's xml i have a tag <start_date>20080101</start_date>.
Is it possible in xslt to transform the content of this tag into
<start_date>01/01/2008</start_date>

Thanks in advance for your help.

Greetings

 
Old July 9th, 2008, 07:22 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sure, take a look at the concat() and substring() functions.

<xsl:template match="start_date">
  <xsl:value-of select="concat(substring(.,8,4), '/', substring(.,3,2), '/', substring(.,1,2))"/>

(Not sure from your example whether you want dd/mm/yyyy or mm/dd/yyyy)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 9th, 2008, 09:48 AM
Authorized User
 
Join Date: Jul 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vsempoux
Default

Hi,

Thanks for the quick reply.

Works great.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform Automatically DJAJ XSLT 0 March 10th, 2006 09:38 PM
transform in xslt kgoldvas XSLT 1 January 24th, 2006 07:14 AM
Recursive Transform chuck.boyer XSLT 0 December 5th, 2005 05:51 PM
Transform query tulincim Access ASP 2 October 4th, 2005 08:50 AM
XSLT Transform scubaduba C# 0 November 30th, 2004 06:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.