Package groovy.xml

# Class XmlNodePrinter.NamespaceContext

java.lang.Object
groovy.xml.XmlNodePrinter.NamespaceContext

Enclosing class:
  XmlNodePrinter

protected static class XmlNodePrinter.NamespaceContext extends Object
Tracks namespace declarations already emitted while printing a subtree.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NamespaceContext()`
  Creates an empty namespace context.
  `NamespaceContext(XmlNodePrinter.NamespaceContext context)`
  Creates a namespace context initialized from an existing context.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getNamespace(String prefix)`
  Returns the namespace URI currently registered for the supplied prefix.
  `boolean`
  `isPrefixRegistered(String prefix, String uri)`
  Checks whether a prefix is already registered for the supplied namespace URI.
  `void`
  `registerNamespacePrefix(String prefix, String uri)`
  Records a namespace prefix mapping if it has not already been registered.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### NamespaceContext

    public NamespaceContext()
    Creates an empty namespace context.

  - ### NamespaceContext

    public NamespaceContext(XmlNodePrinter.NamespaceContext context)
    Creates a namespace context initialized from an existing context.
    Parameters:
      `context` - the context to copy

- ## Method Details

  - ### isPrefixRegistered

    public boolean isPrefixRegistered(String prefix, String uri)
    Checks whether a prefix is already registered for the supplied namespace URI.
    Parameters:
      `prefix` - the namespace prefix to look up
      `uri` - the namespace URI to compare against
    Returns:
      `true` if the prefix is already registered for that URI

  - ### registerNamespacePrefix

    public void registerNamespacePrefix(String prefix, String uri)
    Records a namespace prefix mapping if it has not already been registered.
    Parameters:
      `prefix` - the namespace prefix to register
      `uri` - the namespace URI to associate with `prefix`

  - ### getNamespace

    public String getNamespace(String prefix)
    Returns the namespace URI currently registered for the supplied prefix.
    Parameters:
      `prefix` - the namespace prefix to resolve
    Returns:
      the registered namespace URI, or `null` if none is registered