users@jaxb.java.net

Re: [BULK] xsd:any unmarshalled to DOM

From: Jeremiah Voris <JVoris_at_naverus.com>
Date: Wed, 10 Oct 2007 11:51:30 -0700

Sparefroh <zwatte_at_gmx.net> wrote on 10/09/2007 10:12:09 AM:
     <snip>
> Any ideas how to preserve these whitespaces between elements?

Jeremiah Voris <JVoris_at_naverus.com> wrote on 10/09/2007 01:13:03 PM:
> The only thing I can think of is to try adding the xml:space attribute
to
> your root element: <http://www.w3.org/TR/REC-xml/#sec-white-space>

Sparefroh <zwatte_at_gmx.net> wrote on 10/10/2007 01:05:34 AM:
> I tried this already but it didn't have any effect to the result :-/

I did remember another attribute that I would expect to be necessary to
get your desired effect: http://www.w3.org/TR/xmlschema-0/#mixedContent

If I remember correctly, an anonymous <complexContent> element (which I
assume you're using) defaults to element-only or, at least, a preference
for that if there is no obvious indication that mixed="true" should be
inferred. In other words, if you had non-whitespace I think the inference
can be mixed="true" was intended rather than failing to validate the
document, but white space is, by default, supposed to be considered
unimportant unless explicitly indicated otherwise so it would not be
something that would tell the parser to infer the attribute. So, for
example, with the following I would be less surprised if the white space
were not preserved:

<rootElement xml:space="preserve">
 <complexContent>

  <things />

  <stuff />

 </complexContent>
</rootElement>

With this version, however, I would be more surprised (and displeased) if
it were not preserved:

<rootElement xml:space="preserve">
 <complexContent mixed="true">

  <things />

  <stuff />

 </complexContent>
</rootElement>

There you have explicitly stated that whatever is found within that tag is
important, including space. If that doesn't work I'd consider it a bug. :)

--
Jeremiah