XSLT disable-output-escaping

L

Lisa

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
 
M

Martin Honnen

Lisa said:
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.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top