net.sf.saxon.evpull
Class NamespaceMaintainer

java.lang.Object
  extended by net.sf.saxon.evpull.NamespaceMaintainer
All Implemented Interfaces:
EventIterator, PullEvent, NamespaceResolver

public class NamespaceMaintainer
extends Object
implements EventIterator, NamespaceResolver

NamespaceMaintainer is an EventIterator responsible for maintaining namespace context in an event stream. It allows the current namespace context to be determined at any time while processing the stream of events.

Note that this class merely provides the service of keeping track of which namespaces are currently in scope. It does not attempt to remove duplicate namespace declarations, and it does not perform namespace fixup.


Constructor Summary
NamespaceMaintainer(EventIterator base)
          Create a namespace context for a pull-events pipeline
 
Method Summary
 String getURIForPrefix(String prefix, boolean useDefault)
          Get the namespace URI corresponding to a given prefix.
 boolean isFlatSequence()
          Determine whether the EventIterator returns a flat sequence of events, or whether it can return nested event iterators
 Iterator iteratePrefixes()
          Get an iterator over all the prefixes declared in this namespace context.
 PullEvent next()
          Get the next event in the sequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceMaintainer

public NamespaceMaintainer(EventIterator base)
Create a namespace context for a pull-events pipeline

Parameters:
base - the previous stage in the pipeline, from which events are read
Method Detail

isFlatSequence

public boolean isFlatSequence()
Determine whether the EventIterator returns a flat sequence of events, or whether it can return nested event iterators

Specified by:
isFlatSequence in interface EventIterator
Returns:
true if the next() method is guaranteed never to return an EventIterator

next

public PullEvent next()
               throws XPathException
Get the next event in the sequence

Specified by:
next in interface EventIterator
Returns:
the next event, or null when the sequence is exhausted. Note that since an EventIterator is itself a PullEvent, this method may return a nested iterator.
Throws:
XPathException - if a dynamic evaluation error occurs

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 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.