Subject: Making nested elements from elements with level attributes
From: Russell Urquhart <russurquhart1@xxxxxxxxxxx>
Date: Tue, 21 Sep 2010 23:56:56 -0500
|
Hi,
I have section elements that level attributes like the following:
<section level=1>
<paragraph>Test line</paragraph>
</section>
<section level=2>
<paragraph>Test line</paragraph>
</section>
<section level=2>
<paragraph>Test line</paragraph>
</section>
<section level=3>
<paragraph>Test line</paragraph>
</section>
<section level=4>
<paragraph>Test line</paragraph>
</section>
<section level=5>
<paragraph>Test line</paragraph>
</section>
<section level=3>
<paragraph>Test line</paragraph>
</section>
I would like to transfrom that to something like:
<section>
<paragraph>Test Line</paragraph>
<section>
<paragraph>...</paragraph>
</section>
<section>
<paragraph/>
<section>
<paragraph/>
<section>
<paragraph/>
<section>
<paragraph/>
</section>
</section>
<section>
<paragraph/>
</section>
Is there an elegant algorithim to do this, or am i looking at a recursive routine with a named template?
Thanks,
Russ
</section>
|