HTML and CSS Reference
In-Depth Information
Plan
Ahead
Creating a document instance.
The main data of an XML document is the document instance. The document instance is all the
components of the document, whether the document is free-form text or a database. When
creating the document instance, a designer should complete the following tasks:
Use the relation or logical schema with attributes created in the XML Schema
Definition.
Determine if namespaces are necessary if duplicate identifier names are used.
Identify the data values for the various XML elements.
Creating the Document Instance in an XML Document
The second part of an XML document is the document instance, or elements. The
document instance section contains the document elements and actual content or data.
There must be one root element with all other elements nested inside the root. This format
creates a hierarchical, treelike structure. This structure defines the XML document as a
well-formed document. Table 12-18 shows the general form of an element tag.
Table 12-18 General Form of an Element Tag
General form:
<element start tag>element contents</element end tag>
Comment:
XML documents require start and end element tags. The element tag name must be a valid
name. The tag describes the type of content represented by the element (for example, item-
description, item-brand). Start and end tags must match exactly in spelling and case. The
element contents or data are the text entered between the tags.
Examples:
<item-description>Stainless Steel Work Table 36X18</item-description>
<item-brand>ChefMaster</item-brand>
<item-cost>497.99</item-cost>
To Start Entering a Document Instance in an XML Document
As shown in Table 12-19, item-id, item-description, item-boh, item-brand, item-cost, and item-vendor_ID are all
child elements within the <item> element. The item element is a child element nested within the <products> root element.
Table 12-19 Code for Inserting the Document Instance
Line
Code
4
<products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="chapter12-1products.xsd">
5
<item>
6
<item-id>A345</item-id>
7
<item-description>Stainless Steel Work Table 36X18</item-description>
8
<item-boh>4</item-boh>
9
<item-brand>ChefMaster</item-brand>
10
<item-cost>497.99</item-cost>
11
<item-vendor_ID>5T300</item-vendor_ID>
12
</item>
Search WWH ::




Custom Search