I have a question that caused me a terrible headache. Please help me. The input is:
<body>
<p class="section"> section 1 </p>
<p class="code"> some code </p>
<p class="code"> following code </p>
<p class="code"> following code </p>
<p class="section"> section 2 </p>
<p class="code"> other code </p>
<p class="code"> following code </p>
<p class="code"> following code </p>
<p class="section"> section 3 </p>
<p class="code"> still other code </p>
<p class="code"> following </p>
<p class="code"> following </p>
</body>
The output I'd like:
<body>
<p class="section"> section 1 </p>
<pre> some code following code following code </pre>
<p class="section"> section 2 </p>
<pre> other code following code following code </pre>
<p class="section"> section 3 </p>
<pre> still other code following following </pre>
</body>
The problem is to collapse to a <pre>
tag all adjacent <p class="code">
tags. Don't find a way to do this using XSLT. Do you think a solution exists?
You don't need to rebuild your XML, take a look here: XSLT Grouping Siblings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With