Page 1 of 1

HTML in XML through XSL

Posted: Wed May 23, 2007 8:47 am
by HotSpot
Hello everyone ! This is my first post and its very urgent for me :) hope you guys will help me out here.

I have this xml in which I have html tags. I want to render the "<myhtml>" (as in example below) content through my XSL while retaining its formatting. At the moment my xsl (<xsl:value-of select="/top/myhtml"/>) is rendering <myhtml> node's inner content as it is without taking care of any formatting tags present inside the node.

e.g.

<top>
<myhtml>
Some <b>bold</b> content and some <i>italic</i> content
</myhtml>
</top>

Thanks in advance.

Posted: Wed May 23, 2007 9:59 am
by george
Use
<xsl:copy-of select="/top/myhtml/node()"/>
instead of value-of.

Regards,
George

Posted: Wed May 23, 2007 11:50 am
by HotSpot
george wrote:Use
<xsl:copy-of select="/top/myhtml/node()"/>
instead of value-of.
Thanks for your early response, George!

I did the change you said, but it truncated rest of the node's text as soon as it found the first HTML (<b>) tag.

And so the output visible in IE was only 'Some'

Code: Select all

Some

Posted: Wed May 23, 2007 2:21 pm
by george
Well, the above works, you can try it also in oXygen with a stylesheet like below:

Code: Select all


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:g="http://www.oxygenxml.com/george">

<xsl:template match="/">
<xsl:copy-of select="/top/myhtml/node()"/>
</xsl:template>
</xsl:stylesheet>
Regards,
George