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

Posted on 2004-11-03
Last Modified: 2008-02-26

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.


Question by:ca_roland
    LVL 19

    Accepted Solution

    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" />

    LVL 26

    Expert Comment

    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" />


    <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.

    Mike Sharp

    Author Comment

    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.

    Author Comment


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

    Anyway, I did get Japanese there.


    LVL 26

    Assisted Solution

    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:


    Mike Sharp

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    Title # Comments Views Activity
    Symfony2 > Accept incomming XML connection 2 33
    SVG, jquery, menu 14 54
    D3, Javascript, SVG, HTML canvas, div 2 75
    c#, split 12 68
    The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
    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.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now