encodig attribute of output element ignored

Using xslt in .NET 2.0 I found no way to get the right encoding (UTF-8) 
in the resulting xml file.

Here my setup:

test.xslt:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-
declaration="no"/>

  <xsl:template match="/">
    <html>
      <body></body>
    </html>
  </xsl:template>
  
</xsl:stylesheet> 


c#-code:

XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(@"c:\temp\test.xslt");
XmlWriterSettings ws = xslt.OutputSettings.Clone();
xslt.Transform(@"C:\temp\test.xml", XmlWriter.Create(Console.Out, ws));



OUTPUT:

<?xml version="1.0" encoding="Windows-1252"?>
<html>
  <body />
</html>


Any help appeciated!

- Markus.
0
8/7/2007 4:52:41 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
580 Views

Similar Articles

[PageSpeed] 8

Markus Neugebauer wrote:
> Using xslt in .NET 2.0 I found no way to get the right encoding (UTF-8) 
> in the resulting xml file.

> XslCompiledTransform xslt = new XslCompiledTransform();
> xslt.Load(@"c:\temp\test.xslt");
> XmlWriterSettings ws = xslt.OutputSettings.Clone();
> xslt.Transform(@"C:\temp\test.xml", XmlWriter.Create(Console.Out, ws));

You are not writing to a file, you are writing to Console.Out which is a 
TextWriter that has an encoding. Write to a file or stream and you will 
get the encoding specified in ws. If you want to change the encoding of 
Console.Out then set Console.OutputEncoding as needed.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1778)
8/7/2007 5:06:27 PM
Martin Honnen <mahotrash@yahoo.de> wrote in news:ekdSMVR2HHA.748
@TK2MSFTNGP04.phx.gbl:

> Markus Neugebauer wrote:
>> Using xslt in .NET 2.0 I found no way to get the right encoding (UTF-8) 
>> in the resulting xml file.
> 
>> XslCompiledTransform xslt = new XslCompiledTransform();
>> xslt.Load(@"c:\temp\test.xslt");
>> XmlWriterSettings ws = xslt.OutputSettings.Clone();
>> xslt.Transform(@"C:\temp\test.xml", XmlWriter.Create(Console.Out, ws));
> 
> You are not writing to a file, you are writing to Console.Out which is a 
> TextWriter that has an encoding. Write to a file or stream and you will 
> get the encoding specified in ws. If you want to change the encoding of 
> Console.Out then set Console.OutputEncoding as needed.
> 
> 

Following your hint and writing to text file the encoding got all right. 
Thank you very much for the quick and helpful response!

- Markus.
0
8/8/2007 7:31:39 AM
Reply:

Similar Artilces:

How do I change the Read Only attribute on a file?
I am working out of a publisher file that had been saved to a CD. I was able to edit the file but it will not let me save because it was Read Only. Can I change the read only attribute on this file to allow me to edit and save? Hi Terry, You have to save the file from the CD onto your hard drive. If you right-click on the file and click on Properties, you can turn off the Read Only attribute. If the CD is a read-write CD, you may be able to go into Windows Explorer and right-click on the file that is on the CD and click on Properties to turn off the Read Only attribute. Most people ...

encodig attribute of output element ignored
Using xslt in .NET 2.0 I found no way to get the right encoding (UTF-8) in the resulting xml file. Here my setup: test.xslt: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml- declaration="no"/> <xsl:template match="/"> <html> <body></body> </html> </xsl:template> </xsl:stylesheet> ...

More than one attribute.
you can write writer.WriteStartElement("data", "http://www.w3.org/1999/XMLSchema-instance"); in your code for, <data xmlns="http://www.w3.org/1999/XMLSchema-instance"> how do you write, <data xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../documents/xml/epic.xsd"> for two attributes? Dave wrote: > you can write > writer.WriteStartElement("data", "http://www.w3.org/1999/XMLSchema-instance"); > > in your code for, > > <data xmlns="http...

<xsl:text disable-output-escaping="yes"> does not work in XslCompi
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"> does not work when using XslCompiledTransform to do the trnasform (namely the output contain < not <), while it works when using MSXML2 to do the transform. Does anyone have the same problem and how to make the escape work? Thanks. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8"/> <xsl:preserve-space elements="*"/> <...

"Rehearsing" element timings too
I know that slide transition timings can be set by rehearsing them. However, can the animation timings within the slides be set that way (or in a related way) too? In other words, I'm doing a slide show of pictures. The slides have varying number of pictures in them and i'd like to be able to set the animation times for each of the pictures one at a time by clicking through them like you can wih slide transitions using the rehearse timings features. Thanks. BTW, i have both PPT 07 and the PPT 10 Beta. "Allen" wrote: > I know that slide transition ti...

