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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

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

    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>Fals e</showall>
    </forms>
    </page>

    My xsl looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
    version="2.0">
    <xsl:template match="/">
    <xsl:variable name="nTabNumbe r">6</xsl:variable>
    <html>
    <head>
    <SCRIPT LANGUAGE="JAVAS CRIPT" />
    </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="JAVAS CRIPT" /tag in XML Spy, does anyone know why?

    Thanks,
    Eric

  • Andy Dingley

    #2
    Re: xslt transformation, where is charset=UTF-16 coming from?


    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:output encoding="utf-8" />

    Good practice might even do this:
    <xsl:output 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" />

    Comment

    Working...