| Author |
Newbie Question
|
Tomchi Tang
Greenhorn
Joined: Apr 25, 2003
Posts: 15
|
|
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
Joined: Jan 23, 2002
Posts: 11962
|
|
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...?
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Karthik Guru
Ranch Hand
Joined: Mar 06, 2001
Posts: 1209
|
|
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
Joined: Jan 23, 2002
Posts: 11962
|
|
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
Joined: Mar 06, 2001
Posts: 1209
|
|
|
Yes, i meant identity transformation only.
|
 |
Tomchi Tang
Greenhorn
Joined: Apr 25, 2003
Posts: 15
|
|
|
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
Joined: Jan 23, 2002
Posts: 11962
|
|
|
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.
|
 |
 |
|
|
subject: Newbie Question
|
|
|