Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now