You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by gerritjan <ge...@mac.com> on 2004/10/22 21:34:05 UTC

Xalan ESLT function date:date-add

Hello,

This XSLT:
<?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" >
   <xsl:import href="date.add.function.xsl" />
   <xsl:output method="xml"/>
   <xsl:param name="p_dagen_terug"/>

   <xsl:template match="onderwerpen">
     <xsl:variable name="d1"><xsl:value-of 
select="date:date()"/></xsl:variable>
     <xsl:variable name="d2"><xsl:value-of select="substring-before 
($d1, '+02:00')"/></xsl:variable>
     <xsl:variable name="d5"><xsl:value-of 
select="date:date-add($d2,'-P50D')"/></xsl:variable>
     <basis>
     1
     <xsl:value-of select="$d1"/>
     2
     <xsl:value-of select="$d2"/>
     5
     <xsl:value-of select="$d5"/>
     </basis>
   </xsl:template>

</xsl:stylesheet>

Gives this error;
org.apache.cocoon.ProcessingException: Failed to execute pipeline.: 
java.lang.RuntimeException: java.lang.RuntimeException: 
java.lang.NullPointerException

I'm not sure if Xalan supports this EXSLT function natively , but with 
'import' I was hoping to use this EXSLT function anyway
by the way: without the 'import' line I get the same error...
The 'imported' file is downloadable from www.exslt.org

Gerritjan Koekkoek

Re: Xalan ESLT function date:date-add

Posted by gerritjan <ge...@mac.com>.
Thank you,

You are right, java gives a lot of power.
I also discovered that some exslt functions are not implemented (yet)  
in Xalan, as in almost no important
To use the external functions (being the xslt version og Jeni Tennison  
or the Java stuff thats on the www.exslt.org site i needed to change  
the namespace to make clear distiction between the 'included in xalan'  
versus the 'not included in Xalan'

Gerritjan Koekkoek
Op 25-okt-04 om 8:15 heeft Jan Hoskens het volgende geschreven:

> If you're trying to work with dates, you can use the java extensions  
> in xalan. This way you can call any java stuff you need.
>
> namespace to include:
> xmlns:java="http://xml.apache.org/xslt/java"
>
> <xsl:variable name="locale"  
> select="java:java.util.Locale.new('nl','BE')"/> <!-- Class.new creates  
> new instance -->
> <xsl:variable name="currentCalendar"  
> select="java:java.util.Calendar.getInstance($locale)"/> <!-- static  
> factory method -->
> <xsl:variable name="currentDate"  
> select="java:getTime($currentCalendar)"/>
> <xsl:variable name="dateFormat"  
> select="java: 
> java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM,  
> java.text.DateFormat.MEDIUM, $locale)"/>
> <xsl:variable name="TimeStamp" select="java:format($dateFormat,  
> $currentDate)"/> <!-- normal functions, first give object on which to  
> perform the function, then arguments-->
>
> Kind Regards,
> Jan
>
> gerritjan wrote:
>
>> Hello,
>>
>> This XSLT:
>> <?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" >
>> <xsl:import href="date.add.function.xsl" />
>> <xsl:output method="xml"/>
>> <xsl:param name="p_dagen_terug"/>
>>
>> <xsl:template match="onderwerpen">
>> <xsl:variable name="d1"><xsl:value-of  
>> select="date:date()"/></xsl:variable>
>> <xsl:variable name="d2"><xsl:value-of select="substring-before ($d1,  
>> '+02:00')"/></xsl:variable>
>> <xsl:variable name="d5"><xsl:value-of  
>> select="date:date-add($d2,'-P50D')"/></xsl:variable>
>> <basis>
>> 1
>> <xsl:value-of select="$d1"/>
>> 2
>> <xsl:value-of select="$d2"/>
>> 5
>> <xsl:value-of select="$d5"/>
>> </basis>
>> </xsl:template>
>>
>>
>> </xsl:stylesheet>
>>
>> Gives this error;
>> org.apache.cocoon.ProcessingException: Failed to execute pipeline.:  
>> java.lang.RuntimeException: java.lang.RuntimeException:  
>> java.lang.NullPointerException
>>
>> I'm not sure if Xalan supports this EXSLT function natively , but  
>> with 'import' I was hoping to use this EXSLT function anyway
>> by the way: without the 'import' line I get the same error...
>> The 'imported' file is downloadable from www.exslt.org
>>
>> */_Gerritjan Koekkoek_/*
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>

Re: Xalan ESLT function date:date-add

Posted by Jan Hoskens <jh...@schaubroeck.be>.
If you're trying to work with dates, you can use the java extensions in 
xalan. This way you can call any java stuff you need.

namespace to include:
xmlns:java="http://xml.apache.org/xslt/java"

<xsl:variable name="locale" 
select="java:java.util.Locale.new('nl','BE')"/> <!-- Class.new creates 
new instance -->
<xsl:variable name="currentCalendar" 
select="java:java.util.Calendar.getInstance($locale)"/> <!-- static 
factory method -->
<xsl:variable name="currentDate" select="java:getTime($currentCalendar)"/>
<xsl:variable name="dateFormat" 
select="java:java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM, 
java.text.DateFormat.MEDIUM, $locale)"/>
<xsl:variable name="TimeStamp" select="java:format($dateFormat, 
$currentDate)"/> <!-- normal functions, first give object on which to 
perform the function, then arguments-->

Kind Regards,
Jan

gerritjan wrote:

> Hello,
>
> This XSLT:
> <?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" >
> <xsl:import href="date.add.function.xsl" />
> <xsl:output method="xml"/>
> <xsl:param name="p_dagen_terug"/>
>
> <xsl:template match="onderwerpen">
> <xsl:variable name="d1"><xsl:value-of 
> select="date:date()"/></xsl:variable>
> <xsl:variable name="d2"><xsl:value-of select="substring-before ($d1, 
> '+02:00')"/></xsl:variable>
> <xsl:variable name="d5"><xsl:value-of 
> select="date:date-add($d2,'-P50D')"/></xsl:variable>
> <basis>
> 1
> <xsl:value-of select="$d1"/>
> 2
> <xsl:value-of select="$d2"/>
> 5
> <xsl:value-of select="$d5"/>
> </basis>
> </xsl:template>
>
>
> </xsl:stylesheet>
>
> Gives this error;
> org.apache.cocoon.ProcessingException: Failed to execute pipeline.: 
> java.lang.RuntimeException: java.lang.RuntimeException: 
> java.lang.NullPointerException
>
> I'm not sure if Xalan supports this EXSLT function natively , but with 
> 'import' I was hoping to use this EXSLT function anyway
> by the way: without the 'import' line I get the same error...
> The 'imported' file is downloadable from www.exslt.org
>
> */_Gerritjan Koekkoek_/* 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org