Here you can find the source of getNamespace(final Package targetPackage)
private static String getNamespace(final Package targetPackage)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.annotation.XmlSchema; public class Main { private static String getNamespace(final Package targetPackage) { String namespaceURI;/*from w w w . j a v a 2s .co m*/ if (targetPackage == null) { namespaceURI = ""; } else { final XmlSchema xmlSchemaAnnotation = targetPackage.getAnnotation(XmlSchema.class); if (xmlSchemaAnnotation == null) { namespaceURI = ""; } else { final String packageNamespace = xmlSchemaAnnotation.namespace(); if (packageNamespace == null || "".equals(packageNamespace)) { namespaceURI = ""; } else { namespaceURI = packageNamespace; } } } return namespaceURI; } }