Reputation: 5821
Say I have the following XML:
<root>
<node attr="<b>hi</b>" />
<node attr="<b>bye</b>" />
</root>
How can I get the XSLT 1.0 code to render the actual HTML in the attribute?
This doesn't work as it ouputs <b>hi</b>
.
<xsl:value-of select="@attr" disable-output-escaping="yes"/>
Any ideas?
Clarification
I am using this on SharePoint 2010 in a DVWP WebPart. The WebPart will let me use XSLT to transform the XML returned of a list into HTML that is displayed on the browser. Right now the rendered output is <b>hi</b>
instead of bolded text. I guess what I need to do is disable-output-escaping twice. The first time will get the <b>hi</b>
and the second time it'll be rendered. Make sense?
Upvotes: 1
Views: 1186
Reputation: 117073
You are asking for something that is not. The result of an XSL transformation is a text document: it can be XML, HTML or plain text (in fact, XML and HTML are also types of plain text documents).
Bolded text as such exists only on the screen, after some application has rendered the text marked up as bold. In the case of an HTML markup, the application that does the rendering is a web browser.
If you want to see a rendered view of the HTMl resulting from your transformation, you need to insert a browser at the end of your processing chain. Some XSLT editors have a built-in web browser, allowing you to switch the view of the result between the "raw" result and a rendered view. But that has nothing to do with the XSL transformation itself.
Added in view of your clarification:
There are two things you should know about disable-output-escaping
that may be relevant to your situation:
An XSLT processor is not required to support disabling output escaping.
An XSLT processor will only be able to disable output escaping if it controls how the result tree is output. This may not always be the case.
These are direct quotes from the XSLT 1.0 specification.
I am not sure how SharePoint works, but if - for example - the XSLT transformation passes its result directly to the browser as a DOM tree, instead of serializing it to "a sequence of bytes' (i.e. a file), then disable output escaping
will have no effect.
Upvotes: 2