HTML and CSS Reference
In-Depth Information
To Start Notepad++ and Create a New XML Schema Document
The following step uses Notepad++ to create a new XML Schema document.
1
maximize the Notepad++ window.
If the word wrap feature is not
enabled, enable it.
Start Notepad++, and, if necessary,
newly created
blank XML Schema
Definition file
your computer, click File on the
menu bar, and then click Save As on
the File menu.
With the USB drive plugged into
Chapter12\ChapterFiles folder on
your storage device.
If necessary, navigate to the
Figure 12-5
chapter12-1products.xsd in the File name text box.
Type
Click the Save button in the Save As dialog box to save the Schema Definition file (Figure 12-5).
Creating an XML Schema Definition
An XML Schema Definition describes the structure of an XML document, which
includes the data types. An XML Schema Definition is more useful than a Document
Type Definition (DTD), because DTDs do not describe the data types. In addition, the
DTD is not able to enforce that a specific data type, such as a date, is being implemented.
Because of these limitations, XML standards prefer the use of an XML Schema Definition
to describe an XML file.
XML Schema Definitions are XML files, and as such, they must conform to the
same rules that any XML document must follow. Tags must have a beginning and end
tag, though many XML Schema Definitions will use an empty tag with attributes. The
rules for attributes must be followed: they must be lowercase and values must be enclosed
in quotation marks. The basic component of an XML Schema Definition is the element.
Table 12-4 shows the basic format of an XML Schema Definition <element> tag.
Table 12-4 General Form of an XML Schema Definition Element
General form:
<xs:element name="ield name" type="data type" />
Comment:
xs: is a namespace, to differentiate this element from any other element that may have
the same name. The name is an attribute to define the field name; type is an attribute to
state one of the valid data types. Simple elements may have an optional default or fixed
attributes to assign a default value to a field. The default value is assigned if no other value
is assigned; the fixed value does not allow any other value to be assigned. Most developers
use xs or xsd as a default namespace. This text uses xs.
Examples:
<xs:element name="item-brand" type="xs:string" />
Elements in an XML Schema Definition can be either simple type or complex
type. A simple type element is one that contains only text. A complex type element is
one that contains sub or child elements and/or attributes, which themselves contain data.
Table 12-5 compares simple type and complex type elements.
 
Search WWH ::




Custom Search