My source xml:
Code:
<root>
<emp>
<level>1</level>
<salary>20000</salary>
</emp>
<emp>
<level>1</level>
<salary>16000</salary>
</emp>
<emp>
<level>1</level>
<salary>19000</salary>
</emp>
<emp>
<level>1</level>
<salary>17000</salary>
</emp>
<emp>
<level>1</level>
<salary>18000</salary>
</emp>
<emp>
<level>1</level>
<salary>19000</salary>
</emp>
<emp>
<level>1</level>
<salary>16000</salary>
</emp>
<emp>
<level>1</level>
<salary>15000</salary>
</emp>
<emp>
<level>1</level>
<salary>14000</salary>
</emp>
<emp>
<level>1</level>
<salary>13000</salary>
</emp>
</root>
I need to produce a table showing which quartile an employee belongs to:
Level Salary Quartile
1 20000 1
1 19000 1
1 19000 1
1 18000 2
1 17000 2
1 16000 3
1 16000 3
1 15000 3
1 14000 4
1 13000 4
The table has to be ordered by Level ascending, Salary descending and then each item ranked into a quartile. From the example, we take all the employees with Level=1, take the distinct Salary (20,19,18,17,16,15,14 and 13000) and assign a quartile to which the employee falls in. 20 and 19 fall into the first quartile so all the employees with a salary of 20 or 19 (3 items) are given the quartile 1.
this is my xslt so far. I can get as far as the order but have no idea how to give rating for quartiles.... any help would be greatly appreciated. my xslt so far:
Code:
<xsl:key name="levels" match="emp" use="level"/>
<xsl:template name="InsertTable">
<xsl:for-each select="//emp[generate-id() = generate-id(key('levels', level)[1])]">
<xsl:sort select="level" data-type="number"/>
<xsl:for-each select="key('levels', level)">
<xsl:sort select="salary" data-type="number" order="descending"/>
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:for-each>
</Table>
</xsl:template>
<xsl:template match="emp">
</xsl:template>