Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Element. // Used for XPath and serialization Why is Element.getNamespacePrefixesInScope() private?

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Steve Loughran <steve.loughran AT gmail.com>
  • To: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • Cc: Elliotte Harold <elharo AT metalab.unc.edu>, xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Element. // Used for XPath and serialization Why is Element.getNamespacePrefixesInScope() private?
  • Date: Mon, 23 Jan 2006 17:29:28 +0000

On 1/23/06, Wolfgang Hoschek <wolfgang.hoschek AT mac.com> wrote:
>
> On Jan 23, 2006, at 5:18 AM, Michael Kay wrote:
>
> >>> javax.xml.namespace.NamespaceContext
> >>
> >> I don't think I want to introduce an external dependency on
> >> that class
> >> since it wasn't a standard part of the JDK until 1.5, and there's
> >> probably some silly legal reason I can't ship it bundled into XOM.
> >
> > And if you need another reason, it's a very poorly designed interface,
> > offering no method to find out all the namespaces that are in scope.
>
> Yes, I only realized how poorly designed that interface really is
> until I had to implement it and XMLStreamReader as part of the "make
> a XOM tree appear as a STAX pull parser" effort. the javax.*.QName is
> rather poor as well. Don't go there unless you have to.
>

point taken.

Instead I'm trying to extract all defined namespaces from a node into
a hashmap for my own use, by getting the local declarations then
walking up the tree.

Can I observe that the implementation of getNamespacePrefix(int) and
getNamespaceDeclarationCount() are both, well, aggressively suboptimal
as they create set structures that are discarded every run. That would
make enumerating all the namespaces an O(n*n) kind of process, rather
than the more simpler O(n) operation that would appear to be possible.




Archive powered by MHonArc 2.6.24.

Top of Page