Extract list and count of different values
Posted: Tue Feb 23, 2010 3:38 pm
I have data of the following form:
<a>
<b att="x"> ... </b>
<b att="c"> ... </b>
<b att="y"> ... </b>
<b att="z"> ... </b>
<b att="x"> ... </b>
<b att="x"> ... </b>
<b att="z"> ... </b>
<b att="c"> ... </b>
</a>
I want to generate a table based on this data in the following format, a list of all the values used for att paired with the number of b elements that have each att. The values for att are not restricted by the schema.
I can see how to do this when I know what the possible values of att are using count(descendant:b[att='c']) and so on. But I don't know how to dynamically build a list of each of the different att values used. As usual, I'm sure this is easy to do and I'm just not seeing the obvious solution. Any help will be appreciated.
<a>
<b att="x"> ... </b>
<b att="c"> ... </b>
<b att="y"> ... </b>
<b att="z"> ... </b>
<b att="x"> ... </b>
<b att="x"> ... </b>
<b att="z"> ... </b>
<b att="c"> ... </b>
</a>
I want to generate a table based on this data in the following format, a list of all the values used for att paired with the number of b elements that have each att. The values for att are not restricted by the schema.
Code: Select all
att number of elements
c 2
x 3
y 1
z 2