Get the following siblings with a limit

Here should go questions about transforming XML with XSLT and FOP.
sunnykeerthi
Posts: 3
Joined: Wed Oct 23, 2013 9:07 am

Get the following siblings with a limit

Post by sunnykeerthi »

Hi,

I'm want an XSLT that will extract the content following the h1 and before the next h1 or end of the document.

Here is my data.

Code: Select all

<div id="toc">
<h1>Head 1</h1>
<p>para text</p>
<div class="class1">div content</div>
<h1>Head 2</h1>
<p>para text</p>
  <span>span content</span>
<h1>Head 3</h1>
<p>para text</p>
</div>
when I try descendant::h1[1]/following::node() it retrieves everything. this works fine with descendant::h1[3]/following::node(), because there is no following h1 after h1[3]. Please let me know on how can I do it.
Radu
Posts: 9018
Joined: Fri Jul 09, 2004 5:18 pm

Re: Get the following siblings with a limit

Post by Radu »

Hi,

Maybe you can try something like this (descendant::h1[1]/following::*)[1]

By the way node() matches elements, text content, comments, processing instructions. This is why I used "*" which matches only elements.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply