Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Difference between transformNode and transformNodeToObject with respect to character encoding Difference between transformNode and transformNodeToObject with respect to character encodingTo: NULL Date: 1/6/2007 6:02:00 AM Hi, Yesterday I had an interesting bug in a piece of code that applied a stylesheet to a XML document. The input document used some "special" characters (specifically the symbol for micro - which was specified in the input XML as µ). The stylesheet was being used to convert the input XML to Excel's SpreadsheetML. To make a long story short, the micro used to disappear when viewed from XML. We we using ActiveX and MSXML 4.0. We spent almost half a day trying to figure out what was going wrong, and finally tracked it down the code that applied the stylesheet - the buggy code used to look like this ... outXMLString = inputDoc.transformNode(stylesheet) ' Code to write outXMLString to a file ... The input XML was something like this: (The micro was being used as in the unit Micro Amperes) <Stuff> <Data> µA </Data> </Stuff> And the XSLT was something like this: ... <xsl:value-of select="./Data" /> ... The problem was that the µ used to come out as a single character. (A lot of digging around revealed that you need two characters to represent micro - C2 B5 rather than just B5 - btw B5 is 181 represented in hex) Some applications - like Excel - would just pretend that the character wasn't there. Some others - like Visual Studio, Firefox would show a helpful little question mark instead of the character - and some others - like VIM would actually render it as micro. Me not knowing too much about character encodings - having dealt with ASCII all my life - was about as confused as I could. But after trying this, that and everything else, with thanks some kind hearted souls on Usenet, found that changing the code that applied the stylesheet to look like this: ... inputDoc.transformNodeToObject(stylesheet, outputDoc) outputDoc.save(filename) ... would fix the problem. My question to any wise and helpful souls out there is pretty simple: Why does this work, while the old one doesn't? My current guess is that this has something do with how the string coming out transformNode is encoded, but I don't really understand the details. Can you guys help out please? | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
