Solved

How to display the x item using XSLT

Posted on 2013-02-04
1
211 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now