Hi, bjorsq: Thanks a lot for your help. Please open the following page, to see whether the Chinese characters are displayed: http://www.pinyinology.com/test/span3.html
The characters in the table in that page are directly entered with Chinese IME, instead of unicode. About a year ago, a great programmer in this group helped me with a project by writing a wonderful code. http://www.pinyinology.com/test/characters.svg I wish this great person is still here with us. I've placed the code you wrote for me in the svg file. It needs more modification to display the ideographs: http://www.pinyinology.com/test/chinese4.svg Thanks again. Fulio ----- Original Message ---- From: bjorsq <[EMAIL PROTECTED]> To: svg-developers@yahoogroups.com Sent: Wednesday, September 10, 2008 6:15:51 AM Subject: [svg-developers] Re: Insert Chinese ideographic writing in svg file Hi Fulio, The code you posted has no chance of working in SVG because innerText is not part of the SVG DOM - you need to first clear all the children of the group, then create and append a new text element to it. Also, your function is not called in the page, so has no chance of firing - I would use the onload handler of the svg element to call it like this: <svg width="100%" height="100% " version="1.1" xmlns="http://www.w3. org/2000/ svg" onload="writeText( evt);"> You then need something like this to do what you want: function writeText(evt) { /* SVG namespace */ var svgns = "http://www.w3. org/2000/ svg"; /* get a reference to the SVG document element */ var svgDoc = evt.target.ownerDoc ument; /* map element ids and chinese chars */ var map = {'moon': 'hello &x6708;', 'tree': '&x6728;', 'man': '&x4eba;', 'water': '&x6c34;'}; for (el_id in map) { /* get the g element */ var el = svgDoc.getElementBy Id(el_id) ; /* clear the children of the g element */ if (el.hasChildNodes( )) { while (el.childNodes. length >= 1) { el.removeChild( el.firstChild) ; } } /* create a new text element */ var textel = svgDoc.createElemen tNS(svgns, "text"); /* create a text node for the text content */ var text = svgDoc.createTextNo de(map[el_ id]); /* append the text node to the text element */ textel.appendChild( text); /* append the text element to the g element */ el.appendChild( textel); } } However, this doesn't work for a number of reasons - your HTML example did not work in my browser - the unicode characters could not be displayed - I guess I would have the same problem in SVG. Also, the text element in the above example is not styled in any way, so takes on the style of its parent g element - you could add styles using textel.setAttribute NS(null, name, value). I hope the above helps you get a little further with your problem. --- In svg-developers@ yahoogroups. com, Fulio Pen <[EMAIL PROTECTED] .> wrote: > > hello, > > I am trying to replace the English object names in an svg file with Chinese ideographic writing. My purpose to compare the > > features of English and Chinese writing. Following is the svg file: > > http://www.pinyinol ogy.com/test/ chinese2. svg > > > And following is the code which is already in the svg file: > > > <script type="text/javascri pt"> > function chinText() > { > document.getElement ById("moon" ).innerHTML = "\u6708"; > document.getElement ById("tree" ).innerHTML = "\u6728"; > document.getElement ById("man" ).innerHTML = "\u4eba"; > document.getElement ById("water" ).HTML = "\u6c34"; > } > </script> > > I tested the above code in an > html page. It works. But I don't know how to implement the code in the svg file. Following is the html page: > > http://www.pinyinol ogy.com/test/ span2.html > > I hope someone can help me. Thanks for your expertise. > > Fulio Pen > > > > > [Non-text portions of this message have been removed] > [Non-text portions of this message have been removed] ------------------------------------ ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ----Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/