Site icon Tutorial

Defining Attributes

What is an Attribute?

Simple elements cannot have attributes. If an element has attributes, it is considered to be of a complex type. But the attribute itself is always declared as a simple type.

How to Define an Attribute?

The syntax for defining an attribute is:

where xxx is the name of the attribute and yyy specifies the data type of the attribute.

XML Schema has a lot of built-in data types. The most common types are:

Example

Here is an XML element with an attribute:

And here is the corresponding attribute definition:

Go to- Certified XML Developer Tutorial
Exit mobile version