Solved

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

Posted on 2010-08-18
5
1,091 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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