Simple types with attributes

When an element has simple content, but also has attributes, it cannot simply refer to a data type, such as 'string'. Instead, it must include the ComplexType element, so that attribute declarations can be made. However, there remains the problem of how to specify the simple data type of the element content. The SimpleContent element is used to indicate that the complex element will actually be based on a simple data type. The Extension element is employed, both to specify the data type of the element in its Base attribute, and to extend the type by adding the required attribute:

 <complexType> <simpleContent> <extension base="string"> <attribute name="security" type="string" /> </extension> </simpleContent> </complexType> ...

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.