|
|
|
date: Wed, 7 May 2008 10:14:40 -0500,
group: microsoft.public.xml
back
Re: issue when transforming
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> </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/
date: Wed, 07 May 2008 17:28:36 +0200
author: Martin Honnen
Re: issue when transforming
Thanks for the feedback. It looks like the XmlTextWriter was doing
something screwy when it encountered that. Duh!!! But after doing what you
said it's looking good.
Lance Johnson
"Martin Honnen" wrote in message
news:uewUGcFsIHA.2292@TK2MSFTNGP03.phx.gbl...
> 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> </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/
date: Wed, 7 May 2008 10:50:00 -0500
author: Lance Johnson
|
|