[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re:Re: [xsl] Current date in a Xsl variable


Subject: Re:Re: [xsl] Current date in a Xsl variable
From: Rajendra S Rawat <rajsrawat@xxxxxxxxx>
Date: Wed, 10 Sep 2003 05:49:42 -0700 (PDT)

try 

xmlns:java="http://xml.apache.org/xslt/java"
exclude-result-prefixes="java">

in <xsl:stylesheet ...

 then use

<xsl:value-of
select="java:format(java:java.text.SimpleDateFormat.new('dd/MM/yyyy'),
java:java.util.Date.new())"/>

to directly print currrent date


Cheers,

Raj
--- logchem.news@xxxxxxxxx wrote:
> Hi M.David, 
> 
> When I use your code, I get the error:
> "Error in XPath expression, Function not in
> namespace"
> Do you know whats wrong?
> 
> Thanks,
> Peter
> 
> 
> Xsl file:
>
______________________________________________________
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format"
> xmlns:my="urn:my-scripts">
> <xsl:output method="html"/>
> 
> 	<xsl:template match="root">
> 		<html><head>
> 
> 		<script type="JavaScript" 
> implements-prefix="my"><![CDATA[
> 		
> 		        function returnDate(){
> 		
> 		           var d, s;
> 		           d = new Date();
> 		           s += (d.getMonth() + 1) + "/";
> 		           s += d.getDate() + "/";
> 		           s += d.getYear();
> 		           return(s);
> 		        }
> 
> 		]]></script>
> 
> 		</head><body>				
> 		<xsl:variable name="date"
> select="my:returnDate()"/>
> 	
> 		<p>Today: <xsl:value-of select="$date"/></p>
> 		</body></html> 
> 	</xsl:template>
> 
> </xsl:stylesheet>
>
_____________________________________________________
> 
> Xml file:
>
_____________________________________________________
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
> 	<naam>Peter</naam>
> 	<datum>2000-08-28T15:39:49</datum>
> 	<dag>28</dag>
> 	<maand>3</maand>
> 	<jaar>2000</jaar>
> </root>
>
______________________________________________________
> 
> 
> 
> -- 
>
_____________________________________________________________________
> Snel en voordelig ADSL nu voor iedereen bereikbaar.
> Zon Breedband Budget vanaf EUR 14,95 per maand.
> Nu tijdelijk geen aansluitkosten. Bestel snel op
> zonnet.nl/breedband
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords