Hi

I'm looking into how to work with namespaces with XMLElement, and is
getting confused :-)

* XMLElement.getNamespace() seems to return the namespace prefix, if
any. Should probably be renamed to getNamespacePrefix()? Also, the
following test case breaks badly:
        List<XMLParticle> particles = new ArrayList<XMLParticle>();
        particles.add(new XMLParticle("<p:balanced xmlns:p=\"urn:foo\"/>"));
        XMLElement xmlElement = (XMLElement)
xmlRawToFragmentConverter.convert(particles);
        assertEquals("p", xmlElement.getNamespace());

Will fail since getNamespace() will return "balanced".

* Getting the real namespace (the URI) for an element seems to be done
by calling XMLElementVerifier.getUniqueXMLNSValue() which looks it up
from the attribute collection. First, wouldn't make more sense to have
this as a getNamespaceURI() on XMLElement? Second, this method seems a
bit buggy, for example, the following test case:
        List<XMLParticle> particles = new ArrayList<XMLParticle>();
        particles.add(new XMLParticle("<p:balanced xmlns=\"urn:bar\"
xmlns:p=\"urn:foo\"/>"));
        XMLElement xmlElement = (XMLElement)
xmlRawToFragmentConverter.convert(particles);

        assertEquals("urn:foo", xmlElement.getVerifier().getUniqueXMLNSValue());

Will fail since it returns null.

It seems this area needs some more test cases, or is it me being clueless?

The second issue currently breaks interoperability with Pidgin as it
will send multiple namespace declarations on the auth element during
SASL negotiation, which will fail finding a stanza handler.

/niklas

Reply via email to