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

Re: Re: Random?

Subject: Re: Re: Random?
From: Ali Choumane <ali.choumane@xxxxxxx>
Date: Mon, 2 May 2005 15:42:15 +0200
xslt random id
with generate-id() , I have the same "id" at witch call,
The use of generate-id() is here :
...
<sentence>
  <xsl:attribute name="stamp">
      <xsl:value-of select="generate-id()"/>
  </xsl:attribute>
  <xsl:attribute name="state">nonDesamb</xsl:attribute>
  <xsl:value-of select="concat($arg1/sentence[last()], $arg2)"/>
</sentence>
...

the result is:
...
  <sentence stamp="id108131" state="nonDesamb">111 111 111</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 222 222</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 333 333 333</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 444 444 444</sentence>
  <sentence stamp="id108131" state="nonDesamb">555 555 555</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 666 666 666</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 777 777 777</sentence>
  <sentence stamp="id108131" state="nonDesamb"> 888 888 888, 999 999</sentence>
...

I have 8 call to generate-id() (8 sentences) witch are equal.
you think I am doing an error?
I will try the last solution gave me Dimitre. 

Thanks for your help.
 

Quoting Ramkumar Menon <ramkumar.menon@xxxxxxxxx>:

> Not sure if I got your question right - but yes, generate-id() is a
> valid  XSLT 2.0 Function. if you pass in a node to it, it generates an
> id unique for that node.
> so it you pass generate-id(<a sentence node>), it wd generate a unique
> id for each "sentence" node.
> 
> On 5/2/05, Ali Choumane <ali.choumane@xxxxxxx> wrote:
> > 
> > If we can use a function like generate-id()...  that solve my problem.
> because
> > that we are trying to do with Dimitre has as goal to generate unique
> values
> > for the value of stamp,... but manualy...
> > a function as generate-id() exist ??
> > 
> > 
> > Quoting Ramkumar Menon <ramkumar.menon@xxxxxxxxx>:
> > 
> > > I had a question on this. Can't we use a function like generate-id()
> > > on each "sentence" node in the target to generate unique values for
> > > the value of stamp ?
> > > Just curious....
> > >
> > > rgds,
> > > Menon
> > >
> > > On 5/2/05, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> > > > Hi Ali,
> > > >
> > > > On 5/2/05, Ali Choumane <ali.choumane@xxxxxxx> wrote:
> > > > > Hi Dimitre,
> > > > > first, thanks for your help,
> > > > > second,
> > > > > I am using the seconds part of the current time -- as the value of
> the
> > > pSeed
> > > > > parameter (by using the library  of exslt).
> > > > >
> > > > > But the problem is : I am calling the function randomSequence
> several
> > > times
> > > > > per second ,so I have the same value of the parameter pSeed to the
> > > > > randomSequence.
> > > > >
> > > > > I want to use the third part of the current time (milliseconds) ???
> its
> > > > > possible?? I can't find anything!
> > > >
> > > > It seems that you are generating a lot of sequences of random numbers
> > > > -- with what length?
> > > >
> > > > I would suggest two ways around the problem:
> > > >
> > > >   1. Generate only one (but sufficiently long) sequence of randoms,
> > > > then use its subsequences as needed.
> > > >
> > > >   2. In case you'd need N sequences of random numbers, then generate
> > > > a sequence of N random numbers and use these as the seeds to generate
> > > > the corresponding N sequences.
> > > >
> > > > Cheers,
> > > > Dimitre Novatchev.
> > > >
> > > > >
> > > > >
> > > > > Quoting Dimitre Novatchev <dnovatchev@xxxxxxxxx>:
> > > > >
> > > > > > 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.
> > > > > >
> > > > >
> > > > > Ali CHOUMANE
> > > > > M2R III ,Univ Joseph fourrier, UFR IMA
> > > > > WAM/INRIA & GETA/CLIPS
> > > > > portable.      06 71 55 80 65
> > > > > Bureau(INRIA). 04 76 61 54 13
> > > > > Email. ali.choumane@xxxxxxx
> > > > >
> > > > > -------------------------------------------------
> > > > > envoyi via Webmail/IMAG !
> > > >
> > > >
> > >
> > >
> > > --
> > > Shift to the left, shift to the right!
> > > Pop up, push down, byte, byte, byte!
> > >
> > > -Ramkumar Menon
> > >  A typical Macroprocessor
> > >
> > >
> > 
> > Ali CHOUMANE
> > M2R III ,Univ Joseph fourrier, UFR IMA
> > WAM/INRIA & GETA/CLIPS
> > portable.      06 71 55 80 65
> > Bureau(INRIA). 04 76 61 54 13
> > Email. ali.choumane@xxxxxxx
> > 
> > -------------------------------------------------
> > envoyi via Webmail/IMAG !
> > 
> > 
> 
> 
> -- 
> Shift to the left, shift to the right!
> Pop up, push down, byte, byte, byte!
> 
> -Ramkumar Menon
>  A typical Macroprocessor
> 
> 


Ali CHOUMANE
M2R III ,Univ Joseph fourrier, UFR IMA
WAM/INRIA & GETA/CLIPS
portable.      06 71 55 80 65
Bureau(INRIA). 04 76 61 54 13 
Email. ali.choumane@xxxxxxx

-------------------------------------------------
envoyi via Webmail/IMAG !

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.