Solved

How to display the x item using XSLT

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
XSD Data to SQL Tables 2 21
Merge XML into DOM 5 27
character entities and entity references in XML 17 99
Nessus Scan 1 64
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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

10 Experts available now in Live!

Get 1:1 Help Now