我有以下 xml 檔案。如果結束日期是另一個節點的開始日期,我需要洗掉每個節點的結束日期。
<time_Off_Event_group>
<StartDate>20211206</StartDate>
<EndDate>20211207</EndDate>
</time_Off_Event_group>
<time_Off_Event_group>
<StartDate>20211209</StartDate>
<EndDate>20211210</EndDate>
</time_Off_Event_group>
<time_Off_Event_group>
<StartDate>20211210</StartDate>
<EndDate>20211211</EndDate>
</time_Off_Event_group>
期望的xml資訊應該是這樣的。這可以做到xlst嗎?
<time_Off_Event_group>
<StartDate>20211206</StartDate>
<EndDate>20211207</EndDate>
</time_Off_Event_group>
<time_Off_Event_group>
<StartDate>20211209</StartDate>
<EndDate>20211211</EndDate>
</time_Off_Event_group>
uj5u.com熱心網友回復:
從您的示例來看,如果第一個節點的結束日期與第二個節點的開始日期相同,則您實際上是在嘗試合并相鄰節點。據推測,一個組中可以有兩個以上這樣的節點。
如果這是一個正確的解釋,我會使用
<xsl:for-each-group select="time_Off_Event_group"
group-starting-with="*[not(StartDate = preceding-sibling::*[1]/EndDate)]">
<time_Off_Event_group>
<StartDate>
<xsl:value-of select="current-group()[1]/StartDate"/>
</StartDate>
<EndDate>
<xsl:value-of select="current-group()[last()]/EndDate"/>
</EndDate>
</time_Off_Event_group>
</xsl:for-each-group>
但是您還沒有非常清楚地說明您的要求,所以這可能是一個瘋狂的猜測。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/401047.html
