This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: xsl Filter Question
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 23 Jul 2002 09:08:59 +0100
- Subject: RE: [xsl] xsl Filter Question
- Reply-to: xsl-list at lists dot mulberrytech dot com
> 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@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list