First guess as to problem is dates, but not sure. 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" xmlns:str="http://exslt.org/strings" exclude-result-prefixes="str foxy dt"
<xsl:template match="/"> <html> <body> <xsl:call-template name="foxy:h12-mm-ap"> <xsl:with-param name="date" select="dt:time('2001-01-01T12:00:00')"/> </xsl:call-template> </body> </html> </xsl:template>
<xsl:template name="foxy:h12-mm-ap">
<xsl:param name="date" select="dt:date-time()"/>
<xsl:variable name="h" select="dt:hour-in-day($date)"/>
<xsl:variable name="min" select="dt:minute-in-hour($date)"/>
<xsl:variable name="hour"><xsl:choose>
<xsl:when test="$h>12"><xsl:value-of select="$h - 12"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$h"/></xsl:otherwise>
</xsl:choose></xsl:variable>
<xsl:variable name="ampm"><xsl:choose>
<xsl:when test="$h>12">pm</xsl:when>
<xsl:otherwise>am</xsl:otherwise></xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($hour,':')"/>
<xsl:call-template name="foxy:padnum">
<xsl:with-param name="num" select="$min"/>
<xsl:with-param name="padding" select="2"/>
</xsl:call-template>
<xsl:value-of select="concat(' ',$ampm)"/>
</xsl:template><xsl:template name="foxy:padnum">
<xsl:param name="num"/>
<xsl:param name="padding"/>
<xsl:value-of select="str:align(string($num),
str:padding($padding,'0'),'right')"/>
</xsl:template>
</xsl:stylesheet>Commend strings:
java org.apache.xalan.xslt.Process -xsl c:/fox/text/foxy/journal/test-problem-1.xsl
java org.apache.xalan.xslt.Process -xsltc -xt -xo xjournal_xsltc -xx -xsl c:/fox/text/foxy/journal/test-problem-1.xsl
Ouput of Xalan: <html> <body>12:00 am</body> </html>
Output of XSLTC: ERROR: 'null'
(Location of error unknown)XSLT Error (javax.xml.transform.TransformerConfigurationException): Could not compile stylesheet
Doesn't matter if it's called with dt:time() or not. (I use that because I ran into a problem calling it without it in Xalan, however, I can only replicate it with my full stylesheet and xml input document chain, so I'll leave that for later.) Commenting out the foxy:h12-mm-ap template and all calls to it works fine.
Second XSLTC error: (I simply have no luck with the thing.) 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.
Any help on workarounds for either of these, or confirmations (or fixes!) of bugs before I go blindly hacking would be most appreciated. ^_^
An enhancement request: Would it be difficult to add the dt:date-format EXSLT function? It's a bit nonstandard, but after all, wouldn't it involve nothing more than a call to java.text.SimpleDateFormat and passing the results back?
Finally, I'd like to bring up an issue. XSLTC does not support user-defined functions (although it doesn't like to admit it; it should say something like, well, "XSLTC does not support user-defined functions" when it comes across func:function), but they are included in the XSLT 2.0 draft, and popular enough that they will likely be finalized. Will XSLTC be restructured to make use of these? The lack of support would mean a lack of conformance, after all. The XSLT 2.0 functions differ from the EXSLT functions in that no parameters can be optional, so perhaps this would make it easier to implement? Although the EXSLT is still more useful because of that, and that style would make a great extension-flag for the 2.0 branch:
<xsl:function name="..." xalan:arguments-optional="yes">
I mostly ask because I build my Xalan stylesheets with extensive use of functions, since they're so much easier and more compact to call than templates with parameters. It's a pain, but not impossible, to refactor them for XSLTC.
Thanks, Foxy
Swiftpaw Foxyshadis, wildlife artist [EMAIL PROTECTED] | http://foxyshadis.dyndns.org/
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
