Yes, it is possible, but you need to be aware of a few
things.
In XMLSchema, a default value on an element behaves
differently than a default value on an attribute in that an absent element
with a default value does *not* end up as an element with the default value in
PSVI, but an absent attribute with a default value does show up in the PSVI
(also an empty element with default value shows up as an element with that
value).
Keeping this in mind, if you had this in your XML
file
<parent>
<testElement/>
</parent>
and you did
parent.getTestElement()
then you would get "1234", the default
value.
But if you had
<parent>
</parent>
then parent.getTestElement() would return
null.
Radu
From: Sriram Vaidyanathan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 30, 2006 3:30 PM
To: [email protected]
Subject: Default values in elements
Hi,
I am
new to XMLBeans. Is it possible that the generated XML Bean java objects can
return a default value associated with an element in the
schema?
For
eg:
<
xsd:simpleType name="mySimpleType"><xsd:restriction base="xsd:string">
<xsd:maxLength value="4"/>
</xsd:restriction>
</xsd:simpleType>
<
xsd:complexType name="MyComplexType"><
xsd:element name="testElement" type="tns:mySimpleType" default="1234" minOccurs="0"/> </xsd:complexType>So,
here suppose that i don't set the testElement value in my client and send
the SOAP message to a service and then on the server side when i do
a getTestElement() , i would expect it to return the default value
"1234". But i get a null instead.
Is there some
setting i need to do for getting the default values.?
Thanks
for any help on this.
_______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

