Solved

XSLT to encode the Nordic characters

Posted on 2004-09-08
5
754 Views
Last Modified: 2013-12-03
Hello experts,
Can any of you give a piece of code in xslt using CDATA which can be used to convert nordic characters.

I am sure that you all will know how the nordic characters will look. I need to encode them to be displayed correctly.
I can also do so by changing the encoding format to UTF-8. But i am not allowed to change the encoding standard.

I want a xslt which can do the above.


Thanks in advance,
bhalpa
0
Comment
Question by:bhalpa
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:rdcpro
ID: 12007371
CDATA isn't going to help you here--it's merely a way of using characters that would otherwise be considered markup, like < and >.  

To display them, you need two things:

1.  text in an encoding that contains code points for the characters you want to use.  

2.  A system installed font that contains glyphs representng those characters.


What encoding does your XML use?  What encodings are you "allowed" to use?  Frankly UTF-8 or UTF-16 would be good choices, but if not, use one of the latin encodings, like ISO-8859-15.

Regards,
Mike Sharp
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 12013361
you can replace all nordic characters to their entities, if document encoding doesn't contain code points for it, but you still need font with right glyphs.
0
 

Author Comment

by:bhalpa
ID: 12131440
Hi dualsoul,

Yes I need to replace all nordic characters to their entities. Can you give me an example of doing so? I would appreiciate if the answer is given ASAP.

Thanks in advance,
Bhalpa

0
 
LVL 26

Accepted Solution

by:
rdcpro earned 125 total points
ID: 12137034
What encoding are you using??   If the encoding is messed up (say, because you're using ISO-8859-1), then you're using the wrong encoding.  If you want Nordic characters, and for some reason you want an ISO character set, use ISO-8859-10.  

You say you can't change the encoding, but you haven't said what encoding that you are using--it may not need to be changed.  

To use a character entity represention of any character, nordic or otherwise, you use &#x[HEXCODE];

For example, the 27th, 28th and 29th characters in Norway and Swedish alphabets are:

Norway
æ = &#x00E6;
Æ = &#x00C6;
ø = &#x00F8;
Ø = &#x00D8;
å = &#x00E5;
Å = &#x00C5;

Sweden
å = &#x00E5;  
Å = &#x00C5;
ä = &#x00E4;
Ä = &#x00C4;
ö = &#x00F6;
Ö = &#x00D6;


The HTML codes for these are:

æ = &aelig;
Æ = &AElig;
ä = &auml;
Ä = &Auml;
ø = &oslash;
Ø = &Oslash;
ö = &ouml;
Ö = &Ouml;
å = &aring;
Å = &Aring;

But of course you can't use HTML entities in XML.

But, you really need to provide us with more information.  You don't "Convert" nordic characters...they are simply code points in a particular encoding.  What is it you're trying to accomplish?

Regards,
Mike Sharp
0
 

Author Comment

by:bhalpa
ID: 12521843
Hi expert,

I don't want to use Nordic char in my web page. The actual scenario is like this. We get a search result as xml file which will have these charecters. When i try to transform using xslt it gives me an error cannot parse this.

I need to tell the parser that if it encounters the nordic chac, replace them with the english char and then move on
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

758 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

18 Experts available now in Live!

Get 1:1 Help Now