Subject: Re: [xsl] Non English characters in attribute values From: David Sinclair <dsinclair@xxxxxxxxxxxx> Date: Mon, 20 Sep 2004 17:47:14 +0100 |
The problem was fixed by Michael Kays solution - the problem seems to have been caused by the attribute value being escaped, which I now suppress with escape-uri-attributes="no" in an output tag as suggested.
I am no longer specifying 2 different encodings. I think this must have been a copy and paste reuse artifact! Thanks for all the help,
Hi David,with
Your stylesheet uses xml:output encoding="UTF-8":
<xsl:output method="html" version="4.01" indent="yes" encoding="UTF-8"/>
Yet in the output html, there's a meta tag with another encoding:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
If you take the generated output file and change charset=iso-8859-1 to charset=utf-8, does the html form field display the correct string?
I don't know how this meta-tag ends up in the result, but there might be an encoding conflict in your input file:
<?xml version="1.0" encoding="utf-8"?> <result> <values> <value>Larry</value> <value>Gishle</value> </values> </result>
If you open that file in a hex-editor, how is the 'h' encoded? The xml-declaration specifies "utf-8" so that should be two bytes with hex value 'C3A8'. A 'normal' text-editor would display "GisC(le" in that case. If the 'h' is encoded as one byte 'E8', the actual encoding is not utf-8 but probably "iso-8859-1".
If that's the case, you can either stick to "utf-8" and replace "Gishle"
</li>"GisC(le" in the input file, or replace "utf-8" with "iso-8859-1" in your xml-declarations (both xml source and xsl stylesheet) and in xsl:output.
I'm not sure if that will solve the javascript part, probably it will still show something like "javascript:pushSelectionBackToOpener('Gis%E8le')" but maybe the html form will show the correct string then.
Good luck, Anton Triest
----- Original Message ----- From: "David Sinclair" <dsinclair@xxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, September 20, 2004 12:55 PM Subject: [xsl] Non English characters in attribute values
Hi,
I am having a problem with non-english characters and how they appear in attribute values as apposed to element content. This is a simplified version of the code I having a problem with:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:output method="html" version="4.01" indent="yes" encoding="UTF-8"/> <xsl:template match="/"> <html> <body><xsl:apply-templates select="//values" /></body> </html> </xsl:template>
<xsl:template match="values"> <ul><xsl:apply-templates select="value" /></ul> </xsl:template>
<xsl:template match="value"> <li> <xsl:element name="a"> <xsl:attribute name="href">javascript:pushSelectionBackToOpener('<xsl:value-of select="."/>')</xsl:attribute> <xsl:value-of select="."/> </xsl:element> </li> </xsl:template> </xsl:stylesheet>
Here is an example of the source document: <?xml version="1.0" encoding="utf-8"?> <result> <values> <value>Larry</value> <value>Gishle</value> </values> </result>
The result of running this xsl on the source doc is as follows (note that the href attribute is different from the element content): <html xmlns:fo="http://www.w3.org/1999/XSL/Format"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title> </head> <body></body> <ul> <li><a href="javascript:pushSelectionBackToOpener('Larry')">Larry</a></li> <li><a href="javascript:pushSelectionBackToOpener('Gis%C3%A8le')">Gisèle</a>
</ul> </html>
The javascript function puts its parameter into an htm form field, and appears as "GisC(le" instead of "Gishle". Does anyone know how I can get the right value to apear in the attribute value? I am using Saxon 8 BTW.
David Sinclair.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Non English characters in, cking | Thread | RE: [xsl] not getting expected matc, Crouch, Luke H. |
Re: [xsl] Non English characters in, cking | Date | [xsl] Release Date vs. Highlight Un, xsl-list |
Month |