Solved

How to display the x item using XSLT

Posted on 2013-02-04
1
212 Views
Last Modified: 2013-02-04
Hello,

I am trying to display the last 4 items of a product list using XSLT. So far I have this:

<xsl:for-each select="(//product) [position() &lt; 5]">
            <xsl:sort select="position()" data-type="number" order="descending"/>
                <xsl:value-of select="@Product"/>

This displays the first 4 items not the last 4 items. What am I doing wrong?
0
Comment
Question by:Pete_Zed
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 38852484
for-each selects a set of nodes,
the sort happens on the selected set

if you need to just have the final four products
<xsl:for-each select="(//product) [position() &gt; count(//product) - 5]">
(I recommend to put the count in a variable first)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question