I wanted to know why DocumentBuilderFactory is really needed. So i went here. Don't go to that link.
That link talks about Document. To read about it, I went here.
I read the document and did not understand a word of it. There is no plain english explanation for it. . Don't even think about thinking why the normalize() method is there in the code.
So, I am wondering -
Am I thinking too much ? Should developers understand the purpose of each line of code ? Or is it just important to "get the work done" without having good fundamentals ?
Should I become a developer who copy pastes and just understands a little bit ? The boss won't reward me for being a knowledgeable guy. He/she will only care if a product
is created and put to market. Okay, maybe there is no need to go into every method and see how its implemented, but one should know why a line of code is there in the program.
Your first stop for introductory material regarding the Java class library should always be the Java Tutorial; it has a chapter on XML processing as well: http://docs.oracle.com/javase/tutorial/jaxp/index.html
The JAXP FAQ may also be useful: http://jaxp.java.net/1.4/JAXP-FAQ.html
As regards the page you first went to: It just shows the code without any explanations, so it may be good for getting up and running quickly, but not so much for learning what's going on. (Oh, and the "normalize" call is not required. You can experiment with what happens if you leave it in or take it out.)
Ulf Dittmer wrote:(Oh, and the "normalize" call is not required. You can experiment with what happens if you leave it in or take it out.)
Thanks for the links.
Yes, I had done that and it worked. In fact, I mentioned that in mr.mykong's webpage too. Problem is that if its not needed, then why is it there ?
Which makes me think what is the purpose of normalize ?
Normalization of these two documents will result in documents that looks identical to humans.
I was also looking for some kind of example which shows us a (noticeable?) difference in the output of the parser. That is, it shows us an xml doc and points out all the places in the doc which could use normalization (and also tell us what normalization is ??? Is it like the normalization in databases ???). Then, show us output with normalization and without it so that we can compare and see the differences.
I hope I am not making this complicated.
Andy Jack wrote:Then, show us output with normalization and without it so that we can compare and see the differences.
That doesn't make any sense because normalization is a process which you apply to the Document object. It has really nothing to do with the XML document in its serialized form. The two things are not identical at all.
And I've been working with XML for years and years and never had to concern myself with whether a Document object was normalized or not.