XML: Check if anything exists between two nodes
- by sebastian
Hi there,
I need to find out if anything exists between two nodes. My XML looks like this:
<event value1="1" value2="2" value3="3"
       <info="some info here"/>
          Line 1.</lb>
          Line 2.</lb></lb>
          Line 3.</lb>
          Line 4.</lb>
</event>
My goal is to convert the </lb> nodes to </br> HTML tags using XSLT. There is one additional requirement to fulfill though. In case there is one </lb> directly following another </lb> I want to output only one </br>.
My XSLT looks like this:
 <xsl:template match="lb">
    <xsl:if test="not(preceding-sibling::lb[1])">
       <br/>
    </xsl:if>
 </xsl:template>
The problem with the XSLT above is that it works correctly for line 1 only as the text between both nodes is ignored. 
Maybe someone here can help.