我试图使用XSLT 2.0来总结每个Year/YearQtr的产品[Widgets]的所有单个销售人员[VOL],并按其销售部门进行分组。可能有多种产品类型,我只是将它留在了一种类型中,以试图简化代码。XSLT 2组和总和值
- 我已经成功地使用的,各领YearQtr值列表中某一年,但我不能工作,如何让显示为全年和YearQtr元素的不同列表SalesPerson/Performance的孩子。
- 我试过currentgroup(),但不能看到如何指定分组,以便我只能得到部门级别的总和,而不是每个SalesPerson。
我正在使用的XML是:
<salesteam id="Team1">
<department id="dept1">
<salespeople>
<salesperson id="98765">
<performance>
<year id="2013">
<yearqtr id="1">
<yearMonth id="1">
<products>
<widgets>
<vol>5</vol>
<val>50000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="2">
<products>
<widgets>
<vol>10</vol>
<val>100000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="3">
<products>
<widgets>
<vol>15</vol>
<val>150000</val>
</widgets>
</products>
</yearMonth>
</yearqtr>
<yearqtr id="2">
<yearMonth id="4">
<products>
<widgets>
<vol>20</vol>
<val>200000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="5">
<products>
<widgets>
<vol>25</vol>
<val>250000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="6">
<products>
<widgets>
<vol>30</vol>
<val>300000</val>
</widgets>
</products>
</yearMonth>
</yearqtr>
</year>
</performance>
</salesperson>
<salesperson id="12345">
<performance>
<year id="2013">
<yearqtr id="1">
<yearMonth id="1">
<products>
<widgets>
<vol>5</vol>
<val>50000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="2">
<products>
<widgets>
<vol>10</vol>
<val>100000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="3">
<products>
<widgets>
<vol>15</vol>
<val>150000</val>
</widgets>
</products>
</yearMonth>
</yearqtr>
<yearqtr id="2">
<yearMonth id="4">
<products>
<widgets>
<vol>20</vol>
<val>200000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="5">
<products>
<widgets>
<vol>25</vol>
<val>250000</val>
</widgets>
</products>
</yearMonth>
<yearMonth id="6">
<products>
<widgets>
<vol>30</vol>
<val>300000</val>
</widgets>
</products>
</yearMonth>
</yearqtr>
</year>
</performance>
</salesperson>
</salespeople>
</department>
</salesteam>
我想达到什么是
<table>
<tbody>
<tr>
<th>2013Q1</th>
<th>2013Q2</th>
<th>2013Q3</th>
<th>2013Q4</th>
</tr>
<tr>
<td>30</td>
<td>75</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>
我不太明白为什么你所有的'yearqtr'都有ID 1,其中一半是'Q2'。这是一个错误吗?您的示例输出也似乎并不能说明您想如何代表独立的销售人员。 – JLRishe 2013-03-17 12:57:04
嗨,是的。我刚刚复制粘贴的例子,对不起。我期望yearqtr = 1的yearmonth id为1,2或3 – leejkennedy 2013-03-17 13:17:47