472,331 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 10553


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*******@yahoo.de> wrote in message
news:40******@olaf.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.04</data>
<autor>Marcin</autor>
<kat>Przyroda</kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.08</data>
<autor>Anna</autor>
<kat>Krajobraz</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********@yahoo.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*******@yahoo.de> wrote in message
news:40******@olaf.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.04</data>
<autor>Marcin</autor>
<kat>Przyroda</kat>
</foto>
<foto>
<min>2m.jpg</min>
<max>2.jpg</max>
<data>2004.03.08</data>
<autor>Anna</autor>
<kat>Krajobraz</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
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...
2
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...
2
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...
2
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...
1
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...
21
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...
26
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...
48
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...
4
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...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.