Hey i have the foolowing xml file :
<?xml version="1.0"?>
<accidents>
<accident>
<org>1</org>
<com>194</com>
<dep>010</dep>
<grav>0.64</grav>
</accident>
<accident>
<org>1</org>
<com>194</com>
<dep>420</dep>
<grav>0.54</grav>
</accident>
<accident>
<org>1</org>
<com>44</com>
<dep>010</dep>
<grav>0.4</grav>
</accident>
</accidents>
And i want to apply an xslt 1.0 to have the number of accidents by dep :
the out put should be like this :
dep 010 : 2 accidents ; dep 420 : 1 accidents
thanks ,note i use php so the saxon cant be used
This transformation:
when applied on the provided XML document:
produces the wanted, correct result:
Explanation:
Muenchian method for grouping.
Push style of XSLT processing.
Update: The OP doesn’t have available a true XSLT processor — his tool doesn’t implement
xsl:keyIn this case the following solution (note — this is much less efficient than Muenchian grouping) still solves the problem and produces the exact wanted output:
when applied on the same XML document (above), the same wanted, correct result is produced: