Oracle Application Server 10g Essentials [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Oracle Application Server 10g Essentials [Electronic resources] - نسخه متنی

Donald Bales

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








10.1 XML, DTDs, and XML Schemas


For an XML document to be used for
information exchange, it must be parseable, and to be parseable, it
must be
well-formed. A well-formed document, among other
rules, must have an end tag for every start tag, and different start
and end tags may not be placed in such a matter as to cross each
other's boundaries.

For instance, Example 10-1 is a well-formed XML
document that contains information about a person named Jane Doe,
born on January 1, 1980.

Example 10-1. An example of a well-formed XML document

<?xml version="1.0"?>
<person>
<name>
<last_name>Doe</last_name>
<first_name>Jane</first_name>
</name>
<birth_date>1980-01-01</birth_date>
<gender>Female</gender>
</person>

If a document is to be shared with more than one computer program, or
shared between organizations, it should also be
valid. A valid XML document is one that
conforms to an agreed-upon format. An XML document is valid if it can
be validated against a Document Type Definition
(DTD) or an XML
Schema.

DTD is the first schema standard developed for
formally describing an XML document's format. A DTD
is narrative document-centric, so while it provides a means to
describe a document's structure, it
doesn't include the ability to specify datatypes.

To continue with the Jane Doe example, Example 10-2
shows a DTD that can validate the XML document in Example 10-1.

Example 10-2. An example of a Document Type Definition

<!ELEMENT person (name, birth_date, gender)>
<!ELEMENT name (last_name, first_name)>
<!ELEMENT last_name (#PCDATA)>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT birth_date (#PCDATA)>
<!ELEMENT gender (#PCDATA)>

XML Schema, a more recent standard, is data document-centric. Not
only does it define document structure, it also supports user-defined
datatypes and some object-oriented principles, such as inheritance.
By validating an XML document against its XML Schema, you can
validate its structure as well as the datatypes of its content. This
is ideal for computer-to-computer data exchange.

Example 10-3 is an example of a possible XML Schema
for the XML document in Example 10-1. If you compare
this XML Schema with the DTD in Example 10-2,
you'll see the additional specification of the
datatypes for each element. Not only do XML Schemas add datatypes,
but they also add complex constraints and namespace support, concepts
that we will address in the sections that follow.

Example 10-3. An example of an XML Schema

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="last_name"
type="xsd:string" minOccurs="1"/>
<xsd:element name="first_name"
type="xsd:string" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="birth_date"
type="xsd:date"/>
<xsd:element name="gender"
type="xsd:string" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

A DTD, an XML Schema, or both can be used to define an XML
document's vocabulary. This vocabulary, which is a
formal specification, is called an XML
application. This type of application is very
different from our normal notion of an application, such as a set of
programs coded in a programming language such as Java or PL/SQL. This
distinction also brings to light the fact that XML itself
isn't a programming language, a protocol, or a
database management system.

Because of its capabilities and its promise as a universal data
format, XML has suffered more than its fair share of hype. While XML
is ideal for storing information in a universal format, making it a
perfect choice for information exchange, it makes a poor database.
Yes, it can be used as a database to store relatively small amounts
of information in an organized manner, but beyond that, information
stored as XML is slow to retrieve and/or manipulate when compared to
information stored in an object-relational database such as
Oracle.


/ 119