Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.transform.TransformerException;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    private static void transformerExceptionMsg(TransformerException ex, Node contextNode, String str) {
        System.out.println("[XPathUtil] Transformer exception selecting " + "XObject for " + "XPath String " + str
                + " with context node " + nodeToString(contextNode) + ": " + ex);
    }

    public static String nodeToString(Node node) {
        String ret = "<null/>";
        if (node != null) {
            ret = "<" + node.getNodeName() + " ";
            NamedNodeMap attrs = node.getAttributes();
            if (attrs != null) {
                for (int i = 0; i < attrs.getLength(); i++) {
                    Node attr = (Node) attrs.item(i);
                    ret = ret + attr.getNodeName() + "='";
                    ret = ret + attr.getNodeValue() + "' ";
                }
            }
            ret = ret + "/>";
        }
        return ret;
    }
}