I've convinced myself that the implementation of aegis+json for JAX-RS, with
respect to namespaces, has absolutely got to change.

Let me lay out the situation as I see it.

When we are writing XML, Aegis assigns prefixes on the fly, though it will
respect a map of preferred prefixes. These prefixes are fed to StaX,
incrementally, and all is well.

The Jettison implementation of the StaX API is badly crippled with respect
to namespaces. It ignores setPrefix, and will throw an unchecked exception
in the presence of any namespace that is not defined, in advanced, in the
'Convention' object.

In my tree at the moment, I've gotten around this by subclassing the
Jettison MappedXMLStreamWriter and handling the exception and respecting the
available prefix. However, this only moves the problem down the pipe.

It would be cleaner to write, say, a DOM tree, then collect all the
prefixes, and then put them in Jettison's stupid map, and then copy from the
DOM tree to Jettison. Slower but cleaner.

The result of all of this is json that has undefined namespace prefixes. The
json keys just look like 'ns1.HereIsMyObject'. Nothing is written to in the
JSON that defines what namespace 'ns1' is.

Instead, the code sort of takes it on faith that 'ns1' will be the prefix
for the top-level element, and defines no other prefixes. The code to derive
that namespace is wrong, and I can fix it, but that won't make the unbounded
collection of other prefixes for other schema appear by magic.

Part of the problem here is that the flags to write XSI types are turned
off, at least in the test case I'm working with. Still, I don't see how it
can be interoperable to write out these prefixes without definitions if we
expect to get them back.

Reply via email to