You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/01/24 19:41:46 UTC

DO NOT REPLY [Bug 16403] New: - First call of date-time functions badly damaged

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16403>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16403

First call of date-time functions badly damaged

           Summary: First call of date-time functions badly damaged
           Product: XalanJ2
           Version: 2.4
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: org.apache.xalan.lib
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: foxyshadis@hotmail.com


The first use of date-time functions seems to be badly screwed up on this
stylesheet. On other stylesheets it works, when used near the end; haven't yet
tried it on others near the beginning. Same results whether a date is passed in,
default param used, or datetime:date-time() substituted for $date in the function.

When head is commented out and title commented in, crashes with an NPE. When
both are in, title section works fine.

This worked fine in CVS early Dec or so.




XML:

<xbooklist base="C:\text\story" baseuri="C:/text/story">
<book name="fiction\Neil Gaiman - Smoke and Mirrors.xbook"
uri="fiction/Neil%20Gaiman%20-%20Smoke%20and%20Mirrors.xbook" size="67845"/>
</xbooklist>

XSL:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:func="http://exslt.org/functions"
xmlns:datetime="http://exslt.org/dates-and-times"
xmlns:foxy="http://foxyshadis.dyndns.org" xmlns:math="http://exslt.org/math"
xmlns:str="http://exslt.org/strings" xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="foxy func datetime string xalan math">

<xsl:output method="xml" indent="no" encoding="ISO-8859-1"/>

<xsl:variable name="date" select="datetime:date-time()"/>
<xsl:variable name="newline"><xsl:text>
</xsl:text></xsl:variable>

<xsl:template match="/">
<html>
<head><xsl:call-template name="head"/></head>
<body>
<!-- <xsl:call-template name="title"/> -->
</body></html>
</xsl:template>

<xsl:template name="head">
<title><xsl:call-template name="meta-title" /></title>
</xsl:template>

<xsl:template name="meta-title">
Foxyshadis Fiction <xsl:value-of
select="foxy:yyyy-s-mm-s-dd($date)"/></xsl:template>

<xsl:template name="title">
<div id="title">
<h1>Foxyshadis's Fiction List</h1>
<h2><xsl:value-of select="foxy:yyyy-s-mm-s-dd($date)"/></h2>
<h2>Books: <xsl:value-of select="count(//book)"/></h2>
<h2>Total Size: <xsl:value-of select="floor(sum(//book/@size[1]) div 1000)"/>k</h2>
</div>
</xsl:template>

<func:function name="foxy:padnum">
<xsl:param name="num"/>
<xsl:param name="padding"/>
<func:result select="str:align(string($num),str:padding($padding,'0'),'right')"/>
</func:function>

<func:function name="foxy:yyyy-s-mm-s-dd">
<xsl:param name="date" select="datetime:date-time()"/>
<func:result select="concat(datetime:year($date),'/',
 foxy:padnum(datetime:month-in-year($date),2),'/',
 datetime:day-in-month($date))"/>
</func:function>

- & -

<func:function name="foxy:yyyy-s-mm-s-dd">
<xsl:param name="date" select="datetime:date-time()"/>
<func:result select="concat(datetime:year($date),'/',
 datetime:month-in-year($date),'/',
 datetime:day-in-month($date))"/>
</func:function>


Output:

<?xml version="1.0" encoding="ISO-8859-1"?>
<html><head><title>
Foxyshadis Fiction 2003/0/24</title></head><body/></html>

- & -

<?xml version="1.0" encoding="ISO-8859-1"?>
<html><head><title>
Foxyshadis Fiction 2003/00/NaN</title></head><body/></html>