xsl-list
[Top] [All Lists]

Re: [xsl] Randomly displaying articles from RSS feed

2008-01-10 13:09:32
Brent,

The only hard part of what you're describing is the "randomly" part.
XSLT by itself provides no random or pseudo-random number generation.
I am not exactly sure if you really meant displaying these articles randomly if you want articles appearing more often than the rest.

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

If you want to, say generate something like have certain articles print out more often than the others, for the function part, you can use

<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)))
"/>

</xsl:function>

to get what you might want to do. This preserves the minute, second and hour that you could customize into your <xsl:if> statements. You can actually then control the variables and have those that are certain numbers to do certain things.

* 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei(_at_)indiana(_dot_)edu


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>