XSLT disable-output-escaping

Discussion in 'XML' started by Lisa, Jul 7, 2004.

  1. Lisa

    Lisa Guest

    I need to apply the HTML formatting tags and the French accented
    characters in a XML document. The XML is generated from a database
    that has HTML tags and French accented characters in the records.

    I have specified <xsl:eek:utput method="html"/> and
    encoding="iso-8859-1".

    When I apply the xsl:value-of and set the disable-output-escaping to
    "yes", the HTML formatting tags are displayed correctly, but the
    French accented characters are displayed as "?". If I set the
    disable-output-escaping to "yes", the French accented characters are
    displayed properly, but not the HTML formatting tags. The HTML
    formatting tags are output as &lt;...&gt; and display <..> in the
    browser (e.g. <p>)

    Any suggestion that how I can display both HTML formatting tag and
    French accented characters properly …


    Thanks in advance,


    Lisa
     
    Lisa, Jul 7, 2004
    #1
    1. Advertising

  2. Lisa wrote:

    > I need to apply the HTML formatting tags and the French accented
    > characters in a XML document. The XML is generated from a database
    > that has HTML tags and French accented characters in the records.
    >
    > I have specified <xsl:eek:utput method="html"/> and
    > encoding="iso-8859-1".
    >
    > When I apply the xsl:value-of and set the disable-output-escaping to
    > "yes", the HTML formatting tags are displayed correctly, but the
    > French accented characters are displayed as "?". If I set the
    > disable-output-escaping to "yes", the French accented characters are
    > displayed properly, but not the HTML formatting tags. The HTML
    > formatting tags are output as &lt;...&gt; and display <..> in the
    > browser (e.g. <p>)
    >
    > Any suggestion that how I can display both HTML formatting tag and
    > French accented characters properly …


    I am not sure what you want to achieve, if you have an XSLT question
    consider to give an example of your XML input data and in particular
    tell us how it is encoded, then show the relevant XSLT you are having
    problem with together with the XSLT output (which you have above).

    I don't see any problem to for instance take the following XML

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <text xml:lang="en">I am tired.</text>
    <text xml:lang="fr">Je suis fatigué.</text>
    <text xml:lang="de">Ich bin müde.</text>
    </root>

    and transform it with the following XSLT stylesheet

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

    <xsl:eek:utput method="html" encoding="ISO-8859-1" />

    <xsl:template match="/">
    <html lang="en">
    <head>
    <title>A text in Englisch, French, and German</title>
    </head>
    <body>
    <xsl:apply-templates select="root/text" />
    </body>
    </html>
    </xsl:template>

    <xsl:template match="text">
    <p>
    <xsl:attribute name="lang">
    <xsl:choose>
    <xsl:when test="lang('en')"><xsl:text>en</xsl:text></xsl:when>
    <xsl:when test="lang('fr')"><xsl:text>fr</xsl:text></xsl:when>
    <xsl:when test="lang('de')"><xsl:text>de</xsl:text></xsl:when>
    </xsl:choose>
    </xsl:attribute>
    <xsl:value-of select="." />
    </p>
    </xsl:template>

    </xsl:stylesheet>

    to the following HTML output:

    <html lang="en">
    <head>
    <META http-equiv="Content-Type" content="text/html;
    charset=ISO-8859-1">
    <title>A text in Englisch, French, and German</title>
    </head>
    <body>
    <p lang="en">I am tired.</p>
    <p lang="fr">Je suis fatigu&eacute;.</p>
    <p lang="de">Ich bin m&uuml;de.</p>
    </body>
    </html>

    Of course the XSLT processor could as well serialize the output as

    <html lang="en">
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>A text in Englisch, French, and German</title>
    </head>
    <body>
    <p lang="en">I am tired.</p>
    <p lang="fr">Je suis fatigué.</p>
    <p lang="de">Ich bin müde.</p>
    </body>
    </html>

    but that doesn't matter to a browser/user agent.


    That might not be your problem but you haven't really shown us what your
    input looks like, I suspect you are dealing with HTML markup in your
    input which you try to process as text instead processing them as
    elements but we can only help if you show a sample of the input.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jul 7, 2004
    #2
    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. Stylus Studio
    Replies:
    0
    Views:
    682
    Stylus Studio
    Aug 3, 2004
  2. Joe Price
    Replies:
    6
    Views:
    648
    Joe Price
    Sep 26, 2003
  3. Troot

    disable-output-escaping

    Troot, Mar 1, 2006, in forum: XML
    Replies:
    5
    Views:
    2,644
    Troot
    Mar 2, 2006
  4. David Henderson
    Replies:
    3
    Views:
    3,256
    Jerinaw
    Dec 30, 2010
  5. Replies:
    3
    Views:
    167
Loading...

Share This Page