[xsl] Filtering a node-set

Subject: [xsl] Filtering a node-set
From: George James <GeorgeJ@xxxxxxxxxxxxxxx>
Date: Wed, 9 Jan 2008 11:16:09 -0000
I have a variable containing a node-set.  Each element in the node-set has a
lat and lon attribute and I have a template that filters elements in the
node-set based on their proximity to other elements:
      <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
          <xsl:if test="count($elements[(@lon+180) &lt; $right and
(@lon+180) &gt; $left and (@lat+90) &lt; $top and (@lat+90) &gt;
                  <xsl:copy-of select="."/>

The output of this template is an rtf.  I'd like the output to be a node-set
so that I can then further manipulate the results.   I need this to run in
xslt1 without using extensions so I can't just use an extension to convert
the rtf to a node-set.
Is there a way of re-expressing the above template as an xpath expression
that would return a node-set?  I can't see a way of eliminating the use of
the $top, $bottom, $left and $right variables.  Is it possible?

George James Software

Current Thread