users@jaxb.java.net

RE: JAXB 2.0 default values

From: George Datuashvili <George.Datuashvili_at_Siebel.com>
Date: Wed, 7 Sep 2005 16:25:10 -0600

As I've frequetly seen this confuses even seasoned developers, tools,
and technology stacks. Using default values in schema is at the very top
of things to avoid in order to have reasonable interoperability. Right
up there with qname, duration, and constructs like choice of sequences.
 
thanks,
George


  _____

        From: Joe Fialli [mailto:Joseph.Fialli_at_Sun.COM]
        Sent: Wednesday, September 07, 2005 11:39 AM
        To: users_at_jaxb.dev.java.net
        Subject: Re: JAXB 2.0 default values
        
        
        Dmitri Colebatch wrote:

                Hi Joe,
                
                [snip]
                
                  

                        If a child element is missing,
                        nothing is done by the unmarshal process.
                            

                
                I don't understand the logic behind this. Are you
saying that if I have:
                
                <foo>
                  <bar />
                </foo>
                
                where in the schema bar has a default value of "x" then
                foo.getBar().equals("x")? Yet if I have
                
                <foo />
                
                foo.getBar() is null?
                  

        Yes. That is how it is defined in W3C schema.
        
        Non-normative description of element defaulting is in 4th PH in
following URL.
        URL: http://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints
        
        Also, the following relevant rows summarize extracted from
http://www.w3.org/TR/xmlschema-0/#cardinalityTable
        

Elements
(minOccurs <http://www.w3.org/TR/xmlschema-0/#attribute-minOccurs> ,
maxOccurs <http://www.w3.org/TR/xmlschema-0/#attribute-maxOccurs> )
fixed <http://www.w3.org/TR/xmlschema-0/#attribute-fixed> , default
<http://www.w3.org/TR/xmlschema-0/#attribute-default>
Attributes
use <http://www.w3.org/TR/xmlschema-0/#attribute-use> , fixed
<http://www.w3.org/TR/xmlschema-0/#attribute-attr-fixed> , default
<http://www.w3.org/TR/xmlschema-0/#attribute-attr-default>
Notes
(0, 1) 37, - n/a element may appear once, if it does not appear
it is not provided; if it does appear and it is empty, its value is 37;
if it does appear and it is not empty, its value must be 37
(0, 1) -, 37 n/a element may appear once; if it does not appear
it is not provided; if it does appear and it is empty, its value is 37;
otherwise its value is that given


        Normative description from W3C XML Schema spec:
        http://www.w3.org/TR/xmlschema-1/#sic-eltDefault
        
        
        

                Without being an expert on default/absent/empty/nil
values, I would
                have thought that the use case for default values was to
save the need
                to put them in (an xml document) at all.
                
                Could you please point me to something explaining why it
is done this way?
                  


        No rationale is provided for this in XML Schema specification on
why it is done this way.
        
        -Joe
        

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


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


_______________
Siebel
IT'S ALL ABOUT THE CUSTOMER
Visit www.siebel.com

This e-mail message is for the sole use of the intended recipient(s) and contains confidential and/or privileged information belonging to Siebel Systems, Inc. or its customers or partners. Any unauthorized review, use, copying, disclosure or distribution of this message is strictly prohibited. If you are not an intended recipient of this message, please contact the sender by reply e-mail and destroy all soft and hard copies of the message and any attachments. Thank you for your cooperation.