[Home] [By Thread] [By Date] [Recent Entries]
On 30.10.2018 17:46, kevinbrianbird@xxxxxxxxx wrote:
I have tables with arbitrary columns and each cell can have an arbitrary number of paragraphs. I want to split rows on paragraphs, so each row only contains one <p> element. Assuming at least XSLT 2 and that the "td" elements only "p" elements I think you can simply process each "tr" element 1 to max(td/count(p)) times with e.g. <xsl:template match="tr">
<xsl:variable name="this-row" select="."/>
<xsl:for-each select="1 to max(td/count(p))">
<tr>
<xsl:apply-templates select="$this-row/*">
<xsl:with-param name="pos" select="."/>
</xsl:apply-templates>
</tr>
</xsl:for-each>
</xsl:template> <xsl:template match="td">
<xsl:param name="pos"/>
<xsl:copy>
<xsl:apply-templates select="p[$pos]"/>
</xsl:copy>
</xsl:template>Online sample using XSLT 3 (but only for setting up the identity transformation with xsl:mode) is at https://xsltfiddle.liberty-development.net/6qVRKx7.
|

Cart



