02.06.2013 Views

XML Demystified

XML Demystified

XML Demystified

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4 <strong>XML</strong> Schema<br />

You define your own attributes for an element by using the xs:attribute tag. This<br />

tag also requires that you specify a name of the attribute, which is assigned to the<br />

name attribute, and a type attribute, which is the data type of the attribute. Optionally,<br />

you can define a default value, define a fixed value, and indicate whether the<br />

attribute is required or optional.<br />

A facet is a valid value that can be assigned to an attribute. You define facets by<br />

using the xs:restriction and xs:enumeration tags. The xs:restriction tag states there<br />

are restrictions imposed on the attribute, and the xs:enumeration tag specifies those<br />

restrictions. You can set restrictions in the form of a range of values or specify more<br />

complex restrictions by using a regular expression.<br />

You can create your own data type as either simpleType or complexType. You<br />

use a simpleType when defining one element, and a complexType when defining<br />

multiple elements.<br />

Quiz<br />

1. An <strong>XML</strong> schema is used to define a complex type.<br />

a. True<br />

b. False<br />

2. type=“integer” means<br />

a. The content of an element is the word integer.<br />

b. All types except integers can be used in the corresponding element.<br />

c. Only integers can be used in the corresponding element.<br />

d. None of the above.<br />

3. xmlns:xs=“http://www.w3.org/2001/<strong>XML</strong>Schema” is used to<br />

a. Identify ownership of the <strong>XML</strong> schema<br />

b. Identify ownership of the <strong>XML</strong> document<br />

c. Identify the <strong>XML</strong> schema specifications used in the <strong>XML</strong> schema<br />

d. Identify that this is an <strong>XML</strong> schema<br />

4. The xs:sequence tag<br />

a. Specifies the sequence in which elements must appear in an <strong>XML</strong><br />

document<br />

b. Specifies the sequence in which elements must appear in an <strong>XML</strong><br />

schema<br />

67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!