Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.pull
Class PullNamespaceReducer

    java.lang.Object
      net.sf.saxon.pull.PullFilter
          net.sf.saxon.pull.PullNamespaceReducer

All Implemented Interfaces:
  NamespaceResolver, PullProvider

public class PullNamespaceReducer
extends PullFilter
implements NamespaceResolver

PullNamespaceReducer is a PullFilter responsible for removing duplicate namespace declarations. It also performs namespace fixup: that is, it ensures that the namespaces used in element and attribute names are all declared.

This class is derived from, and contains much common code with, the NamespaceReducer in the push pipeline. (In the push version, however, namespace fixup is not performed by the NamespaceReducer, but by the ComplexContentOutputter).

See Also:
  `NamespaceReducer`

Field Summary

Fields inherited from class net.sf.saxon.pull.PullFilter
`currentEvent`

Fields inherited from interface net.sf.saxon.pull.PullProvider
`ATOMIC_VALUE, ATTRIBUTE, COMMENT, END_DOCUMENT, END_ELEMENT, END_OF_INPUT, NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_ELEMENT, START_OF_INPUT, TEXT`

Constructor Summary
`PullNamespaceReducer(PullProvider base)`

Method Summary
`void` | `endElement()` endElement: Discard the namespaces declared on this element.
`AttributeCollection` | `getAttributes()` Get the attributes associated with the current element.
`int` | `getNameCode()` Get the nameCode identifying the name of the current node.
`NamespaceDeclarations` | `getNamespaceDeclarations()` Get the namespace declarations associated with the current element.
`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.
`java.util.Iterator` | `iteratePrefixes()` Get an iterator over all the prefixes declared in this namespace context.
`int` | `next()` next(): handle next event.

Methods inherited from class net.sf.saxon.pull.PullFilter
`close, current, getAtomicValue, getFingerprint, getNamePool, getPipelineConfiguration, getSourceLocator, getStringValue, getTypeAnnotation, getUnderlyingProvider, setPipelineConfiguration, skipToMatchingEnd`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PullNamespaceReducer

    public PullNamespaceReducer(PullProvider base)

Method Detail

### next

    public int next()
             throws XPathException

  next(): handle next event. The START_ELEMENT event removes redundant namespace declarations, and possibly adds an xmlns="" undeclaration.

  Specified by:
    `next` in interface `PullProvider`
  Overrides:
    `next` in class `PullFilter`
  Returns:
    an integer code indicating the type of event. The code `PullProvider.END_OF_INPUT` is returned at the end of the sequence.
  Throws:
    `XPathException`

### getNameCode

    public int getNameCode()

  Get the nameCode identifying the name of the current node. This method can be used after the `PullProvider.START_ELEMENT`, `PullProvider.PROCESSING_INSTRUCTION`, `PullProvider.ATTRIBUTE`, or `PullProvider.NAMESPACE` events. With some PullProvider implementations, but not this one, it can also be used after `PullProvider.END_ELEMENT`: a client that requires the information at that point (for example, to do serialization) should insert an `ElementNameTracker` into the pipeline. If called at other times, the result is undefined and may result in an IllegalStateException. If called when the current node is an unnamed namespace node (a node representing the default namespace) the returned value is -1.

  Specified by:
    `getNameCode` in interface `PullProvider`
  Overrides:
    `getNameCode` in class `PullFilter`
  Returns:
    the nameCode. The nameCode can be used to obtain the prefix, local name, and namespace URI from the name pool.

### getAttributes

    public AttributeCollection getAttributes()
                                      throws XPathException

  Get the attributes associated with the current element. This method must be called only after a START_ELEMENT event has been notified. The contents of the returned AttributeCollection are guaranteed to remain unchanged until the next START_ELEMENT event, but may be modified thereafter. The object should not be modified by the client.

  Attributes may be read before or after reading the namespaces of an element, but must not be read after the first child node has been read, or after calling one of the methods skipToEnd(), getStringValue(), or getTypedValue().

  Specified by:
    `getAttributes` in interface `PullProvider`
  Overrides:
    `getAttributes` in class `PullFilter`
  Returns:
    an AttributeCollection representing the attributes of the element that has just been notified.
  Throws:
    `XPathException`

### getNamespaceDeclarations

    public NamespaceDeclarations getNamespaceDeclarations()
                                                   throws XPathException

  Get the namespace declarations associated with the current element. This method must be called only after a START_ELEMENT event has been notified. In the case of a top-level START_ELEMENT event (that is, an element that either has no parent node, or whose parent is not included in the sequence being read), the NamespaceDeclarations object returned will contain a namespace declaration for each namespace that is in-scope for this element node. In the case of a non-top-level element, the NamespaceDeclarations will contain a set of namespace declarations and undeclarations, representing the differences between this element and its parent.

  It is permissible for this method to return namespace declarations that are redundant.

  The NamespaceDeclarations object is guaranteed to remain unchanged until the next START_ELEMENT event, but may then be overwritten. The object should not be modified by the client.

  Namespaces may be read before or after reading the attributes of an element, but must not be read after the first child node has been read, or after calling one of the methods skipToEnd(), getStringValue(), or getTypedValue().

  *

  Specified by:
    `getNamespaceDeclarations` in interface `PullProvider`
  Overrides:
    `getNamespaceDeclarations` in class `PullFilter`
  Throws:
    `XPathException`

### endElement

    public void endElement()
                    throws XPathException

  endElement: Discard the namespaces declared on this element.

  Throws:
    `XPathException`

### 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 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 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 interface `NamespaceResolver`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD