• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I convert jaxb objects into xml without indentation

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to generate output xml look like the below one using jaxb.

<Item><CODE>605358</CODE><CDATE>03/26/2010</CDATE><IAMT>50.6</IAMT><IDISC>0</IDISC></ITEM>

but it generates jabx like this, the other application is not able streaming this completely rather it does partially.
<Item>
<CODE>605358</CODE>
<CDATE>03/26/2010</CDATE>
<IAMT>50.6</IAMT>
<IDISC>0</IDISC>
</ITEM>

I have tried setting jaxb property but no results.
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, false);

Please throw some light on this.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't be concerned about how the Item element "looks." If you really care about this trivial detail then you can easily write a XSL program that outputs the Item markup without carriage return and line-feed characters.
 
Ramamoorthy Govindaraj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I have to do few things in the existing application to make it working rather writing new piece of functionality. I have to go XSL if no way.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


From my quick (10 seconds) Google search it appears that this causes the generated XML to be formatted for human readability. You have said you don't want that. So try removing this line of code. Or set the property to false instead of true.
 
Ramamoorthy Govindaraj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already tried that. But no luck. Now I am trying to set properties on OutputFormat class. it is generating completely in a single line. if i set the below properties
outputFormat.setPreserveSpace(false);
outputFormat.setIndenting(false);

I am not sure this will work out. I will try using the application. Meanwhile, I look for other option similary doing simple changes.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic