users@jaxb.java.net

Re: how to obtain namespace of the unmarshalled object?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 04 Apr 2003 10:00:03 -0800

I'm bit confused.

> so I had to set the property "jaxb.schemaLocation" to a pair of strings:
> "<namespace> <namespaceURL>"
> this did generate the xml file with same namespace as original file.

I think you are saying that you just needed to restore
xsi:schemaLocation. Even if you don't use "jaxb.schemaLocation" property,
you'll surely get XML in the right namespace, do you.

Since ____jaxb_ri____getNamespaceURI is not meant for the public use,
and we may modify/remove it in future.
It seems to me that the alternative safe approach you can take right now
is to write a SAX XMLFilter and insert xsi:schemaLocation by yourself.

XMLFilter will receive the namespace URI of the root element, so you can
just look up a table and put a correct xsi:schemaLocation attribute.



Personally, I think it makes sense if javax.xml.bind.Element interface
exposes the name of the element. And I guess that will solve the problem
for you...


regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com