[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Re[2]: How can I avoid generating META tag of html

Subject: RE: Re[2]: How can I avoid generating META tag of html?
From: "Julian Reschke" <julian.reschke@xxxxxx>
Date: Thu, 20 Dec 2001 19:43:49 +0100
html cyrilic encoding
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Maxim
> Patramanskij
> Sent: Thursday, December 20, 2001 3:22 PM
> To: Julian Reschke
> Subject: Re[2]:  How can I avoid generating META tag of html?
>
>
> Hello Julian,
>
> JR> *Why* do you want that?
>
> JR> Hint: don't say it's because you think the information is wrong.
>
> I will try to explain. I have a servlet, which implements site search.
> It generates search result in xml and then tells to transformer to
> apply transformation, having template. As well as I want to have
> output multilanguage, all language-specific information stored in
> Unicode format in .properties files and then selected according to
> sending by browser http header Accept-language.

Sounds good.

> So, depending on browser's language, result's charset could be either
> ISO-8859-1, Cp1251, at the moment. I set encoding value to the

Why would the required *encoding* depend on the *language*? I have a very
similar use case (processing Accept-Language, XML source, XSLT
transformation), but I always send UTF-8 to the client.

> response.setContentType("text/html; charset=" + encoding)
>
> and then do transformation:
>
> transformer.transform(new DOMSource(xmlDoc), new
> StreamResult(response.getWriter()))
>
> If the browser's language was ru (Russian), I see nothing in browser,
> untill manually change browser's encoding from UTF-8 to
> Cyrilic(Windows), which is Cp1251. I do think it happens because
> transformer creates the following in html head:
>
> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">

I think you have a mismatch between the encoding of the response object, and
the encoding used by XSLT. Try setting the right encoding in the top-level
instruction xsl:output.

> To avoid this behavior, I should additionaly do the following:
>
>  transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
>
> before starting the transformation.
>
> But after that, locale specific symbols (Cyrilic) became a sequence of
> Unicode:
>
> <title>&#1056;&#1077;&#1079;&#1091;&#1083;&#1100;&#1090;&#1072;</title>
>
> That's why I'm asking, how to avoid <meta...> generating to let browser
> decide content encoding from http headers.

Well, removing the META tag will not help you at all if the encoding you
specify in the HTTP header isn't the one used by the XSLT engine. Maybe the
encoding you are specifying isn''t supported by the XSLT engine, and it's
falling back to the system encoding?


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.