Jump to content

Show HTML in XLST


Se7enDays

Recommended Posts

Hi,i have a problem with my selfmade rss feed. I'm using a XSLT-file as a stylesheet for my xml feed so that you don't have to see the xml tree everytime. however, i have HTML-code within my <description>-tag, which is enclosed by CDATA so that the xml-parser gets along with it. problem is that the XSLT-file does not format this HTML-code into real HTML but rather displays it as plain text. How can i get it to work to show real HTML?I also have problems with several special characters that are not convertet into the character but print out as unicode, like &_gt; (without _) instead of >.Here is XML-file of the feed with the HTML-code as plain text. And here is the XLST-file. Language is german, don't wonder.

Link to comment
Share on other sites

Don't be afraid to write direct entity codes. The board transforms the ampersant into an entity, causing the result to be exactly what you have written. See: >Anyhow, one way that I know of is to use the disable-output-escaping attribute of the value-of element, but that's not working in Transformiix (used by Firefox).I think I may be able to device some complex workaround for this, but if you have server side scripting language at your hands, use it's XSLT processor instead. Most processors support this attribute.

<xsl:value-of select="description" disable-output-escaping="yes"/>

Link to comment
Share on other sites

big thx, the disable-output-escaping attribute made it work for internet explorer and opera. however, as you said, my favorite browser firefox does not accept it.its better now, but if it would work in firefox as well, i would be more than pleased :)

Link to comment
Share on other sites

The only other way is to write elements in the XML itself and use the <xsl:copy-of/> element. However, note that the targeted element's text should be the thing copyed, along with all childs of the targeted element. Otherwise, the targeted element itself will also have a copy.For example, an XML of:

<description>This text also has a <strong>strong part</strong></description>

and an XSLT of

<xsl:copy-of select="description/text()|description/*" />

will produce exactly:

This text also has a <strong>strong part</strong>

unlike the

<xsl:copy-of select="description"/>

which will produce:

<description>This text also has a <strong>strong part</strong></description>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...