[jdom-interest] Reading the xml:base attribute
Jason Hunter
jhunter at xquery.com
Thu Jan 6 10:52:45 PST 2005
Elliotte Harold wrote:
> Bradley S. Huffman wrote:
>
>> Does JDOM need a getAttribute(String localName, String uri)? So far no
>> one has
>> screamed loudly for it.
>
> I suspect not. That would really just duplicate existing functionality
> and JDOM has an unwieldy number of convenience methods already.
>
> I think I was the one who originally came up with the whole Namespace
> class in order to convince Jason and others that attaching a namespace
> to each element wouldn't be excessively heavyweight. At the time they
> didn't want to carry around an extra large string for each element and
> attribute. (It was a few years ago so my memory could be not so accurate.)
My memory's faded too, but I don't think Namespace was ever added as an
optimization. I would have recognized string interning as equivalent.
The issue I recall was what to do with the prefixes which are sometimes
needed and sometimes not really so needed. When you call getNamespace()
for example is it enough to just return the URI? I think not. People
don't like it when you essentially ignore their specially chosen prefix.
We get attached to our prefixes, and xs:integer doesn't look the same
when it's foo:integer even if it's semantically the same. I remember
you saying people should create elements/attributes with a URI and let
JDOM dynamically determine a prefix. But I didn't want to go that
route. So assuming users need to pass in prefix/uri and want to
retrieve prefix/uri in case it needs to get passed around later, it
seems like you need a class as a container for simplicity. Then we made
it a flyweight for efficiency.
> In hindsight I regretted this, which is why XOM has no Namespace class,
> just Strings. It turns out that simply interning most of the Strings is
> all you need to get decent memory usage. But by the time I realized this
> I'm afraid the Namespace class was baked pretty deeply into JDOM, and
> couldn't really be pulled out without major hurt for almost all users.
In XOM I see Element(name, uri) but no way for the user to supply a
prefix? Did you follow through on your earlier plan to just assume
people aren't attached to their prefixes?
-jh-
More information about the jdom-interest
mailing list