Java XML Namespace getNamespace(final Package targetPackage)

Here you can find the source of getNamespace(final Package targetPackage)

Description

get Namespace

License

Open Source License

Declaration

private static String getNamespace(final Package targetPackage) 

Method Source Code

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

Related

  1. getCarbonNamespace()
  2. getDefaultNamespaceURI(final XMLStreamWriter writer)
  3. getFactory(boolean validate, boolean namespaceAware)
  4. getNamespace(Class clazz, String namespace)
  5. getNamespace(Class klass)
  6. getNamespace(Map namespaces, String str, String defaultNamespace)
  7. getNamespaceContext()
  8. getNamespaceContext(final String prefix, final String uri)
  9. getNamespaceCtx()