Implementations have quite a bit of leeway in exactly how they parse and serialize any given document. For example, a parser may represent CDATA sections as CDATASection objects, or it may merge them into neighboring Text objects. A parser may include entity reference nodes in the tree, or it may instead include the nodes corresponding to each entity's replacement text. A parser may include comments, or it may ignore them. DOM3 adds four methods to the Document interface to control exactly how a parser makes these choices:

public void normalizeDocument() 

public boolean canSetNormalizationFeature (String name,
 boolean state)

public void setNormalizationFeature (String name, boolean state)

public boolean getNormalizationFeature

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.