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=18377>.
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=18377
XSLTC error in complex xsl:if statement
Summary: XSLTC error in complex xsl:if statement
Product: XalanJ2
Version: CurrentCVS
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: Other
Component: org.apache.xalan.xsltc
AssignedTo: xalan-dev@xxxxxxxxxxxxxx
ReportedBy: foxyshadis@xxxxxxxxxxx
Input stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:foxy="http://foxyshadis.dyndns.org"
xmlns:dt="http://exslt.org/dates-and-times"
exclude-result-prefixes="xalan str foxy dt func redirect exslt"
xmlns:xalan="http://xml.apache.org/xalan"
>
<xsl:variable name="rawtext">
<xsl:apply-templates select="//entry" mode="grab">
<xsl:sort select="@date" data-type="text" order="descending"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:variable name="text" select="xalan:nodeset($rawtext)"/>
<xsl:template match="*" mode="grab">
<xsl:copy><xsl:apply-templates select="@*|node()" mode="grab"/></xsl:copy>
</xsl:template>
<xsl:template match="@*" mode="grab">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="$text" mode="post"/>
</body>
</html>
</xsl:template>
<xsl:template match="entry" mode="post">
<xsl:variable name="pos" select="position()"/>
<xsl:choose>
<xsl:when test="$pos=1">
Newday- <xsl:value-of select="dt:date(@date)"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="dt:date(@date)!=dt:date($text/entry[$pos - 1]/@date[1])">
Newday- <xsl:value-of select="dt:date(@date)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<entries>
<entry date="2003-03-25T07:30:00"/>
<entry date="2003-03-23T14:00:00"/>
<entry date="2003-03-21T17:30:00"/>
<entry date="2003-03-23T18:00:00"/>
<entry date="2003-03-21T16:30:00"/>
<entry date="2003-03-25T08:30:00"/>
</entries>
Command strings:
java org.apache.xalan.xslt.Process -xsl
c:/fox/text/foxy/journal/test-problem-2.xsl -in
c:/fox/text/foxy/journal/test-problem-2.xml
java org.apache.xalan.xslt.Process -xsltc -xt -xo xjournal_xsltc -xx -xsl
c:/fox/text/foxy/journal/test-problem-2.xsl -in
c:/fox/text/foxy/journal/test-problem-2.xml
Xalan output:
<html>
<body>
Newday- 2003-03-25
Newday- 2003-03-23
Newday- 2003-03-21</body>
</html>
XSLTC output:
(Location of error unknown)XSLT Error (java.lang.NoSuchMethodError):
org.apache.xalan.xsltc.runtime.BasisLibrary.compare(
Lorg/apache/xpath/objects/XString;Lorg/apache/xpath/objects/XString;
ILorg/apache/xalan/xsltc/DOM;)Z
XSLTC output with the complex if test commented out:
<html>
<body>
Newday- 2003-03-25</body>
</html>
The logic here is to capture all pertinent data in a variable, which is the
turned into a nodeset and acted upon. This does seem inefficient, but it lets
me
do all of the sorting, authorization, and selection beforehand, without putting
that mess into the main code. I'm assuming the DTM is optimized enough to not
make a fuss on big chunks of text.
The big if then tests if the current date is different from last time's date.
|