net.sf.saxon.expr.instruct
Class SavedNamespaceContext

java.lang.Object
  extended by net.sf.saxon.expr.instruct.SavedNamespaceContext
All Implemented Interfaces:
Serializable, NamespaceResolver

public final class SavedNamespaceContext
extends Object
implements Serializable, NamespaceResolver

An object representing a list of Namespaces. Used when the namespace controller in the stylesheet needs to be kept for use at run-time. The list of namespaces is maintained in the form of numeric prefix/uri codes, which are only meaningful in the context of a name pool

See Also:
Serialized Form

Constructor Summary
SavedNamespaceContext(Iterable<NamespaceBinding> nsBindings)
          Create a NamespaceContext object
SavedNamespaceContext(Iterator<NamespaceBinding> nsBindings)
          Create a NamespaceContext object
SavedNamespaceContext(NamespaceResolver resolver)
          Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver
 
Method Summary
 String getURIForPrefix(String prefix, boolean useDefault)
          Get the namespace URI corresponding to a given prefix.
 Iterator<String> iteratePrefixes()
          Get an iterator over all the prefixes declared in this namespace context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SavedNamespaceContext

public SavedNamespaceContext(Iterable<NamespaceBinding> nsBindings)
Create a NamespaceContext object

Parameters:
nsBindings - an array of namespace bindings. Each namespace code is an integer in which the first 16 bits represent the prefix (zero if it's the default namespace) and the next 16 bits represent the uri. These are codes held in the NamePool. The list will be searched from the "high" end.

SavedNamespaceContext

public SavedNamespaceContext(Iterator<NamespaceBinding> nsBindings)
Create a NamespaceContext object

Parameters:
nsBindings - an array of namespace bindings. Each namespace code is an integer in which the first 16 bits represent the prefix (zero if it's the default namespace) and the next 16 bits represent the uri. These are codes held in the NamePool. The list will be searched from the "high" end.

SavedNamespaceContext

public SavedNamespaceContext(NamespaceResolver resolver)
Create a SavedNamespaceContext that captures all the information in a given NamespaceResolver

Parameters:
resolver - the NamespaceResolver
Method Detail

getURIForPrefix

public String getURIForPrefix(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 interface NamespaceResolver
Parameters:
prefix - the namespace prefix
useDefault - 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 Iterator<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 interface NamespaceResolver
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


Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.