xsl-list
[Top] [All Lists]

Re: [xsl] selecting nodes based on sibling values

2010-11-23 09:22:19
Fabien Tillier wrote:

What could be the XPath expression to get the maximum number of nodes of
level=50 in data those keycode starts like the level=40 line ?
Here the answer would be 3 as the maximum number of level = 50 nodes for
a given level = 40 is 3

As you originally asked for an XPath expression here is a more compact form of the previous suggestion:

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="2.0">

  <xsl:param name="l1" select="'50'"/>
  <xsl:param name="l2" select="'40'"/>

  <xsl:key name="k1" match="row" use="level"/>

  <xsl:template match="/">
    <xsl:value-of
      select="max(
               for $group in key('k1', $l2)
return count(key('k1', $l1)[starts-with(keycode, $group/keycode)])
             )"/>
  </xsl:template>

</xsl:stylesheet>


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--