Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is a coding for newline based on space but i need wherever newline is necessary...

xml:

XML
<item>
    <id>1</id>
    <title>Resume</title>
    <desc>A summary of your objectives,educational qualification,experience,skills relevant to the field of work you are going to enter.Here you can detail down each.It highlights your accomplishments to show a potential employer that you are qualified for the work you want.Remember it is not a biography of everything you have done.Its core PURPOSE is to get you an interview.</desc>
</item>



XSLT:
XML
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="t">
  <p>
    <xsl:apply-templates/>
  </p>
 </xsl:template>

 <xsl:template match="text()" name="insertBreaks">
   <xsl:param name="pText" select="."/>

   <xsl:choose>
     <xsl:when test="not(contains($pText, '&#xA;'))">
       <xsl:copy-of select="$pText"/>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="substring-before($pText, '&#xA;')"/>
       <br />
       <xsl:call-template name="insertBreaks">
         <xsl:with-param name="pText" select=
           "substring-after($pText, '&#xA;')"/>
       </xsl:call-template>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
Posted
Updated 12-Aug-13 21:27pm
v3
Comments
H.Brydon 13-Aug-13 17:58pm    
I'm not suggesting that this is an answer but where you have '&#xA;' I think it needs to be '&#x0A;'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900