[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: splitting the date field in xml

Subject: Re: splitting the date field in xml
From: jim smith <jim@xxxxxxxxx>
Date: Wed, 14 Feb 2001 00:44:36 +0000
xml date field
Hi

I have a xml file which looks like this

<Context>
	<Date>Tue Jan 11 16:00:00 PST 1949</Date>
</Context>

I need to show the date in 3 textfields as

Jan 11 1949



Obviously with...

<satire>

<xsl:script implements="really-obvious-regex-things-XSLT-pretends-it-doesn't-need" language="perl">

</satire>

More seriously:

I've cheated a bit and made two assumptions:

1. that the length of the day of the month field never changes
2. that the length of the of the time field never changes

You can probably fix it if only one of those changes with a string-length() - eg if the string is less than 28 characters you know you're dealing with a shortened date or time and can wrap it in an xsl:when

If both change - eg, if you don't pad date and time with leading zeroes, then i'm baffled.

I also cheated and pinched the padding spaces from the string itself.

<?xml version="1.0"?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="Context">

<xsl:value-of select="substring(Date, 5, 4)" /><xsl:value-of select="substring(Date, 9, 3)" /> <xsl:value-of select="substring(Date, 25, 4)" />

	</xsl:template>
</xsl:stylesheet>
--



jim smith
020 7837 0377

XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.