users@jaxb.java.net

Re: Interesting tidbit, has anyone seen this?

From: Robert Lowe <rmlowe_at_rmlowe.com>
Date: Fri, 02 May 2003 02:53:47 +0800

>>From page 16 of the spec:

"How a JAXB technology implementation handles unmarshalling of an invalid
document when validation is disabled is implementation-specific."

My reading of this is that the result of unmarshalling an invalid document
is undefined if validation is disabled. In which case, it's not a bug.

Makes sense really. The whole point of turning off validation is to speed up
unmarshalling by eliminating checks such as this. If you don't like that
behaviour I guess you should turn on validation and suffer the performance
cost.


----- Original Message -----
From: "Sriram Thyagarajan" <Sriram_Thyagarajan_at_KEANE-NNE.com>
To: <JAXB-INTEREST_at_JAVA.SUN.COM>
Sent: Friday, May 02, 2003 2:27 AM
Subject: Re: Interesting tidbit, has anyone seen this?


> From my usage, I belive it happens when minOccurs="0", which makes it
> optional...
>
> I used it as a feature, which lets the optional xml elements appear in any
> order, because the value is set anyway... Even with Unmarshalling with
> validation, we can catch the event and ignore it.
>
> Is this a bug ?
>
> -----Original Message-----
> From: Han Ming Ong [mailto:hanming_at_mac.com]
> Sent: Thursday, May 01, 2003 2:04 PM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Interesting tidbit, has anyone seen this?
>
>
> Given this schema fragment
>
> <xs:element name="local-tx-datasource">
> <xs:complexType>
> <xs:sequence>
> <xs:element minOccurs="0" maxOccurs="unbounded"
> ref="user-name"/>
> <xs:element minOccurs="0" maxOccurs="unbounded"
> ref="password"/>
> <xs:element minOccurs="0" ref="idle-timeout-minutes"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> I realized that JAXB can unmarshal the following XML fragment, where
> <password> and <user-name> are out of order and then magically correct
> the order during marshalling:
>
> <local-tx-datasource>
> <password></password>
> <user-name>sa</user-name>
> </local-tx-datasource>
>
> Well, I know, I know, it is probably a bug but what a great side effect
> if you don't need validation during unmarshalling :-)
>
> By the way, the magic (or bug) happens when you add
> 'maxOccurs="unbounded"' to the elements.
>
> Han Ming