users@jaxb.java.net

Re: Polymorphism problems

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_Sun.COM>
Date: Tue, 29 Jun 2004 12:18:02 -0400

Matt Munz wrote:

> Ed,
>
> Thanks.
>
>
>> * The spec doesn't require JAXB implementations to marshal valid
>> XML.
>
>
> I don't know if I should laugh or cry :) Can someone please explain
> what the point of marshalling invalid XML is? Certainly,
> implementations should *try* to make it *easier* to generate valid
> XML and should *discourage* (if not overtly make difficult or
> prevent) the creation of invalid XML. I mean, I appreciate the
> "power" and "flexibility" to make invalid XML, but what what else
> do I get ? ;)
>

You hit the nail on the head - performance and flexibility. The JAXB
expert group decided that validation had to be optional because it is
such an expensive operation. In many cases, the design cycle only
relies on validation during development. When the application is
deployed, validation is disabled to achieve higher throughput. There
are many other reasons to make it switchable. For example, validation
may occur in another phase before the XML even reaches JAXB, so you
wouldn't want to validate again during unmarshal.

As far as ease of use goes, I tend to think that validation in JAXB is
easy - a boolean on the unmarshal side and a call to validate() before
marshalling. API's should be flexible enough to allow people to do
what they want, be it valid or invalid xml.

Thanks,

--Ryan


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