|
| who controls the encoding when transforming xml? |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.xml.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Jiho Han |
I do a transform of an xml document into another xml using XslTransform. In my xsl file, I specify using <xsl:output encoding="utf-8"/>. However, when my transform is done, the resulting xml is in utf-16. What gives? Anyone?
|
|
|
| |
|
| |
| | |
| |
| Oleg Tkachenko [MVP] (VIP) |
Jiho Han wrote:
[Original message clipped]
Show us your code. <xsl:output encoding="utf-8"/> only works when you transform to Stream. Otherwise it's ignored and other stuff defines output encoding. -- Oleg Tkachenko [XML MVP, XmlInsider] http://blog.tkachenko.com
|
|
|
| |
|
|
| |
| |
| Jiho Han |
This is my xsl header section:
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" indent="no" media-type="text/xml" method="xml"/>
This is my data:
<association>
<associationid>5b5acf84-6a76-4447-ad88-dc0b7d031741</associationid>
</association>
Here's my code for the transform:
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(dataXml);
XmlDeclaration xmldecl;
xmldecl = xdoc.CreateXmlDeclaration("1.0", null, null);
xmldecl.Encoding="UTF-8";
xdoc.InsertBefore(xmldecl, xdoc.DocumentElement);
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("client/association.xsl"));
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
xslt.Transform(xdoc, null, sw);
return sb.ToString();
As you can see I tried to insert a XML declaration in there but it really didn't do much. Thanks for looking into this. Much appreciated. Jiho
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:%Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
| |
| | |
| | |
|
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|