Displaying embedded html from an xml file through an xsl stylesheet

J

Joe Price

Hi chaps

I've got an XML file, within that file i've embedded html code using
the
<![CDATA[ ]]>
tag

I'm displaying that xml file through a browser using an xsl style
sheet. However it is displaying any html from the xml file as text,
ie its displaying as text <br/> and <b> etc

How can i tell my xml file to display the html tags as html and not
display them as text?

Many thanks
 
M

Martin Boehm

I've got an XML file, within that file i've embedded html code using
the <![CDATA[ ]]> tag

I'm displaying that xml file through a browser using an xsl style
sheet. However it is displaying any html from the xml file as text,
ie its displaying as text <br/> and <b> etc

Sure, because the XSL Processor correctly escapes these tags, so they do
not lose their (in this case textual) meaning in HTML.
What you have to do is prevent this process called "output-escaping"
from happening.

When you have
<native>
<![CDATA[<p>Hallo</p><br><b>test</b>]]>
</native>

then this does the trick:
<xsl:template match="native">
<xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:template>

HTH Martin
 
J

Joe Price

cheers bud, worked a treat


Martin Boehm said:
I've got an XML file, within that file i've embedded html code using
the <![CDATA[ ]]> tag

I'm displaying that xml file through a browser using an xsl style
sheet. However it is displaying any html from the xml file as text,
ie its displaying as text <br/> and <b> etc

Sure, because the XSL Processor correctly escapes these tags, so they do
not lose their (in this case textual) meaning in HTML.
What you have to do is prevent this process called "output-escaping"
from happening.

When you have
<native>
<![CDATA[<p>Hallo</p><br><b>test</b>]]>
</native>

then this does the trick:
<xsl:template match="native">
<xsl:value-of disable-output-escaping="yes" select="."/>
</xsl:template>

HTH Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top