How to find other attribute value corresponding searced attribute
Header("Item1") returns <MenuItem Content="Open file" Name="Item1" /> How to change this so it returns Content attribute value "Open file" corresponding to Name attribute value ? public static string Header(string entity) { return Menu.Descendants("MenuItem").Where(m => (string)m.Attribute("Name") == entity).Single().ToString(); } Menu type is XElement and it contains: <Menu> <MenuItem Content="File"> <Items> <MenuItem Content="FilemenuSubMen...

Deleted Attributes
Hi all, I have to fix a situation where someone went in and removed the exchange attributes for one user. She has a huge amount of stuff in this mailbox and for the life of me I cannot figure out how to reattach her mailbox to her account. Can anyone offer any guidance? Exchange 2000 on a Server 2000 domain controller (its NOT my design) Thank you, Mike Go in to the mailbox store where her mailbox is located, right click on the Mailboxes list and choose Run Cleanup Agent. In a few minutes, that mailbox should be marked as deleted. Then, right click on the mailbox, choose Reconne...

How can I add numbers but ignore the minus signs?
How can I add numbers but ignore the minus signs? In the following, the answer I'm after is 17 A1 -10 A2 5 A3 -2 =SUMPRODUCT(ABS(A1:A3)) Gord Dibben MS Excel MVP On Thu, 07 Jun 2007 04:19:52 GMT, Invalid <invalid@invalid.comINVALID> wrote: >How can I add numbers but ignore the minus signs? In the following, the >answer I'm after is 17 > >A1 -10 >A2 5 >A3 -2 > > Gord Dibben <gorddibbATshawDOTca> wrote in news:1o2f63pa84r8o6tdf65sa9ptpbv0nlt7u6@4ax.com: Thank you Gord. ----- > =SUMPRODUCT(ABS(A1:A3)) > > > Gord Dibben M...

missing namespace on root element of WCF proxy client
Hi, I have the following class that is exposed as a webservice method parameter parameter . [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:schemas.sequel.com/ genericImport")] [System.Xml.Serialization.XmlRootAttribute(Namespace="urn:schemas.sequel.com/ genericImport", IsNullable=false)] public partial class Schema { private Import importField; /// <remarks/> public Import Import { get { return this.importField; } set { this.importField = value; ...

Column Attributes
We have successfully reverse engineered an Entity Relationship Diagram into Visio. The tables are there with the column names but the column attributes are not showing up. What do we have to do to get the column attributes to show up??? Figured it out... Database ==> Options ==> Document ==> Table Tab...Data Types towards bottom...ensure the radio for Show Physical is checked. "wnfisba" wrote: > We have successfully reverse engineered an Entity Relationship Diagram into > Visio. The tables are there with the column names but the column attributes > are ...

Automatic Update application ignores permissions
I have a managed account on my computer - I've allowed the user to launch all Office applications except the Updater, Remove Office, and the Handheld Sync Installer. However, if the user clicks "Check for updates" in the Help menu in Word, the Updater application launches, and the AU daemon is put in the list of applications to startup on login. I guess this is the place to report such a bug - does anyone know how to prevent the user from launching the Updater application in this way? Does the user account have the "Allow Supporting Programs" box in the allow/disall...

Removing the default root attributes when serializing
In an application I'm making I've got a config object which I would like to serialize to the XML format in a .config file which would then be loaded the next time the application starts up using Configuration class. I've got all the elements and attributes correctly named but the default namespaces that get added when an object is serialized are causing the program to crash when it loads the .config file. These are the attributes I mean - xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" I know there are easier ...

Save excel as xml: null elements are missing #2
Hi, I am saving a xls file to xml data format, I use a xsd for the mapping. For some reasons the following happened: 1. On the output, the first line on the XML it says says <xml ... =91standalone =3D =93yes=94>. Is there anything I can set in xls, so that c= an be removed? 2. Some of the elements on the output is not shown when the Excel's cells is empty (not even the element's tag name) . I need those elements to appear even the cell is empty. Thanks in advance. Your help would be greatly appreciated. ...

Duplicate Detection Available Attributes
Hi, Can anybody confirm what attributes are availabe when checking for duplicates in CRM 4.0? Is it just text and number type attributes? We have a few scenarios where it would be useful to check that bit fields are equal but these fields are not selectable - is this by design? Kind Regards D ...

Changing Attributes in V2
I want to change barcodes types of the colours I know are incorrect. In version 1.3 of Store Ops Manager, rather than selecting each item one at time and changing the barcode type there was a quicker way of achieving this by filtering the colours. Although it’s set out differently, version 2.0 allows you to do this, but it doesn’t work properly. To make it easier I’ve made a step-by-step list below to explain what I’m doing. 1. I double click Matrix item, in this case WAL 6903(G) Isabel 2. I click Component items tab 3. Currently all colours are set to barcode type Interleaved 2 of 5, ...

