[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to access to a node content randomly in xsl:fo

Subject: Re: 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
get node content
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.