Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] RandomList.xsl from FXSL-xslt2

From: Dimitre Novatchev <dnovatchev@-----.--->
To: xsl-list@-----.------------.---
Date: 10/2/2009 5:11:00 PM
On Fri, Oct 2, 2009 at 9:20 AM, Jesper Tverskov
<jesper.tverskov@g...> wrote:
> Now, in my project I have around 300 items, and I need to pair each
> item with four of the other items randomly, and I will have to do that
> many times a day.
>
> I only need one seed, but I will have to make 300 transformations
> every time a need to get the items "paired", so XSLT looks like not
> being an option.


It is not necessary at all to "make 300 transformations". Just get a
random sequence in which every of the 300 items is reperesented
exactly once (if I remember well, you'll need the "random-index"
template for this). Then for every item in the sequence get it
together with the four that are its neighbors (for example the item
plus the two preceding and the two following -- with minor exceptions
for items that are at the ends of the sequence).



>
> So far I have used C# calling a shuffle routine again and again in
> other parts of the project, and I have a feeling that I will have to
> continue doing it that way. Turns out to be one of the few things
> being too nasty in XSLT in my particular use case.


As noted above, even the described C# processing seems to be
needlessly inefficient.


-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
I enjoy the massacre of ads. This sentence will slaughter ads without
a messy bloodbath.



>
> Cheers,
> Jesper
>
> --~------------------------------------------------------------------
> 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@l...>
> --~--
>
>

--~------------------------------------------------------------------
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@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent