• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to produce a carriage return?

 
jim yin
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I try to produce a carriage return using <xsl:text></xsl:text>, and line up <heading> and <text> tags, but in vain. The output seems always on one line.
xml file:

<xdata>This is a test</xdata>

xslt file:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl utput method="xml" omit-xml-declaration="yes"/>
<xsl:template match="xdata">
<heading>xdata</heading><xsl:text>
</xsl:text>
<text><xsl:apply-templates/></text>
</xsl:template>
</xsl:stylesheet>

The result xml file:

<heading>xdata</heading>
<text>This is a test</text>

There is always several spaces before the second line. How to remove this? Thanks.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try the following (I'm not sure about it) -
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It gets tricky
<![CDATA[& # 13;]]> with no spaces!
 
jim yin
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does not work, it just adds another line
with that symbol. Thanks anyways.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim,
If the output xml is for the web, you can use the <br/> tag.
If you deal text files, the CDATA section should do it.
I tried with xalan <![CDATA[
]]> with CR inside and nothing happened. I tried <![CDATA[-]]> and got three new lines No idea why.
Hope it helps,
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic