Q:

XSLT inject HTML

I have the following XML:
<person>
      <name>John</name>
      <htmlDescription>A <strong>very</strong> <b><i>nice</i></b> person </htmlDescription>
</person>

I would somehow like to use this XML in XSLT transform to produce HTML such as
A very nice person
is this possible using XSLT?

A:

If you transform it to HTML:
<xsl:stylesheet version='1.0'
                xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method='html'/>

<xsl:template match='person'>
    <td>
        <xsl:copy-of select='htmlDescription/node()'/>
    </td>
</xsl:template>

</xsl:stylesheet>

If you transform it to XHTML:
<xsl:stylesheet version='1.0'
                xmlns='http://www.w3.org/1999/xhtml'
                xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method='xml'/>

<xsl:template match='htmlDescription//text()'>
    <xsl:value-of select='.'/>
</xsl:template>

<xsl:template match='htmlDescription//*'>
    <xsl:element name='{local-name()}'>
        <xsl:copy-of select='@*'/>
        <xsl:apply-templates select='node()'/>
    </xsl:element>
</xsl:template>

<xsl:template match='person'>
    <td>
        <xsl:apply-templates select='htmlDescription/node()'/>
    </td>
</xsl:template>

</xsl:stylesheet>

