Subject: Re: [xsl] Randomly displaying articles from RSS feed From: Alice Wei <ajwei@xxxxxxxxxxx> Date: Thu, 10 Jan 2008 15:06:21 -0500 |
Brent,I am not exactly sure if you really meant displaying these articles randomly if you want articles appearing more often than the rest.
The only hard part of what you're describing is the "randomly" part. XSLT by itself provides no random or pseudo-random number generation.
You can get around this, or through it, by:
* calling out to your environment, e.g. with an extension function, to get a random number
<xsl:function name="functx:dateTime" as="xs:dateTime" xmlns:functx="http://www.functx.com" > <xsl:param name="hour" as="xs:anyAtomicType"/> <xsl:param name="minute" as="xs:anyAtomicType"/> <xsl:param name="second" as="xs:anyAtomicType"/>
<xsl:sequence select=" xs:dateTime( concat(functx:time($hour,$minute,$second))) "/>
* passing in a random or virtually-random number as a parameter, and using that * using FXSL, which provides support for generating pseudo-random numbers (this requires invoking FXSL libraries) * other possibilities I may be neglecting
Which of these is best will depend on externals, such as which processor you're using, whether an extension function or (say) FXSL is more feasible for you, and so forth.
Lick that problem and the rest is straightforward, as XSLT can handle the weighting part of it (providing, of course, the weights are available as source data).
For FXSL on this, see http://fxsl.sourceforge.net/articles/Random/Casting%20the%20Dice%20with%20FXSL-htm.htm.
Cheers, Wendell
At 02:34 PM 1/10/2008, you wrote:Hi,
I have an RSS feed that I use to display articles on my website. I would like to randomly display one article at a time, but I want to be able to artificially weight the articles so that article 1 comes up %50 of the time, article 2 comes up 25% of the time, etc.
Is this something that XSL is capable of doing?
Please and thank you.
Brent Wilcox
____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Alice Wei MIS 2008 School of Library and Information Science Indiana University Bloomington ajwei@xxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Randomly displaying artic, Wendell Piez | Thread | Re: [xsl] Randomly displaying artic, Abel Braaksma |
Re: [xsl] Randomly displaying artic, Wendell Piez | Date | [xsl] XSL search, Lewis, Russell |
Month |