Solved

XSLT to encode the Nordic characters

Posted on 2004-09-08
5
767 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

773 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