axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <>
Subject Re: [Axis2][OM] Simpler way to get NameSpace
Date Mon, 13 Dec 2004 13:24:40 GMT
Hi Eran, all:

Eran Chinthaka wrote:
>>>"Glen Daniels" <> writes:
>>>>3) Map namespaces at a given OMElement:
>>>>   void registerNamespace(String uri, String prefix)


>>>>4) Ensure that we have a consistent view on what is a namespace
>>>>declaration and what is an attribute.  For this XML:
>>>>   <foo xmlns:ns1="http://ns1" attr1="bar"/>
>>>>getAttributes() returns JUST attr1, and getAllAttributes() returns both
>>>>the ns1 declaration and att1
>>>>getAttributes() returns both attributes.
>>>>I prefer the former.  In either case I think we should consistency check
>>>>attributes by noticing if they are namespace declarations when they get
>>>>added.  After this:
>>>>   OMAttribute attr = new OMAttribute(new QName(XMLNS, "ns1"),
>>>>                                      "http://ns1");
>>>>   element.addAttribute(attr);
>>>>The element should now have a new namespace mapping, and our code should
>>>>complain if the "ns1" prefix is already mapped in this element.
>>>So this comes down to whether the AXIOM representation is for XML 1.0
>>>or XML 1.0 + Namespaces. My pref would be to say that its *only* a
>>>namespace aware Infoset model and *never* treat namespace declarations
>>>as attributes.

I don't think this works, unfortunately - there are some use cases I can 
think of, like encryption/signing, which definitely need the ability to 
get the entire attribute list, in order including namespace 
declarations.  I'm sure there are other scenarios I can't think of at 
the moment, too.

>>>That means, getAttribues() only returns "attr1" and we don't have
>>>something called getAllAttributes().

-1, see above.

> [Chinthaka] I also agree with you for not returning namespaces, when asked
> for allAttributes()
> Current OMElement is like this.
> We have a getAllAttributes() to return a collection of *only* the
> attributes.
> We have getAllDeclaredNamespaces() in OMElement to retrieve all the
> namespaces declared in this element (not in the scope).

I'd like to see element.getNamespaces() (or getNamespaceDecls()) to get 
all namespace declarations on this element, and 
element.getInScopeNamespaces() to get all active namespace mappings.

> In addition to that we have following methods as Sanjiva and Alek suggested
> earlier.
> public OMNamespace declareNamespace(String uri, String prefix);
>     public OMNamespace declareNamespace(OMNamespace namespace);
>     public OMNamespace findInScopeNamespace(String uri, String prefix)
> throws OMException;
>     public OMNamespace findDeclaredNamespace(String uri, String prefix)
> throws OMException;

Why do we need these last two at all?  Does OMNamespace give me some 
kind of pointer to the OMElement where it is attached?  If not, I don't 
see a reason to have these methods.  If all I want to know is whether a 
particular prefix/uri combination is in scope, I can just do:

String mappedURI = element.getNamespaceFromPrefix(prefix);
if (myURI.equals(mappedURI)) {
   // namespace is there


View raw message