[jdom-interest] JDOM namespace bug?

Cole, Brian bcole at nsf.gov
Wed Apr 11 13:29:34 PDT 2001


  I'm using beta6 of JDOM and I'm quite happy with it--good job!--but I am
having to work around one bug. Or at least I think its a bug.

  The XML document I'm parsing has tags in two different namespaces.
Tags with the "ej" prefix are in the default namespace, and tags with
no prefix are in the XHTML namespace. (To put it another way, the
null prefix maps to a non-null URI, and the non-null prefix maps to the
null URI. There, did that help any, or confuse it further?)

  Anyway, the trouble I'm having is that elt.getNamespace.getPrefix() 
returns the empty string for both kinds of tags. I was expecting a non-
empty string when called on an <ej:foo/> element, even though it belongs
to the default namespace. Is this a bug, or my expectations off?

  Should I call elt.getQualifiedName() and truncate after-and-including
a colon (if one exists) instead? After all, what I'm really after is the
of the element itself, not of its namespace. But that seems like a lot of
work, and I haven't tried it yet.

  What I'm doing as a work-around right now is
where foo is known to be of one of the two types of elements I'm dealing
Thing is, unless I think of something better, I am going to want to be able
to use
two different prefixes (prefices?) that both map to the same namespace
the default namespace), and elt.getNamespace().equals() will not distingush



More information about the jdom-interest mailing list