Here you can find the source of getQName(Class> klass)
public static QName getQName(Class<?> klass)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.annotation.XmlSchema; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; public class Main { public final static String DEFAULT_NAMESPACE_VALUE = "##default"; public static QName getQName(Class<?> klass) { XmlType xmlType = klass.getAnnotation(XmlType.class); if (xmlType == null) return null; String namespace = getNamespace(klass); String name = xmlType.name(); return new QName(namespace, name); }/*from www. j a v a 2 s.c o m*/ public static String getNamespace(Class<?> klass) { String namespace = null; XmlType xmlType = klass.getAnnotation(XmlType.class); if (xmlType != null) { String ns = xmlType.namespace(); if (!DEFAULT_NAMESPACE_VALUE.equals(ns)) { namespace = ns; } } if (namespace == null) { namespace = DEFAULT_NAMESPACE_VALUE; Package pkg = klass.getPackage(); XmlSchema xmlSchema = pkg.getAnnotation(XmlSchema.class); if (xmlSchema != null) { namespace = xmlSchema.namespace(); } } return namespace; } }