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 March 30th, 2005, 10:06 AM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Modifying time with XSLT

HI All,
I'm new to xslt and xml and just trying to get my head around things. Is there a way to modify time from and xml doc with xslt? The time in my xml doc is GMT and I would like it to reflect my time zone(AST). Below is the xslt code... I was trying to import another date-time template but it didn't work. Can I use Javascript or VBscript to format the time? Or do I have to use a template?

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">
<xsl:import href="date.add.template.xsl" />

<xsl:template match="/">


<table width='171' border='0' cellspacing='0' cellpadding='0' bgcolor='#CCCCCC'>

   <tr align='center' valign='top'>
          <td colspan='2'><xsl:value-of select="rpuData/essIdent/essIdentification/essSiteDescription"/></td>
        </tr>
        <tr>
          <td colspan='2'><img src='../images/5x100transspacer.gif' width='100' height='2' /></td>
        </tr>
        <tr align='center' valign='top'>
          <td colspan='2'><img src='../images/dateandtimepoll.gif' width='165' height='12' /></td>
        </tr>
        <tr align='center' valign='top'>
          <td colspan='2'>
          <xsl:call-template name="date:add">
   <xsl:with-param name="date-time" select="rpuData/essIdent/@TimeStamp" />
   <xsl:with-param name="duration" select="-P4" />
</xsl:call-template>AST</td>
        </tr> <tr align='center'>
          <td colspan='2'><img src='../images/5x100transspacer.gif' width='100' height='2' /></td>
        </tr>
         </tr>
      </table>



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



Any suggestion would be greatly appreciated.
Thanks


 
Old March 30th, 2005, 10:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You're thinking on the right lines: you either want to do this with XSLT 2.0, or failing that, with the EXSLT library of extensions for XSLT 1.0.

You say it didn't work. Without more information, no one can tell you why it didn't work. What did you do, and how did it fail?

I guess that by -P4 you mean a timezone four hours before GMT (I should know what AST is but I don't...). The correct representation of this duration is "-PT4H".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 30th, 2005, 10:53 AM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not sure how the code fails... the page displays everything except the time. There is no error message and the time cell is blank.
It seems to just ignore the code and finish displaying the page.... there is nothing in the source.

AST stands for Atlantic Standard time.

If you had to modify time in a XML doc with XSL what would you do?

 
Old March 30th, 2005, 11:56 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I'm not sure how the code fails... the page displays everything except the time. There is no error message and the time cell is blank.

That's useful information, it means you don't have any nasty installation problems. The explanation is probably that you are calling the EXSLT code with incorrect parameters, e.g. the path expression in the parameter returns nothing. Just debug the EXSLT template as if it were your own code.

>If you had to modify time in a XML doc with XSL what would you do?

I would use XSLT 2.0.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Time transform blackest XSLT 10 April 1st, 2008 03:07 AM
Current Date and Time in XSLT devMc XSLT 6 October 21st, 2007 04:49 AM
getting current date and time in xslt 1.0 ashyabhi_hp XSLT 1 September 24th, 2007 03:17 AM
modifying a node in xslt the rail dale XSLT 3 July 17th, 2007 09:15 AM
XSLT and time change przemek XSLT 4 January 12th, 2007 02:58 AM





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