=====On 2010-3-12 Raymond Feng wrote ======
>Hi,
>
>I tried your sample inside Eclipse (I had to change the file encoding to 
>UTF-8 in the "Property" pop-up dialog). 
>
>And I can see the result as:
><?xml version="1.0" encoding="UTF-8"?>
><ns:root xmlns:ns="http://ns";>中文</ns:root>

I tried the sample again,as exactly as you done in Eclipse. But it still
cannot save Chinese successfully. I have tried Tuscany SDO 1.1.1 Release and
the snap-shot source from SDO 's SVN. They both have same error;

So could you tell me which version sdo you are using? And could you help me
send your eclipse project ?

>package test;
>
>import org.junit.Assert;
>
>import commonj.sdo.DataObject;
>import commonj.sdo.helper.XMLDocument;
>import commonj.sdo.helper.XMLHelper;
>
>public class TestChinese {
>    public static void main(String[] args) {
>        String s =
>            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:StringE 
>xmlns:ns=\"http://test/choice\";>中文</ns:StringE>";
>        XMLDocument doc = XMLHelper.INSTANCE.load(s);
>        DataObject o = doc.getRootObject();
>
>        //here we'll load the xml success; and the assertion will passed
>        // 
>Assert.assertTrue(((SimpleAnyTypeDataObjectImpl)o).getValue().toString().in
>d
>exOf("中文") >= 0);
>
>        String xml = XMLHelper.INSTANCE.save(o, "http://ns";, "root");
>        //assertion failed, here we'll got a xml (using utf-8 encoding) 
>contains  error character code.
>        Assert.assertTrue(xml.indexOf("中文") >= 0);
>        System.out.println(xml);
>
>    }
}
Thanks,
Raymond

--------------------------------------------------
From: "ext2" <x...@tongtech.com>
Sent: Thursday, March 11, 2010 4:47 AM
To: <user@tuscany.apache.org>
Subject: Tuscany SDO-Java implementation failed to save sdo(contains 
multi-byte character) to xml

> Hi
> The tuscany sdo 's java implementation can load xml (contains
> muti-byte code) correct. But cannot save the sdo (has Chinese character
> value) to xml correctly;
>
> For example:
> I could load a xml(utf-8 encoding specified) which contains Chinese
> character to sdo correctly. But it will failed to save it to xml (using
> utf-8 encoding).
>
> I have ensured using correct "javac -encoding " to compile the
> source java file.
>
> Code sample:
>
> String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns:StringE
> xmlns:ns=\"http://test/choice\";>中文</ns:StringE>";
> XMLDocument doc= scope.getXMLHelper().load(s);
> DataObject o = doc.getRootObject();
>
> //here we'll load the xml success; and the assertion will passed
>
assertTrue(((SimpleAnyTypeDataObjectImpl)o).getValue().toString().indexOf("
> 中文") >= 0);
>
> String xml = scope.getXMLHelper().save(o,  uri, name);
> //assertion failed, here we'll got a xml (using utf-8 encoding) contains
> error character code.
> assertTrue(xml.indexOf("中文") >= 0);
>
>
> 




Reply via email to