public class NamespaceCache
extends java.lang.Object
implements javax.xml.namespace.NamespaceContext
Constructor and Description |
---|
NamespaceCache(org.w3c.dom.Document document,
boolean rootOnly)
Constructor parses the document and stores all namespaces it can find.
|
NamespaceCache(XmlNs... nsMappings)
Constructor initialises the cache from non-null, non-empty
nsMappings . |
Modifier and Type | Method and Description |
---|---|
void |
addMapping(java.lang.String prefix,
java.lang.String uri)
Adds mapping for
prefix and uri to the cache. |
java.util.List<XmlNs> |
getAllXmlNs() |
java.lang.String |
getNamespaceURI(java.lang.String prefix) |
java.lang.String |
getPrefix(java.lang.String namespaceURI) |
java.util.Iterator |
getPrefixes(java.lang.String namespaceURI) |
XmlNs |
getXmlNs(java.lang.String uri)
Returns namespace instance if
uri has been bound to a prefix, null otherwise. |
java.lang.String |
toString() |
public NamespaceCache(org.w3c.dom.Document document, boolean rootOnly)
document
- source documentrootOnly
- restriction of the search to enhance performance; only namespaces in the root are
stored.public NamespaceCache(XmlNs... nsMappings)
nsMappings
.public void addMapping(java.lang.String prefix, java.lang.String uri)
prefix
and uri
to the cache.public XmlNs getXmlNs(java.lang.String uri)
uri
has been bound to a prefix, null otherwise.public java.util.List<XmlNs> getAllXmlNs()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getNamespaceURI(java.lang.String prefix)
Method called by XPath; returns the default namespace, if the prefix is null or "".
getNamespaceURI
in interface javax.xml.namespace.NamespaceContext
public java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in interface javax.xml.namespace.NamespaceContext
public java.util.Iterator getPrefixes(java.lang.String namespaceURI)
getPrefixes
in interface javax.xml.namespace.NamespaceContext
Copyright 2009-2016 Tatjana (Tanja) Kostic