473,779 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Noob question

Hello,

Now I have this:
<xsl:for-each select="A">
<xsl:sort select="B" />
</xsl:for-each>

Now I would like to get first node from this sorted list (which has the
smallest value). But if I write:
<xsl:value-of select="A[1]/B" />, I get first node from unordered list
(the first node in xml).
How can I get the first node from this sort?

Thanks

May 27 '06 #1
3 1122


Pravljica wrote:
Now I have this:
<xsl:for-each select="A">
<xsl:sort select="B" />
</xsl:for-each>

Now I would like to get first node from this sorted list (which has the
smallest value). But if I write:
<xsl:value-of select="A[1]/B" />, I get first node from unordered list
(the first node in xml).
How can I get the first node from this sort?


With XSLT 1.0 you would need to sort into a variable and then make use
of an extension function to convert the variable value, a result tree
fragment, into a node set.
Or you need to chain two stylesheets where the first stylesheet sorts
the input XML and the second works with the sorted result of the first.
--

Martin Honnen
http://JavaScript.FAQTs.com/
May 27 '06 #2
Hey,

I didn't understood a bit of your answer :)
How do you sort into variable? Also - what is an extension function?
Can you give me a link or something?

I need this to get smallest date from my xml, I thought to do it this
way. I sort on date, and the first node is smallest date, the last node
is biggest date. Maybe I can do this easier?

Thanks

May 27 '06 #3


Pravljica wrote:

I didn't understood a bit of your answer :)
How do you sort into variable? Also - what is an extension function?
Can you give me a link or something?
Here is a thread that has both an XSLT 1.0 example as well as an XSLT
2.0 example.
<http://groups.google.c om/group/microsoft.publi c.xsl/browse_frm/thread/4b125811eb0b4f8 9/7e8b9562a75eb0b c?lnk=st&q=perf orm-sort+group%3Ami crosoft.public. xsl+author%3Aho nnen&rnum=1&hl= en#7e8b9562a75e b0bc>

I need this to get smallest date from my xml, I thought to do it this
way. I sort on date, and the first node is smallest date, the last node
is biggest date. Maybe I can do this easier?


Depends on the date format. If you have e.g.

<date-list>
<date>2006010 1</date>
<date>2005010 1</date>
<date>2006052 7</date>
<date>2004123 1</date>
</date-list>

then the XPath expression

/date-list/date[not(. > ../date)]

gives you the minimum date (e.g. 20041231).
For your earlier example you might also want to try

<xsl:for-each select="A">
<xsl:sort select="B" />
<xsl:if test="position( ) = 1">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
--

Martin Honnen
http://JavaScript.FAQTs.com/
May 27 '06 #4

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

Similar topics

1
1948
by: Dave Williams | last post by:
First off...total noob to VB. So far have learned a lot in 1.5 days and feel fairly comfortable at throwing screens up. However, I want to start writing forms that revolve around an access database. From what I have read to date it looks like VB can only display 1 record at a time. I suspect this is not the case. How easy is it to display 10 records at a time (in a table format) that can be scrolled up and down ? When the current...
10
2136
by: Matt Hollingsworth | last post by:
Hello, Very new to python, so a noob question. When I've written stuff in JavaScript or MEL in the past, I've always adopted the variable naming convention of using a $ as the first character (no, I don't use perl, never have). Not possible in python. What are some good options that people commonly use so that they can easily and quickly identify variable with just a glance? When I was writing stuff in SoftImage XSI/JScript, many of...
1
1808
by: davestrike | last post by:
I am a noob to sql and asp programming. I am working on a db for the gaming squad I am a member of. One of the pages I created is a roster list of all the squad members. Part of this roster is listing each member's email address. What several people have asked of me is to make it so the email addresses can be clicked on to open their email programs, just as html allows the mailto function to work. Here is a copy of the coding I am...
3
6080
by: We need more power captain | last post by:
Hi, I know less than a noob, I've been asked to do some compiles in VC++ 6 without knowing too much at all. (I'm a COBOL program normally so this is all too much for me) I open VC++6, open the workspace and then: Build>Batch Build
8
2145
by: Ivan Shevanski | last post by:
Alright heres another noob question for everyone. Alright, say I have a menu like this. print "1. . .Start" print "2. . .End" choice1 = raw_input("> ") and then I had this to determine what option.
2
1373
by: Chris Dunaway | last post by:
I was looking over some asp.net code and saw this asp:Image control: <asp:Image ImageUrl="~/images/logo.gif" runat="server" ID="Image1"/> What does the tilde (~) mean in the ImageUrl attribute? Is it some sort of relative addressing? On the design surface, that shows as an error until I change it to read:
2
1913
by: Dan McCollick | last post by:
Hi All, Noob question that I can not seem to figure out: I am trying to implement a screenscraper to pull data from two seperate websites, here is some test code so far: public static void Main(string args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
0
1485
by: AndyW | last post by:
Hey folks. I am trying to get a soap wsdl service working and have a bit of a noob php programming question for it. I'm using PHP 5.x btw. I have written a soap server that contains a single method in the form: SayHelloWorld( $name ) { return "Hello " .$name; };
6
1634
by: Lang Murphy | last post by:
I'm baaaaack... some of you answered a question I had last week. Only problem is: I'm a dope who doesn't understand most of what y'all posted. Raw noob when it comes to .Net and C#. So I'm going to be more specific... All I need to do at the moment is figure out how to replace our usage of .ini files as configuration files for our small, utility type apps. I'm not looking to use XML as a data stream or anything like that. Not right now,...
1
3542
by: SCRIPT KEEPER | last post by:
Hello, I am a complete noob and just starting off with csharp so I apologize for my basic question. I am wanting to start powershell from inside a batch script and then to pass the powershell args from the batch, so from the batch I can use the name of the compiled csharp app without having to include the "call" command. Something like "Compiled Csharp app.exe" "PowerShell Args" etc..... Thank You for any help.
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8958
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
7478
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
6723
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
5372
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
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
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
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.