Hans wrote:
> Why does sun/java insist on overriding namespace prefixes?
We don't.
> Yes I understand that the prefix has no real meaning and in a more
> orthodox context the namespaceURI is all that matters. BUT in the real
> world, in a real apps context you inevitably face this issue. The
> namespaceprefixmapper is not a solution to me (it has no sense of scope
> at all).
To preserve the namespace bindings including where they are bound in an
input document, one needs to keep the whole XML infoset in memory.
JAXB is all about reading XML into POJOs, and so those two goals aren't
really compatible.
NamespacePrefixMapper does allow you to rename ugly ns1, ns2, ... into
your choice of prefix. For example, you can use SAX filter on input to
capture prefixes used in the input and try to reproduce that in output.
In that way the only thing you'd lose is where they are bound.
> Has anyone seen the simplicity and elegance of .net/xml and/or python
> xml? Its like a line or two of code vs. the 20+ lines that java makes
> you handle, and java gets all religious and drops the xml prefixes that
> you specify ... ns1 ns2 n3 ...
I don't know about Python, but I believe .NET XmlSerializer has the same
problem as JAXB does.
I'm sympathetic to the lines of code, though. If you have any specific
suggestions to shorten them, I'm all ears.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com