W3C home > Mailing lists > Public > xproc-dev@w3.org > November 2010

Re: Random Number Generator

From: James Sulak <jsulak@gmail.com>
Date: Mon, 29 Nov 2010 19:57:42 -0600
Message-ID: <AANLkTimwdNV7-uTwW5TfwDTpi4U3-yoVD1bXY+7_hheo@mail.gmail.com>
To: Betty Harvey <harvey@eccnet.com>
Cc: Conal Christopher Tuohy <conal.tuohy@versi.edu.au>, XProc Dev <xproc-dev@w3.org>
Just to throw out a a couple of other ideas:

- you could use p:exec to call an arbitrary program that returns a
random number to stdout.
- you could use an exising webservice (maybe
http://www.random.org/clients/http/, but I can't vouch for it) or
write your own.  If you're doing a simple http get you can just use
p:document and not have to mess with p:http-request.

-James

On Mon, Nov 29, 2010 at 8:11 PM, Betty Harvey <harvey@eccnet.com> wrote:
> Thanks Conal!
>
> I will take a look at that feature.  I have approximately 5+ million
> records I want to process and the random number needs to be between 1 and
> 2874. The variable in the XSLT is working well but without XProc
> converting that many files is a challenge.
>
> I am using Calabash within Oxygen.
>
> I am ingesting them into MarkLogic and I am thinking about trying the
> MarkLogic ingest transformation but I think I might run into the same
> problem.
>
> Thanks!
>
> Betty
>
>> There's also the system property "p:episode".
>>
>> http://www.w3.org/TR/xproc/#f.system-property
>>
>> Quote:
>>  p:episode
>>
>>     Returns a string which should be unique for each
>>     invocation of the pipeline processor. In other
>>     words, if a processor is run several times in
>>     succession, or if several processors are running
>>     simultaneously, each invocation of each
>>     processor should get a distinct value from
>>     p:episode.
>>
>>     The unique identifier must be a valid XML name.
>>
>> So it's not a number, and it may not have a great pseudo-random
>> distribution, but maybe it could be a seed for a random number generator
>> in XSLT?
>>
>> Con
>>
>> -----Original Message-----
>> From: xproc-dev-request@w3.org on behalf of Betty Harvey
>> Sent: Tue 30/11/2010 7:38 AM
>> To: XProc Dev
>> Subject: Random Number Generator
>>
>> I have included the following variable in my XSLT for generating a
>> random number:
>>
>>   <xsl:variable name="seed">
>>             <xsl:value-of select="math:random() * 1000"
>>                 xmlns:math="java:java.lang.Math"/>
>>   </xsl:variable>
>>
>> This is working well in the XSLT and Saxon 9.  However, when I call the
>> XSLT from Calabash I get the following error:
>>
>> Description: XPath syntax error at char 14 on line 89 in {math:random() *
>> 1000}:
>>     Cannot find a matching 0-argument function named
>> {java:java.lang.Math}random()
>>
>> Are there any tricks of the trade in XProc to get a random number
>> generator
>> working in XSLT.
>>
>> TIA!
>>
>> Betty
>>
>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
>> Betty Harvey                         | Phone:  410-787-9200  FAX: 9830
>> Electronic Commerce Connection, Inc. |
>> harvey@eccnet.com                    | Washington,DC XML Users Grp
>> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
>> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
>> Member of XML Guild (www.xmlguild.org)
>>
>>
>>
>
>
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> Betty Harvey                         | Phone:  410-787-9200  FAX: 9830
> Electronic Commerce Connection, Inc. |
> harvey@eccnet.com                    | Washington,DC XML Users Grp
> URL:  http://www.eccnet.com          | http://www.eccnet.com/xmlug
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/
> Member of XML Guild (www.xmlguild.org)
>
>
Received on Tuesday, 30 November 2010 01:58:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 30 November 2010 01:58:47 GMT