I’m having an issue with my transform and was hoping for some ideas, I’m dealing with a really flat input document where all important nodes are siblings of one another.
It kind of looks like this:
<title1> Rule 51 </title1>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>
<title1> Rule 52 </title1>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>
My goal is for this input to look like this:
<section>
<title1> Rule 51 </title1>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>
</section>
<section>
<title1> Rule 52 </title1>
<p> text here </p>
<p> text here </p>
<p> text here </p>
<p> text here </p>
<note> Source </note>
<p> text here </p>
</section>
As you can see above my main goal is grouping each title1 and all of it’s following siblings until it hits another title1 into a section element. Any ideas??
Thanks in advance.
Try
in XSLT 2.0.
If you can only use XSLT 1.0, look up Muenchian Grouping, and holler if you need help.