Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re:   issue when transforming

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 5/7/2008 5:29:00 PM

Lance Johnson wrote:
> We are currently using the XslCompiledTransform class to transform an 
> xml file, but we're getting this strange a character with a hat over it 
> (Â). When I look at the xsl the part that is causing this has something 
> like this:
> <span>
>             <xsl:text>&#160;</xsl:text>
> </span>

Well the issue is perhaps not with the XSLT stylesheet but rather how 
you look at or display the transformation result. The code below writes 
to a HTML document. How do you display that document?
How does the xsl:output element in your stylesheet look? Does the HTML 
document the stylesheet generates have a
   <meta http-equiv="Content-Type" content="text/html; charset=somecharset">
element in the head?


> //create the output stream
> using (XmlTextWriter myWriter = new XmlTextWriter("output.html", null))
> {
>    using (XmlWriter xmlWriter = XmlWriter.Create(myWriter, 
> trans.OutputSettings))
>    {
>        //do the actual transform of Xml
>        trans.Transform(doc, null, xmlWriter);
>    }
> }

Drop the outer XmlTextWriter, simply use

    using (XmlWriter xmlWriter = XmlWriter.Create("output.html", 
trans.OutputSettings))
    {
        //do the actual transform of Xml
        trans.Transform(doc, null, xmlWriter);
    }

that way you ensure that the meta element in the HTML document that is 
generated and the encoding of the document match.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent