martinanton
martinanton

Reputation: 217

Compare text and nodes after a certain node

I try to figure out how to address a certain part of a closer-statement of a letter. In this xml-file

 <?xml version="1.0" encoding="UTF-8"?>
<a>
    <closer>regards<lb/><signed>William</signed></closer>
    <closer>until next tuesday<lb/>regards<lb/><signed>William</signed></closer>
    <closer>until next tuesday<lb/>regards <signed>William</signed></closer>
</a>

I am positioned at the last linebreak (lb) and want to know whether there is more text following than just the signature. I fruitlessly tried things like

//substring-after(parent::closer, lb[last()]) = signed

But it did not work. How do I properly test for that?

Upvotes: 0

Views: 31

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167571

You can use following-sibling::node()[not(self::signed)] to select any nodes following the context node (which you say is an lb element) that are not signed elements. In a boolean context like <xsl:if test="following-sibling::node()[not(self::signed)]"> that would then evaluate to true only if such a node exists.

Upvotes: 1

Related Questions