In the element ElementProxy class, the
guaranteeThatElementInCorrectSpace method doesn't to
have the expected behavior :

String localnameSHOULDBE = this.getBaseLocalName();
String namespaceSHOULDBE = this.getBaseNamespace();

String localnameIS =
this._constructionElement.getLocalName();
String namespaceIS =
this._constructionElement.getNamespaceURI();

if (!localnameSHOULDBE.equals(localnameIS)||
!namespaceSHOULDBE.equals(namespaceSHOULDBE))
{
  (...)
}

I think the condition should read :

if (!localnameSHOULDBE.equals(localnameIS)||
!namespaceSHOULDBE.equals(namespaceIS))
{
  (...)
}

Furthermore, I'd like to know your mind about a slight
change.
Coded as it is now, there can be a NPE issued when
trying to compare two namespaces. 

I think (but I'm not sure) that a null namespace is
supposed to represent the default XML namespace and
thus, is a legal value. Therefore, I propose a little
rewrite of this to allow null namespaces.

But well, maybe it's just not supposed to happen at
all.
However the W3C's Element interface's getNamespaceURI
method states that it returns "the namespace URI of
this node, or null if it is unspecified."

Alternative code :

if (localnameSHOULDBE.equals(localnameIS))
  {
    if (namespaceSHOULDBE != null &&
namespaceSHOULDBE.equals(namespaceIS))
      return;
    else if (namespaceSHOULDBE == null && namespaceIS
== null)
      return;
  }
Object exArgs[] = { namespaceIS + ":" + localnameIS,
namespaceSHOULDBE + ":" + localnameSHOULDBE };
throw new XMLSecurityException("xml.WrongElement",
exArgs);

- Guillaume -


        

        
                
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com

Reply via email to