|
|
Subject: Re: Migrating from castor to XMLBeans - msg#00108
List: text.xml.xmlbeans.user
If you don't have schemas defined for your XML and have already existing beans use:
http://xstream.codehaus.org/
Giedrius
On 10/21/05, Zhong ZHENG < heavyzheng@xxxxxxxxx> wrote:
Hi there,
I have a project that uses castor to do the xml-java data binding.
I am planning to migrate from castor to XMLBeans. What i need is to
marshall an XML file to java beans, and unmarshall java beans to an XML
file. The format of my XML files is quite simple, and i didn't use
schemas. The java beans are already coded and i do not want to use
generated classes. I checked the documenations of XMLBeans, but
did not find any articles or samples about simple
marshalling/unmarshalling. (Perhaps i am not patient enough). I would
like to know, may the XMLBeans project meet my requirements?
I am completely new to XMLBeans. May someone tell me if i am
in the correct way to migrate from castor to XMLBeans? Or if i'd better
keep playing with castor?
All your suggestions are appreciated. Thanks in advance.
-- ZHENG Zhong 1 Avenue Alphand 75116 Paris, France +33 6 76 80 45 90
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
RE: write an xmlbean to string: creating xmlns:xsi and the like
Thanks, Maarten!
I've put it on my todo list to add your sample to the FAQ,
Radu
-----Original Message-----
From: maarten [mailto:maartenb@xxxxxx]
Sent: Tuesday, October 18, 2005 12:41 AM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: Re: write an xmlbean to string: creating xmlns:xsi and the like
Michael Wirz wrote:
>Hello List,
>I am using xmlbeans to create an xml document, the bean is named
>RequestDocument as below:
>
>RequestDocument reqDoc = RequestDocument.Factory.newInstance();
>RequestType request = reqDoc.addNewRequest();
>
>I then fill all the members and do a
>
>String dataString = reqDoc.xmlText();
>
>The document element shows up as
>
><mpc:Request xmlns:mpc="http://www.xyz.de/test">
>
>I'd like it to show up as
>
><mpc:Request xmlns:mpc="http://www.xyz.de/test"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xsi:schemaLocation="http://www.xyz.de/test
>http://www.xyz.de/test2/mpcdta_1.0.xsd ">
>
>How do I do this with the XMLBeans API ?
>At the moment it is some ugly string/substring/indexof stuff...
>
>Thanks a lot for help!
>Michael Wirz
>from near Munich, Germany
>
>
>
>
This should go into the FAQ:
protected void addSchemaLocation(XmlObject xmlObject, String location) {
XmlCursor cursor = xmlObject.newCursor();
if (cursor.toFirstChild()) {
cursor.setAttributeText(
new
QName("http://www.w3.org/2001/XMLSchema-instance","schemaLocation"),
location);
}
}
Maarten
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: user-help@xxxxxxxxxxxxxxxxxxx
Next Message by Date:
click to view message preview
Re: Migrating from castor to XMLBeans
Hi,
Thanks for your advice. But the format of my XML file is already
defined, although i did not create schemas. If necessary, i may create
schema for my XML. But i do not want to use XMLBeans-generated classes.
So is it possible to do the data binding by using my own java beans?
Regards.On 10/22/05, Giedrius Trumpickas <trumpyla@xxxxxxxxx> wrote:
If you don't have schemas defined for your XML and have already existing beans use:
http://xstream.codehaus.org/
Giedrius
--
ZHENG Zhong
1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90
Previous Message by Thread:
click to view message preview
Migrating from castor to XMLBeans
Hi there,
I have a project that uses castor to do the xml-java data binding. I am planning to migrate from castor to XMLBeans. What i need is to marshall an XML file to java beans, and unmarshall java beans to an XML file. The format of my XML files is quite simple, and i didn't use schemas. The java beans are already coded and i do not want to use generated classes. I checked the documenations of XMLBeans, but did not find any articles or samples about simple marshalling/unmarshalling. (Perhaps i am not patient enough). I would like to know, may the XMLBeans project meet my requirements?
I am completely new to XMLBeans. May someone tell me if i am in the correct way to migrate from castor to XMLBeans? Or if i'd better keep playing with castor?
All your suggestions are appreciated. Thanks in advance.
-- ZHENG Zhong1 Avenue Alphand75116 Paris, France+33 6 76 80 45 90
Next Message by Thread:
click to view message preview
Re: Migrating from castor to XMLBeans
Hi,
Thanks for your advice. But the format of my XML file is already
defined, although i did not create schemas. If necessary, i may create
schema for my XML. But i do not want to use XMLBeans-generated classes.
So is it possible to do the data binding by using my own java beans?
Regards.On 10/22/05, Giedrius Trumpickas <trumpyla@xxxxxxxxx> wrote:
If you don't have schemas defined for your XML and have already existing beans use:
http://xstream.codehaus.org/
Giedrius
--
ZHENG Zhong
1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90
|
|