Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-08-18
5
Medium Priority
?
1,111 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

783 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