Java XML QName Create createQName(String qnameString)

Here you can find the source of createQName(String qnameString)

Description

Create QName.

License

Open Source License

Parameter

Parameter Description
qnameString a qualified name.

Return

a QName object.

Declaration

public static QName createQName(String qnameString) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2002-2005 IBM Corporation and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://  ww w. ja  v a  2  s. c o  m
 *   IBM - Initial API and implementation
 *******************************************************************************/

import javax.xml.namespace.QName;

public class Main {
    /**
     * Create QName.
     * 
     * @param qnameString a qualified name.
     * @return a QName object.
     */
    public static QName createQName(String qnameString) {
        QName qname = null;

        // Locate local part
        int index = qnameString.lastIndexOf(":");

        // Create new QName
        if (index != -1) {
            qname = new QName(qnameString.substring(0, index), qnameString.substring(index + 1));
        }

        else {
            qname = new QName(qnameString);
        }

        return qname;
    }
}

Related

  1. convertStringsToQNames(List expandedQNames)
  2. convertStringToQName(String expandedQName)
  3. createQName(Node node)
  4. createQName(String localPart)
  5. createQName(String namespaceUri, String localPart, String prefix)
  6. createQName(String qualifiedName, Node node)
  7. createQNameWithCustomNamespace(String key)
  8. getEmptyQName()
  9. string2qname(String name)