I wanted to add <p> tag for every <li> elements, but there is a special situation when it is a nested list. If there is descendant <ol> tag, this adding <p> must be closed before this <ol> tag. Although it is happened, I could not be able to remove the <s>test tag</s><br/>part repetition.
Please help!
Input:
<a>
<ol>
<li>
<s>test tag</s><br/>
<ol>
<li>list item1</li>
<li>list item2</li>
<li>list item3</li>
</ol>
</li>
</ol>
</a>
Expected output:
<a>
<ol>
<li>
<p><s>test tag</s><br/></p>
<ol>
<p><li>list item1</li></p>
<p><li>list item1</li></p>
<p><li>list item1</li></p>
</ol>
</li>
</ol>
</a>
XSLT code:
<xsl:template match="ol">
<ol>
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="li[not(descendant::ol)]">
<li>
<p>
<xsl:apply-templates/>
</p>
</li>
</xsl:template>
<xsl:template match="li[descendant::ol]">
<li>
<p>
<xsl:apply-templates select="node()[parent::li][following-sibling::ol]"/>
</p>
</li>
<xsl:apply-templates select=""/>
</xsl:template>
<xsl:template match="node()[parent::li][following-sibling::ol]"/>
pas a child ofol. I'm not going to help you produce invalid HTML unless you explain why you want to do so.