on 11-01-2005 3:33 PM
I am trying to get the current date/time from java in my xsl mapping. I can't seem to get it to work. This is the code I am using in my xsl file.
<IDField>
<xsl:template name="currentTime" xmlns:date="java:java.util.Date">
<xsl:value-of select="date:new()"/>
</xsl:template>
</IDField>
also tried
<xsl:value-of select="java:java.util.Date:new()"/>
I simply want to put the current date time in the IDField. What am I doing wrong? I am currently getting back a xslt mapping error. Here's the error....
Transformer configuration exception occurred when loading XSLT
I've tried a few different ways, but none have worked. What I'm looking for is the specific code that would display the date/time.
- Emmett
I figured it out. The main problem was that I didn't have the following in this line....
<xsl:stylesheet version="1.0" <b>xmlns:java="http://xml.apache.org/xslt/java" </b>xmlns:xsl="http://www.w3.org/1999/XSL/Transform" .....>
Once I included xmlns:java="http://xml.apache.org/xslt/java" all the java functions were available. I also found the great date template. In case anyone wants to check it out here it is...
<xsl:template name="today"
xmlns:cal="xalan://java.util.GregorianCalendar">
<xsl:variable name="rightNow" select="cal:getInstance()" />
<!-- The GregorianCalendar class counts months from zero
so we have to add one to get the customary number -->
<xsl:variable name="month" select="cal:get($rightNow, 2) + 1" />
<xsl:variable name="day" select="cal:get($rightNow, 5) " />
<xsl:variable name="year" select="cal:get($rightNow, 1)" />
<xsl:value-of
select="$year" />-<xsl:value-of
select="$month" />-<xsl:value-of
select="$day" />
</xsl:template>
I found this template here...
http://cafeconleche.org/books/xmljava/chapters/ch17s03.html
- Emmett
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.