Doubled namespaces: bug or feature?

BTW, I’'m getting the following strange behavior while tunneling my data thru XMPP (using Smack).

On the sending side:[/u]

OCPacketExtension extension = new OCPacketExtension(t);

Message m = new Message(jid);


log.debug("sending "+m.toXML());

synchronized (connection) {



sending <n1:post n1:author=“Log F” n1:branch=“oc:///TextbyE.text” n1:distance=“1.0” n1:rdistance=“1.0” n1:ttlremaining=“9223372036853751807” xmlns:n1=“urn:oc:token”><n2:text n2:date=“2006.01.28 17:13:10 YEKT” xmlns:n2=“urn:oc:text”>just a test</n2:text></n1:post>

On the receiving side:[/u]

public class XMPPContact implements PacketListener …

public void processPacket(Packet packet) {

log.debug("got "+packet.toXML());

Iterator i = packet.getExtensions();

while (i.hasNext()) {

… etc etc[/i]

got <n1:post n1:author=“Log F” n1:branch=“oc:/TextbyE.text” n1:distance=“1.0” n1:rdistance=“1.0” n1:ttlremaining=“9223372036853388807” xmlns:n1=“urn:oc:token”><n2:n2:text n2:n2:date=“2006.01.28 17:13:10 YEKT” xmlns:xmlns:n1=“urn:oc:token” xmlns:xmlns:n2=“urn:oc:text” xmlns:xmlns:stream=“” xmlns:n2=“urn:oc:text”>just a test</n2:n2:text></n1:post>

Sorry for not looking into Smack sources…

Is it bug or some expected behavior?

Wildfire has logged this message as

<n1:post xmlns:n1=“urn:oc:token” n1:author=“Log F” n1:branch=“oc:///TextbyE.text” n1:distance=“1.0” n1:rdistance=“1.0” n1:ttlremaining=“9223372036840844807”><n1:post xmlns:n1=“urn:oc:token” n1:author=“Log F” n1:branch=“oc:///TextbyE.text” n1:distance=“1.0” n1:rdistance=“1.0” n1:ttlremaining=“9223372036840844807”><n2:text xmlns:n2=“urn:oc:text” n2:date=“2006.01.28 17:13:10 YEKT”>just a test</n2:text></n1:post>


public String toXML() {

StringBuffer buf = new StringBuffer();


if (getPacketID() != null) {

buf.append(" id="").append(getPacketID()).append(""");


if (getTo() != null) {

buf.append(" to="").append(StringUtils.escapeForXML(getTo())).append(""");


if (getFrom() != null) {

buf.append(" from="").append(StringUtils.escapeForXML(getFrom())).append(""");


… etc etc

Guys! What about serializers and namespaces?

OK, the problem seems to originate from org.xmlpull.v1.dom2_builder.DOM2XmlPullBuilder… if not from me…

private Element parseSubTree()

throws XmlPullParserException, IOException


pp.require( XmlPullParser.START_TAG, null, null);

String name = pp.getName();

String ns = pp.getNamespace( );

String prefix = pp.getPrefix();

String qname = prefix != null ? prefix*":"*name : name;[/b]

Element parent = docFactory.createElementNS(ns, qname);

//declare namespaces - quite painful and easy to fail process in DOM2

declareNamespaces(pp, parent);

// process attributes

for (int i = 0; i < pp.getAttributeCount(); i++)


String attrNs = pp.getAttributeNamespace(i);

String attrName = pp.getAttributeName(i);

String attrValue = pp.getAttributeValue(i);

if(attrNs == null || attrNs.length() == 0) {

parent.setAttribute(attrName, attrValue);

} else {

String attrPrefix = pp.getAttributePrefix(i);

String attrQname = attrPrefix != null ? attrPrefix*":"*attrName : attrName;[/b]

parent.setAttributeNS(attrNs, attrQname, attrValue);



Sorry, it was my bug.

It was caused by getTagName() instead of getLocalName() in my DOM->XPP serializer.