First of all, the provided XSLT code is rather strange :
<xsl:template match="//client"> <xsl:value-of select="./nom/." /> </xsl:template>
It is much better written as equivalent :
<xsl:template match="client"> <xsl:value-of select="nom" /> </xsl:template>
And the way to output multi-line text ... well, to use a newline:
<xsl:template match="client"> <xsl:value-of select="nom" /> <xsl:if test="not(position()=last())"> <xsl:text>
</xsl:text> </xsl:if> </xsl:template>
Here is the complete conversion:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:strip-space elements="*"/> <xsl:template match="client"> <xsl:value-of select="nom" /> <xsl:if test="not(position()=last())"> <xsl:text>
</xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet>
when this conversion is applied to the following XML document:
<t> <client> <nom>A</nom> </client> <client> <nom>B</nom> </client> <client> <nom>C</nom> </client> </t>
the desired, correct result is output:
A B C
If you want to create xHtml output (and not just text), then the <br> element must be created instead of the NL character :
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="client"> <xsl:value-of select="nom" /> <xsl:if test="not(position()=last())"> <br /> </xsl:if> </xsl:template> </xsl:stylesheet>
Now output :
A<br/>B<br/>C
, and it appears in the browser as :
but
IN
FROM
Dimitre novatchev
source share