users@jaxb.java.net

AW: Duplicated namespace declaration from output xml

From: Claus Nagel <claus.nagel_at_gmail.com>
Date: Tue, 18 Nov 2008 13:12:21 +0100

Hi all -

From the responses in this thread I understand that having control over the
namespace declarations produced by the Marshaller is an issue for many
people which is not addressed by the JAXB API so far.

Currently I have also implemented a SAX filter for this purpose. However, I
would really prefer a simple way to customize the marshalling process. Is
there any chance that this will be a feature of upcoming JAXB versions?

Cheers,
Claus

________________________________________
Von: Colin Fleming [mailto:colin.mailinglist_at_gmail.com]
Gesendet: Dienstag, 18. November 2008 13:01
An: users_at_jaxb.dev.java.net
Cc: claus.nagel_at_gmail.com
Betreff: Re: Duplicated namespace declaration from output xml

Hi all,

Sorry for the late response, I just saw this.

For a slightly less foul solution, consider marshalling through a
TransformerHandler, and using SAX to filter the namespace events you don't
want. It's still pretty ugly, but it works for us.

Cheers,
Colin
2008/10/22 Wolfgang Laun <wolfgang.laun_at_gmail.com>
I'm aware that I'm suggesting a terrible hack, wrought with ifs and buts, so
don't tell me.

To effect certain local modifications on the marshalled text you could do
the following:

Call marshal with a PipedOutputStream pos as its second parameter. Connect a
PipedInputStream pis to that and start a thread reading from pis,
accumulating characters into a StringBuffer. At certain positions (e.g.at
line ends, after requesting JAXB_FORMATTED_OUTPUT) delete strings such as
xmlns:xs="..." from the StringBuffer and emit the StringBuffer to the
ultimate destination for your marhalled text. Insert is, of course, possible
as well, assuming you can identify the position.


On Tue, Oct 21, 2008 at 6:25 PM, Son Nguyen <sontrang91_at_gmail.com> wrote:


I think the problem comes from the xs:anySimpleType. If I change it to
string, it will works as normal. It also make sense that jaxb create output
with types for anySimpleType element. However, it will be a lot nicer if
jaxb can group all the xml declaration on the top and just use the nametag
for it. Do you know a way to tell jaxb to do that?

Attachment is the complete project for you to run.

Thanks,


--
View this message in context:
http://www.nabble.com/Duplicated-namespace-declaration-from-output-xml-tp200
69914p20094153.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net