2014-09-11 30 views
0

如何找到直接位於「specialElem」-element(本例中爲「Foo-」)前面的文本節點?當「主」元素內的所有其他空格都應保留時,「特殊元素」元素前面的空格將被刪除。XSLT在混合內容元素中查找前面的文本節點

<main> 
    Foo Foo 
    <someElem> 
    Foo Foo 
    </someElem> 
    Foo Foo 
    <otherElem> 
     <subElem> 
      Foo Foo 
     </subElem> 
    </otherElem> 
    Foo-  <!-- the whitespaces here shall be removed --> 
    <specialElem> 
     Bar! 
    <specialElem/> 
    Foo Foo 
</main> 

所需的輸出:

富富富富富富富富富酒吧! Foo Foo

Thnaks提前!

+0

你能給我們一個真實的例子,你需要什麼?這似乎有點奇怪的要求。 – JLRishe 2014-09-11 13:29:09

回答

0

如果關閉正確的<specialElem>標籤和刪除註釋,則:

/main/text()[following-sibling::node()[1][self::specialElem]] 

將選擇請求的文本節點/秒。

-
不太確定您輸入的格式是什麼。

+0

謝謝!這似乎工作。你能用正常的語言解釋選擇器表達嗎? – Schinski 2014-09-11 13:36:47

+0

@Schinski選擇文本節點/ s('main'的子節點),其緊接的兄弟節點是'specialElem'元素。 – 2014-09-11 13:38:34

相關問題