Random photo
Loading...
Domains for sale
|
March 2, 2004EXSLT Random module for EXSLT.NETI'm going to implement EXSLT Random module for EXSLT.NET lib. It contains the only extension function: The problem is that .NET's Random class accepts seed as int, while in XPath numbers are double. So simple (I hope) question: how do you think it should be converted? March 2, 2004 5:46 PM
| #XML in .NET
Comments
The name doesn't matter -- may be rand may be num, ... or whatever. I will access the individual elements with "*". Posted by: Dimitre Novatchev at March 3, 2004 11:27 PMOk, then what elemnt name you suggest? > Sorry, Dimitre, I don't get (uint) Oopps.., I thought the seed was also restricted to the [0,1] interval. If not, then you must implement the reverse scaling -- from all possible double values to all possible int values. One way to do this (not scaling, but an operation, which largely preserves the randomness of the seeds) is to find the remainder of dividing the double by the maximum possible int like e.g.: double d = 1234567890123E0;
> So, what do you think we should return - text It actually doesn't matter, as long as the Anyway, a text node does not exist by itself -- it must have a parent. So you'd be returning text nodes, which belong to a new temporary tree -- you'd have also created the parents of these text nodes. AFAIK the XML Infoset conbines any two adjacent text nodes into a single text node, therefore to avoid this they either will have to have different parents, or be part of mixed content... It is largely a matter of taste. I'd personally prefer to return element nodes, whose only text node child is one of the generated randoms. This would be convenient in a subsequent xsl:copy-of operation. Cheers, Sorry, Dimitre, I don't get (uint)(4294967295*x) example, could you elaborate it? I've read that in exslt mail list archive. Another comment: When we were specifying the signature of the method, we were all deeply into using XSLT 2.0/XPath 2.0. This is why we didn't notice that there is no sequence data types in XPath 1.0. I noticed this later and proposed to the EXSLT-list that the return type must be changed to node* (actually this must be element* ). This was accepted, however it seems that the web page, which also acts as the spec, has not been updated.
Try something like this example: uint i; When you get the random number, you must performe the reverse conversion. Cheers, Dimitre Novatchev, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL Post a comment
|