?
Solved

How to display the x item using XSLT

Posted on 2013-02-04
1
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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