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

RE: parsing string or numbers after x characters

Subject: RE: parsing string or numbers after x characters
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 13 Jul 2004 09:51:14 +0100
xsl parsing string
> My problem is that I receive for example a date in a 
> concatenated format:
> 
> Ex: 20041207
> 
> And I have to retrieve it in a readable format through my xslt-fo 
> transformation.
> 
> Ex. 12 July 2004

Are you sure that date is 12 July and not 7 December? Probably a stupid
question, it's just that I've never seen dates written as YYYYDDMM before.

Anyway: two solutions. I'll assume the value is in $d.

XSLT 2.0:

format-date(
  xs:date(
    concat(
      substring($d,1,4),
      '-',
      substring($d,7,2),
      '-',
      substring($d,5,2))),
    '[D01] [MNn] [Y0001]')

XSLT 1.0:

   concat(
      substring($d,1,4),
      '-',
      $months/m[number(substring($d,7,2))],
      '-',
      substring($d,5,2))> 

where $months is

<xsl:variable name="months">
<m>January</m>
<m>February</m>

etc.

Michael Kay


> I tried using the substring attribute for that, but I don't have any 
> reference character to look at so it doesn't work. Is there a 
> function 
> which parses strings or numbers after a certain amount of characters 
> directly?
> 
> Thanks in advance for those which will response.
> 
> 
> Julien

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.