如何将值与 XSLT 中的其他节点值进行比较并输出唯一值

How to compare the values with other nodes values in XSLT and output the unique values

我有以下 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>

从您的示例来看,如果第一个节点的结束日期与第二个节点的开始日期相同,您实际上是在尝试合并相邻节点。据推测,一个组中可以有两个以上的这样的节点。

如果这是正确的解释,我会使用

<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>
  

但是您没有很清楚地说明您的要求,所以这可能是一个疯狂的猜测。