This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: select="..." expressions in XSLT
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Knebels, Francis" <francis_knebels at merck dot com>
- Cc: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 20 Dec 2001 17:03:39 +0000
- Subject: Re: [xsl] select="..." expressions in XSLT
- Organization: Jeni Tennison Consulting Ltd
- References: <AF64B9B75F9AD511952500508BCF904EF3F30A@uswpmx15.merck.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Francis,
> I'm trying to get this XSL to work, but it is not giving me the output I'm
> looking for. The XSL looks like this:
>
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
> match="/"><xsl:copy-of select="/campaign/question[@start-date
> <=20011220<=@end-date]"/>
> </xsl:template>
> </xsl:stylesheet>
The XPath test:
@start-date <= 20011220 <= @end-date
Is parsed as if it were:
(@start-date <= 20011220) <= @end-date
So if @start-date <= 20011220, then it's:
true() <= @end-date
Which is why it doesn't work.
Basically, you can't do two comparisons back to back in that way. You
have to use 'and' to join the two tests.
@start-date <= 20011220 and 20011220 <= @end-date
or (if you want to avoid escaping less-than signs):
20011220 >= @start-date and @end-date >= 20011220
So try:
<xsl:copy-of select="/campaign/question[20011220 >= @start-date and
@end-date >= 20011220]" />
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list