What is the expected result for the inline formula on a Repeating element?

I am trying to customize the way that the number of details in my schema is being determined. Instead of using a Repeating Element with a random number of instances between a minimum and maximum number of elements, I want to use a formula to set the number of details.

So far, I have not been able to create a formula that comes close. I either get errors or just a fixed text or number.

I tried

  • returning a number
  • returning an XML snippet
  • the syntax as shown on the help page right before the formula (both with quotes and without): details[3]

The end goal I am trying to achieve, is to get a random number of details with a severe bias to small numbers: so in most cases the result should be 1, 2 or 3, but higher numbers of details should also occur with decreasing probability. Something like 80% has 1, 2 or 3 details, 10% has between 4 and 25 details, 6% has between 25 and 500 details, 4% has between 500 and 10,000 details.

It would be great if I can at least get an explanation on what formula to use on the Repeating Element type.
Any additional pointers toward the end goal would be tremendous (especially if the Repeating Element formula is the wrong approach).

Thanks,
Manuel.

Too bad there is no answer to this.
The help really doesn’t seem to explain how to use the formula for a Repeating element.