Reputation: 67
I'm trying to add a line break to the XML output with my XSLT.
here is what I'm trying to do.
<Description>
<xsl:value-of select=concat($var1,ADD_LINE_BREAK,$var2,ADD_LINE_BREAK,$var3)"/>
</Description>
* I realize that ADD_LINE_BREAK is not correct XSLT syntax
The xml output would then look something like this:
<Description>
$var1
$var2
$var3
</Description>
Thanks!
UPDATE
It looks like that actually works, but I think I'm figuring out the REAL problem. Quick run down on what I'm doing. Pull XML data from a system -> use XSLT transform to massage the data -> putting xml output into a different system. I think my issue is that the system that I'm putting the data into doesn't understand the line breaks, so I might need a way to figure out how to include HTML line breaks, so that the system can consume.
I've tried this with no luck
<Description>
<xsl:value-of select="$var1"/>
<br></br>
<xsl:value-of select="$var2"/>
<br></br>
<xsl:value-of select="$var3"/>
</Decsription>
Upvotes: 5
Views: 31246
Reputation: 73
I had a similar issue where I had a string field called DESCRIPTION, which had line breaks between paragraphs, but the output kept showing up like this:
This was the first paragraph<br><br>This was the second paragraph.
So I used tokenize to separate everything between the <br><br> tags like this:
<xsl:for-each select="tokenize(DESCRIPTION,'<br><br>')">
<item>
<xsl:value-of select="normalize-space(.)"/><br></br><br></br>
</item>
</xsl:for-each>
And it worked for me.
Upvotes: 0
Reputation: 29
Believe it or not, depending on how fussy your XSLT processor or XML validation is, I've found this embarrassingly simple one works when all else -- like 
or &10;
, etc. -- fails (including a literal like <br>,/br>
:
<xsl:text>
</xsl:text>
One or more lines for your preference.
Upvotes: 1
Reputation: 52888
Use either 

or &10;
for a line feed character.
Use either 
or &13;
for a carriage return character.
Upvotes: 2
Reputation: 25397
Try something like this:
<Description>
<xsl:value-of select="$var1" /><xsl:text>
</xsl:text>
<xsl:value-of select="$var2" /><xsl:text>
</xsl:text>
<xsl:value-of select="$var3" />
</Description>
This will add a line feed (\n
) character. Maybe you will need to add extra <xsl:text>
</xsl:text>
to get the additional linebreaks in your desired output.
Upvotes: 3