This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Selecting a random node from source-tree


--- "Martin Lormes" <martin dot lormes at gmx dot net> wrote:

> 
> ----- Original Message -----
> From: "Dimitre Novatchev" dnovatchev at yahoo dot com
> To: <xsl-list@lists.mulberrytech.com>
> Sent: Thursday, September 26, 2002 5:11 PM
> Subject: [xsl] Re: Selecting a random node from source-tree
> 
> 
> > > I was thinking of an XPath expression like this:
> > >
> > > document('funnies.xml')/funnies/quote[random()]
> > >
> > > Can I avoid using extension elements?
> >
> > Yes, use the "randNext" template from FXSL.
> >
> > More information is contained in the article:
> >
> > "Casting the Dice with FXSL: Random Number Generation Functions in
> > XSLT"
> >
> > http://fxsl.sourceforge.net
> > /articles/Random/Casting%20the%20Dice%20with%20FXSL-htm.htm
> >
> > Hope this helped.
> 
> 
> Thanks, Dimitre. Awsome article!
> 
> Unfortunately I always get the same random number (which makes
> perfect
> sense, since I can't dynamically generate a starting number :-( )
> 
> So I must add this as a condition to my original question: the
> stylesheet is
> static. No way of changing that.
> 
> 
> Thanks for your help.
> Martin Lormes


That's easy -- have the minutes or seconds part of the current time (or
whatever else you find appropriate) passed as a parameter to the
stylesheet and use that as the seed (or use a subsequence of the
original sequence, starting with the element having index equal to this
parameter.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]