?
Solved

How to display the x item using XSLT

Posted on 2013-02-04
1
Medium Priority
?
216 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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