logo       

RE: default values for created beans: msg#00140

text.xml.xmlbeans.user

Subject: RE: default values for created beans

Right, we have thought about it and rejected the idea of adding required
elements/default values automatically. The reason is that it can become
confusing very quickly (say you have a required element "a" with minOccurs=1,
then you add another element "b" with minOccurs=1, now one would expect to see
both elements automatically added; but then you turn the sequence containing
"a" and "b" into a choice, and it's no longer clear what to do).
Basically, I want to be able to answer the question "what's the behavior of
addNewXXX()?" accurately and concisely.
On the other hand, in V2 there is an "org.apache.xmlbeans.impl.xsd2inst"
package which contains code that will generate a sample instance document based
on a given SchemaType. Based on this, one could easily write a method that,
given an XmlObject, will populate it with all required
elements/attributes/values, even recursively, so you can have the best of both
worlds.

Radu

-----Original Message-----
From: florian.hehlen@xxxxxxx [mailto:florian.hehlen@xxxxxxx]
Sent: Monday, January 24, 2005 10:07 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: RE: default values for created beans


Hi.

I find that very interesting. Although I am not sure I would wan it to be a
default behaviour. Maybe any given bean could provide a method like
addDefaultElements() to populate the document with minimum elements and default
values.

I think it is a valuable feature of XMLBeans that _invalid_ documents can be
built/manipulated with it.

Florian Hehlen

>-----Original Message-----
>From: mg [mailto:xmlbeans@xxxxxxxxxxxxxxxxxxxxx]
>Sent: Tuesday, January 25, 2005 3:16 AM
>To: user@xxxxxxxxxxxxxxxxxxx
>Subject: default values for created beans
>
>
>Hi there,
>
>I am creating new beans using the addNewXXX methods in the compiled
>beans. However I was really hoping that the default values that I have
>specified in the schema would be used to fill in the new bean.
>Also if a
>child element is specified as having a minOccurs of 1 I would
>think that
>the element would be automatically created as well.
>
>What do you think?
>Marius.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@xxxxxxxxxxxxxxxxxxx
>For additional commands, e-mail: user-help@xxxxxxxxxxxxxxxxxxx
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: user-help@xxxxxxxxxxxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise