Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Wed, 7 May 2008 10:14:40 -0500,    group: microsoft.public.xml        back       


  issue when transforming   
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>

So I guess I'm trying to figure out why it's happening and how we can get 
around this.  Here's the code I'm currently using.  If I try this with a 
memory stream and dig into it I see a character with ascii code 160 and 
that's causing the display issue.

XmlDocument doc = new XmlDocument();
doc.LoadXml(_XmlInfo);

XslCompiledTransform trans = new XslCompiledTransform();
trans.Load("ccr.xsl");

//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);
    }
}
date: Wed, 7 May 2008 10:14:40 -0500   author:   Lance Johnson

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

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us