By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,496 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,496 IT Pros & Developers. It's quick & easy.

XSLT disable-output-escaping

P: n/a
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:output 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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


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:output 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:output 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/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.