HTML in attribute of a node

Here should go questions about transforming XML with XSLT and FOP.
fedehf
Posts: 3
Joined: Tue Jan 29, 2008 4:47 pm

HTML in attribute of a node

Post by fedehf »

Hello!

I'm having some problems generating HTML with a xslt. I have a XML with some html code in a node attribute. For example

XML:

Code: Select all



<?xml version="1.0" encoding="utf-8"?>
<root>
<guidance gui_content="<div> <b>Hello, this is a test</b> </div>" />
</root>
(I didn't escape the < and > just to make it more readable.)

And this is my xslt:

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
<xsl:call-template name="dvt_1.rowview" />
</xsl:template>

<xsl:template name="dvt_1.rowview">

<p style="font-weight:bold; text-align:center; font-size:10pt;">
<xsl:variable name="fieldValue">
<xsl:value-of select="/root/guidance/@gui_content" />
</xsl:variable>
<xsl:copy-of select="$fieldValue" />
</p>

</xsl:template>
</xsl:stylesheet>
This is what I get:

Code: Select all

<div> <b>Hello, this is a test</b> </div>
As you can see, the html code from the attribute is not read as html in the browser.

Is there a way to make html code from an attribute node?

PS: Sorry for my english :S
fedehf
Posts: 3
Joined: Tue Jan 29, 2008 4:47 pm

Re: HTML in attribute of a node

Post by fedehf »

Nevermind..

disable-output-escaping solved the problem

<xsl:value-of select="@gui_content" disable-output-escaping="yes" />
Post Reply