我完全卡住了。我正在嘗試使用XLST來查找/替換我的xml輸出文件的部分內容。我甚至沒有出發點。我試過使用Altova DiffDog來自動生成我的xlst,因爲我沒有牢牢掌握如何自己編寫它。需要幫助刪除文本並通過XLST替換xlm
這是我目前的XML輸出文件:
<?xml version='1.0' encoding='UTF-8'?>
<BB:Report_Data xmlns:BB="urn:com.playdate.report/Report-Outbound">
<BB:Report_Entry>
<BB:leaveBalanceTotal.employeeId>1234567</BB:leaveBalanceTotal.employeeId>
<BB:leaveBalanceTotal.bmbId>9280136270</BB:leaveBalanceTotal.bmbId>
<BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:leaveBalanceTotal.leaveCodeId>1010</BB:leaveBalanceTotal.leaveCodeId>
<BB:leaveBalanceTotal.balanceAmount>0</BB:leaveBalanceTotal.balanceAmount>
<BB:leaveBalanceTotal.effectiveDate>2012-07-05</BB:leaveBalanceTotal.effectiveDate>
<BB:leaveBalanceTotal.lastPayEndDate>2012-07-05</BB:leaveBalanceTotal.lastPayEndDate>
</BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:leaveBalanceTotal.leaveCodeId>1014</BB:leaveBalanceTotal.leaveCodeId>
<BB:leaveBalanceTotal.balanceAmount>96</BB:leaveBalanceTotal.balanceAmount>
<BB:leaveBalanceTotal.effectiveDate>2012-07-05</BB:leaveBalanceTotal.effectiveDate>
<BB:leaveBalanceTotal.lastPayEndDate>2012-07-05</BB:leaveBalanceTotal.lastPayEndDate>
</BB:All_Eligible_Time_Off_Plans_for_Worker>
<BB:leaveBalanceTotal.totalDaysService>1459</BB:leaveBalanceTotal.totalDaysService>
</BB:Report_Entry>
</BB:Report_Data>
這是我需要它看起來像:
<?xml version='1.0' encoding='UTF-8'?>
<BB:Report_Data xmlns:BB="urn:com.playdate.report/Report-Outbound">
<leaveBalanceTotal>
<leaveBalanceTotal.employeeId>1234567</leaveBalanceTotal.employeeId>
<leaveBalanceTotal.bmbId>9280136270</leaveBalanceTotal.bmbId>
<leaveBalanceTotal.leaveCodeId>1010</leaveBalanceTotal.leaveCodeId>
<leaveBalanceTotal.balanceAmount>0</leaveBalanceTotal.balanceAmount>
<leaveBalanceTotal.effectiveDate>2012-07-05</leaveBalanceTotal.effectiveDate>
<leaveBalanceTotal.lastPayEndDate>2012-07-05</leaveBalanceTotal.lastPayEndDate>
<leaveBalanceTotal.leaveCodeId>1014</leaveBalanceTotal.leaveCodeId>
<leaveBalanceTotal.balanceAmount>96</leaveBalanceTotal.balanceAmount>
<leaveBalanceTotal.effectiveDate>2012-07-05</leaveBalanceTotal.effectiveDate>
<leaveBalanceTotal.lastPayEndDate>2012-07-05</leaveBalanceTotal.lastPayEndDate>
<leaveBalanceTotal.totalDaysService>1459</leaveBalanceTotal.totalDaysService>
</leaveBalanceTotal>
</BB:Report_Data>
基本上我試圖刪除以下的所有實例:
- BB:All_Eligible_Time_Off_Plans_for_Worker
- /BB:All_Eligible_Time_Off_Plans_for_Worker
- BB:
而且我需要leaveBalanceTotal更換Report_Entry。
任何幫助,將不勝感激!
您的第一個模板下的xsl:apply-templates是毫無意義的浪費。這些節點類型永遠不會有子節點。 – 2012-07-13 18:13:10
非常感謝!它像一個魅力!我非常感謝你的時間。 – 2012-07-13 18:38:36
@ LC_123 - 非常歡迎。 – 2012-07-13 18:41:54