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 January 9th, 2007, 11:44 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT and time change

Hi,

Is there any way to transform in a simple way time value using XSLT?

What I have is time in GMT+1 and need to change it according to daylight saving.

<Event time= "07:00:00" name= "JUVENTUS-MILAN"/>

Regards,
Przemek

 
Old January 9th, 2007, 12:01 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's easy in XSLT 2.0: there's a function adjust-time-to-timezone().

But in 1.0, you're on your own.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 11th, 2007, 01:54 PM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much. It took me some time to discover why EclipseXSLT (orangevolt) that I am using did not want to accept adjust-time-to-timezone() - it uses Saxon 8.4-B and xmlns:fn was set to wrong date. Now I get correct time output, but I have no idea why I get stylesheet settings inside each output attribute. What I have is:

<xsl:stylesheet
      xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='2.0'
      xmlns:xs='http://www.w3.org/2001/XMLSchema'
      xmlns:fn='http://www.w3.org/2005/04/xpath-functions'
      xmlns:xdt='http://www.w3.org/2005/04/xpath-datatypes'>

...

<xsl:attribute name="time"><xsl:value-of select="fn:adjust-time-to-timezone(xs:time(START//TIME),xdt:dayTimeDuration('PT3H'))"/>
          </xsl:attribute>

And I get as an output:

<Event xmlns:xdt="http://www.w3.org/2005/04/xpath-datatypes" xmlns:fn="http://www.w3.org/2005/04/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" time="07:00:00+03:00" date="2006/12/15" name="Polowanie na czerwony pazdziernik"/>

Could you please elaborate on that?

Best Regards,
Przemek


 
Old January 11th, 2007, 02:25 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You mean, why does the output include the xdt and fn namespaces?

It's part of the specification of literal result elements that all the in-scope namespaces from the stylesheet are copied to the result document unless you request otherwise. You can request otherwise using exclude-result-prefixes="xdt fn" on the xsl:stylesheet element.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 12th, 2007, 02:58 AM
Registered User
 
Join Date: Jan 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you! Namespaces are not displayed anymore. It's time for me to consider buying XSLT reference now ;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Date Time picker change Paulys72 Access 1 August 20th, 2007 06:21 AM
Rename file without time change surendran PHP How-To 1 July 26th, 2006 05:38 AM
XSLT change class attribute by ID? matallen XSLT 8 March 1st, 2006 05:00 PM
How to Change value in Date Time Picker, Help PLZ shopgirl Classic ASP Professional 2 April 29th, 2004 08:34 PM
How do I change the Server Date and Time happygv SQL Server 2000 4 January 5th, 2004 11:28 AM





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