XSL copy-of and value-of

Like most languages there are often a variety of ways of achieving similar results, and XSL is no different.

Take the xsl copy-of and value-of commands.

Assuming the following sample xml document:

<text>Good <b>news</b> everybody!</text>

The following uses of copy-of and value-of all achieve similar but different results.


<xsl:copy-of select="/xml/text" />
<text>Good <b>news</b> everybody!</text>

Using node()

<xsl:copy-of select="/xml/text/node()" />
Good <b>news</b> everybody!

Using *

<xsl:copy-of select="/xml/text/*" />


<xsl:value-of select="/xml/text" />
Good news everybody! 


This is the personal blog of Adrian Lynch, owner of Millstream, developers of Spring CMS.

Version: 1.3