mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernd Fondermann <bf_...@brainlounge.de>
Subject Re: [Vysper] Namespace handling on XMLElement
Date Mon, 06 Jul 2009 05:36:14 GMT
Niklas Gustavsson wrote:
> Hi
> 
> I'm looking into how to work with namespaces with XMLElement, and is
> getting confused :-)

Yes, I'm too.
In the beginning, I thought this is like XML. But it isn't quite like
it. Prefixes only are important when starting streams (and maybe later
when you have conflicting XML payload in a stanza.

Here an excerpt from 12.2.3. Extended Namespaces in
  http://tools.ietf.org/html/draft-saintandre-rfc3920bis-09

>>>>
   An implementation SHOULD NOT generate namespace prefixes for elements
   qualified by content (as opposed to stream) namespaces other than the
   default namespace.  However, if included, the namespace declarations
   for those prefixes MUST be included on the stanza root or a child
   thereof, not at the level of the stream element (this helps to ensure
   that any such namespace declaration is routed and delivered with the
   stanza, instead of assumed from the stream).
<<<<

This confused me a lot.

Also, admittedly, the namespace implementation is half-baked.

> 
> * XMLElement.getNamespace() seems to return the namespace prefix, if
> any. Should probably be renamed to getNamespacePrefix()?

+1

> 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?

More tests will not neccessarily help comprehension, but: yes, we need
them ;-)

> 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.

Do you have the malicious stanza at hand?

  Bernd

Mime
View raw message