Re: One problem using Date:add utility from exslt
"Mallikarjuna, Nagendra" <[email protected]> Thu, 13 Nov 2008 00:47:05 -0500
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Message-ID | <DAC11958BCE1D44AB2B7E05B023C038B02C80978@gsmbnbp28es.firmwide.corp.gs.com> |
Thanks. This was helpful. We have a xalan.jar which has exsltdatetime
class under that. So we were trying to use that.
Now we started using xalan://java.util.GregorianCalendar and it worked
fine for us.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cal="xalan://java.util.GregorianCalendar"
version="1.0">
<xsl:template match="/">
<xsl:variable name="rightNow" select="cal:new()" />
<html>
<table>
<tr>
<xsl:variable name="year" select="cal:get($rightNow, 1)" />
<xsl:variable name="month" select="cal:get($rightNow, 2)" />
<xsl:variable name="date" select="cal:get($rightNow, 5)" />
<xsl:value-of select="cal:add($rightNow,2,-6)" />
<xsl:variable name="year1" select="cal:get($rightNow, 1)" />
<xsl:variable name="month1" select="cal:get($rightNow, 2)" />
<xsl:variable name="date1" select="cal:get($rightNow, 5)" />
<tr><td>Current Date : <xsl:value-of
select="$year"/>/<xsl:value-of select="$month"/>/<xsl:value-of
select="$date"/></td></tr>
<tr><td>After 6 Months : <xsl:value-of
select="$year1"/>/<xsl:value-of select="$month1"/>/<xsl:value-of
select="$date1"/></td></tr>
</tr>
</table>
</html>
</xsl:template>
</xsl:stylesheet>
Regards
Nag
-----Original Message-----
From: [email protected]
[mailto:[email protected]]
Sent: Wednesday, November 12, 2008 10:24 PM
To: Mallikarjuna, Nagendra
Cc: [email protected]
Subject: Re: [exslt] One problem using Date:add utility from exslt
Hi Nagendra,
I use exslt dates-and-times functions by importing the XSLT
implementation
as named templates, so for example:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="date" >
<xsl:include href = "exslt/date.add.template.xsl" />
<xsl:template match="/">
<xsl:call-template name = "date:add">
<xsl:with-param name = "date-time" select = "'2000-01-01'"
/>
<xsl:with-param name = "duration" select = "'P20D'" />
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
- should work just fine (note, in this example, the exslt script is
located
in a 'exslt' sub-directory). It's not as neat as defining an extension
function (I don't have any experience of doing this with Xalan-J; I'm
not
sure if it's supported), but has the advantage of portability - I'm
writing
code to run under both Xalan and MSXML.
I guess you read the advice on using extension functions at
http://www.exslt.org/howto.html?
Best regards,
Harry
Internet
Nagendra.Malli
[email protected]
To
[email protected]
Sent by:
cc
exslt-bounces@
lists.fourthou
Subject
ght.com [exslt] One problem using Date:add
utility from exslt
12/11/2008
09:05
Hi,
I am trying to use the date-and-times package to get current date and 6
months back date. The date:add function to add duration to date is
giving
the following error. Any idea what could have gone wrong.
->java org.apache.xalan.xslt.Process -in test.xml -xsl test.xsl
file:///home/mallin/test.xsl; Line #11; Column #57; XSLT Error
(javax.xml.transform.TransformerConfigurationException):
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Illegal value:
date:add('2000-01-01','P20D') used for QNAME attribute: name
Exception in thread "main" java.lang.RuntimeException:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Illegal value:
date:add('2000-01-01','P20D') used for QNAME attribute: name
at org.apache.xalan.xslt.Process.doExit(Process.java:1153)
at org.apache.xalan.xslt.Process.main(Process.java:1126)
cat test.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
version="1.0">
<xsl:template match="/">
<xsl:call-template name="date:add('2000-01-01','P20D')">
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Thanks
Nagendra M
AML Compliance IT _______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list