XML Schema Tutorial



Attributes


An element of the complex type can have attributes.


A simple element can contain only its value.


XSD Attribute Example:

<xs:attribute name="power" type="xs:integer"/>


The following is an element with the attribute declared in the above example.

<hero power='1000'/>



For data types, refer to Simple Element page



Default Value


A default value is assigned when no value was specified.


<xs:attribute name="target" type="xs:string" default="single"/>



Fixed Value


An attribute with a fixed value can't have any other value.


<xs:attribute name="target" type="xs:string" fixed="single"/>



Required Attribute


A required attribute must appear in the element containing it.


<xs:attribute name="target" type="xs:string" use="required"/>