我試圖使用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