我試圖在同一個XML文檔中的兩個子元素之間進行排序的交集。比較一系列元素並通過XSLT/Xpath替換匹配
<links>
<old>
<xref linkend="zzzzz">/chapter/subchapter[1]/section[2]/@id</xref>
<xref linkend="aaaaa">/chapter/section[1]/@id</xref>
</old>
<new>
<xref linkend="xxxxx">/chapter/subchapter[1]/section[2]/@id</xref>
<xref linkend="sssss">/chapter/@id</xref>
</new>
</links>
每當有新的/外部參照老/外部參照的路徑字符串之間的匹配,我想加入的兩個元素,創造一個像這樣的輸出:
<matches>
<match old-linkend='zzzzz' new-linkend='xxxxx'>/chapter/subchapter[1]/section[2]/@id</match>
</matches>
這是我第一次嘗試比較序列,所以我有點迷路。我在撒克遜使用XSLT 2.0。
您可以在old/xref上做一個選擇匹配,然後使用xsl:if如/ new/xref [position()]。你可能必須去父母,這取決於你如何做你的匹配,即../新/外部參照[位置()]。 – 2015-02-23 17:28:35