dev@fi.java.net

Re: JAXB and Namespaces

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 14 Jun 2005 20:12:41 +0200

Kohsuke Kawaguchi wrote:
> Paul Sandoz wrote:
>
>> Hi Kohsuke,
>>
>> A couple of questions on namespaces.
>>
>> When serializing "bound XML" will the XML namespace ever be declared
>> such that it will be written?
>
>
> You mean it will be "overwritten"? I suspect that it doesn't.
>

No, i mean will it ever get serialized as a namespace attribute?


>> Is there a way to obtain the namespace URI index (the one set on the
>> Name produced by the NameBuilder) from the
>> NamespaceContextImpl.Element class?
>
>
> Right now you can't do that quickly, but we can certainly add it.
>
> But the only time you want to get prefix -> nsUri is when the
> XMLSerializer uses (int prefix, String localName), which is for dynamic
> unbound contents, which could be slower.
>
> Whereas maintaining prefix -> nsUri cost would be incur cost even if
> such a method is never used. So is that going to be a justifiable
> trade-off?
>

Probably not.

I think i have a way around the solution. The JAXB prefixIndex can be
used to access an array that contains both the FI prefix and namespace
URI index. Thus there is still the same cost for namespace declarations
(which are rare) but the lookup is fast for literal names (which is more
common).


>> When using the nsUriIndex2prefixIndex array is the same prefix index
>> returned for the same uri index over the period of serialization?
>
>
> Yes, I think so. Unless the serialization goes into the wildcard or some
> such.
>

OK. I think i may be able to avoid depending on this assumption now.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109