8.1. An Example of a Trivial Element Type

The most basic element type is one that associates an element name with a built-in datatype. The following element demonstrates the XML representation of city, which associates the name ‘city’ with the built-in token datatype:

<xsd:element name="city" type="xsd:string"/> 

The value of a city element, which is an instance of the city element type, is a string of any length. Of course, this string is constrained by the constraining facets that specify token (Chapter 12 discusses all of the built-in datatypes—including token). Given the preceding element type, the following element is valid in an XML instance:

<city>New York</city> 

Tip

The city element type example can—and probably should—cover a large ...

Get XML Schema Complete Reference, The 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.