XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> - XSL-fo and how to line feed th... (1)
-> + Houston we have a problem (2)
-> + XSL-FO PDF generation (2)
-> + StylusStudio - pick XSLT 1.0 b... (6)
-> - Stylus Studio 2010 debugging f... (1)
-> - Drop down menu List / Option M... (1)
-> - XML transformation using Java ... (1)
-> + i can't to find XSLT editor in... (2)
-> - Copy xml input as value of an ... (1)
-> - Remove Name space from the Tab... (1)
-> - CGI formatted URL with name/va... (1)
-> - Problem with counting (1)
-> + for-each loop is only returnin... (3)
-> - sort date but some dates may b... (1)
-> - Entity Conversion (1)
-> - How can I build an xml convert... (1)
-> + Little Help (2)
-> + how do I merge nodes to one sc... (2)
-> - beginner help xslt and xpath (1)
-> - Convert XML Feed to CSV/SQL/XL... (1)
-> - Working with text node. (1)
-> - No Topic (1)
-> - API for XSLT Converter for .NE... (1)
-> - Getting started (1)
-> + saxon sql extensions - mysql a... (2)
-> - How do I copy and create new e... (1)
-> + substring-before and sums (3)
-> + Parsing special characters in ... (2)
-> + Schema - Require attribute in ... (2)
-> - Edit existing XSL files when n... (1)
-> + How can I use one single XSLT ... (2)
-> - Default selection of value in ... (1)
-> - Problem with watermark in pdf ... (1)
-> + XSLT Parameter Values dialog n... (3)
-> + Value of File Name is not acce... (10)
-> - Need help with a complex table... (1)
-> - How to replace all nordic char... (1)
-> - XSLT java heap space error wit... (1)
-> - Table Overflow to next page (1)
-> - Using XSLT 2.0 to define custo... (1)
-> - "standalone" attribute and xs... (1)
-> + Standardizing IP addresses (2)
-> + Programmatically changing page... (6)
-> + Can Stylus generate XSLT if so... (5)
-> + Extraction based on NODE Name. (2)
-> + NO XSLT:WYSIWYG (2)
-> + determine condition at run tim... (2)
-> - How to reduce top margin in ev... (1)
-> + need help on xsl looping (4)
-> - Convert Symbol to Element (1)
-> + Separator -only- between field... (3)
-> + DocBook (9)
-> + First Occurance of Alphabet (2)
-> + XSL:Key and Document (2)
-> + Excel Macro using XSLT (2)
-> + Add missing element and attrib... (2)
-> + XSL: Stop Count at First Match (2)
-> + XSD to EDI (4)
-> + How to access data from nested... (2)
-> + Simple division of XML file (2)
-> - XML to Flat File (1)
-> + Dispalying data whith xsl:for ... (3)
-> - distinct nodes - into 3 column... (1)
-> + Newbie at XML (2)
-> + XSL Not Working (3)
-> + to draw table using xsl (2)
-> + Base64 decoder (5)
-> + How to create a hidden sheet u... (3)
-> + XML Reports (2)
-> + Copying image files from one d... (2)
-> + XML conversion to RSS (2)
-> + Inserting Image (2)
-> + Xml to Pdf using Xsl (2)
-> + Using a parameter (or similar)... (2)
-> + How to avoid creating empty xm... (2)
-> + how to read txt files in xml (2)
-> + Limit records to 4 per page. P... (4)
-> + XSLT Mapping Based on JDK5 (2)
-> + XML Mappin (2)
-> + Format Datetime with xslt (3)
-> + Cell border missing (2)
-> + XSL: Key (not matches) (5)
-> + Loop through each char in stri... (2)
-> + What is the best way to sum va... (3)
-> + xslt sort help (2)
-> + getting the count (2)
-> + XSL dynamic variables (5)
-> + XSL:Key use (3)
-> + Help With Updating Attributes ... (8)
-> + GETTING COUNT AND POSITION usi... (3)
-> - Hi Everyone !! (1)
-> + Graph Traversal (Keep track of... (2)
-> + XSL IF with sum (2)
-> + Param not incrementing (2)
-> + Iterating through value tags (3)
-> + URGENT :::: Remove the name sp... (2)
-> + Pass new param values to ASP O... (2)
-> + Detect Browser Version in XSL (2)
-> + xslt result-document (2)
-> + Unique nodes based on two attr... (3)
-- Previous [181-200] [201-220] [221-240] Next
+ XQuery Help and Discussion (2016)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
David MartinSubject: Date formating
Author: David Martin
Date: 15 Nov 2005 12:58 PM
I'm new to date formating from within style sheets using xslt....but aging quickly.

How do I use and test ms:format-date from within Stylus 6?

It is not clear to me how Stylus supports testing the date-format spec exactly...and so I'm looking for a working set of date formating examples for testing within Stylus studio using MSXML 4 and preferrably MSXML 6. Since I'm using .NET ms:format-date seems to be what I want...however I would I'm not sure if that necessitates marking up my raw xml data.

<?xml version="1.0" standalone="yes"?>
<!-- [mytypicaldatesamplethatistrickytoformatinxslt.xml] -->
<dsMyData xml:space="preserve" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<vw_my_data>
<my_date dt:dt="datetime">2005-11-15T10:01:00.0000000-04:00</my_date>
</vw_my_data>
</dsMyData>

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:dt="urn:schemas-microsoft-com:datatypes">
<xsl:output method="html"/>
<xsl:template name="HowToFormatAdate">

<!-- I want to format this date MMM dd, yyyy hh:mm am ?-->
<xsl:value-of select="ms:format-date(dsMyData/vw_my_data/my_date, 'MMM dd, yyyy' )"/>

</xsl:template>
<xsl:template match="/">
<html><head></head>
<body/>
</html>
</xsl:template>
</xsl:stylesheet>

Output I want:
November 15, 2005 10:01 am


djm

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 15 Nov 2005 01:52 PM
David,

ms:format-date(dsMyData/vw_my_data/my_date, 'MMM dd, yyyy') and
ms:format-time(dsMyData/vw_my_data/my_date, 'hh:mm tt')

give you most of what you want. Are you also looking for something to do the timezone conversion to present the result in the local time zone?


Clyde Kessel


Unknowndate.xsl

Postnext
David MartinSubject: Date formating
Author: David Martin
Date: 15 Nov 2005 10:12 PM
ms:format-date does the trick and was all I wanted to use...just some "simple" date formating.

But I never managed to get it working for some reason using the studio (and still can't) - I may have mucked something up in my environment with various betas I was evaluating.


djm

Postnext
Ivan PedruzziSubject: Date formating
Author: Ivan Pedruzzi
Date: 15 Nov 2005 10:22 PM
Hi David,

Did you set the processor to be MSXML or .NET in the scenario dialog?
which error are you getting?

Thanks!
Ivan Pedruzzi
Stylus Studio Team

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 16 Nov 2005 09:17 AM
Dave,
Your original .xslt file had a couple of small errors.
Try the one I attached in my earlier post. Also, as Ivan suggested, make sure your processor is set to MSXML 4 (in the scenario processor tab).

- clyde

Postnext
GG KrishSubject: Date formating
Author: GG Krish
Date: 23 Nov 2005 12:06 PM
Originally Posted: 23 Nov 2005 12:05 PM
How about timezone info? Actually, we want to convert GMT time we are getting to local time. Thanks.

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 23 Nov 2005 12:53 PM
GG,

The original date presented as an example in this thread was:
2005-11-15T10:01:00.0000000-04:00
If you convert that using the ms:format-date function,
You get the equivalent UTC, namely 2:01 PM.
If you use substring() to strip off the "-4:00" at the end before
calling ms:format-date, you will get the local time, 10:01 AM.

- clyde

Postnext
GG KrishSubject: Date formating
Author: GG Krish
Date: 23 Nov 2005 12:57 PM
We DO NOT have the timezone portion in the timestamp info we get. It is simply a GMT timestamp. We need to add the timezone info based on the local time.

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 23 Nov 2005 01:11 PM
GG,

I don't know which timezone you are in, but suppose you are in EST like me. Then concatenate "+0400" to the end of the time stamp and do the conversion. I think you will get what you want.

clyde

Postnext
GG KrishSubject: Date formating
Author: GG Krish
Date: 23 Nov 2005 02:02 PM
We need to capture the timezone info based on the machine it is running on. It is NOT always EST.

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 23 Nov 2005 02:30 PM
So, if I understand correctly, you are getting a GMT time stamp from somewhere, and you want to convert it to the local time.

I need to understand your environment. Are you working with David (the person who started this thread?) If you are, then I assume you want to use the Microsoft date-time functions ms:....

If not, then what is your environment, what is your date format, and what functions are you using to manipulate them?

Thanks
Clyde

P.S. You are posting the same reply 2 or 3 times to the bulletin board.

Postnext
GG KrishSubject: Date formating
Author: GG Krish
Date: 23 Nov 2005 02:41 PM
We are in a .NET (but not .NET 2) environment.

Regarding multiple posts, looks like when I refresh the page, it "reposts" - so now I logoff after posting a reply to avoid this.

Thanks.

Postnext
(Deleted User) Subject: Date formating
Author: (Deleted User)
Date: 23 Nov 2005 04:38 PM
This is what I understand:

You get time stamps which look like this:
2005-11-15T10:01:00.0000000
without any time zone info. You are interpreting them as times in UTC, and want to convert them to the local time zone for display. You (or I) can write a Java extension function which gets the local time zone, and concatenate that (with a suitable + or -) and then use the ms:format-date and ms:format-time functions to do the time-zone offset.

One problem with this is that it will probably give the wrong answer right around the time that daylight savings goes on/off.

Does this solve your problem?
Clyde

Posttop
David MartinSubject: Date formating
Author: David Martin
Date: 25 Nov 2005 08:47 AM
Sorry for delay in responding and thanks for tips. ms:format-date and ms:format-time was exactly what I was trying to use all along. After my initial post and review of responses, I went back and tried calling the exact same routines again in my code, as is, and all worked fine (I had just mocked up a snippet for the post). It appears like I must have had some other issue at the time I was trying to initially implement the function call...and that sent me on quite a bit of a chase prior to posting actually.

Unfortunately, I changed several things along the way just prior to posting and so now to actually roll back to what my initial issue was...java jdk, eval studio (4->6), xslt processor (saxon 8.6x), restructured and linked xsl templates, .net (beta to release)...so I can not shed any light on what my original problem actually was (and we won't speculate on that one any further) but the likely issue was just a style sheet template usage mistake by me...eh hem, hem.

So I can now at least enjoy the satisfaction that xsl date formating works fine with the ms:format-date and ms:format-time calls as previous members have pointed out.

I did also hit the fact that ms:format-time applies the sql server gmt offset when formating the time. As previous posts point out the gmt can be appended (or modified)...if missing.

Thanks again,
djm

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.