473,847 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can get RANDOM record from XML file?

*************** *************** **********
How can get RANDOM record from XML file?
*************** *************** **********
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.
Thanks !
*************** *************** **********
Jul 20 '05 #1
6 10639


Diodak wrote:
*************** *************** **********
How can get RANDOM record from XML file?
*************** *************** **********
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
See:
"Casting the Dice with FXSL: Random Number Generation Functions in XSLT"
at:

http://fxsl.sourceforge.net/articles...20FXSL-htm.htm

This is pure XSLT 1.0 (and also 2.0) code.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:40******@o laf.komtel.net. ..


Diodak wrote:
*************** *************** **********
How can get RANDOM record from XML file?
*************** *************** **********
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3
Thank's but this solution not exacly what i want.
I want display only one from recordcount and that one mast be
integer and random. Maybe my english is to poor to explain that.
//part of xml file
<galeria>
<foto>
<min>1m.jpg</min>
<max>1.jpg</max>
<data>2004.04.0 4</data>
<autor>Marcin </autor>
<kat>Przyroda </kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.0 8</data>
<autor>Anna</autor>
<kat>Krajobra z</kat>
</foto>
.............
</galeria>
I want display random node 'foto'

How i can do that?
Please give me hint or part of source xsl file

Best Regards!

_______________ _______________ _______________ _____
U¿ytkownik "Dimitre Novatchev [MVP XML]" <dn********@yah oo.com> napisa³ w
wiadomo¶ci news:c5******** ****@ID-152440.news.uni-berlin.de...
See:
"Casting the Dice with FXSL: Random Number Generation Functions in XSLT"
at:

http://fxsl.sourceforge.net/articles...ce%20with%20FX
SL-htm.htm
This is pure XSLT 1.0 (and also 2.0) code.
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:40******@o laf.komtel.net. ..


Diodak wrote:
*************** *************** **********
How can get RANDOM record from XML file?
*************** *************** **********
for e.g. in xml files i have aprox.200 records.
how get random position and display that in html.
My Xml (and english) i'ts very poor.
Help..... maybe some solution or example.


If you are using XSLT you could use the random extension from
http://www.exslt.org/random/function...nce/index.html to
generate a random number and then index some elements as needed.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 20 '05 #4

"Diodak" <di*****@poczta .onet.pl> wrote in message
news:c5******** **@news.onet.pl ...
Thank's but this solution not exacly what i want.
I want display only one from recordcount and that one mast be
integer and random. Maybe my english is to poor to explain that.
//part of xml file
<galeria>
<foto>
<min>1m.jpg</min>
<max>1.jpg</max>
<data>2004.04.0 4</data>
<autor>Marcin </autor>
<kat>Przyroda </kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.0 8</data>
<autor>Anna</autor>
<kat>Krajobra z</kat>
</foto>
............
</galeria>
I want display random node 'foto'

How i can do that?
Please give me hint or part of source xsl file


In the quoted article there is an example with source code
(test1-random.xsl) of generating 100 randoms in the range [1, 10].

Use the same code to generate one (or whatever number of randoms you need)
random in the range [1, count(/galeria/foto)]. Let's have this random in a
xsl:variable named $theRand.

Then your random node is:

/galeria/foto[$theRand]
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #5
Thank's again!
MSIE5 don't support: count(/galeria/foto) and if i use Variable same too :(


Jul 20 '05 #6

"Diodak" <di*****@poczta .onet.pl> wrote in message
news:c5******** **@news.onet.pl ...
Thank's again!
MSIE5 don't support: count(/galeria/foto) and if i use Variable same too

:(

You were asking an *XSLT* question -- this has little to do with IE5 (a
browser).

IE5 can "support" true XSLT if MSXML3 isinstalled in "replace mode" -- just
search for:
msxml3 replace mode
Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #7

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

Similar topics

10
6345
by: Stefanie | last post by:
Hi, I have a question about declaring variables for writing data to a file for random access. I have two string variables declared in a module (user-defined types). The point is that for one of them i can't define (hard coded) a fixed length because the application is reading data from another file (In that file they have the same lenght). Is it possible to use the lenght i obtain from reading that other file to declare my variable or...
2
6300
by: Ini | last post by:
Hi, Is there an easy way to pick at random one record out of a recordset and then leave this recordset? I was thinking about doing a recordcount of the recordset, then find at random the number between 1 and <recordcount> and then move to this record in the recordset. There is a easier way, isn't it?
2
2517
by: sugaray | last post by:
I want to write a school computer billing system, one of the function is to distribute machine id using rand() for each student log on, suppose there's 100 machines, when each person log on, the system will store user's info such as name, student id number, log on time, log out time into a database file, when the next student log on, the function loads the database, and compare the random generated machine id with the existing ids store...
2
1460
by: Pete via DotNetMonster.com | last post by:
Hi, I need to display a different random record or link each day. I have the random part working so that if the browser is refreshed a new record will display. I'm not sure however how to specify that it only happens once a day. This is the select statement I'm using to generate a random record. Dim queryString As String = "SELECT Top 1 . FROM ORDER BY NEWID()"
1
5261
by: Steven Smith | last post by:
Hi Guys How do I check whether or not a specific record number in an initialised random access file is empty or not ? What I need to do is when DisplayButton.Click event is triggered the procedure should check if the record number (seat number) is valid(this works fine), then if the record number(seat number) is vaild but not been assigned to anyone the app should throw up a messagebox "seat X is
21
3815
by: Gary Bond | last post by:
Hi All, I am a bit stuck with a project: Specifically, when making a database like engine in 'the old days', I would have wrapped a record class with a stream class, so I could have a file of records on disc, such that I could always jump straight to the record number I wanted. Simple random file access. Maybe they were fixed length records and I knew the n'th record was (n*length of record) into the file. I could therefore jump...
26
3168
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i need to open the DB and randomly select a record (and then display the name, which i dont have a problem with) how can i randomly select a record? im guessing id have to open a recordset
48
4278
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) * -1 Set oConn=Server.CreateObject("ADODB.Connection") Set oRS=Server.CreateObject("ADODB.recordset") oConn.Provider="Microsoft.Jet.OLEDB.4.0" oConn.Open Server.MapPath("temp.mdb")
4
2676
by: knuckels23 | last post by:
Hi All, I have a Random access file which is written using VB 6.0. I need to read this file using C#. The record used in VB to write the Random access file is as follows Type AA aa1 As Integer aa2 As Integer aa3 As Integer aa4 As Integer
0
9732
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10987
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...
1
10709
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9486
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
7885
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
7058
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
5723
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
5914
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4535
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

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.