Re: [xsl] Fundimentle Predicate Problem or Bug??

Subject: Re: [xsl] Fundimentle Predicate Problem or Bug??
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 17 Sep 2008 16:07:23 +0200
Chris Hughes wrote:

<ORCB082>
   <ROWSET>
      <ROW num="1">
        <Fixture>
            <FixtureDate>2008-10-17</FixtureDate>
            <FixtureDayText>DAY ONE TEST</FixtureDayText>
            <Race>
               <RaceType>S</RaceType>
            </Race>
            <Race>
               <RaceType>H</RaceType>
            </Race>
         </Fixture>
      </ROW>
   </ROWSET>
</ORCB082>


Stylesheet 1 ------------

This stylesheet outputs "DAY ONE TEST" message, IMO it should match no records and not output anything.

<?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
<xsl:output method="text" indent="yes"/>


<xsl:template match="/">

  <xsl:for-each select="/ORCB082/ROWSET/ROW/Fixture[FixtureDate &gt;= '2008-01-01' and FixtureDate &lt;= '2010-01-01' and
                                                    Race/RaceType &gt;= 'R' and Race/RaceType &lt;= 'R']" >

Race/RaceType >= 'R' is true for the <RaceType>S</RaceType> element, Race/RaceType <= 'R' is true for the <RaceType>H</RaceType>.


So the result you see is a consequence of >= or <= applied to node-set operands (in XPath 1.0) or sequence operands (in XPath 2.0) being true if there is at least one item in each operand node-set/sequence for which the comparison is true.


--


	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread