• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie Question

 
Tomchi Tang
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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...?
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yes, i meant identity transformation only.
 
Tomchi Tang
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic