How does one select the first sibling of a xml node with all its child nodes and apply some transformations on it? So far I only succeeded in selected either the first sibling and only the first sibling (no child nodes that is) or everything following the xml node.
Say we have xhtml like this:
<div class="chapter">Chapter <span class="number">1.1</span> Lorum ipsum</div>
<h2 class="article">Article <span class="number">1.</span> Lorum ipsum</h2>
<p>Lorum ipsum</p>
And the result we are after is xml like this:
<chapter>
<heading>
<label>Chapter</chapter>
<number>1.1</number>
<title>Lorum ipsum</title>
</heading>
<article>
<heading>
<label>Article</chapter>
<number>1.</number>
<title>Lorum ipsum</title>
</heading>
<par>Lorum ipsum</par>
</article>
</chapter>
My guess is that I need to do some regex magic to get the label and title tags right, but if this could also been done using plain xslt that would be great.