Complete XML Schema Reference
The attribute element defines an attribute.
(The ? sign declares that the element can occur zero or one time inside the attribute element)
| Attribute | Description |
|---|---|
| default | Optional. Specifies a default value for the attribute. Default and fixed attributes cannot both be present |
| fixed | Optional. Specifies a fixed value for the attribute. Default and fixed attributes cannot both be present |
| form | Optional. Specifies the form for the attribute. The default value is
the value of the attributeFormDefault attribute of the element
containing the attribute. Can be set to one of the following:
|
| id | Optional. Specifies a unique ID for the element |
| name | Optional. Specifies the name of the attribute. Name and ref attributes cannot both be present |
| ref | Optional. Specifies a reference to a named attribute. Name and ref attributes cannot both be present. If ref is present, simpleType element, form, and type cannot be present |
| type | Optional. Specifies a built-in data type or a simple type. The type attribute can only be present when the content does not contain a simpleType element |
| use | Optional. Specifies how the attribute is used. Can be one
of the following values:
|
| any attributes | Optional. Specifies any other attributes with non-schema namespace |
The example above indicates that the "code" attribute has a restriction. The only acceptable value is two of the uppercase letters from a to z.
To declare an attribute using an existing attribute definition within a complex type, use the ref attribute:
Attributes can have either a default value OR a fixed value specified. A default value is automatically assigned to the attribute when no other value is specified. In the following example the default value is "EN":
A fixed value is also automatically assigned to the attribute when no other value is specified. But unlike default values; if you specify another value than the fixed, the document is considered invalid. In the following example the fixed value is "EN":
All attributes are optional by default. To explicitly specify that the attribute is optional, use the "use" attribute:
To make an attribute required:
Complete XML Schema Reference
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.