Link to home
Start Free TrialLog in
Avatar of capsoftuk
capsoftukFlag for United Kingdom of Great Britain and Northern Ireland

asked on

XSL transform (C# Visual Studio) from xml to html converting   to ?

XSL version 1.0, can't change to 2.0 at the moment because of Visual Studio I believe.

Converting html code from an xml document with a few minor edits to straight html output.
There are many places in the source file where there are series of  s, I've tried calling normalize-space on the text as it's being processed but this doesn't appear to make a blind bit of difference.

The source xml file is ANSI.
I've tried the xsl file's own encoding and the output encoding as windows-1252 but it doesn't help.

I've also got the encoding for the XmlTextWriter for the transform output set to ASCIIEncoding in the C# code.

Any suggestions?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

make a general template for text nodes()
in which you do
<xsl:value-of select="normalize-space(translate(., '&#160;', ' ')"/>

or run that on every value-of you have
Avatar of capsoftuk

ASKER

That's my last resort but I'd like to understand why it's happening.
I'm sure it's something to do with the encoding.

Should <template select="text()"> run it for for all text nodes?
I've tried doing that and debugging the xsl but it doesn't seem to be picking up the text from inside paragraph tags, just stray text and spaces that are inside div tags.
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, so it doesn't work on nbsp, that I didn't know, and it of course explains everything.
Thank you!