Skip Headers

Oracle9i Application Developer's Guide - XML
Release 1 (9.0.1)

Part Number A88894-01
Go To Documentation Library
Go To Product List
Solution Area
Go To Table Of Contents
Go To Index

Go to previous page Go to next page

An XML Primer

This Appendix contains the following sections:

What is XML?

XML, eXtensible Markup Language, is the standard way to identify and describe data on the web. It is widely implementable and easy to deploy.

XML is a human-readable, machine-understandable, general syntax for describing hierarchical data, applicable to a wide range of applications, databases, e-commerce, Java, web development, searching, and so on.

Custom tags enable the definition, transmission, validation, and interpretation of data between applications and between organizations.


XML elements use start tags (<) and end tags (>). For example, <author> where author, the name of the tag, is enclosed is start and end tags. You can name tags whatever you want.


Attributes add more information about each XML element. Attributes can be used to describe how the data is encoded or represented, to indicate where the links or external resources are located, to identify and call external processes such as applets, servlets, and so on, and to specify element instance in documents so that you can find them rapidly during a document search. Attributes also can provide extra information about the XML document's content or other elements. Attributes are not used to specify fonts, colors, or other style or formatting.

XML attributes can be held in the start tag of a start-end tag pair, or an empty tag. They can be name value pairs. For example, <image="adx10.jpg" ada_txt="XSQL Description"/>. Attributes must always be in quotes.

Attributes and their content are defined in DTDs or XML Schema.


An example of an element in an XML document is <author>charles kopman</author>. The element includes the start, tag, end tag, and text in the middle of the start and end tags.

Every XML document must have a root or top-level element. This is the outermost element and contains all the other elements. You can select any name for your root element. In HTML, the root element was always <html>....</html>.


Entities are virtual storage units that can contain graphics, text, sound files, binary data. in XML entities are represented by character strings. You can create your own entities. Five internal entities are already defined for you to use in XML:

less than sign, < uses &lt;

greater than sign, > uses &gt;

ampersand &, uses &amp;

single quote or apostrophe, ' uses &apos;

double quotation mark, " uses &quot;

Basic Rules for XML Markup

Here are eight basic XML markup rules:

W3C XML Recommendations

The World Wide Web Consortium (W3C) XML recommendations are an ever-growing set of interlocking specifications.

The XML family of applications is illustrated in Figure A-1.

Figure A-1 The XML Family of Applications ('Including XML-Based Standards')

Text description of adxml007.gif follows
Text description of the illustration adxml007.gif

XML Features

The following bullets describe XML features:

Although this manual is not intended to expound on XML syntax, a brief overview of some key XML topics is presented here. You can refer to the many excellent resources listed in "Additional XML Resources" for more information on XML syntax.

How XML Differs From HTML

Like HTML, XML is a subset of SGML (Structured Generalized Markup Language), optimized for delivery over the web.

Unlike HTML, which tags elements in web pages for presentation by a browser, for example, <bold>Oracle</bold>, XML tags elements as data, such as, <company>Oracle</company>. You can use XML to give context to words and values in web pages, identifying them as data instead of simple textual or numeric elements.

The following example is in HTML code. This is followed by the corresponding XML example. The examples show employee data:

HTML Example 1


XML Example 1

In the XML code, note the addition of XML data tags and the nested structure of the elements.

<?xml version="1.0"?>

HTML Example 2

Consider the following HTML that uses tags to present data in a row of a table. Is "Java Programming" the name of a book? A university course? A job skill? You cannot be sure by looking at the data and tags on the page. Imagine a computer program trying to figure this out!

     <TD>Java Programming</TD>
     <TD>Paul Thompson</TD>

The analogous XML example has the same data, but the tags indicate what information the data represents, not how it should be displayed. It's clear that "Java Programming" is the Name of a Course, but it says nothing about how it should be displayed.

XML Example 2

<?xml version="1.0"?>
      <Name>Java Programming</Name>
      <Name>Paul Thompson</Name>

XML and HTML both represent information:

Summary of Differences Between XML and HTML

Figure 29-2 summarizes, how XML differs from HTML.

Table 29-2 XML and HTML Differences

Represents information content 

Represents the presentation of the content 

Has user-defined tags 

Has a fixed set of tags defined by standards. 

All start tags must have end tags 

Current browsers relax this requirement on tags <P>, <B>, and so on. 

Attributes must be single or double quoted 

Current browsers relax this requirement on tags  

Empty elements are clearly indicated 

Current browsers relax this requirement on tags  

Element names and attributes are case sensitive 

Element names and attributes are not case sensitive. 

Presenting XML Using Stylesheets

A key advantage of using XML as a datasource is that its presentation (such as a web page) can be separate from its structure and content.

Stylesheet Uses

Consider these ways of using stylesheets:

Stylesheets can be applied on the server or client side. The XSL-Transformation Processor (XSL-T Processor) transforms one XML format into XML or any other text-based format such as HTML. Oracle XML Parsers all include an XSL-T Processor.

How to apply stylesheets and use the XSL-T Processor is described in the following sections:

eXtensible Stylesheet Language (XSL)

eXtensible Stylesheet Language (XSL), the stylesheet language of XML is another W3C recommendation. XSL provides for stylesheets that allow you to do the following:

Cascading Style Sheets (CSS)

Cascading Style Sheets (CSS1), a W3C specification was originally created for use with HTML documents. With CSS you can control the following aspects of your document's appearance:

CSS2 was published by W3C in 1998 and includes the following additional features:

'Cascading' here implies that you can apply several stylesheets to any one document. On a web page deploying CSS, for example, three stylesheets can apply or cascade:

  1. User's preferred stylesheet takes precedence

  2. Cascading stylesheet

  3. Browser stylesheet

    See Also:

    Chapter 4, "Using XSL and XSLT" 

Extensibility and Document Type Definitions (DTD)

Another key advantage of XML over HTML is that it leaves the specification of the tags and how they can be used to the user. You construct an XML document by creating your own tags to represent the meaning and structure of your data.

Tags may be defined by using them in an XML document or they may be formally defined in a Document Type Definition (DTD). As your data or application requirements change, you can change or add tags to reflect new data contexts or extend existing ones.

The following is a simple DTD for the previous XML example:



The DOCTYPE declaration is only used when the DTD is embedded in XML code. 

Well-Formed and Valid XML Documents

Well-Formed XML Documents

An XML document that conforms to the structural and notational rules of XML is considered well-formed. A well-formed XML document does not have to contain or reference a DTD, but rather can implicitly define its data elements and their relationships. Well-formed XML documents must follow these rules:

Valid XML Documents

Well-formed XML documents that also conform to a DTD are considered valid. When an XML document containing or referencing a DTD is parsed, the parsing application can verify that the XML conforms to the DTD and is therefore valid, which allows the parsing application to process it with the assurance that all data elements and their content follow rules defined in the DTD.

Why Use XML?

XML, the internet standard for information exchange is useful for the following reasons:

Other Advantages of Using XML

Other advantages of using XML include the following:

Additional XML Resources

Here are some additional resources for information about XML:

Go to previous page Go to next page
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Go To Product List
Solution Area
Go To Table Of Contents
Go To Index