xslt transformation, where is charset=UTF-16 coming from?

Discussion in 'XML' started by Eric, Dec 27, 2006.

  1. Eric

    Eric Guest

    Hello,

    I have the following xml:

    <?xml-stylesheet type="text/xsl" href="C:\mypath\myxsl.xsl"?>
    <page>
    <appl>
    <datedisplay>mm/dd/yy</datedisplay>
    </appl>
    <forms>
    <showall>False</showall>
    </forms>
    </page>

    My xsl looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0">
    <xsl:template match="/">
    <xsl:variable name="nTabNumber">6</xsl:variable>
    <html>
    <head>
    <SCRIPT LANGUAGE="JAVASCRIPT" />
    </head>
    <body></body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    I've pared both of these down from much larger files. With the larger
    files I was getting an error message similar to:

    XML Error Loading 'file:///d:/mypath/myxsl.xsl'
    Switch from current encoding to specified encoding not supported.

    at line 1, character 40"<?xml version="1.0" encoding="UTF-8" ?>"


    When stepping through the larger file (and the examples I have above)
    in XML Spy, I see the characterset getting changed to UTF-16, but I
    don't understand why, I see the html produced by the above
    transformation as:

    <html><head> <META http-equiv="Content-Type" content="text/html;
    charset=UTF-16"><SCRIPT></SCRIPT></head></html>

    The charset=UTF-16 line appears when I'm stepping over the <SCRIPT
    LANGUAGE="JAVASCRIPT" /> tag in XML Spy, does anyone know why?

    Thanks,
    Eric
    Eric, Dec 27, 2006
    #1
    1. Advertising

  2. Eric

    Andy Dingley Guest

    Eric wrote:

    > When stepping through the larger file (and the examples I have above)
    > in XML Spy, I see the characterset getting changed to UTF-16, but I
    > don't understand why,


    It comes out of your XSL transformation engine, which could be whatever
    you've configured XML Spy to use.

    Try forcing it to use UTF-8 by adding this to your stylesheet
    <xsl:eek:utput encoding="utf-8" />

    Good practice might even do this:
    <xsl:eek:utput method="html"
    encoding="utf-8"
    omit-xml-declaration = "yes"
    standalone = "yes"
    doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
    doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
    cdata-section-elements = "script pre"
    indent = "yes"
    media-type = "text/html" />
    Andy Dingley, Dec 27, 2006
    #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. Guest
    Replies:
    0
    Views:
    558
    Guest
    Feb 20, 2004
  2. Damon Payne
    Replies:
    0
    Views:
    9,138
    Damon Payne
    Mar 8, 2005
  3. Jesús Bosch
    Replies:
    1
    Views:
    13,061
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 3, 2006
  4. Steve Holden

    PyCon is Coming! PyCon is Coming!

    Steve Holden, Jan 5, 2006, in forum: Python
    Replies:
    0
    Views:
    301
    Steve Holden
    Jan 5, 2006
  5. optimistx

    javascript charset <> page charset

    optimistx, Aug 14, 2008, in forum: Javascript
    Replies:
    2
    Views:
    259
    optimistx
    Aug 15, 2008
Loading...

Share This Page