Package net.sf.saxon.pull
Class NamespaceContextImpl
- java.lang.Object
-
- net.sf.saxon.pull.NamespaceContextImpl
-
- All Implemented Interfaces:
javax.xml.namespace.NamespaceContext
,NamespaceResolver
public class NamespaceContextImpl extends java.lang.Object implements NamespaceResolver, javax.xml.namespace.NamespaceContext
This class bridges between the JAXP 1.3 NamespaceContext interface and Saxon's equivalent NamespaceResolver interface. It allows any implementation of the Saxon NamespaceResolver to be wrapped as a JAXP NamespaceContext.
-
-
Constructor Summary
Constructors Constructor Description NamespaceContextImpl(NamespaceResolver resolver)
Constructor: wrap a Saxon NamespaceResolver as a JAXP NamespaceContext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getNamespaceURI(java.lang.String prefix)
Implement the JAXP getNamespaceURI() method in terms of the Saxon-specific methodsjava.lang.String
getPrefix(java.lang.String uri)
Get the prefix bound to a particular namespace URI, if there is one, or null if not (JAXP method)java.util.Iterator<java.lang.String>
getPrefixes(java.lang.String uri)
Get all the prefixes mapped to a given namespace URI (JAXP method)java.lang.String
getURIForPrefix(java.lang.String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix.java.util.Iterator<java.lang.String>
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.
-
-
-
Constructor Detail
-
NamespaceContextImpl
public NamespaceContextImpl(NamespaceResolver resolver)
Constructor: wrap a Saxon NamespaceResolver as a JAXP NamespaceContext- Parameters:
resolver
- the Saxon NamespaceResolver
-
-
Method Detail
-
getURIForPrefix
public java.lang.String getURIForPrefix(java.lang.String prefix, boolean useDefault)
Get the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope.- Specified by:
getURIForPrefix
in interfaceNamespaceResolver
- Parameters:
prefix
- the namespace prefixuseDefault
- true if the default namespace is to be used when the prefix is ""- Returns:
- the uri for the namespace, or null if the prefix is not in scope
-
iteratePrefixes
public java.util.Iterator<java.lang.String> iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context. This will include the default namespace (prefix="") and the XML namespace where appropriate- Specified by:
iteratePrefixes
in interfaceNamespaceResolver
- Returns:
- an iterator over all the prefixes for which a namespace binding exists, including the zero-length string to represent the null/absent prefix if it is bound
-
getNamespaceURI
public java.lang.String getNamespaceURI(java.lang.String prefix)
Implement the JAXP getNamespaceURI() method in terms of the Saxon-specific methods- Specified by:
getNamespaceURI
in interfacejavax.xml.namespace.NamespaceContext
- Parameters:
prefix
- a namespace prefix- Returns:
- the corresponding URI, if the prefix is bound, or "" otherwise
-
getPrefix
public java.lang.String getPrefix(java.lang.String uri)
Get the prefix bound to a particular namespace URI, if there is one, or null if not (JAXP method)- Specified by:
getPrefix
in interfacejavax.xml.namespace.NamespaceContext
- Parameters:
uri
- the namespace URI- Returns:
- the prefix bound to the URI if there is one, or null if not
-
getPrefixes
public java.util.Iterator<java.lang.String> getPrefixes(java.lang.String uri)
Get all the prefixes mapped to a given namespace URI (JAXP method)- Specified by:
getPrefixes
in interfacejavax.xml.namespace.NamespaceContext
- Parameters:
uri
- the namespace URI- Returns:
- an iterator over all the prefixes bound to this namespace URI
-
-