 |
| 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
|
|
|
|

March 6th, 2009, 02:08 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
converting date format from utc time in seconds to GMT
Hi All,
I have a situation, where I have to convert date:1224850501 which is UTC( seconds from 1970) to GMT:2008-10-24T12:15:01.
If some one knowa how to conver the date plz replay me.
Thanks In Advance
|
|

March 6th, 2009, 02:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Please show your input xml, code and needed output.
__________________
Rummy
|
|

March 6th, 2009, 02:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Try current-dateTime() function.
__________________
Rummy
|
|

March 6th, 2009, 05:07 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
In XSLT 2.0,
($in * xs:dayTimeDuration('PT1S')) + xs:dateTime('1970-01-01T00:00:00')
where $in is the input, as an integer.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

March 9th, 2009, 08:38 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Thanks Rummy and Kay.
Plz find the input xml and out put xml.
input file:
<dm_document>
<r_creation_date dmfttype="dmdate">1236610744</context>
</dm_document>
output file
<dm_document> <r_creation_date dmfttype="dmdate">2009-03-09T14:59:04</r_creation_date>
</dm_document>
Basically the value of the r_creation_time in the input value is in seconds from 1970.
Awaiting for your(Rummy and Kay) reply.
Thanks
--Murali
|
|

March 9th, 2009, 08:46 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
What part of my previous response didn't you understand?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

March 10th, 2009, 12:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
Mike has already replied for your question.
Try this:
Code:
<xsl:template match="dm_document">
<xsl:apply-templates select="r_creation_date"></xsl:apply-templates>
</xsl:template>
<xsl:template match="r_creation_date">
<xsl:variable name="in" select="."></xsl:variable>
<xsl:value-of select="($in * xs:dayTimeDuration('PT1S')) + xs:dateTime('1970-01-01T00:00:00')"></xsl:value-of>
</xsl:template>
__________________
Rummy
|
|

March 10th, 2009, 07:25 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Rummy,
Thanks for your help.
It did worked from the xslt editor(Altova). I am using this template in java.
Java uses 1.0 xslt version, looks to be the api is not supported in java.
I have got the following error.
Can you help me how to get out of this situation?
ERROR: 'The first argument to the non-static Java function 'dayTimeDuration' is not a valid object reference.'
FATAL ERROR: 'Could not compile stylesheet'
Exception in thread "main" javax.xml.transform.TransformerConfigurationExcept ion: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTemplates(TransformerFactoryI mpl.java:829)
at com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTransformer(TransformerFactor yImpl.java:623)
at com.emc.documentum.ess.SimpleJaxp1.main(SimpleJaxp 1.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:90)
Process finished with exit code 1
Many thanks Rummy.
|
|

March 10th, 2009, 07:56 AM
|
|
Friend of Wrox
|
|
Join Date: Feb 2009
Posts: 119
Thanks: 25
Thanked 3 Times in 3 Posts
|
|
Use Saxon 9B as it is xslt 2.0 compliant and free, its also written in java so you should have no problems
|
|
 |