Java tutorial
//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; 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; } }