• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Newbie Question

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I wanted to ask a very basic question. I have a java object and i want to serialize it as an xml file. How should i do it
a) Create a new document using DOM and then serialize it using XSLT
b) Create the xml file by simply writing data (along with the tags) to a file.
Pls. suggest.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

a) Create a new document using DOM and then serialize it using XSLT
b) Create the xml file by simply writing data (along with the tags) to a file.


Following the simplest thing that could possibly work principle, I'd say b) is a better option. Especially when I don't quite see why you would need to use XSLT for serializing a DOM tree into disk as XML...?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



use XSLT for serializing a DOM tree into disk as XML...?


With JAXP 1.1, this was the only way to serialize XML documents I guess.
Not sure if JAXP1.2 has added a standard way of serializing XML documents though.
On a side note I wonder if JAXP has been a huge success and if people have been doing XML processing on top of JAXP :roll:
I beleive there are always situations when we are better off using processor specific features. Can anybody share their views?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

With JAXP 1.1, this was the only way to serialize XML documents I guess.


Ok. I think you guys are talking aboutRight?
I didn't consider that as being "XSLT" (which I associate to "having an .xsl file")...
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, i meant identity transformation only.
 
Tomchi Tang
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Now i am convinced that DOM is a better option. On a little bit of research, I found there is another option available - JDom. What do you guys think about it - JDOM or DOM + XSLT.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would probably stick to "DOM + XSLT" over JDom just to avoid adding yet-another third party library into the project but instead use a portable, standard piece of code.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic