XSLT - add <p> into text strings instead of \n

Etheships

New Member
I have an XML document like this:\[code\]<xml> <item> <title>Article 1</title> <text><![CDATA[Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec lorem diam, eleifend sed mollis id, condimentum in velit.Sed sit amet erat ac mauris adipiscing elementum. Pellentesque eget quam augue, id faucibus magna.Ut malesuada arcu eu elit sodales sodales. Morbi tristique porttitor tristique. Praesent eget vulputate dui. Cras ut tortor massa, at faucibus ligula.]]></text> </item></xml>\[/code\]Where there are empty lines between the "paragraphs".And I need to use XSLT transformation where the element will have each paragraph of text between < p > and < / p >. So my desired output would be like:\[code\]<h2>Article 1</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec lorem diam, eleifend sed mollis id, condimentum in velit.</p><p>Sed sit amet erat ac mauris adipiscing elementum. Pellentesque eget quam augue, id faucibus magna.</p><p>Ut malesuada arcu eu elit sodales sodales. Morbi tristique porttitor tristique. Praesent eget vulputate dui. Cras ut tortor massa, at faucibus ligula.</p>\[/code\]So far I have an XSLT which looks like this:\[code\]<xsl:template match="/"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Page title</title> </head> <body> <h1>Table of contents</h1> <ol> <xsl:for-each select="xml/item> <li><xsl:value-of select="./title"/></li> </xsl:for-each> </ol> <hr/> <xsl:for-each select="xml/item"> <h2><xsl:value-of select="./title"/></h2> <xsl:value-of select="./text" disable-output-escaping="yes"/> </xsl:for-each> </body> </html></xsl:template>\[/code\]Could anyone please help me how to deal with replacements of \n on the right places with paragraph HTML tags? I checked similar questions here, but I'm obviously not able to implement them to my problem. Thank you and have a nice day.
 
Back
Top