Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-18
5
Medium Priority
?
1,106 Views
Last Modified: 2013-11-18
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?
0
Comment
Question by:capsoftuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33465669
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
0
 

Author Comment

by:capsoftuk
ID: 33466492
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.
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 33466614
why? since non breaking space is not supposed to be collapsed by normalize-space()
If they are in there, you will need to get them out one way or another

a template with text nodes will be active for all text nodes that are pushed out using apply-templates
if you have a value-of somewhere, that means end-point of processing... and you will not hit the template

but you can usually safely replace
<xsl:value-of select="."/> with <xsl:apply-templates/>
0
 

Author Comment

by:capsoftuk
ID: 33483531
Ah, so it doesn't work on nbsp, that I didn't know, and it of course explains everything.
Thank you!
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33483619
welcome
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question