# Path: pyxmpp/xmlextra.py
# COMMON_NS = "http://pyxmpp.jajcus.net/xmlns/common"
# class StreamHandler:
#     class error(Exception):
#     class _SAXCallback(libxml2.SAXCallback):
#     class _PythonReader:
# class StreamReader:
#     def __init__(self):
#     def _stream_start(self,_doc):
#     def _stream_end(self,_doc):
#     def _stanza(self,_doc,_node):
#     def stream_start(self,doc):
#     def stream_end(self,doc):
#     def stanza(self, _unused, node):
#     def error(self,descr):
#     def warning(self,desc):
#     def replace_ns(node, old_ns,new_ns):
#     def _escape(data):
#         def __init__(self, handler):
#         def cdataBlock(self, data):
#         def characters(self, data):
#         def comment(self, content):
#         def endDocument(self):
#         def endElement(self, tag):
#         def error(self, msg):
#         def reference(self, name):
#         def startDocument(self):
#         def startElement(self, tag, attrs):
#         def warning(self):
#         def __init__(self,handler):
#         def feed(self, data):
#     def _get_ns(node):
#     def replace_ns(node, old_ns, new_ns):
# def get_node_ns(xmlnode):
# def get_node_ns_uri(xmlnode):
# def xml_node_iter(nodelist):
# def xml_element_iter(nodelist):
# def xml_element_ns_iter(nodelist, ns_uri):
# def remove_evil_characters(s):
# def safe_serialize(xmlnode):
#     def __init__(self,handler):
#     def doc(self):
#     def feed(self,s):


import unittest
import libxml2
from pyxmpp import xmlextra
from stream_reader import xml_elements_equal
        doc = libxml2.newDoc("1.0")

        root = doc.newChild(None, "root", None)
        common_ns = root.newNs(xmlextra.COMMON_NS, None)
        root.setNs(common_ns)
        doc.setRootElement(root)

        n = input_doc.getRootElement()
        try:
            input_ns = n.ns()
        except libxml2.treeError:
            input_ns = None
        n = n.children
        while n:
            n1 = n.docCopyNode(doc, 1)
            root.addChild(n1)
            if n1.type == 'element':
                try:
                    n1_ns = n1.ns()
                except libxml2.treeError:
                    ns1_ns = None
                if n1_ns.content == input_ns.content:
                    xmlextra.replace_ns(n1, n1_ns, common_ns)
            n = n.next
        self.failUnless(xml_elements_equal(root, output_root))

    def test_replace_null_ns(self):
        doc = libxml2.newDoc("1.0")

        root = doc.newChild(None, "root", None)

# Path: pyxmpp/xmlextra.py
# COMMON_NS = "http://pyxmpp.jajcus.net/xmlns/common"
# class StreamHandler:
#     class error(Exception):
#     class _SAXCallback(libxml2.SAXCallback):
#     class _PythonReader:
# class StreamReader:
#     def __init__(self):
#     def _stream_start(self,_doc):
#     def _stream_end(self,_doc):
#     def _stanza(self,_doc,_node):
#     def stream_start(self,doc):
#     def stream_end(self,doc):
#     def stanza(self, _unused, node):
#     def error(self,descr):
#     def warning(self,desc):
#     def replace_ns(node, old_ns,new_ns):
#     def _escape(data):
#         def __init__(self, handler):
#         def cdataBlock(self, data):
#         def characters(self, data):
#         def comment(self, content):
#         def endDocument(self):
#         def endElement(self, tag):
#         def error(self, msg):
#         def reference(self, name):
#         def startDocument(self):
#         def startElement(self, tag, attrs):
#         def warning(self):
#         def __init__(self,handler):
#         def feed(self, data):
#     def _get_ns(node):
#     def replace_ns(node, old_ns, new_ns):
# def get_node_ns(xmlnode):
# def get_node_ns_uri(xmlnode):
# def xml_node_iter(nodelist):
# def xml_element_iter(nodelist):
# def xml_element_ns_iter(nodelist, ns_uri):
# def remove_evil_characters(s):
# def safe_serialize(xmlnode):
#     def __init__(self,handler):
#     def doc(self):
#     def feed(self,s):


# Path: tests/ns_operations.py
import unittest
import libxml2
from pyxmpp import xmlextra
from stream_reader import xml_elements_equal

        doc = libxml2.newDoc("1.0")

        root = doc.newChild(None, "root", None)
        common_ns = root.newNs(xmlextra.COMMON_NS, None)
        root.setNs(common_ns)
        doc.setRootElement(root)

        n = input_doc.getRootElement()
        try:
            input_ns = n.ns()
        except libxml2.treeError:
            input_ns = None
        n = n.children
        while n:
            n1 = n.docCopyNode(doc, 1)
            root.addChild(n1)
            if n1.type == 'element':
                try:
                    n1_ns = n1.ns()
                except libxml2.treeError:
                    ns1_ns = None
                if n1_ns.content == input_ns.content:
                    xmlextra.replace_ns(n1, n1_ns, common_ns)
            n = n.next
        self.failUnless(xml_elements_equal(root, output_root))

    def test_replace_null_ns(self):
        doc = libxml2.newDoc("1.0")

        root = doc.newChild(None, "root", None)

        common_ns = root.newNs(xmlextra.COMMON_NS, None)