Class DOMStreamer.NamespaceNormalizingDOMStreamer

  • Enclosing class:

    public static class DOMStreamer.NamespaceNormalizingDOMStreamer
    extends AbstractSAXProducer
    This API is deprecated, migrate code to the XML APIs provided by the JDK.
    Streams a DOM tree to SAX events and normalizes namespace declarations on the way.

    The code in this class is based on the org.apache.xml.utils.TreeWalker class from Xalan, though it differs in some important ways.

    This class will automatically fix up ("normalize") namespace declarations while streaming to SAX. The original DOM-tree is not modified. The algorithm used is described in an appendix of the DOM Level 3 spec.

    This class will NOT check the correctness of namespaces, e.g. it will not check that the "xml" prefix is not misused etc.

    • Constructor Detail

      • NamespaceNormalizingDOMStreamer

        public NamespaceNormalizingDOMStreamer()
    • Method Detail

      • recycle

        public void recycle()
        Description copied from class: AbstractSAXProducer
        Recycle the producer by removing references, and resetting handlers to null (empty) implementations.
        recycle in class AbstractSAXProducer
      • getNamespaceForPrefix

        public java.lang.String getNamespaceForPrefix​(java.lang.String prefix,
                                                      org.w3c.dom.Element namespaceContext)
        Searches the namespace for a given namespace prefix starting from a given Element.

        Note that this resolves the prefix in the orginal DOM-tree, not in the DOMStreamer.NamespaceNormalizingDOMStreamer.ElementInfo objects. This is used to resolve prefixes of elements or attributes created with createElement or setAttribute instead of createElementNS or setAttributeNS.

        The code in this method is largely based on org.apache.xml.utils.DOMHelper.getNamespaceForPrefix() (from Xalan).

        prefix - the prefix to look for, can be empty or null to find the default namespace
        the namespace, or null if not found.