matching a dynamic xslt template

xcaliburcr

New Member
OK so I have an xslt issue that I cannot seem to solve. This is my second attempt at asking the question please do not mark as duplicate.My issue is that I would like to include some HTML after the fourth \[code\]<p>\[/code\] tag in my document. The issue is that there can be \[code\]<p>\[/code\] tags with the attribute \[code\]class="exclude"\[/code\]If the \[code\]<p>\[/code\] tag has that class, I would like to not render that paragraph. At the same time, I would still like to render my included html after the 4th paragraph, regardless of the number of \[code\]<p class="excludes"\[/code\] there are EDIT::Here is the xsl I had previously. This would slot my included html into the 4th paragraph.\[code\]<xsl:template match="content/p[position() = 4]"> content include<xsl:apply-templates /></p></xsl:template> \[/code\]Here are some example inputs / outputsFirst is the base example where there are no \[code\]<p class="excludes">\[/code\] My input is:\[code\]<body><p></p><p></p><p></p><p></p>include new HTML here<p></p>...</body>\[/code\]In that example, the html renders nicely after the 4th paragraph after passing through my xslt. However, I need to take into account \[code\]<p class="exclude">\[/code\]Here is a more complicated example with \[code\]<p class="exclude" being used >\[/code\]\[code\]<body><p class="exclude"></p> (should not be rendering on page)<p></p><p></p><p></p><p></p>include new HTML here<p></p>...</body>\[/code\]Notice that in this example, the included HTML is appearing after the 5th* paragraph because the first paragraph should not be rendering on the page, but at the same time I want the rendered HTML to be included after the 4th rendered paragraph. Lets look at one more example that is more complicated.\[code\]<body><p class="exclude"></p> (this should not be rendering on page)<p></p><p class="exclude"></p> (this should not be rendering on page)<p class="exclude"></p> ...<p></p><p class="exclude"></p> ...<p></p><p class="exclude"></p> ...<p class="exclude"></p> ...<p class="exclude"></p> ...<p></p>new HTML include here<p></p>...<body><p class="exclude"></p>\[/code\]Now, in my final example you can see that multiple \[code\]<p class="excludes"\[/code\] have been added and yes i still want the new html content to render after the 4th rendered paragraph, or in this example the 11th total over all paragraph. If anyone has any xslt that could help me achieve this that would be great. Please keep in mind I am using xslt 1.0 Thanks in advance
 
Back
Top