From the course: XML Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Declaring attributes

Declaring attributes - XML Tutorial

From the course: XML Essential Training

Start my 1-month free trial

Declaring attributes

- Now that we have looked at declaring elements with Schema, let's take a look at how we would declare attributes. Like elements, attributes are declared using their own element in Schema and that happens to be the xsd attribute tag. Attributes, unlike elements are always simple types. There's no complex types for attributes in Schema. Any of the simple types that you saw in the earlier tables I showed can be used for elements. It can also be used for attributes. Recall from that table, we had values, such as string and boolean and date and youri and so on. Any of those types you can use in attribute declarations. Here's an example. This tag declares an attribute named age and it's type is an integer. In addition to the name and the type, you can place an attribute called use on your attribute. Use can have one of three values. It can either be optional, when in which case the attribute can be either included or almated in your date, it can be required, which means the attribute has…

Contents