473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

navigating a sorted list

Hi folks, please help

I have a xml file with a list of items. The list is sorted during xslt
processing. Based on this sorted list I want a navigation facility to
walk through the sorted list starting from a choosen item via <back> and
<next>.

Say this is the list:

<a>
<b id="1">2</b>
<b id="15">1</b>
<b id="19">45</b>
<b id="1299">10</b>
<b id="121">5</b>
</a>
This is the position of the choosed item, which should be in this case
the third item of the sorted list (e.g. <b id="121">5</b>):

<xsl:variable name="pos">3</xsl:variable>
Here is a scetch of the intended navagation generator:

<xsl:template match="a">
<xsl:for-each select="b">
<xsl:sort/>
<xsl:if test="postion() = $pos">
<xsl:message>
back id: <xsl:value-of select="../b[$pos-1]/@id"/>, pos:
<xsl:value-of select="$pos-1"/>
current id: <xsl:value-of select="self::node()/@id"/>, pos:
<xsl:value-of select="$pos"/>
next id: <xsl:value-of select="../b/[$pos+1]/@id"/>, pos:
<xsl:value-of select="$pos+1"/>
</xsl:message>
</xsl:if>
...
</xsl:for-each>
...
</xsl:template>

I also tried with sibling selection:
back id: <xsl:value-of select="preceding-sibling::node()/@id"/>, pos:
<xsl:value-of select="$pos-1"/>

But I alway got the ids of original xml list and not the sorted one.

Any help appreciated.

Regards
Khayrat
Apr 11 '06 #1
1 1567


Khayrat wrote:

But I alway got the ids of original xml list and not the sorted one.


Consider doing a two step transformation where the first stylesheet
sorts the original XML and the second selects based on that parameter,
taking the result of the first transformation as the input.
Or sort that input into a variable and use an extension function to
convert the variable value (rtf, result tree fragment) into a node set
to process if further.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Daniele Varrazzo | last post by:
If you need a container to look into, there is the sets module that provides a couple of them. If you need a sorted list, there is the bisect module. But i don't think it fits your need for a...
57
by: Egor Bolonev | last post by:
why functions created with lambda forms cannot contain statements? how to get unnamed function with statements?
5
by: MackS | last post by:
Dear all, I've got several large sets in my program. After performing several operations on these I wish to present one set to the user sorted according to a certain criterion. Is there any...
10
by: Der Andere | last post by:
I need to implement a sorted (ordered) list. STL has no sorted list type as far as I know. Is there a (straight) way to implement a sorted list using STL? BTW: The type of items in the list will...
3
by: Andrew Clark | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** it's been a while since i have poseted to this newsgroup, but for a long time i was not programming at all. but now that i am out of...
3
by: excel_hari | last post by:
Hi, I couldnt locate a Classic ASP group hence posting here. One of my colleagues has designed an intranet site and one of the pages has a drop-down box with close to 300 options. I want to...
1
by: J L | last post by:
I want to create a sorted list whose values are themselves sorted lists. I wrote the following simple test program but it does not behave as I would expect. What I wanted to do was have the...
4
by: shrishjain | last post by:
Hi All, I need a type where I can store my items in sorted order. And I want to keep adding items to it, and want it to remain sorted. Is there any type in .net which I can make use of. I see...
8
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.