Attributes
I backed up my October Outlook to a CD - the personal folders, archive, database - My system had to be restored. Now when I try to import or open the folders, there is a message that the disc is read only, I can't copy, move, change - do anything! I'm the owner of the computer and the disc and the data and the software! It was just a Staples CD-RW I saved to - I did nothing special to it - why does it have attributes now? I'm stuck and can't get to my all important contact data - I was able to get all my other backed up data on CDs- Word, Excel - an older version of...

CRM Attributes
It is possible to create a CRM attribute to allow a user to attach a file? I was looking through the list of attribute types, and they don't seem to have one that allows it. Brent no Brent, there is no such attribute type. Dave Ireland "Brent" <somebody@somewhere.com> wrote in message news:%23YnL4fCHKHA.1340@TK2MSFTNGP05.phx.gbl... > It is possible to create a CRM attribute to allow a user to attach a file? > I was looking through the list of attribute types, and they don't seem to > have one that allows it. > > Brent > I didn't thi...

Invisible attributes in an entity of common ownership
Is it possible in CRM to have some attributes in the same entity invisibles for a specific role and visible for another role? I am waiting for your answers! Thanks a lot! You could do this with client-side scripting. You would first need to invoke a web service to determine the role, then you could hide fields as appropriate. -- Matt Parks MVP - Microsoft CRM "Ioanna Karra" <IoannaKarra@discussions.microsoft.com> wrote in message news:0DAF6B19-D2DE-468A-A0E1-3CE1F2BB8E98@microsoft.com... Is it possible in CRM to have some attributes in the same entity invisibles for...

Export MS-Access report output
Hi! I would like to export some MS-Access reports output to pdf. However, the only possibility offered by Access (afaik) for me to export formatted output is snp (snapshot) (I use MS-Office XP Prof. 2002 version). With formatted output I mean the *exactly* output I produce from executing my report (information is gathered from an ODBC database). 1) Is there a way (e.g. using VBA) for me to export directly in pdf? 2) If not, where can I find a tool for me to convert snp to pdf (or other, that could be converted to pdf (e.g. MS-Word .doc))? Thanks in advance, JC Access won't make PD...

Copying data from formula output
I've used my concatenate formula to merge cells. Now I need to copy the cells to another workbook. When I paste, I get a ref#. What's up with that? Insteading of pasting, use Paste Special and select Values. That will "hard code" your formula results. -- Elisabeth "robin m" wrote: > I've used my concatenate formula to merge cells. Now I need to copy the cells > to another workbook. When I paste, I get a ref#. What's up with that? Thank you. It worked like a charm. "Elisabeth" wrote: > Insteading of pasting, use Paste Special an...

Data value display attributes linked to table attributes
Is there a way to cause data value points to take on attributes such as bold, italic or color set at the table from which they are derived? For example, suppose I was charting hits at several web sites as function of time, and the some characteristic of the site was being altered back and forth (say font "A" and font "B") as part of an experiment. I can easily produce a line graph x=hits y=time for the various sites, but these is no way to visualize which condition (A or B) was in effect at each data value point. I'd like to be able to display the portion of each li...

serialisation : remove defaut attribute
Hi Here is another EASY question When you serialise an object in .NET, serialisation adds defaut attributes that I dont care EXEMPLE : <root_test xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ....... .... </root_test> my class is : Public Class root_test .... end class I dont want these parameters... I just want this : <root_test>....</root_test> how can i do????? thanks for this answer Bye bye lobrys msnews.microsoft.com wrote: > Here is another EASY question > > Whe...

Ignoring Elements in XSD
How do I write a schema that is only validating elements: 1,4,7,8,9 and ignores every other element? I also need to not to care about the order of the elements or how many are in between elements that I am trying to validate. XML: <root> <element1 /> <element2 /> <element3 /> <element4 /> <element5 /> <element6 /> <element7 /> <element8 /> <element9 /> </root> XSD: <xs:element name="root"> <xs:complexType> ...

Problem: Attribute "border" exists, but can not be used for this element
hi asp.net 3.5 when validating my site I get the error mention in the subject of this post, here is the source code generating the problem. I mean thisis the source code taken from the browser: <span><input type="image" name="ctl00$Login2$LoginView1$Login1$Submit" id="ctl00_Login2_LoginView1_Login1_Submit" src="Images/Go.gif" alt="alt text is here" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Login2$LoginView1$Login1$Submit&quot;, &quot;&quot;, true, &...

attribute
I followed the guide in PCWorld to convert my Outlook from 2002 to 2003 attributes. When I looked at it the next day, it was back to 2002. "Asussertown" <DROPsusertown@adelphia.net> wrote in message news:%23KawWpzCGHA.1124@TK2MSFTNGP10.phx.gbl... >I followed the guide in PCWorld to convert my Outlook from 2002 to 2003 > attributes. When I looked at it the next day, it was back to 2002. > If you want help please remember that the newsgroup members where not party to whatever you were doing. What did you want to do? What exactly did you do? And what has happened...