• Post Reply Bookmark Topic Watch Topic
  • New Topic

Xstream mapping for complex xml string to flatenned object.  RSS feed

 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i just started playing with xstream.
i have an xml stream string which i have to convert to a flattened bean.
my xml message is




when extreme converts this into a bean it maps to an object graph. So my question object will have id, answerCount,url,publicationtime as properties defined.
Again i have a TopAnswer object which have its its meta data.

i wanted all this information to be transformed into a single flat object.
my proposed Question object will be flat and it will have properties like
id, answerCount,url,publicationtime,answerId,answerPublicationTime etc...
how do i provide this kind of complex xml message into a single flat bean.

Any help will be appreciated.

Thanks
darniz
 
Darvesh Niz
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok after reading more document i was able to flatten out the object.
Just wanted to make sure is this the correct way of doing it.

I still have the class structure defined and pass the xml.
I implemented a class which implements convertor interface and in the unmarhall method i am returning my own flattened objects.
This is what i am doing.


and in the QuestionsConvertor class in the unmarshal method i am returning a list of flattened QuestionItem objects.



Is there any other better way

please let me know

Thanks
darniz




 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!