嗨,要刪除XML重複的節點如何使用XSLT 1.0
請幫我從xml.Condition移除重複的節點,除去重複的節點是相當複雜的。
條件1:在根據policyKey節點的每個政策節點i必須檢查policyNbr和PolicyFormCode /代碼和policyEffectiveDt和策略ID 是在所有的策略節點相同的,如果它們是相同的,我有隻保留具有sourceSystemCd策略節點/代碼='SCBP'出現在它中。
條件2:如果在上述條件policyNbr和PolicyFormCode/code和policyEffectiveDt和policyID中有任何不同的值,我需要顯示所有的策略節點。
輸入XML: 條件1:
<?xml version="1.0" encoding="utf-8"?>
<policies>
<!-- policy 1-->
<policy>
<policyKey>
<policyNbr>4567</policyNbr>
<policyEffectiveDt>2014-11-14</policyEffectiveDt>
<policyFormCd>
<code>669</code>
</policyFormCd>
</policyKey>
<transactionSplitTrans>
<sourceSystemCd>
<code>ARA</code>
</sourceSystemCd>
</transactionSplitTrans>
</policy>
<!-- second -->
<policy>
<policyKey>
<policyNbr>1234</policyNbr>
<policyID>115774001</policyID>
<policyEffectiveDt>2014-11-11</policyEffectiveDt>
<policyFormCd>
<code>660</code>
</policyFormCd>
</policyKey>
<transactionSplitTrans>
<sourceSystemCd>
<code>ARAR</code>
</sourceSystemCd>
</transactionSplitTrans>
</policy>
<!-- third -->
<policy>
<policyKey>
<policyEffectiveDt>2014-11-14</policyEffectiveDt>
<policyFormCd>
<code>660</code>
</policyFormCd>
<policyID>115774001</policyID>
<policyNbr>1234</policyNbr>
</policyKey>
<transactionSplitTrans>
<sourceSystemCd>
<code>SCBP</code>
</sourceSystemCd>
</transactionSplitTrans>
</policy>
</policies>
Expexted輸出:
<policies>
<!-- policy 1-->
<policy>
<policyKey>
<policyNbr>4567</policyNbr>
<policyEffectiveDt>2014-11-14</policyEffectiveDt>
<policyFormCd>
<code>669</code>
</policyFormCd>
</policyKey>
<transactionSplitTrans>
<sourceSystemCd>
<code>ARA</code>
</sourceSystemCd>
</transactionSplitTrans>
</policy>
<!-- third -->
<policy>
<policyKey>
<policyEffectiveDt>2014-11-14</policyEffectiveDt>
<policyFormCd>
<code>660</code>
</policyFormCd>
<policyID>115774001</policyID>
<policyNbr>1234</policyNbr>
</policyKey>
<transactionSplitTrans>
<sourceSystemCd>
<code>SCBP</code>
</sourceSystemCd>
</transactionSplitTrans>
</policy>
</policies>
條件2:顯示所有三個policyNodes
所以,如果有沒有重複,你要保持一個沒有政策ID? – Mike 2014-12-03 05:43:13
您是否熟悉[Muenchian分組](http://www.jenitennison.com/xslt/grouping/muenchian.html)? – 2014-12-03 06:52:55