Package net.sf.saxon.evpull
Class NamespaceMaintainer
- java.lang.Object
-
- net.sf.saxon.evpull.NamespaceMaintainer
-
- All Implemented Interfaces:
EventIterator
,PullEvent
,NamespaceResolver
public class NamespaceMaintainer extends java.lang.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
Constructors Constructor Description NamespaceMaintainer(EventIterator base, NamePool namePool)
Create a namespace context for a pull-events pipeline
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected short
getURICode(short prefixCode)
Get the URI code corresponding to a given prefix code, by searching the in-scope namespaces.java.lang.String
getURIForPrefix(java.lang.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 iteratorsjava.util.Iterator
iteratePrefixes()
Get an iterator over all the prefixes declared in this namespace context.PullEvent
next()
Get the next event in the sequence
-
-
-
Constructor Detail
-
NamespaceMaintainer
public NamespaceMaintainer(EventIterator base, NamePool namePool)
Create a namespace context for a pull-events pipeline- Parameters:
base
- the previous stage in the pipeline, from which events are readnamePool
- the NamePool
-
-
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 interfaceEventIterator
- 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 interfaceEventIterator
- 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
-
getURICode
protected short getURICode(short prefixCode)
Get the URI code corresponding to a given prefix code, by searching the in-scope namespaces. This is a service provided to subclasses.- Parameters:
prefixCode
- the 16-bit prefix code required- Returns:
- the 16-bit URI code, or -1 if the prefix is not found
-
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 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
-
-