users@jaxb.java.net

Re: Validator finds cycles where there are none?

From: Charles Simon <charles.simon_at_charter.net>
Date: Tue, 27 Jul 2004 16:09:06 -0400

I just saw this go by.

There are many cases where the same object can validly appear in a
object graph. The most obvious is reusing a String.

But there are other cases, the most common I have seen is the use of the
"enumeration" pattern where a class does not have a public constructor
but defines public static object references that are the only valid
instantiations of that class. These objects would very likely appear
repeatedly in an object graph of any size that used them.

Now this does present a problem when unmarshalling, since the class does
not have a public constructor. You would need specialized code to
unmarshal the XML objects back into the valid instances of the class.


Kohsuke Kawaguchi wrote:

>>does this sound reasonable/the correct behaviour?
>>
>>
>
>It is the expected behavior, although I'm not sure if that's the
>desirable behavior.
>
>The error message "cycle" is confusing. It should be more like "the same
>object is appering more than once in the object graph"
>
>
>I guess at least a part of the motivation to flag this as an error is
>our assumption that under the normal circumstances you wouldn't want to
>copy the same fragment more than once into the same XML --- that just
>seems like a bad design of XML. Plus, the unmarshaller never reuses the
>same object in two places. And I also thought about the ID issue.
>
>But now that I think about it, I guess we can construct a consistent
>semantics even if we allow the same object to appear more than once.
>
>
>I'd be interetsed in knowing why you'd like to print one D object twice.
>
>regards,
>--
>Kohsuke Kawaguchi
>Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>
>

-- 
Charles Simon
charles.simon_at_charter.net



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