[xsl] Converting siblings into children

Subject: [xsl] Converting siblings into children
From: "Woods, Christopher" <cwoods@xxxxxxxxxxxxxxxxx>
Date: Fri, 4 Nov 2005 15:48:43 -0500
I have a number of html files that I converted to xml using python.
Problem is that all the <p> tags are siblings.

Given this:

<?xml version="1.0"?>
<html>
<body>
<p><a name="one"><b>1.1.1</b></a></p>
<p>1.1.1.1 </p>
<p>1.1.1.2 </p>
<p>1.1.1.3 </p>
<p>1.1.1.4 </p>
<p><a name="two"><b>1.1.2</b></a></p>
<p>1.1.2.1  </p>
<p>1.1.2.2 </p>
<p>1.1.2.3 </p>
<p>1.1.2.4 </p>
<p>1.1.2.5 </p>
<p>1.1.2.6 </p>
<p>1.1.2.7 </p>
<p>1.1.2.8 </p>
<p><a name="three"><b>1.1.3</b></a></p>
<p>1.1.3.1 </p>
<p>1.1.3.2 </p>
<p>1.1.3.3 </p>
<p>1.1.3.4 </p>
<p>1.1.3.5 </p>
<p>1.1.3.6 </p>
</body>
</html>

I need an output like this:

<p>
<a name="one"><b>1.1.1</b></a>
<p>1.1.1.1 </p>
<p>1.1.1.2 </p>
<p>1.1.1.3 </p>
<p>1.1.1.4 </p>
</p>

<p>
<a name="two"><b>1.1.2</b></a>
<p>1.1.2.1  </p>
<p>1.1.2.2 </p>
<p>1.1.2.3 </p>
<p>1.1.2.4 </p>
<p>1.1.2.5 </p>
<p>1.1.2.6 </p>
<p>1.1.2.7 </p>
<p>1.1.2.8 </p>
</p>

<p>
<a name="three"><b>1.1.3</b></a>
<p>1.1.3.1 </p>
<p>1.1.3.2 </p>
<p>1.1.3.3 </p>
<p>1.1.3.4 </p>
<p>1.1.3.5 </p>
<p>1.1.3.6 </p>
</p>

Any ideas?  Thanks in advance.

Current Thread