Results 1 to 2 of 2

Thread: xslt - Stopping output Escaping!

  1. #1
    Join Date
    Jun 2010

    Exclamation xslt - Stopping output Escaping!

    I have an xsl stylesheet.

    I want to populate it (is that the correct termonology?) with data from a xml file to form a HTML page.

    The data is HTML like:
    <data><b>Data includes HTML element</b></data>
    However when the xsl is populated, the tags are escaped - I want the browser to render them as HTML tags. I have tried:
    <xsl:output method="html"/>
    <xsl:value-of select="comment" disable-output-escaping="yes"/>
    But these don't work (a cross browser solution is required.)

    Anyone have any suggestions?
    Many thanks,

    Note: the full story is much more complicated with stuff been created with Javascript but this is definately where the problem lies...

  2. #2
    Join Date
    Jun 2010
    I've looked into this and have concluded:
    Firefox does not support "disable-output-escaping" (which is really anoying as all the other major browser do!)

    The only fix I've come up with is letting Firefox do it's parsing and escpaing the tags then rebuiling them with javascript afterwards:
    if (navigator.userAgent.indexOf("Firefox") != -1)	{
           var interface = /*xslt populatates the xsl with xml data and returns in div*/;
    	var content = interface.innerHTML;
    		content = content.replace(/&lt;/gi,			"<");
    		content = content.replace(/&gt;/gi, 		">");
    		content = content.replace(/&amp;#60;/gi,	"&lt;");
    		content = content.replace(/&amp;#62;/gi,	"&gt;");
    	interface.innerHTML = content;
    It works nicely in my situation as everything is javascript so this is just an addition after the XSLT. I can't imagine this is the best fix if you're not dealing in javascript.

    However, I'm happy. Unless anyone's got any better suggestions, case closed!
    Last edited by acestuff; 06-15-2010 at 07:27 PM. Reason: Missing grammer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center