Here you can find the source of toQName(NamespaceContext namespaceContext, String qualifiedName)
Parameter | Description |
---|---|
namespaceContext | The namespace context. |
qualifiedName | The qualified name. |
public static QName toQName(NamespaceContext namespaceContext, String qualifiedName)
//package com.java2s; //License from project: Apache License import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; public class Main { /**//w w w. j ava2 s.c o m * Return the qname represented by the qualified name. * @param namespaceContext The namespace context. * @param qualifiedName The qualified name. * @return The qname. */ public static QName toQName(NamespaceContext namespaceContext, String qualifiedName) { final int index = qualifiedName.indexOf(':'); if (index == -1) { return new QName(qualifiedName); } else { String prefix = qualifiedName.substring(0, index); String localName = qualifiedName.substring(index + 1); String namespaceURI = getNormalisedValue(namespaceContext.getNamespaceURI(prefix)); return new QName(namespaceURI, localName, prefix); } } /** * Get the normalised value of the string. * @param value The string value. * @return The normalised value. */ public static String getNormalisedValue(final String value) { if (value != null) return value; return ""; } }