Package com.jamesmurty.utils
Class NamespaceContextImpl
- java.lang.Object
-
- com.jamesmurty.utils.NamespaceContextImpl
-
- All Implemented Interfaces:
NamespaceContext
public class NamespaceContextImpl extends Object implements NamespaceContext
Mappings between prefix strings and namespace URI strings, as required to perform XPath queries on namespaced XML documents.- Author:
- jmurty
-
-
Constructor Summary
Constructors Constructor Description NamespaceContextImpl()
Create an empty namespace context.NamespaceContextImpl(Element element)
Create a namespace context that will lookup namespace information in the given element.
-
Method Summary
Modifier and Type Method Description void
addNamespace(String prefix, String namespaceURI)
Add a custom mapping from prefix to a namespace.String
getNamespaceURI(String prefix)
String
getPrefix(String namespaceURI)
Iterator
getPrefixes(String namespaceURI)
-
-
-
Constructor Detail
-
NamespaceContextImpl
public NamespaceContextImpl()
Create an empty namespace context.
-
NamespaceContextImpl
public NamespaceContextImpl(Element element)
Create a namespace context that will lookup namespace information in the given element.- Parameters:
element
- Element in which to look up namespace information.
-
-
Method Detail
-
addNamespace
public void addNamespace(String prefix, String namespaceURI)
Add a custom mapping from prefix to a namespace. This mapping will override any mappings present in this class's XML Element (if provided).- Parameters:
prefix
- the namespace's prefix. Use an empty string for the default prefix.namespaceURI
- the namespace URI to map.
-
getNamespaceURI
public String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURI
in interfaceNamespaceContext
-
getPrefix
public String getPrefix(String namespaceURI)
- Specified by:
getPrefix
in interfaceNamespaceContext
-
getPrefixes
public Iterator getPrefixes(String namespaceURI)
- Specified by:
getPrefixes
in interfaceNamespaceContext
-
-