I work with XQuery to do statistics. I have one document like this :
<tr>
<td>Element 1</td>
<td>100</td>
</tr>
<tr>
<td>Element 2</td>
<td>80</td>
</tr>
<tr>
<td>Element 3</td>
<td>40</td>
</tr>
<tr>
<td>Element 4</td>
<td>12</td>
</tr>
<tr>
<td>Element 5</td>
<td>8</td>
</tr>
And want to retrieve only a part of this document : I want to have only 80% of the sum of the number of element (The Pareto distribution in fact).
In this case, I have a total of 240 elements. I want in my output the first elements so that the total of the elements is 192 (240*80/100).
In this example, the ideal output would have only the first three elements, like this :
<tr>
<td>Element 1</td>
<td>100</td>
</tr>
<tr>
<td>Element 2</td>
<td>80</td>
</tr>
<tr>
<td>Element 3</td>
<td>40</td>
</tr>
I hope I’m clear :s. I am looking for long time, without success, I don’t find how to do…
Thank so much
Use:
When this XPath expression (yes this is an XQuery expression that is also an XPath 2.0 expression) is evaluated against the provided XML (wrapped into a single tope element to be made a well-formed XML document):
the wanted, correct result is produced: