Here you can find the source of getPrefix(final Package targetPackage, String namespaceURI)
private static String getPrefix(final Package targetPackage, String namespaceURI)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import javax.xml.bind.annotation.XmlNs; import javax.xml.bind.annotation.XmlSchema; public class Main { private static String getPrefix(final Package targetPackage, String namespaceURI) { String prefix;/*from w ww . j av a 2s .com*/ final Map<String, String> namespacePrefixes = new HashMap<String, String>(); if (targetPackage != null) { final XmlSchema xmlSchemaAnnotation = targetPackage.getAnnotation(XmlSchema.class); if (xmlSchemaAnnotation != null) { for (XmlNs xmlns : xmlSchemaAnnotation.xmlns()) { namespacePrefixes.put(xmlns.namespaceURI(), xmlns.prefix()); } } } prefix = namespacePrefixes.get(namespaceURI); return prefix; } }