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

RE: date formating

Subject: RE: date formating
From: "Roman Kisin" <rkisin@xxxxxxxxxxx>
Date: Fri, 17 Aug 2001 12:21:49 -0700
roman kisin
I'm a new to this list so I don't know what XSLT processor you are talking
about but I'd suspect that node is passed into your extension function.
I use Xalan processor and the way it would work is that for
<xsl:variable name="moreover-date"
      select="harvest_time" />
if would store a node/Element in the variable.
Easiest fix I think would be change it to look like:
<xsl:variable name="moreover-date">
	<xsl:value-of select="harvest_time" />
</xsl:variable>

In this case the text value is stored in the variable.

Thanks,
Roman

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Samina Islam
Sent: Friday, August 17, 2001 11:42 AM
To: xsl-list-digest@xxxxxxxxxxxxxxxxxxxxxx;
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  date formating


Hi All,

For some reason the parse method in SimpleDateFormat
class is not recognizing harvest_time value as a valid
string.  Does anyone know why?  It is giving me a
runtime error that says:

javax.xml.transform.TransformerException: Cannot
format given Object as a Date.


Again, my XML document looks like this:
<moreovernews>
  <article id="_23314341">
    <url>http://c.moreover.com/</url>
    <harvest_time>Aug 15 2001 1:07PM</harvest_time>
  </article>

...

In my XSL stylesheet I have this:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:DateFormat="myDateFormat"
    extension-element-prefixes="DateFormat">

...

<xsl:variable name="moreover-date"
      select="harvest_time" />
<xsl:value-of select= "DateFormat:transformDate(
        $moreover-date,
        'yyyy-MM-dd&apos;T&apos;HH:mm:ssz',
        'MMM dd yyyy hh:mma' )" />

...


myDateFormat java class looks like this:

import java.util.*;
import java.text.*;

public class myDateFormat {

   public SimpleDateFormat init(
            String isoDate,
            TimeZone tz) {

       SimpleDateFormat prismDate = new
           SimpleDateFormat(isoDate);
       prismDate.setTimeZone(tz);
       return prismDate;
   }

   public String transformDate(
            String moreoverTime,
            String isoDateFormat,
            String oldDateFormat) {

       SimpleDateFormat moreoverDate = new
            SimpleDateFormat(oldDateFormat);

       TimeZone tz = new SimpleTimeZone(0, "Z");
       SimpleDateFormat prismDate =
             this.init(isoDateFormat,tz);

       ParsePosition pp = new ParsePosition(0);
       moreoverDate.parse(moreoverTime, pp);
       String isoDate =
prismDate.format(moreoverTime);

       return isoDate;
   }
}

Any suggestions on why this is happening will be
great!!  Thanks!

Samina

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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



 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.