Beta
Thread-safe XML namespace dictionary that provides a one-to-one map of namespace alias to URI.
Implementation is thread-safe. For maximum efficiency, applications should use a single
globally-shared instance of the XML namespace dictionary.
A namespace alias is uniquely mapped to a single namespace URI, and a namespace URI is
uniquely mapped to a single namespace alias. In other words, it is not possible to have
duplicates.
If the uri is null, the namespace alias will be removed. Similarly, if the alias is
null, the namespace URI will be removed. Otherwise, if the alias is already mapped to a
different URI, it will be remapped to the new URI. Similarly, if a URI is already mapped to a
different alias, it will be remapped to the new alias.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class XmlNamespaceDictionary (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.xml.XmlNamespaceDictionary)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.xml.XmlNamespaceDictionary) \n\n public final class XmlNamespaceDictionary\n\n[Beta](/java/docs/reference/google-http-client/latest/com.google.api.client.util.Beta) \n\nThread-safe XML namespace dictionary that provides a one-to-one map of namespace alias to URI.\n\nImplementation is thread-safe. For maximum efficiency, applications should use a single\nglobally-shared instance of the XML namespace dictionary.\n\nA namespace alias is uniquely mapped to a single namespace URI, and a namespace URI is\nuniquely mapped to a single namespace alias. In other words, it is not possible to have\nduplicates.\n\nSample usage: \n\n\n static final XmlNamespaceDictionary DICTIONARY = new XmlNamespaceDictionary()\n .set(\"\", \"http://www.w3.org/2005/Atom\")\n .set(\"activity\", \"http://activitystrea.ms/spec/1.0/\")\n .set(\"georss\", \"http://www.georss.org/georss\")\n .set(\"media\", \"http://search.yahoo.com/mrss/\")\n .set(\"thr\", \"http://purl.org/syndication/thread/1.0\");\n \nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e XmlNamespaceDictionary \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### XmlNamespaceDictionary()\n\n public XmlNamespaceDictionary()\n\nMethods\n-------\n\n### getAliasForUri(String uri)\n\n public synchronized String getAliasForUri(String uri)\n\nReturns the namespace alias (or `\"\"` for the default namespace) for the given namespace\nURI.\n\n### getAliasToUriMap()\n\n public synchronized Map\u003cString,String\u003e getAliasToUriMap()\n\nReturns an unmodified set of map entries for the map from namespace alias (or `\"\"` for\nthe default namespace) to namespace URI.\n\n### getUriForAlias(String alias)\n\n public synchronized String getUriForAlias(String alias)\n\nReturns the namespace URI for the given namespace alias (or `\"\"` for the default\nnamespace).\n\n### getUriToAliasMap()\n\n public synchronized Map\u003cString,String\u003e getUriToAliasMap()\n\nReturns an unmodified set of map entries for the map from namespace URI to namespace alias (or\n`\"\"` for the default namespace).\n\n### serialize(XmlSerializer serializer, String elementName, Object element)\n\n public void serialize(XmlSerializer serializer, String elementName, Object element)\n\nShows a debug string representation of an element data object of key/value pairs.\n\n### serialize(XmlSerializer serializer, String elementNamespaceUri, String elementLocalName, Object element)\n\n public void serialize(XmlSerializer serializer, String elementNamespaceUri, String elementLocalName, Object element)\n\nShows a debug string representation of an element data object of key/value pairs.\n\n### set(String alias, String uri)\n\n public synchronized XmlNamespaceDictionary set(String alias, String uri)\n\nAdds a namespace of the given alias and URI.\n\nIf the uri is `null`, the namespace alias will be removed. Similarly, if the alias is\n`null`, the namespace URI will be removed. Otherwise, if the alias is already mapped to a\ndifferent URI, it will be remapped to the new URI. Similarly, if a URI is already mapped to a\ndifferent alias, it will be remapped to the new alias.\n\n### toStringOf(String elementName, Object element)\n\n public String toStringOf(String elementName, Object element)\n\nShows a debug string representation of an element data object of key/value pairs."]]