xsl-list
[Top] [All Lists]

Re: [xsl] Confused using a loop...

2007-03-28 08:30:57



Well, I'm really not sure. I'm not clear on how sort works. I have a
select that grabs a node, I then sort that node, then don't I need to
select the first 3 from that sorted node if I only want to list 3
items?



If you only select one node, you have nothing to sort (sorting a list of
length 1 is dull)

XSLt seems more natural if you use the terminoligy that it uses 

the idiom you want is

<xsl:for-each select="/an/x/path"/>
<xsl:sort selct="relative/path/to/sort/key"/>
<xsl:if test="position() &lt; 4">
  do something
</xsl:if>
</xsl:for-each>


/an/x/path

selects a set of nodes

For each of these nodes relative/path/to/sort/key is evaluated (relative
to that node) to generate a sort key.

The original node set is then ordered in the ordering specified by thos
sort keys and assigned a position (an integer greater than equal to 1)

For those nodes with a position less than 4, you do something.

David

--~------------------------------------------------------------------
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>
--~--