Well my scenario is:
I have a web service that take a String parameter, this String represents a
XML and this a pojo class (A). I need parse this XML parameter in the server
side parse it and add/remove/modify elements if I need:
webServiceMethod(String xml){
A a = convertStringXmlToPojo(xml) / or / XmlObject xobj =
convertStringXmlToXmlObject(xml)
parse a / or / parse xobj (check add/modify/remove...)
String res = converPojoToString(a) / or / res =
convertXmlObjectToString(xobj)
return res
}
Vinh Nguyen (vinguye2) wrote:
>
> Imorales,
> I think what you want is to automatically convert a POJO into an XML
> string, right? That way, you can convert the XML string into an
> XmlObject?
>
> Not sure why you need to do that if you can already work with the POJO
> directly.
>
> Other than that, as Paul pointed out, you can use XStream to automatically
> deserialize your POJO to XML. Then, you should be able to convert the XML
> into an untyped XmlObject. But, you probably would only use the XmlObject
> for traversing the XML tree. You won't have methods like getB() and
> setB() since you aren't generating the XmlObject from a predefined schema.
>
>
>
> -----Original Message-----
> From: Paul French [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 06, 2007 11:53 AM
> To: [email protected]
> Subject: RE: xmlbeans beginner - help
>
> XStream does exactly what you want.
>
> Paul
>
> -----Original Message-----
> From: Wing Yew Poon [mailto:[EMAIL PROTECTED]
> Sent: 06 November 2007 19:34
> To: [email protected]
> Subject: RE: xmlbeans beginner - help
>
> imorales,
> I think you're looking for something that XMLBeans is not designed for.
> It sounds like you want to start with a POJO class and somehow
> automagically get something like an XmlObject out of it. There is no
> mechanism to do that.
> What Cezar wrote about is the capability of XMLBeans to parse xml without
> a schema to get an untyped XmlObject. So if you are getting xml from
> somewhere, you can turn that xml into an XmlObject. But it sounds like
> you're looking for something else.
> - Wing Yew
>
> -----Original Message-----
> From: imorales [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 06, 2007 7:41 AM
> To: [email protected]
> Subject: RE: xmlbeans beginner - help
>
>
> Yes I know but, can I convert a simple java class A to a XmlObject
> without
> schema ?
>
> Albert Bupp wrote:
>>
>> He means the XmlObject class which you'll find in the XmlBeans
> library.
>>
>> -Albert
>>
>> At 10:27 AM 11/6/2007, you wrote:
>>
>>>That sounds good but, I don´t have a XmlObject, I have a simple pojo
> (class
>>>A) and i want to convert it to XmlObject, my class A have to
> implements
>>>XmlObject ? How can I do this ??
>>>
>>>Cezar Andrei wrote:
>>> >
>>> > It is possible, but a little less forward that using schema. Just
> use
>>> > XmlObject, it handles all un-typed XML in XMLBeans.
>>> >
>>> > Use XmlObject xo = XmlObject.Factory.parse(xmlText) to load the xml
>>> into
>>> > XmlObject.
>>> > And String xmlText = xo.xmlText() to get back to xml.
>>> >
>>> > To navigate/read/modify the XmlObject without a schema, you have to
> use
>>> > either the cursor xo.newCursor() or the DOM xo.newDomNode().
>>> >
>>> > Cezar
>>> >
>>> >> -----Original Message-----
>>> >> From: imorales [mailto:[EMAIL PROTECTED]
>>> >> Sent: Tuesday, November 06, 2007 8:50 AM
>>> >> To: [email protected]
>>> >> Subject: RE: xmlbeans beginner - help
>>> >>
>>> >>
>>> >> Is there any way to get from Java classes without XML schema and
> vice
>>> >> versa?
>>> >>
>>> >> Thanks.
>>> >>
>>> >> Schalk Neethling-4 wrote:
>>> >> >
>>> >> > You will more then likely have to start with a schema. So define
>>> your
>>> >> > schema and the from this generate your XMLBean which will give
> you
>>> >> object
>>> >> > A, you can then populate object A using the set methods that
> will be
>>> >> > generated and once you have the completed object you can invert
> it
>>> into
>>> >> a
>>> >> > XML string with one step by calling A.xmlText();
>>> >> >
>>> >> > HTH!
>>> >> >
>>> >> > Regards,
>>> >> > Schalk Neethling
>>> >> >
>>> >> > -----Original Message-----
>>> >> > From: imorales [mailto:[EMAIL PROTECTED]
>>> >> > Sent: 06 November 2007 11:29 AM
>>> >> > To: [email protected]
>>> >> > Subject: xmlbeans beginner - help
>>> >> >
>>> >> >
>>> >> > Hi is my first time using xmlbeans and I hava a couple of
> question,
>>> I
>>> >> > explain
>>> >> > my scenario and I would like someone to resolve my ignorance
> about
>>> >> > xmlbeans.
>>> >> >
>>> >> > Well I hava a pojo class:
>>> >> >
>>> >> > ------------------------------------------
>>> >> > public class A{
>>> >> > private String b;
>>> >> >
>>> >> > public A(){}
>>> >> >
>>> >> > public String getB(){ return b;}
>>> >> > public void setB(String b){this.b = b;}
>>> >> > }
>>> >> > ------------------------------------------
>>> >> >
>>> >> > I´m using a web service that takes one parameter (String), this
>>> >> parameter
>>> >> > is
>>> >> > the XML associated to the class A. My question is how I can
> using
>>> >> xmlbeans
>>> >> > conver one object A to a XML and then to String. I have no
> schema to
>>> do
>>> >> > this
>>> >> > and I don´t know if is necessary.
>>> >> >
>>> >> > Thanks in advance.
>>> >> >
>>> >> > --
>>> >> > View this message in context:
>>> >> >
>>>
> http://www.nabble.com/xmlbeans-beginner---help-tf4756991.html#a13603299
>>> >> > Sent from the Xml Beans - User mailing list archive at
> Nabble.com.
>>> >> >
>>> >> >
>>> >> >
>>> ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> >> > For additional commands, e-mail: [EMAIL PROTECTED]
>>> >> >
>>> >> >
>>> >> > This email and all content are subject to the following
> disclaimer:
>>> >> >
>>> >> > http://content.momentum.co.za/content/legal/disclaimer_email.htm
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> ---------------------------------------------------------------------
>>> >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> >> > For additional commands, e-mail: [EMAIL PROTECTED]
>>> >> >
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> View this message in context:
>>> http://www.nabble.com/xmlbeans-beginner---
>>> >> help-tf4756991.html#a13608035
>>> >> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >>
> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>>> >
>>> >
>>> > Notice: This email message, together with any attachments, may
> contain
>>> > information of BEA Systems, Inc., its subsidiaries and
> affiliated
>>> > entities, that may be confidential, proprietary, copyrighted
> and/or
>>> > legally privileged, and is intended solely for the use of the
>>> individual
>>> > or entity named in this message. If you are not the intended
> recipient,
>>> > and have received this message in error, please immediately return
> this
>>> by
>>> > email and then delete it.
>>> >
>>> >
> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> > For additional commands, e-mail: [EMAIL PROTECTED]
>>> >
>>> >
>>> >
>>>
>>>--
>>>View this message in context:
>>>http://www.nabble.com/xmlbeans-beginner---help-tf4756991.html#a1360887
> 5
>>>Sent from the Xml Beans - User mailing list archive at Nabble.com.
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/xmlbeans-beginner---help-tf4756991.html#a13609293
> Sent from the Xml Beans - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> Notice: This email message, together with any attachments, may contain
> information of BEA Systems, Inc., its subsidiaries and affiliated
> entities, that may be confidential, proprietary, copyrighted and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/xmlbeans-beginner---help-tf4756991.html#a13622912
Sent from the Xml Beans - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]