You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Raymond Feng <en...@gmail.com> on 2006/04/16 01:37:16 UTC

[AXIS2] How does Axiom handle namespaces in ancestor scopes?

Hi,

I have an OM containment hiearchy as "SOAPEnvelope --> SOAPBody --> OMElement e1" and the namespace xmlns:ns1="http://ns1" is declared at the SOAPEnvelope level (I observe that It's the behavior when the SOAPEnvelope is received from the Axis2 engine).

XMLStream reader = e1.getXMLStreamReader();

For the reader, I found "reader.getNamespaceCount()" returns 0. Is it by design because the namespace "http://ns1" is not declared at e1 level? If so, it could be a problem if I pull events from the reader directly since the "http://ns1" won't be reported. What's the best way to populate namespaces from the ancestor scopes into e1?

Thanks,
Raymond



Re: [AXIS2] How does Axiom handle namespaces in ancestor scopes?

Posted by Eran Chinthaka <ch...@opensource.lk>.
Raymond Feng wrote:
> Hi, Eran.
> 
> Thanks for the reply. I understand your point. But it also means that
> e1.getXMLStreamReader() returns a reader pointing to the XML fragment
> which is only valid with the parent chain.
> 
> Another way to ask the question would be:
> 
> Is there any utility to detach/clone the child OMElement so that it can
> be used as a standalone OMElement with all the required namespaces
> declared/populated?

The straight answer is no.

Detach was implemented to ease some one from handling the pointers here
and there, in the case of llom implementation or any other implementation.

If this seems useful, please file a JIRA and I will implement this when
I get a chance :).

-- Chinthaka


Re: [AXIS2] How does Axiom handle namespaces in ancestor scopes?

Posted by Raymond Feng <en...@gmail.com>.
Hi, Eran.

Thanks for the reply. I understand your point. But it also means that 
e1.getXMLStreamReader() returns a reader pointing to the XML fragment which 
is only valid with the parent chain.

Another way to ask the question would be:

Is there any utility to detach/clone the child OMElement so that it can be 
used as a standalone OMElement with all the required namespaces 
declared/populated?

Thanks,
Raymond



----- Original Message ----- 
From: "Eran Chinthaka" <ch...@opensource.lk>
To: <ax...@ws.apache.org>
Sent: Sunday, April 16, 2006 5:38 AM
Subject: Re: [AXIS2] How does Axiom handle namespaces in ancestor scopes?



Re: [AXIS2] How does Axiom handle namespaces in ancestor scopes?

Posted by Eran Chinthaka <ch...@opensource.lk>.
Raymond Feng wrote:
> Hi,
>  
> I have an OM containment hiearchy as "SOAPEnvelope --> SOAPBody -->
> OMElement e1" and the namespace xmlns:ns1="http://ns1" is declared at
> the SOAPEnvelope level (I observe that It's the behavior when the
> SOAPEnvelope is received from the Axis2 engine).
>  
> XMLStream reader = e1.getXMLStreamReader();
>  
> For the reader, I found "reader.getNamespaceCount()" returns 0. Is it by
> design because the namespace "http://ns1" is not declared at e1 level?
> If so, it could be a problem if I pull events from the reader directly
> since the "http://ns1" won't be reported. What's the best way to
> populate namespaces from the ancestor scopes into e1?

According to StAX api
(http://java.sun.com/webservices/docs/1.5/api/javax/xml/stream/XMLStreamReader.html#getNamespaceCount())

"Returns the count of namespaces declared on this START_ELEMENT or
END_ELEMENT....".

So getNamespaceCount() should only return the namespace declared within
e1 element.

But if you call reader.getNamespaceURI() after START_ELEMENT of e1, you
should get http://ns1.

-- Chinthaka