xsl-list
[Top] [All Lists]

XSLT function optimization - datetime comparisons?

2005-09-21 12:53:02
I don't profess to be well seasoned in XSLT.  Simply put I have a function that 
I call an awful lot in stylesheet.  I'm wondering if I'm being very inefficient 
about how it's coded.  Does anyone have any comments how best to do the 
comparison that I'm doing below for datetimes of the form YYYY-MM-DDTHH:MM:SS ?

I'm using Saxon - I found that Xalan (2.7) just couldn't do this sort of thing 
for reasons I don't understand to this day.


<xsl:function name="my:compDate" as="xs:boolean">
        <xsl:param name="dt_a" as="xs:string" />
        <xsl:param name="dt_b" as="xs:string" />
        <xsl:choose>
                <xsl:when test="
xs:integer(translate(translate(translate($dt_a,'-',''),'T',''),':','')) gt 
xs:integer(translate(translate(translate($dt_b,'-',''),'T',''),':',''))">
                        <xsl:copy-of select="true()"/>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:copy-of select="false()"/>
                </xsl:otherwise>
        </xsl:choose>
</xsl:function>

--
Jeffrey Schrab
Internet Application Developer

GS Design
6665 N. Sidney Place
Milwaukee, WI 53209

P: 414.228.9666
F: 414.228.9652
E: jschrab(_at_)gsdesign(_dot_)com http://www.gsdesign.com


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>