| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
The NamespaceContext interface is a helper tool for
 XML parsing applications which need to know the mappings between XML
 namespace prefixes and namespace URI's. As such, it is closely related
 to the events
 ContentHandler.startPrefixMapping(String,String),
 and ContentHandler.endPrefixMapping(String) in
 ContentHandler.
In what follows, it is important to note, that a single prefix can only be mapped to a single namespace URI at any time. However, the converse is not true: Multiple prefixes can be mapped to the same namespace URI's.
For example, in the case of an XML Schema parser, an instance
 of NamespaceContext might be used to resolve the namespace
 URI's of referenced data types, and element or attribute names, which
 are typically given as qualified names, including a prefix and a local
 name.
| Method Summary | |
|  java.lang.String | getNamespaceURI(java.lang.String pPrefix)Given a prefix, returns the namespace URI associated with the prefix. | 
|  java.lang.String | getPrefix(java.lang.String pNamespaceURI)This method returns a prefix, which is currently mapped to the given namespace URI. | 
|  java.util.Iterator | getPrefixes(java.lang.String pNamespaceURI)This method returns a collection of prefixes, which are currently mapped to the given namespace URI. | 
| Method Detail | 
public java.lang.String getNamespaceURI(java.lang.String pPrefix)
Given a prefix, returns the namespace URI associated with the prefix. More precisely, the following rules apply:
| Prefix (Input) | Namespace URI (Output) | 
|---|---|
| XMLConstants.DEFAULT_NS_PREFIX("") | The current default namespace URI or null, if there is no such default. (In which case the absence of a prefix indicates the absence of a namespace URI.) | 
| XMLConstants.XML_NS_PREFIX("xml") | XMLConstants.XML_NS_URI("http://www.w3.org/XML/1998/namespace") | 
| XMLConstants.XMLNS_ATTRIBUTE("xmlns") | XMLConstants.XMLNS_ATTRIBUTE_NS_URI("http://www.w3.org/2000/xmlns/") | 
| Any other prefix | The namespace URI currently mapped to the prefix or null, if no such mapping is established. | 
pPrefix - The prefix being looked up in the list of mappings.
java.lang.IllegalArgumentException - The input prefix is null.public java.lang.String getPrefix(java.lang.String pNamespaceURI)
This method returns a prefix, which is currently mapped to the given
 namespace URI. Note, that multiple prefixes may be mapped to the namespace
 URI, in which case the returned prefix is undetermined. Do not make any
 assumptions on the order in such cases. It is a better choice to use
 getPrefixes(String) instead, if you depend on some order
 
| Namespace URI (Input) | Prefix (Output) | 
|---|---|
| Current default namespace URI | XMLConstants.DEFAULT_NS_PREFIX("") | 
| XMLConstants.XML_NS_URI("http://www.w3.org/XML/1998/namespace") | XMLConstants.XML_NS_PREFIX("xml") | 
| XMLConstants.XMLNS_ATTRIBUTE_NS_URI("http://www.w3.org/2000/xmlns/") | XMLConstants.XMLNS_ATTRIBUTE | 
pNamespaceURI - The namespace URI being looked up in the list of mappings.
java.lang.IllegalArgumentException - The input URI is nullpublic java.util.Iterator getPrefixes(java.lang.String pNamespaceURI)
This method returns a collection of prefixes, which are currently mapped
 to the given namespace URI. Note, that the collection may contain more than
 one prefix, in which case the order is undetermined. If you do not depend
 on a certain order and any prefix will do, you may choose to use
 getPrefix(String) instead. The following table describes the
 returned values in more details:
 
| Namespace URI (Input) | Prefix collection (Output) | 
|---|---|
| XMLConstants.XML_NS_URI("http://www.w3.org/XML/1998/namespace") | Collection with a single element: XMLConstants.XML_NS_PREFIX("xml") | 
| XMLConstants.XMLNS_ATTRIBUTE_NS_URI("http://www.w3.org/2000/xmlns/") | Collection with a single element: XMLConstants.XMLNS_ATTRIBUTE | 
pNamespaceURI - The namespace URI being looked up in the list of
   mappings or null, if there is no such mapping.
Iterator: Using it's
   Iterator.remove() method throws an
   UnsupportedOperationException.
java.lang.IllegalStateException - The input URI is null| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||