Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import javax.xml.namespace.QName;

import org.w3c.dom.Node;

public class Main {
    /**
     * @param the
     *            node to create the name from, never <code>null</code>
     * @return the node of the name as qualified name, never <code>null</code>
     */
    public static QName buildQName(Node node) {
        String localPart;
        String nsName;
        String name = node.getTextContent();
        int indexOfColon = name.indexOf(':');
        if (indexOfColon > 0) {
            localPart = name.substring(indexOfColon + 1);
            nsName = node.lookupNamespaceURI(name.substring(0, indexOfColon));
        } else {
            localPart = name;
            // return default namespace URI if any
            nsName = node.lookupNamespaceURI(null);
        }
        return new QName(nsName, localPart);
    }
}