axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xinjun Chen" <xjchen...@gmail.com>
Subject Re: [Axis2] Namespace issue during conversion from DOM Element to OMElement
Date Fri, 12 Jan 2007 10:04:21 GMT
Hi Ruchith,

Thanks for the info.
I think the codes mentioned in [1] has the same effect as root.setAttribute().


Regards,
Xinjun

On 1/12/07, Ruchith Fernando <ruchith.fernando@gmail.com> wrote:
>
> Hi Xinjun,
>
> To make sure you have the namespace declaration properly you have to
> add the namespace attribute. Please see here [1].
>
> Thanks,
> Ruchith
>
> [1]
> http://www.ftponline.com/javapro/2003_06/online/namespace_kjones_06_23_03/
>
> On 1/12/07, Ruchith Fernando <ruchith.fernando@gmail.com> wrote:
> > Hi Xinjun,
> >
> > On 1/11/07, Xinjun Chen <xjchen001@gmail.com> wrote:
> > > Hi Ruchith,
> > >
> > > setNamespaceAware to the original DocumentBuilderFactory solve the
> problem
> > > partially.
> > >
> > > Now the DOM Element reads:
> > > <?xml version="1.0"
> > >   encoding="UTF-8"?>
> > > <getHearingDetailsByCaseNoWSReturn xmlns="http://cis.com">
> > >     <hearingDetailsVO xmlns="http://vo.cis.com">
> > >       <duration/>
> > >       <applicationNo>sAppNo0</applicationNo>
> > >     </hearingDetailsVO>
> > > </getHearingDetailsByCaseNoWSReturn>
> > >
> > > But the OMElement reads:
> > >
> > > <getHearingDetailsByCaseNoWSReturn xmlns="">
> > >     <hearingDetailsVO xmlns="http://vo.cis.com">
> > >       <duration/>
> > >       <applicationNo>sAppNo0</applicationNo>
> > >     </hearingDetailsVO>
> > > </getHearingDetailsByCaseNoWSReturn>
> >
> > IMHO the issue here is with the XMLUtils#outputDOM() method :-)
> >
> > It doesn't serialize the root element's namespaces properly.
> >
> > Please see here [1]
> >
> > >
> > > Observations:
> > > 1. After I setNamespaceAware to the original DOM
> DocumentBuilderFactory, the
> > > inner element <hearingDetailsVO> gets correct namespace. But root
> element
> > > <getHearingDetailsByCaseNoWSReturn> does not. The namespace
> > > of <getHearingDetailsByCaseNoWSReturn> is lost. I created
> > > this element in the following way:
> > >
> > > DocumentBuilderFactory dbf =
> > > DocumentBuilderFactory.newInstance();
> > > dbf.setNamespaceAware(true);
> > > Document doc = dbf.newDocumentBuilder().newDocument();
> > > Element root = doc.createElementNS(" http://cis.com",
> > > "getHearingDetailsByCaseNoWSReturn");
> > >
> > > I think OMElement does not include "http://cis.com" as namespace
> because
> > > "http://cis.com" is not explicitly declared as a namespace in DOM doc.
> I
> > > searched the interfaces of Document and Element, but cannot find a way
> to
> > > explicitly declare a namespace.
> > > I think I need to treat namespace as attribute in DOM. Please correct
> me if
> > > I am wrong.
> > >
> > > Thus I added one line to declare xmlns as attribute.
> > >
> > > root.setAttribute("xmlns", "http://cis.com").
> > >
> > > Is there any other elegant way?
> > >
> > >
> > > 2. Do you have a good way to remove all null elements like
> <duration/>? The
> > > original DOM Element also contains other null elements which contains
> no
> > > value.
> >
> > Hmm ... I'm sorry I don't know any shortcut to do that.
> >
> > Thanks,
> > Ruchith
> >
> > [1] http://rafb.net/p/dXERq036.html
> > --
> > www.ruchith.org
> > www.wso2.org
> >
>
>
> --
> www.ruchith.org
> www.wso2.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Mime
View raw message