I am having an xslt issue that I cannot seem to solve. Right now I have this template match: <xsl:template match="bodytext/p[position() = 4]">
And this works fine. When the 4th paragraph renders I include some content. The issue is that sometimes the <p> element can have a class class="exclude"
I am trying to find a good way to exclude the <p> tags that have that class attribute. The problem is that there can be as many <p class="exclude"> as wanted/needed before or at the 4th paragraph while still rendering the 1st, 2nd, and 3rd paragraphs that do not have “exclude” class. So if a document looks like:
<p></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p></p>
<p class="exclude"></p>
<p></p>
<p></p>
I only want to match the template:
<p></p>
<p></p>
<p></p>
<p></p>
Another example would be an input of:
<p></p>
<p></p>
<p></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p class="exclude"></p>
<p></p>
and output of:
<p></p>
<p></p>
<p></p>
<p></p>
Thanks in advance
You can do it like this:
Here’s the test case. Applying the following transformation:
To:
Produces: