users@jaxb.java.net

RE: Re: Re: Re: marshalling

From: Lulseged Zerfu <lulseged.zerfu_at_ericsson.com>
Date: Fri, 26 Jun 2009 07:59:19 +0200

As I understand I have to add the following in my java code to produce
<?xml version="1.0" encoding="UTF-8"?> in the first line of the
document.

marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
.
.
.
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
.
.
.
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

But it removes it completely.

lulseged




-----Original Message-----
From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
Sent: den 26 juni 2009 07:51
To: users_at_jaxb.dev.java.net
Subject: Re: Re: Re: marshalling

On 6/26/09, Lulseged Zerfu <lulseged.zerfu_at_ericsson.com> wrote:
> Hi
>
> Using what you have suggested removes everything <?xml version="1.0"
> encoding="UTF-8" standalone="yes"?>. What I wanted to remove was only
> part of it <?xml version="1.0" encoding="UTF-8"?>. That's is remove
> standalone="yes".
>
> marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
>

This is what I wrote - please note the second line.

| marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
|
| Write the <?xml...> as you want to the writer of your XML. <<< ! >>>
|
| marshaller.marshal(...)


>
> I have solved the second one by using a namespaceprefix.
>
> marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new
> CustomNameSpacePrefixMapper());
>
> The CustomNameSpacePrefixMapper extends
> com.sun.xml.bind.marshaller.NamespacePrefixMapper and implements one
> special method where you can specify which namespace to include:
> .

Excellent.

-W

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net