473,385 Members | 1,602 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,385 software developers and data experts.

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 1101


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.com/group/microsoft.public.xsl/browse_frm/thread/4b125811eb0b4f89/7e8b9562a75eb0bc?lnk=st&q=perform-sort+group%3Amicrosoft.public.xsl+author%3Ahonnen& rnum=1&hl=en#7e8b9562a75eb0bc>

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>20060101</date>
<date>20050101</date>
<date>20060527</date>
<date>20041231</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
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...
10
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...
1
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...
3
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...
8
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...
2
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...
2
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...
0
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...
6
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...
1
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.