Subject: [xsl] Re: Random? From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 29 Apr 2005 22:51:02 +1000 |
Hi Ali, On 4/29/05, Ali Choumane <ali.choumane@xxxxxxx> wrote: > Hi Dimitre, > > I am using the template "randNext" in random.xsl : > > ... > <sentence> > <xsl:attribute name="stamp"> > <xsl:call-template name="randNext"> > <xsl:with-param name="arg1" select="1"/> > </xsl:call-template> > </xsl:attribute> > <xsl:attribute name="state">nonDesamb</xsl:attribute> > <xsl:value-of select="concat($arg1/sentence[last()], $arg2)"/> > </sentence> > ... > > and this is a part of result of transformation: > ... > <sentence stamp="39022" state="nonDesamb">111 111 111</sentence> > <sentence stamp="39022" state="nonDesamb"> 222 222</sentence> > <sentence stamp="39022" state="nonDesamb"> 333 333 333</sentence> > <sentence stamp="39022" state="nonDesamb"> 444 444 444</sentence> > <sentence/> > <sentence stamp="39022" state="nonDesamb">555 555 555</sentence> > <sentence stamp="39022" state="nonDesamb"> 666 666 666</sentence> > <sentence stamp="39022" state="nonDesamb"> 777 777 777</sentence> > <sentence stamp="39022" state="nonDesamb"> 888 888 888, 999 999999</sentence> > ... > > As the result show, "stamp" it's not a key now. I think because "arg1" is > fixed. > > and I am using the template "randomSequence" in random.xsl, but it can't > resolve the problem. randomSequence produces a sequence of (the pLength parameter) N numbers. If the seed (the pSeed parameter) is the same on two invocations of randomSequence, the two produced sequences are, of course, the same. > I think , if I put a variable value of "arg1" , can resolve the problem? In order to achieve truly "random" results, the transformation has to use some non-fixed number, such as the seconds part of the current time -- and this can be passed as a parameter to the transformation by the external code that invokes it. Then this number can be used as a seed -- to be passed as the value of the pSeed parameter. > But how, when we can't change the value of variables in XSLT? We can't and actually we don't need to. Cheers, Dimitre novatchev.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Random?, Ali Choumane | Thread | [xsl] xsl:for-each...iteration ques, Paul Coletti |
RE: [xsl] removing a null namespace, Michael Kay | Date | Re: [xsl] order-by vs xsl:sort, David Carlisle |
Month |