473,785 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::n ode()/@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="precedi ng-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 1590


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
1590
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 quick lookup: it's a python module so probably it's slower. Furthermore you can __hash__ almost everything, but you can __cmp__ in a consistent way much less stuff. Take definitely a look at sets.
57
3620
by: Egor Bolonev | last post by:
why functions created with lambda forms cannot contain statements? how to get unnamed function with statements?
5
52120
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 direct way to do so? Or must I list = for item in set1:
10
15140
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 be a class. Is it necessary to implement the > or < operators or to write a compare-function that returns the larger or smaller of two classes? Ideally, the list begins with the smallest element. Cheers, Matthias
3
22075
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 college and facing the prospect of getting a real job, i need to get back into the game. anyway, i don't know if some of you know the stanford CS library. i took the problem set a while back and have recently rediscovered it adn have been trying...
3
3205
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 navigate to the desired option quickly just by typing out the name. For example if I want to choose "Other" (All the options are arranged alhabetically within the Drop-down box) from Drop-down and if I Type "O" then I navigate to first entry with...
1
1649
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 doorConflictList be keyed on a door ID and contain a sorted list called conFlictList. I wrote this expecting the following doorConflictList should end up with 3 items. Item 1 would be a sorted list with 1 item
4
1862
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 there is SortedList<key, value> for hash tables, but could find anything for a sorted list. Currently I am using List<string> and whenever I add an item, I need to
8
2596
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; m_ResultArray.Add ( aFoundObject);
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.