users@jaxb.java.net

Re: Supressing namespace in elements when marshalling

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 4 Nov 2008 08:20:38 +0100

Much depends on the way you write your XML schema or the JAXB annotations.

Your XML could define (in the <schem> element) a targetNamespace="
http://x.y/z"
and should use elementFormDefault="unqualified" and
attributeFormDefault="unqualified".
The the marshalled XML won't contain prefixes on elements and attributes.
(xsi:type might still be there if, for instance, you overload element tags.)

If you use annotations, I suggest that you compile a simple schema as
indicated
above and look at the annotations in the generated Java code. Look at
package-info.java and ObjectFactory.java.

The fact that you have xsi:type attributes in your element makes me wonder
how,
exactly, you are producing that XML.

I agree with Benson's statement that XML isn't what the typical user should
be
confronted with. But if it isn't deeply nested and the tags and attributes
are
well chosen, it might be tolerable. It's definitely better than /usr/bin/od
output :-)
-W

On Tue, Nov 4, 2008 at 2:32 AM, gfiehler <gfiehler_at_yahoo.com> wrote:

>
> I am trying JAXB for the first time and the output of my XML has the
> xmlns:..
> in every element. This makes the XML virtually unreadable. This XML will be
> viewed by actual humans so it is necessary that the output is as simple and
> efficient as possible. How can I suppress the namespace as well as
> xsi:type..
>
> I am getting
>
> <Environment xsi:type="xs:string"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">TEST</Environment>
>
> but would like
> <Environment>TEST</Environment>
>
>
> any ideas would be greatly appreciated.
> --
> View this message in context:
> http://www.nabble.com/Supressing-namespace-in-elements-when-marshalling-tp20314654p20314654.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
>
>