HTML in XML through XSL

Here should go questions about transforming XML with XSLT and FOP.
HotSpot
Posts: 2
Joined: Wed May 23, 2007 7:58 am

HTML in XML through XSL

Post 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.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Use
<xsl:copy-of select="/top/myhtml/node()"/>
instead of value-of.

Regards,
George
George Cristian Bina
HotSpot
Posts: 2
Joined: Wed May 23, 2007 7:58 am

Post 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
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post 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
George Cristian Bina
Post Reply