[jdom-interest] Namespace declaration "gets lost"
Bradley S. Huffman
hip at a.cs.okstate.edu
Thu Oct 17 09:42:01 PDT 2002
Laurent Bihanic writes:
>
> Bradley S. Huffman wrote:
>
> > Looks like it been in since b6 or so. Looking deeper, why do we even worry
> > about keeping track of in-scope namespaces? Looks like the only time
> > SAXHandler's getNamescape is called is when a attribute has a prefix. Why
> > not just use element.getNamespace(String) to get the namespace and handle
> > the housekeeping? For most cases it should match the elements namespace.
> > Tried this last night and it seemed to shave off a few cycles for test case
> s
> > with a high number of attributes (probably from getting rid of the iterator
> > creation).
>
> Why not just using Attributes.getURI(int), assuming the parser does its job
> correctly?
True. Know of any parsers that don't?
> > Also looking at Element.getNamespace(String) shouldn't it also return
> > Namespace.XML_NAMESPACE for the prefix 'xml'?
>
> It does as the SAXHandler(JDOMFactory) constructor adds the XML_NAMESPACE to
> the list of available namespaces.
Inside SAXHandler it is, but as it is now a call to element.getNamespace("xml")
will return null, prefix not bound, which it's not true since the prefix
"xml" is always bound.
Brad
More information about the jdom-interest
mailing list