Solved

XSLT to encode the Nordic characters

Posted on 2004-09-08
5
780 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
[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
  • 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

Independent Software Vendors: 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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:

738 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