[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to translate Japanese character contained in XML by XSL to HTML

Posted on 2004-11-03
7
Medium Priority
?
364 Views
Last Modified: 2008-02-26
Experts,

I have a problem.

I created a web interface which is required to allow japanese input and insert the text into SQL server 2000 DB.

The XML, returned by the SP that get data from DB, is able to retrieve the Japanese Text and showing them in my debug page, even without using nVarchar data type at Field.

However, seems my current XSL can not represent what we have got in the XML by display the gibberish like
は進行 ....

Now, on the header of my current XSL has this :

<xsl:output method="html" encoding="iso-8859-1" indent="yes" doctype-public="-//W3C//DTD HTML 3.2 Final//EN" />

And in this XSL file there're a lots of logic,switching between multiple Language (including japanese) based on the user profle, to display messages in those languages hard coded there.

Could you guys help me figure out a way to represent the Japanese Text from the Backend which already correctly contained in the XML in the current context.

Thanks

0
Comment
Question by:ca_roland
  • 2
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
ramazanyich earned 1000 total points
ID: 12488574
the main problem here is defined encoding="iso-8859-1" attribute. It means that your japanese characters will not be shown because that encoding supports only western european character sets. In your case or it should be UTF-8 or it should be your japanese character encoding.
try to set:
<xsl:output method="html" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD HTML 3.2 Final//EN" />


0
 
LVL 26

Expert Comment

by:rdcpro
ID: 12488620
Well, you're sure not going to represent any Japanese characters using iso-8859-1.  What you're seeing is the processor trying to   It's no trouble at all using XSLT to simultaneously represent Japanese characters along with any other locale-specific characters.  Life would be a lot easier if you used Unicode; either UTF-16 or UTF-8.  If you have lots of asian characters, UTF-16 is more compact than UTF-8.  

<xsl:output method="html" encoding="utf-16" indent="yes" doctype-public="-//W3C//DTD HTML 3.2 Final//EN" />

or

<xsl:output method="html" encoding="utf-8" indent="yes" doctype-public="-//W3C//DTD HTML 3.2 Final//EN" />

As long as this XSLT outputs the entire HTML page (including HTML and HEAD tags),  your browser should be able to handle the encoding correctly.  If there are problems, you may have to add a meta tag to the HTML.  Make sure your web server, whatever it is, is using the same response encoding.  

I would still use nText and nVarChar in my database, though.

If you're still having problems, let me know.  Encoding issues can be a PITA to solve, but they are solveable.

Regards,
Mike Sharp
0
 

Author Comment

by:ca_roland
ID: 12493326
Thank you for your quick response.

However, the updates of "encoding=" does not take any effects.

Again I got this in XML : <sChildTitle><![CDATA[&#12399;&#36914;&#34892;&#20013;&#12391;&#12377; ]]></sChildTitle>

However, after XSL processing I got : &#12399;&#36914;&#34892;&#20013; ....

Thank you in advance for our help.
0
 

Author Comment

by:ca_roland
ID: 12493346
Sorry.

After submitting my comments the Japanese Text <sChildTitle> is changed.

Anyway, I did get Japanese there.

Thanks



0
 
LVL 26

Assisted Solution

by:rdcpro
rdcpro earned 1000 total points
ID: 12498150
Oh, well this isn't going to get parsed into the characters at all:

<sChildTitle><![CDATA[&#12399;&#36914;&#34892;&#20013;&#12391;&#12377; ]]></sChildTitle>

Because of the CDATA section.  This will render the characters:

<sChildTitle>&#12399;&#36914;&#34892;&#20013;&#12391;&#12377;</sChildTitle>


Regards,
Mike Sharp
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 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