我有以下輸入XML這需要使用XSLTXSLT:基於名稱屬性刪除重複的節點
輸入XML被轉化:
<result>
<circuit>MX123456</circuit>
<psaresult>
<Live_Alarms>
<diagnosis>
<utr>xxx</utr>
<dtr>xxx</dtr>
<text />
<site>xxx</site>
<address />
<tech_type />
<end />
<network_type>xxx</network_type>
</diagnosis>
<Alarms>
<alarmId>463</alarmId>
<cct>xxx</cct>
<eventTime>12/05/11 09:21:21</eventTime>
<clearTime />
<problemCode>xxxx</problemCode>
<problemText>xxxx</problemText>
<equipmentName>xxx</equipmentName>
<unit>xxx</unit>
<rcKey>xxx</rcKey>
<category>xxx</category>
<rootCause>xxxx</rootCause>
</Alarms>
<Alarms>
<alarmId>464</alarmId>
<cct>xxx</cct>
<eventTime>12/05/11 09:21:22</eventTime>
<clearTime />
<problemCode>yyyy</problemCode>
<problemText>yyyy</problemText>
<equipmentName>yyyy</equipmentName>
<unit>yyyy</unit>
<rcKey>yyyy</rcKey>
<category>yyyy</category>
<rootCause>yyyy</rootCause>
</Alarms>
</Live_Alarms>
</psaresult>
</result>
預期輸出:
<result>
<circuit>MX123456</circuit>
<psaresult>
<Live_Alarms>
<psadiagnosis>
<utr>xxx</utr>
<dtr>xxx</dtr>
<text />
<site>xxx</site>
<address />
<tech_type />
<end />
<network_type>xxx</network_type>
</psadiagnosis>
<Alarms>
<alarmId>463</alarmId>
<cct>xxx</cct>
<eventTime>12/05/11 09:21:21</eventTime>
<clearTime />
<problemCode>xxxx</problemCode>
<problemText>xxxx</problemText>
<equipmentName>xxx</equipmentName>
<unit>xxx</unit>
<rcKey>xxx</rcKey>
<category>xxx</category>
<rootCause>xxxx</rootCause>
</Alarms>
</Live_Alarms>
</psaresult>
</result>
注意:Ony第一個節點需要像什麼SelectSinglenode
做的和所有其他需要被截斷fr輸出。你可以請建議如何從xslt實現這一點?
好問題,+1。請參閱我的回答,以獲取基於最基本且功能強大的XSLT設計模式的完整,簡短易用的解決方案 - 重寫身份規則。 –
也提供解釋和鏈接。 –