This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: select="..." expressions in XSLT


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
> &lt;=20011220&lt;=@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]