-4

Possible Duplicate:
Producing a new line in XSLT

hello can any one help me how to write code for getting newline ....

Community
  • 1
  • 1
praveen
  • 63
  • 4
  • 12
  • 2
    Do you want a newline in the XML/HTML file you are generating, or do you want something that displays as a new line in the browser? If the latter, you need to generate a `
    ` element.
    – Michael Kay Mar 05 '11 at 17:49
  • 2
    Incidentally, you might like to know that I tend to assume people who are careless in writing English (for example, no capital letters) are also probably careless programmers. I might be wrong, but you should be aware of the impression you create. – Michael Kay Mar 05 '11 at 17:51
  • What is your output format(e.g. XML, HTML, text)? How are you verifying the newline(e.g. opening in a text editor or loading in a browser)? – Mads Hansen Mar 06 '11 at 00:23

2 Answers2

1

bro i have tried every thing ....but only newline was not getting for me 

 i have with this all – praveen 4 hours ago

Try:

<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="text()" name="wrapLines">
  <xsl:param name="pText" select="."/>
  <xsl:param name="pNumLines" select="10"/>

  <xsl:if test=
   "string-length($pText) and $pNumLines > 0">
   <xsl:variable name="vLine" select=
   "substring-before(concat($pText,'&#xA;'), '&#xA;')"/>
   <Line>
    <xsl:value-of select="$vLine"/>
   </Line>
   <xsl:call-template name="wrapLines">
    <xsl:with-param name="pNumLines" select="$pNumLines -1"/>
    <xsl:with-param name="pText" select=
      "substring-after($pText, '&#xA;')"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

when this transformation is applied on the following XML document:

<t>
 line2
 line3
 line4
</t>

it correctly finds all occurencies of an NL character and correctly splits the text into separate <Line> elements:

<Line/>
<Line> line2</Line>
<Line> line3</Line>
<Line> line4</Line>
Anthony Pegram
  • 123,721
  • 27
  • 225
  • 246
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
-1

Are you trying to output a new line or hard return? This will output a new line in the transformed file.

<xsl:text>
</xsl:text>
Jeff
  • 877
  • 2
  • 11
  • 17