Home Tutorial Xml Default Values

 
 

Share on Google+Share on Google+
Default Values
Posted on: November 22, 2010 at 12:00 AM
Advertisement
The elements which do not have any children can have default values. Default values are assigned automatically if no value is supplied.

Default Values


The elements which do not have any children can have default values. Default values are assigned automatically if no value is supplied. The "default" attribute of the xs:element element can be used to specify a default value.

If the element appears in the document with content, the default value is ignored.

For example, type is the element which is of string type and its default value is XYZ.
<xs:element name="type" type="xs:string" default="XYZ"/>

If we use "type" element with value as given below, then its default value is not considered and the value provided to the element will be accepted.

<type>ABC</type>

If we use "type" element without value as given below, then its default value will be assigned automatically. Now in this case, type element will be assigned XYZ value.

<type/>

 

Advertisement

Related Tags for Default Values:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 22, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com