Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is xml normalization? [duplicate]

Possible Duplicate:
What does Java Node normalize method do?

What is xml normalization .I found following in javadoc but i cant understand it?Can anyone help?

public void normalize()

Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [XPointer] lookups) that depend on a particular document tree structure are to be used. If the parameter "normalize-characters" of the DOMConfiguration object attached to the Node.ownerDocument is true, this method will also fully normalize the characters of the Text nodes. Note: In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes. Since: DOM Level 3

like image 791
akshay Avatar asked Jul 14 '11 14:07

akshay


1 Answers

Parsers will often return "surprising" text nodes, where text is split up into multiple nodes, or, less commonly, empty text nodes. This is a side-effect of them being streamlined for maximum performance. It may happen when there's ignorable whitespace, buffer boundaries, or anywhere else that it was just convenient for the parser.

normalize() will get rid of all these surprises, merging adjacent text nodes and removing empty ones.

like image 138
Ed Staub Avatar answered Oct 09 '22 02:10

Ed Staub