Java Utililty Methods XML Node Normalize

List of utility methods to do XML Node Normalize

  1. HOME
  2. Java
  3. X
  4. XML Node Normalize

Description

The list of methods to do XML Node Normalize are organized into topic(s).

Method

void normalize(Node node)
Normalize DOM tree.
for (int i = 0; i < node.getChildNodes().getLength(); i++) {
 Node childNode = node.getChildNodes().item(i);
 if (childNode.getNodeType() == Node.TEXT_NODE && childNode.getNodeValue().trim().length() == 0) {
 node.removeChild(childNode);
 i--;
 } else
 normalize(childNode);
void normalize(Node node)
Normalizes the DOM structure starting from the given node
NodeList nodeList = node.getChildNodes();
for (int index = 0; index < nodeList.getLength() - 1; index++) {
 Node child = nodeList.item(index);
 if (child.getNodeType() == Node.TEXT_NODE) {
 for (index++; index < nodeList.getLength(); index++) {
 Node next = nodeList.item(index);
 if (next.getNodeType() != Node.TEXT_NODE)
 break;
...
void normalize(Node node)
Trim all new lines from text nodes.
if (node.getNodeType() == Node.TEXT_NODE) {
 String data = ((Text) node).getData();
 if (data.length() > 0) {
 char ch = data.charAt(data.length() - 1);
 if (ch == '\n' || ch == '\r' || ch == ' ') {
 String data2 = trim(data);
 ((Text) node).setData(data2);
for (Node currentChild = node.getFirstChild(); currentChild != null; currentChild = currentChild
 .getNextSibling()) {
 normalize(currentChild);

AltStyle によって変換されたページ (->オリジナル) /