users@jaxb.java.net

Re: Newbie Questions

From: Malachi de AElfweald <malachi_at_EOTI.ORG>
Date: Wed, 05 Mar 2003 15:55:50 -0700

Ok, I looked through the archive, and downloaded the suggested XMLWriter. I have to admit, it looks very configurable -- but also way more than what I am looking for. I even considered using JDOM's XMLOutputter, which is really nice.

However, shouldn't a user be able to use this API without REQUIRING a 3rd party application/API to make it work correctly?


Looking a bit closer, I think the problem could be resolved by:

1) Add a method addBinding(prefix, uri) to com.sun.xml.bind.marshaller.MarshallerImpl that simply keeps a hashtable of prefix->uri mappings.

2) Add the same method to com.sun.xml.bind.marshaller.SAXMarshaller, but it would just pass the information onto com.sun.xml.bind.serializer.NamespaceContextImpl.addBinding(String prefix, String namespaceUri)

3) During the MarshallerImpl.write call, after constructing the SAXMarshaller, call SAXMarshaller.addBinding for each entry in the hashtable, which would then add each entry to the NamespaceContextImpl.

I believe that should preserve the correct namespace prefixes IF the user assigned them to the Marshaller.

Realistically, an end-user could do this by extending SAXMarshaller, but it would also require that they extend MarshallerImpl and JAXBContext. I doubt that is what is really wanted.


Malachi