0
votes

If I do something like this:

<xsl:variable name="something">
  <xsl:value-of select="node1" /><br />
  <xsl:value-of select="node2" /><br />
  <xsl:value-of select="node3" /><br />
  <xsl:value-of select="node4" /><br />
</xsl:variable>

<h1><xsl:value-of select="$something" /></h1>

The line breaks are ignored. Is that right?

I'm using xslt 1.0 if that makes any difference.

Thanks in advance.

2

2 Answers

4
votes

You should be using xsl:copy-of here, not xsl:value-of because xsl:value-of only outputs the text value of a node

 <h1><xsl:copy-of select="$something" /></h1>
2
votes

You should use copy-of instead of value-of in order to maintain the <br/>. The reason is that the value-of looks for the text of the node that you select so if you want the text and the elements of that node you would need the copy and not the value.

Since you are using XSLT 1.0 you may also want to look into exslt:node-set for better handling of result tree fragments like this.

As a side note, your h1 is being closed by an h2 which is not valid. Hopefully that was just a copy and paste error.