# Path: pyxmpp2/constants.py
# STANZA_NAMESPACES = (STANZA_CLIENT_NS, STANZA_SERVER_NS)
# 
# STREAM_NS = "http://etherx.jabber.org/streams"
# 
# XML_NS = "http://www.w3.org/XML/1998/namespace"


import threading
import re
from xml.sax.saxutils import escape, quoteattr
from .constants import STANZA_NAMESPACES, STREAM_NS, XML_NS
            - `extra_prefixes`: mapping of namespaces to prefixes (not the
              other way) to be used on the stream. These prefixes will be
              declared on the root element and used in all descendants. That
              may be used to optimize the stream for size.
        :Types:
            - `stanza_namespace`: `unicode`
            - `extra_prefixes`: `unicode` to `unicode` mapping.
        """
        self.stanza_namespace = stanza_namespace
        self._prefixes = {}
        if extra_prefixes:
            self._prefixes.update(extra_prefixes)
        self._root_prefixes = None
        self._head_emitted = False
        self._next_id = 1

    def add_prefix(self, namespace, prefix):
        """Add a new namespace prefix.

        If the root element has not yet been emitted the prefix will
        be declared there, otherwise the prefix will be declared on the
        top-most element using this namespace in every stanza.

        :Parameters:
            - `namespace`: the namespace URI
            - `prefix`: the prefix string
        :Types:
            - `namespace`: `unicode`
            - `prefix`: `unicode`
        """

# Path: pyxmpp2/constants.py
# STANZA_NAMESPACES = (STANZA_CLIENT_NS, STANZA_SERVER_NS)
# 
# STREAM_NS = "http://etherx.jabber.org/streams"
# 
# XML_NS = "http://www.w3.org/XML/1998/namespace"


# Path: pyxmpp2/xmppserializer.py
import threading
import re
from xml.sax.saxutils import escape, quoteattr
from .constants import STANZA_NAMESPACES, STREAM_NS, XML_NS

            - `extra_prefixes`: mapping of namespaces to prefixes (not the
              other way) to be used on the stream. These prefixes will be
              declared on the root element and used in all descendants. That
              may be used to optimize the stream for size.
        :Types:
            - `stanza_namespace`: `unicode`
            - `extra_prefixes`: `unicode` to `unicode` mapping.
        """
        self.stanza_namespace = stanza_namespace
        self._prefixes = {}
        if extra_prefixes:
            self._prefixes.update(extra_prefixes)
        self._root_prefixes = None
        self._head_emitted = False
        self._next_id = 1

    def add_prefix(self, namespace, prefix):
        """Add a new namespace prefix.

        If the root element has not yet been emitted the prefix will
        be declared there, otherwise the prefix will be declared on the
        top-most element using this namespace in every stanza.

        :Parameters:
            - `namespace`: the namespace URI
            - `prefix`: the prefix string
        :Types:
            - `namespace`: `unicode`
            - `prefix`: `unicode`
        """

        if prefix == "xml" and namespace != XML_NS: