簡體   English   中英

獲取XSLT中符合條件的先前同級

[英]Get preceding sibling that attends condition in XSLT

我有一個包含以下數據的XML文件作為示例:

<file name="path\to\file1\">
</file>
<file name="path\to\file2\">
<error line="10" message="This file has an error"/>
</file>
<file name="path\to\file3\">
</file>
<file name="path\to\file4\">
<error line="15" message="This file has an error too"/>
</file>

現在,假設我在“ file4”節點上。 我想獲得前面的第一個具有錯誤行的同級文件,在這種情況下為“ file2”,但是在真正的XML中,我將不知道其位置。

我可以使用上preceding-sibling軸進行此檢查嗎?

提前致謝。

我想獲得前面的第一個具有錯誤行的兄弟

我不確定在這種情況下確切的“ get”是什么意思,但是您當然可以使用以下命令選擇前面的第一個具有錯誤行的同級文件:

select="preceding-sibling::file[error][1]"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM