3

Possible Duplicate:
Producing a new line in XSLT

if have the following xslt file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="text" />
    <xsl:template match="//teilnehmer">
        <xsl:value-of select="name"/>
        <xsl:value-of select="kind"/>
    </xsl:template>
</xsl:stylesheet>

the output after transformation is a string without any whitespaces or line breaks

how can I add some formatting (e.g. a line break after a name)?

thanks in advance!

Community
  • 1
  • 1
user1800825
  • 203
  • 1
  • 4
  • 17

1 Answers1

9

The easiest way is with

<xsl:text>&#x0A;</xsl:text>

&#x0A; being a character reference that represents the newline character. Alternatively you can do

    <xsl:text>
</xsl:text>

(i.e. an <xsl:text> containing just a newline character) but you need to ensure there are no spaces between the newline and the closing </xsl:text> (as they would be included in the output), which is easy to mess up if you ever use an IDE that does automatic indentation. Using the character reference is more robust.

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • thank you - that was the solution for my problem – user1800825 Nov 06 '12 at 15:42
  • @user1800825 glad it worked, and welcome to StackOverflow. When an answer solves your problem, please consider _accepting_ it by clicking the tick mark to the left. A track record of accepting good answers is the best way to encourage people to answer your other questions in future. – Ian Roberts Nov 06 '12 at 15:51