firefox doesn't like 'disable-output-escaping' setting... looking for alternatives

Discussion in 'XML' started by David Henderson, Jul 27, 2007.

  1. I know 'disable-output-escaping' has been discussed in the past, but I can't
    put my finger on any of the threads to see if my current problem is
    addressed. Sorry for re-asking the question if it has already been
    answered...



    I have an XML doc that I am transforming via XSLT and JavaScript in the
    browser. This allows me to return unsorted data to the browser and allow
    the user to sort it with a mouseclick and not hit the server just to perform
    the same query with a new sortby clause. My XSLT works fine in Internet
    Explorer, but FireFox doesn't seem to respect the 'disable-output-escaping'
    attribute like I'd expect. The result is that the output HTML includes <
    and " instead of valid HTML.



    Here's a fragment of the XML:

    <Book isbn="0545010225" author="Rowling, J. K.;" pubDate="21 July 2007">
    Harry Potter and the Deathly Hallows
    </Book>



    Here's the XSLT fragment that transforms it to HTML:

    <xsl:template match="Book">

    <tr>

    <td class="link">

    <xsl:text disable-output-escaping="yes">&lt;a
    href=&quot;http://localhost/cgi-bin/book_details?isbn=</xsl:text>

    <xsl:value-of select="@isbn"/>

    <xsl:text disable-output-escaping="yes">&quot; target=&quot;_blank&quot;
    &gt;</xsl:text>

    <center><xsl:value-of select="@defectid"/></center>

    <xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

    </td>

    <td><xsl:value-of select="@author"/></td>

    <td><xsl:value-of select="@pubDate"/></td>

    <td><xsl:value-of select="."/></td>

    </tr>

    </xsl:template>



    The result HTML should look something like this:

    <tr>

    <td><a href="http://localhost/cgi-bin/book_details?isbn=0545010225" target="_blank"
    >0545010225</a></td>


    <td>Rowling, J. K.;</td>

    <td> 21 July 2007</td>
    <td>Harry Potter and the Deathly Hallows</td>

    </tr>



    In FireFox, the 'disable-output-escaping="yes"' is being ignored, so I end
    up with:

    <tr>

    <td class="link">&lt;a
    href=&quot;http://localhost/cgi-bin/book_details?isbn=0545010225&quot;
    target=&quot;_blank&quot; &gt;0545010225&lt;/a&gt</td>

    <td>Rowling, J. K.;</td>

    <td> 21 July 2007</td>
    <td>Harry Potter and the Deathly Hallows</td>

    </tr>



    .. not quite what I was going for. Anyone have a suggestion?

    -David.
     
    David Henderson, Jul 27, 2007
    #1
    1. Advertising

  2. Re: firefox doesn't like 'disable-output-escaping' setting... lookingfor alternatives

    David Henderson wrote:

    > I have an XML doc that I am transforming via XSLT and JavaScript in the
    > browser. This allows me to return unsorted data to the browser and allow
    > the user to sort it with a mouseclick and not hit the server just to perform
    > the same query with a new sortby clause. My XSLT works fine in Internet
    > Explorer, but FireFox doesn't seem to respect the 'disable-output-escaping'
    > attribute like I'd expect. The result is that the output HTML includes &lt;
    > and &quot; instead of valid HTML.


    disable-output-escaping is an optional feature only supported when the
    XSLT processor serializes the result tree. Firefox does not serialize at
    all so it does not support disable-output-escaping.

    Instead of

    <xsl:text disable-output-escaping="yes">&lt;a
    href=&quot;http://localhost/cgi-bin/book_details?isbn=</xsl:text>

    <xsl:value-of select="@isbn"/>

    <xsl:text disable-output-escaping="yes">&quot; target=&quot;_blank&quot;
    &gt;</xsl:text>

    <center><xsl:value-of select="@defectid"/></center>

    <xsl:text disable-output-escaping="yes">&lt;/a&gt;</xsl:text>

    you should simply use literal result elements with attribute value
    templates e.g.

    <a href="http://localhost/cgi-bin/book_details?isbn={@isbn}"
    target="_blank"><center><xsl:value-of select="@defectid"/></a>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jul 27, 2007
    #2
    1. Advertising

  3. Re: firefox doesn't like 'disable-output-escaping' setting... lookingfor alternatives

    Martin Honnen wrote:
    > you should simply use literal result elements with attribute value
    > templates


    Yes. Think in terms of generating XML document structure, ***NOT*** in
    terms of generating XML syntax. Trying to force the former by mucking
    with the latter is not just a bad idea, it often doesn't work, as this
    example demonstrates.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Jul 27, 2007
    #3
  4. David Henderson

    Jerinaw

    Joined:
    Dec 30, 2010
    Messages:
    1
    HTML fragments CDATA

    Ok so I enclose my html fragments in CDATA so that the xslt parser doesn't parse the html fragments with in my xml. In Chrome I set 'disable-output-escaping' to 'yes' and the cdata elements are not escaped and the html renders correctly.

    This is not working in FF since they dont support the 'disable-output-escaping' attribute. Is there a way around this?
     
    Jerinaw, Dec 30, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=

    Looking for embeddable Java alternatives

    =?iso-8859-1?B?bW9vcJk=?=, Dec 13, 2005, in forum: Java
    Replies:
    2
    Views:
    339
    Roedy Green
    Dec 13, 2005
  2. Joe Price
    Replies:
    6
    Views:
    653
    Joe Price
    Sep 26, 2003
  3. Lisa
    Replies:
    1
    Views:
    6,136
    Martin Honnen
    Jul 7, 2004
  4. Troot

    disable-output-escaping

    Troot, Mar 1, 2006, in forum: XML
    Replies:
    5
    Views:
    2,652
    Troot
    Mar 2, 2006
  5. Replies:
    3
    Views:
    170
Loading...

Share This Page