RE: [xsl] xsl Filter Question

Subject: RE: [xsl] xsl Filter Question
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 23 Jul 2002 09:08:59 +0100
> This filter works fine :
> <xsl:for-each  select="report/row[col='some value']">
> 
> But how do filters for >, < in case of text, number and date data ?
> 
> I tried this
> <xsl:for-each  select="report/row[col>'some value']">
> But it did not work.
> 

XPath 1.0 offers "<" and ">" only for numeric values. For other data
types you need to wait till XPath 2.0, or use a workaround.

For dates in iso format, you can strip the punctuation using
translate(), so that 2002-07-23 becomes 20020723, then you can compare
dates as numbers.

For comparing strings alphabetically, the best solution is probably an
extension function, though you can probably do it in XSLT (exploiting
xsl:sort) if you're determined enough.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread