Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 27th, 2006, 01:35 PM
Eric
Guest
 
Posts: n/a
Default 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>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

  #2  
Old December 27th, 2006, 03:05 PM
Andy Dingley
Guest
 
Posts: n/a
Default Re: xslt transformation, where is charset=UTF-16 coming from?


Eric wrote:
Quote:
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" />

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles