RE: [xsl] Filtering a node-set

Subject: RE: [xsl] Filtering a node-set
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 Jan 2008 16:27:24 -0000
>       <xsl:variable name="boxSize" select="'0.002'"/>
> 
>      <xsl:for-each select="$elements">
>           <xsl:variable name="top"    select="@lat + 90  + 
> $boxSize "/>
>           <xsl:variable name="bottom" select="@lat + 90  - $boxSize"/>
>           <xsl:variable name="left"   select="@lon + 180 "/>
>           <xsl:variable name="right"  select="@lon + 180 + $boxSize
> +$boxSize"/>
>           <xsl:if test="count($elements[(@lon+180) &lt; $right and
> (@lon+180) &gt; $left and (@lat+90) &lt; $top and (@lat+90) 
> &gt; $bottom])=0">
>                   <xsl:copy-of select="."/>
>           </xsl:if>
>      </xsl:for-each>
> 

XPath 1.0 is not relationally complete (XPath 2.0 is). You're doing a join
here which, I beleive, sits in the subset of predicate calculus that falls
outside the boundaries of what XPath 1.0 can do. This was the reasoning that
led us to introduce the "for" expression and range variables into XPath 2.0,
despite many people saying it added unnecessary complexity. 

So you can't do it in XPath 1.0, and without the node-set extension, I don't
think you can do it in XSLT 1.0 either.

Michael Kay
http://www.saxonica.com/

Current Thread