some help wanted with grouping following siblings

Joined
Apr 9, 2011
Messages
1
Reaction score
0
Hi there,

I'm trying to convert an initial flat XML to a nested XML but got stuck on the final bits and pieces. I now have the following XML code :

<li><dl><dt>blabla</dt></dl></li>
<dd>blablabla</dd>
<dt>blablabla</dt>
.. much more <dd> and <dt> elements

<li><dl><dt>blabla2</dt></dl></li>
<dd>blablabla2</dd>
<dt>blablabla2</dt>
.. much more <dd> and <dt> elements
<p>some other element</>

And I would like to achieve the following

...
<li>
<dl>
<dt>blabla</dt>
<dd>blablabla</dd>
<dt>blablabla</dt>
.. much more <dd> and <dt> elements
</dl>
</li>
<li>
<dl>
<dt>blabla2</dt>
<dd>blablabla2</dd>
<dt>blablabla2</dt>
.. much more <dd> and <dt> elements
</dl>
</li>
<p>some other element</p>

Or in other words : Whenever I have a List element that contains a <dl> element I want to insert all the following <dt> and <dd> elements following on the <li> element up until the first element that's neither <dt> or <dd>

Anyone that could put me on the right track ? I'm using xslt 2.0 so I assume I need to use some combination of grouping and following sibling, but it's a bit too complex for me to comprehend. Thanks in advance !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top