http://bugs.winehq.org/show_bug.cgi?id=33118
--- Comment #4 from Nikolay Sivov bunglehead@gmail.com 2013-03-11 06:38:08 CDT --- I think the root of the problem is that our code doesn't care enough that namespace definitions are not element children from libxml2 point of view. It uses separate list to maintain namespaces, that's what xmlNewNs() does for example. As result when you do setAttributeNode() you add a real attribute as a child but no namespace definition is created. Later when you set data type we check for existing namespace definition, it doesn't exist and we create a new one; finally when it dumps node content both definition and attribute are there.
It looks like we should really just add namespace definition if "xmlns:ns" kind of attribute is passed to setAttributeNode(), but in this case getAttributeNode() will fail.