|
Subject: Re: [xsl] How to access to a node content randomly in xsl:for-each loop From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Sat, 16 Feb 2002 08:06:58 +0000 |
Hi Cihan,
> I m trying to access the content of a node in random order each time
> when I run the XSL script, is it possible?
XPath doesn't have a random() function, so it isn't possible without
using an extension function. Your processor probably has facilities
for either writing your own extension functions or using Java methods
that would enable you to get hold of a random number. You could then
use that random number to access a single node. Read your processor's
documentation to find out what's available for you.
Once you've created a random() function (I'll call it math:random()),
you can get hold of all the answer elements in a random order by
sorting them based on random numbers with:
<xsl:for-each select="answer">
<xsl:sort select="math:random()" />
...
</xsl:for-each>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] How to access to a node conte, Uslu, Cihan Y (MED) | Thread | Re: [xsl] How to access to a node c, Oliver Becker |
| Re: [xsl] Variables in HTML tags, Jeni Tennison | Date | [xsl] sorting numbers, Frederic Leclercq |
| Month |