我是Stack Overflow和XSLT的新手。基於某些子元素條件,從輸出中刪除重複條目時遇到問題。刪除基於子元素的元素XSLT
這裏是XML的一個例子,我有:
<partyorders>
<order>
<day>12</day>
<month>05</month>
<year>2000</year>
<amount>5000.00</amount>
<decision>pending</decision>
</order>
<order>
<day>19</day>
<month>04</month>
<year>2000</year>
<amount>2000.00</amount>
<decision>pending</decision>
</order>
<order>
<day>19</day>
<month>04</month>
<year>2000</year>
<amount>2000.00</amount>
<decision>reserved</decision>
</order>
<order>
<day>05</day>
<month>04</month>
<year>2000</year>
<amount>1000.00</amount>
<decision>pending</decision>
</order>
<order>
<day>05</day>
<month>04</month>
<year>2000</year>
<amount>1000.00</amount>
<decision>reserved</decision>
</order>
<order>
....
</order>
</partyorders>
....
代表相同的多個訂單如上
我需要輸出爲:
- 只有一個訂單具有待決/批准狀態。
- 如果有兩個訂單僅在狀態不同,我想僅通過比較元素
<day>
,<month>
,<year>
確認後顯示保留的順序,<amount>
我想根據<day>
以下輸出,<month>
, <year>
,<amount>
和<decision>
標籤:
<restrntpartyorders>
<restrntorder>
<partyday>12</partyday>
<partymonth>05</partymonth>
<partyyear>2000</partyyear>
<partyamount>5000.00</partyamount>
<partydecision>pending</partydecision>
</restrntorder>
<restrntorder>
<partyday>19</partyday>
<partymonth>04</partymonth>
<partyyear>2000</partyyear>
<partyamount>2000.00</partyamount>
<partydecision>reserved</partydecision>
</restrntorder>
<restrntorder>
<partyday>05</partyday>
<partymonth>04</partymonth>
<partyyear>2000</partyyear>
<partyamount>1000.00</partyamount>
<partydecision>reserved</partydecision>
</restrntorder>
<restrntorder>
....
</restrntorder>
</restrntpartyorders>
有人能幫助我在獲得使用XSLT 1.0解決?
謝謝Tomalak。我有問題1.如果我想過濾拒絕狀態的訂單,該怎麼辦? 2.如果我需要定製outpout..ie,輸出元素可以是 而不是 和而不是 。請幫忙 –
angi
2009-12-16 20:51:12