[jdom-interest] HELP! I am new to JDOM, can I create and read XML documents that contains Japnese characters? Please reply soon, URGENT!! Thanks!

Angela Amoateng angela.amoateng at kcl.ac.uk
Sun May 20 13:04:24 PDT 2007


Hi Jason,

Thanks for your advice and so quickly! JDOM can read Japanese as long 
as its in unicode, that is great!

I am learning more about attributes and elements and which one would be 
best, when using methods to retrieve the Japanese word or English word.

What I meant by the equalTo method was that when a user entered in 
"apple", for example, via a Java GUI interface, I could some how pass 
this string value to JDOM, which will then scan for the "apple" in the 
XML document and then return the Japanese equivalent, "ringo". Is there 
such method(s)?

Conveying each set of words as you suggested as elements, seems to be a 
good idea, since I would want to break down what type of word it is, 
i.e. verb or noun or a phrase. Would this tree structure be best? :

<words>
   <noun>
     <english>apple</english>
     <japanese>ringo</japanese>
   </noun>

   ...

   <noun>
     <english>book</english>
     <japanese>hon</japanese>
   </noun>

   <verb>
     <english>eat</english>
     <japanese>tabemasu</japanese>
   </verb>

   ...

   <verb>
     <english>see</english>
     <japanese>mimasu</japanese>
   </verb>

   <phrase>
     <english>How are you?</english>
     <japanese>ogenki desuka</japanese>
   </phrase>

   ...

      <phrase>
     <english>Good bye</english>
     <japanese>sayonara</japanese>
   </phrase>
</words>

Would JDOM be able to read this and return the content in the elements, 
so that I could display it in a JTextfield?

Thanks again in advance!

Angela


Quoting Jason Hunter <jhunter at servlets.com>:

>> 1)Does  JDOM recognise and create an XML document containing 
>> Japanese characters, specifically Hiragana? How will I go about this?
>
> JDOM is based on Unicode characters, so that will work so long as the 
> characters are supported in Unicode.
>
>> 2) Can I create an XML document using JDOM, that will enable me to have an
>> "EqualsTo" function  for each word. For example, "apple" in Japanese 
>> is "ringo" so:
>
> You can create any XML document you like in JDOM.  I don't follow 
> what you mean by an EqualsTo function.
>
>> <word>apple = ringo <word>
>
> I'd probably do that this way:
>
> <word><english>apple</english><japanese>ringo</japanese></word>
>
> That makes the two words easier to fetch out.
>
>> 3) Also, if a string input (which would be a word of Japanese or 
>> English) from a Java GUI is entered, that string input could be 
>> compared to the list of words in the XML document and return the 
>> value it equals to. For example, if the user enters "apple" in a 
>> JTextfield, it will return the value "ringo"
>
> You could do that with XPath.
>
> //word[english = "apple"]/japanese
>
> -jh-
>



-- 
Angela Amoateng
angela.amoateng at kcl.ac.uk



More information about the jdom-interest mailing list