You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2010/09/04 14:10:35 UTC

DOMUtils

I've just noticed two traps waiting to bite CXF developers.

1. The MapNamespaceContext does not implement the rules for 'xml' and
'xmlns'.

2. The DOMUtils seems to me to be rather confused between the effective
namespace of an element and the declared namespace of an element.

In a document like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><doc
xmlns="urn:some-namespace"><ele xmlns=""/></doc>

Node.getNamespaceURI() can return null for that inner element.

I don't think we're calling most of the stranger functions in here. Absent
objections, I will remove questionable functions which are never called.

Re: DOMUtils

Posted by Benson Margulies <bi...@gmail.com>.
OK, well, I'm 50% of an idiot.

What is really happening to me is the following:

For some insane reason, JAXB is creating a schema document like:

<schema xmlns:xs='....'>
 ...

</schema>

but not actually putting the schema namespace onto the doc element. Or
something of ours is somehow removing it. This led me into a classic nest of
twisty passages.

I'm still not too fond of the code in DOMUtils, but, nothing is in fact
self-evidently completely busted.

On Sat, Sep 4, 2010 at 8:10 AM, Benson Margulies <bi...@gmail.com>wrote:

> I've just noticed two traps waiting to bite CXF developers.
>
> 1. The MapNamespaceContext does not implement the rules for 'xml' and
> 'xmlns'.
>
> 2. The DOMUtils seems to me to be rather confused between the effective
> namespace of an element and the declared namespace of an element.
>
> In a document like:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?><doc
> xmlns="urn:some-namespace"><ele xmlns=""/></doc>
>
> Node.getNamespaceURI() can return null for that inner element.
>
> I don't think we're calling most of the stranger functions in here. Absent
> objections, I will remove questionable functions which are never called.
>
>

Re: DOMUtils

Posted by Benson Margulies <bi...@gmail.com>.
Presumably you saw my subsequent message. The official javadoc for
getNamespaceURI is amazingly misleading. The DOM tree I was looking did, in
fact, have no namespaces at all, due to the extremely confusing classpath
snafu with JAX-B.

My remarks about NamespaceContext remain.

On Tue, Sep 7, 2010 at 2:00 PM, Daniel Kulp <dk...@apache.org> wrote:

> On Saturday 04 September 2010 8:10:35 am Benson Margulies wrote:
> > I've just noticed two traps waiting to bite CXF developers.
> >
> > 1. The MapNamespaceContext does not implement the rules for 'xml' and
> > 'xmlns'.
> >
> > 2. The DOMUtils seems to me to be rather confused between the effective
> > namespace of an element and the declared namespace of an element.
> >
> > In a document like:
> >
> > <?xml version="1.0" encoding="UTF-8" standalone="no"?><doc
> > xmlns="urn:some-namespace"><ele xmlns=""/></doc>
> >
> > Node.getNamespaceURI() can return null for that inner element.
>
> Isn't that correct?   That said, I do hate a bunch of things about the DOM
> api
> with default namespaces and such.   Some require null, others accept the
> empty
> string, etc...   In general, Stax is the same way.  That's why there are a
> lot
> of StringUtils.isEmpty(str) type calls and such to map things semi
> consistently.
>
> That said, for the most part, I hate much of DOMUtils as well.  For any
> parsing things, I've been trying to switch things over to the StaxUtils.
> I'd
> like DOMUtils to just be a few of the generic DOM lookup things.
>
> > I don't think we're calling most of the stranger functions in here.
> Absent
> > objections, I will remove questionable functions which are never called.
>
> Please do.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>

Re: DOMUtils

Posted by Daniel Kulp <dk...@apache.org>.
On Saturday 04 September 2010 8:10:35 am Benson Margulies wrote:
> I've just noticed two traps waiting to bite CXF developers.
> 
> 1. The MapNamespaceContext does not implement the rules for 'xml' and
> 'xmlns'.
> 
> 2. The DOMUtils seems to me to be rather confused between the effective
> namespace of an element and the declared namespace of an element.
> 
> In a document like:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?><doc
> xmlns="urn:some-namespace"><ele xmlns=""/></doc>
> 
> Node.getNamespaceURI() can return null for that inner element.

Isn't that correct?   That said, I do hate a bunch of things about the DOM api 
with default namespaces and such.   Some require null, others accept the empty 
string, etc...   In general, Stax is the same way.  That's why there are a lot 
of StringUtils.isEmpty(str) type calls and such to map things semi 
consistently.

That said, for the most part, I hate much of DOMUtils as well.  For any 
parsing things, I've been trying to switch things over to the StaxUtils.   I'd 
like DOMUtils to just be a few of the generic DOM lookup things.

> I don't think we're calling most of the stranger functions in here. Absent
> objections, I will remove questionable functions which are never called.

Please do.

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog