Skip Headers

Oracle9i XML Database Developer's Guide - Oracle XML DB
Release 2 (9.2)

Part Number A96620-02
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page

Go to previous page Go to next page
View PDF

Introducing Oracle XML DB

This chapter introduces you to Oracle XML DB by describing the Oracle XML DB benefits, features, and architecture. This chapter contains the following sections:

Introducing Oracle XML DB

This chapter introduces you to Oracle XML DB. It discusses the features available for building XML applications on the Oracle9i database.

From its beginnings, XML's core characteristics of self-description and dynamic extensibility have provided the flexibility needed to transport messages between various applications, and loosely couple distributed business processes.

XML is also language-independent and platform-independent. As XML support has become standard in browsers, application servers, and databases, enterprises have wished to tie legacy applications to the Web using XML to transform various proprietary file- and document-exchange templates into XML.

More recently, a new generation of XML standards, such as XML Schema, has enabled a unified data model that can address both structured data and documents. XML Schema has emerged as a key innovation in managing document content with the same rigor as data by enabling documents marked up as XML to move into the database.

Oracle XML DB is a set of built-in high-performance storage and retrieval technologies geared to XML. Oracle XML DB fully absorbs the World Wide Web Consortium (W3C) XML data model into Oracle9i database and provides new standard access methods for navigating and querying XML. You get all the advantages of relational database technology and XML technology at the same time. Oracle XML DB can be used to store, query, update, transform, or otherwise process XML, while at the same time providing SQL access to the same XML data.

Not a Separate Database Server

Oracle XML DB is not some separate server but rather the name for a distinct group of technologies related to high-performance XML storage and retrieval that are available within the familiar Oracle database. Oracle XML DB can also be thought of as an evolution of the Oracle database that encompasses both SQL and XML data models in a highly interoperable manner, thus providing native XML support.

You use Oracle XML DB in conjunction with Oracle XML Developer's Kit (XDKs). XDKs provide common development-time utilities that can run in the middle tier in Oracle9iAS or in Oracle9i database.

See Also:

Oracle9i XML Developer's Kits Guide - XDK. for more information about XDK

Benefits of Oracle XML DB

Applications often manage structured data as tables and unstructured data as files or Large Objects (LOBs). This subjects developers to different paradigms for managing different kinds of data. Systems channel application-development down either of the following paths:

Oracle XML DB provides the following benefits:

Key Features of Oracle XML DB

Table 1-1 describes Oracle XML DB features. This list includes XML features available since Oracle9i Release 1 (9.0.1).

Table 1-1 Oracle XML DB Features  
Oracle XML DB Features Description


The native datatype XMLType helps store and manipulate XML. Multiple storage options (Character Large Object (CLOB), structured XML) are available with XMLType, and administrators can choose a storage that meets their requirements. CLOB storage is an un-decomposed storage that is like an image of the original XML.

The native structured XML storage is a shredded decomposition of XML into underlying object-relational structures (automatically created and managed by Oracle) for better SQL queriability.

With XMLType, you can perform SQL operations such as:

  • Queries, OLAP function invocations, and so on, on XML data, as well as XML operations
  • XPath searches, XSL transformations, and so on, on SQL data

You can build regular SQL indexes or Oracle Text indexes on XMLType for high performance for a very broad spectrum of applications. See Chapter 4, "Using XMLType".

DOM fidelity

The Document Object Model (DOM) is a standard programmatic representation of XML documents. Oracle XML DB can shred XML documents while storing them (structured XML Storage) in a manner that maintains DOM fidelity: the DOM that you store is the DOM that you get back. DOM fidelity means that your programs can manipulate exactly the same XML data that you got, and the process of storage does not affect the order of elements, the presence of namespaces and so on. DOM fidelity does not, however, imply maintenance of whitespaces, and the like; if you want to preserve the exact layout of XML including whitespaces you can use CLOB storage. See Chapter 5, "Structured Mapping of XMLType".

Document fidelity

For applications that need to store XML while maintaining complete fidelity to the original, including whitespace characters, the CLOB storage option is available.

XML Schema

Oracle XML DB gives you the ability to constrain XML documents to XML schemas. You can create tables and types automatically given a W3C standard XML Schema. You can also enforce that an XML document being stored is schema-valid. This means you have a standard data model for all your data (structured and unstructured) and can use the database to enforce this data model. See Chapter 5, "Structured Mapping of XMLType".

XML Schema storage with DOM fidelity

Use structured storage (object-relational) columns, VARRAYs, nested tables, and LOBs to store any element or element-subtree in your XML schema and still maintain DOM fidelity (DOM stored == DOM retrieved). See Chapter 5, "Structured Mapping of XMLType".

Note: If you choose CLOB storage option, available with XMLType since Oracle9i Release 1 (9.0.1), you can keep whitespaces.

XML Schema validation

While storing XML documents in Oracle XML DB you can optionally ensure that their structure complies (is "valid" against) with specific XML Schema. See Chapter 6, "Transforming and Validating XMLType Data".

XML piecewise update

You can use XPath to specify individual elements and attributes of your document during updates, without rewriting the entire document. This is more efficient, especially for large XML documents. See Chapter 5, "Structured Mapping of XMLType".

XPath search

You can use XPath syntax (embedded in an SQL statement or as part of an HTTP request) to query XML content in the database. See Chapter 4, "Using XMLType" and Chapter 7, "Searching XML Data with Oracle Text".

XML indexes

Use XPath to specify parts of your document to create indexes for XPath searches. Enables fast access to XML documents. See Chapter 4, "Using XMLType".

SQLX operators

New SQL member functions tracking the emerging ANSI SQLX standard, such as, XMLElement (to create XML elements on the fly) and others, to make XML queries and on-the-fly XML generation easy. These render SQL and XML metaphors interoperable.See Chapter 10, "Generating XML Data from the Database".

XSL transformations for XMLType

Use XSLT to transform XML documents through an SQL operator. Database-resident, high-performance XSL transformations. See Chapter 6, "Transforming and Validating XMLType Data" and Appendix D, "XSLT Primer".

Lazy XML loading

Oracle XML DB provides a virtual DOM; it only loads rows of data as they are requested, throwing away previously referenced sections of the document if memory usage grows too large. You can use this to get high scalability when many concurrent users are dealing with large XML documents. The virtual DOM is available through Java interfaces running in a Java execution environment at the client or with the server. See Chapter 8, "PL/SQL API for XMLType".

XML views

You can create XML views to create permanent aggregations of various XML document fragments or relational tables. You can also create views over heterogeneous data sources using Oracle Gateways. See Chapter 11, "XMLType Views".

PL/SQL and OCI interfaces

Use DOM and other APIs for accessing and manipulating XML data. You can get static and dynamic access to XML. See Chapter 8, "PL/SQL API for XMLType".

Schema caching

Structural information (such as element tags, datatypes, and storage location) is kept in a special schema cache, to minimize access time and storage costs. See Chapter 5, "Structured Mapping of XMLType".

XML generation

SQL operators such as SYS_XMLGEN and SYS_XMLAGG provide native, high-performance generation of XML from SQL queries. New operators such as XMLElement(), to create XML tables and elements on the fly, make XML generation more flexible. See Chapter 10, "Generating XML Data from the Database". These operators track the emerging ANSI SQLX standard.

Oracle XML DB Repository

A built-in XML Repository. This Repository can be used for foldering whereby you can view XML content stored in Oracle XML DB as a hierarchy of directory-like folders. See Chapter 13, "Oracle XML DB Foldering".

  • The repository supports access control lists (ACLs) for any XMLType object, and lets you define your own privileges in addition to providing certain system-defined ones. See Chapter 18, "Oracle XML DB Resource Security".
  • You can use the Repository to view XML content as navigable directories through a number of popular clients and desktop tools. Items managed by the repository are called resources.
  • Hierarchical indexing is enabled on the Repository. Oracle XML DB provides a special hierarchical index to speed folder search. Additionally, you can automatically map hierarchical data in relational tables into folders (where the hierarchy is defined by existing relational information, such as with CONNECT BY).

SQL Repository search

You can search the XML Repository using SQL. Operators like UNDER_PATH and DEPTH allow applications to search folders, XML file metadata (such as owner and creation date), and XML file content. See Chapter 15, "RESOURCE_VIEW and PATH_VIEW".

WebDav, HTTP, and FTP access

You can access any foldered XMLType row using WebDAV and FTP. Users manipulating XML data in the Oracle9i database can use the HTTP API. See Chapter 19, "Using FTP, HTTP, and WebDAV Protocols".


Oracle XML DB provides versioning and version-management capabilities over resources managed by the XML Repository. See Chapter 14, "Oracle XML DB Versioning".

Oracle XML DB and XML Schema

XML schema unifies both document and data modeling. In Oracle XML DB, you can create tables and types automatically using XML Schema. In short, this means that you can develop and use a standard data model for all your data, structured, unstructured, and pseudo/semi-structured. You can now use Oracle9i database to enforce this data model for all your data.

You can create XML schema-based XMLType tables and columns and optionally specify, for example, that they:

You can also choose to wrap existing relational and object-relational data into XML format using XMLType views.

You can store an XMLType object as an XML schema-based object or a non-XML schema-based object:

You can map from XML instances to structured or LOB storage. The mapping can be specified in XML schema and the XML schema must be registered in Oracle XML DB. This is a required step before storing XML schema-based instance documents. Once registered, the XML schema can be referenced using its URL.

Oracle XML DB Architecture

Figure 1-1 shows the Oracle XML DB architecture. The two main features in Oracle XML DB architecture are:

The section following Figure 1-1 describes the architecture in more detail.

Figure 1-1 Oracle XML DB Architecture: XMLType Storage and Repository

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

XMLType Tables and Views Storage

"XMLType tables and views storage" in Oracle XML DB provides a native XML storage and retrieval capability in the database, strongly integrated with SQL.

XML data, including XML schema definition files can be stored in LOBs, in structured storage (object-relationally), or using any hybrid combining both LOBs and structured storage. See Chapter 3, "Using Oracle XML DB" and Chapter 4, "Using XMLType".

Supported XML Access APIs

Supported XML Services

In Oracle XML DB, besides accessing or generating XML data, you can also perform various operations on the data:

Oracle XML DB Repository

Oracle XML DB Repository (XML Repository or Repository) is an XML data repository in the Oracle9i database optimized for handling XML data. At the heart of Oracle XML DB Repository is the Oracle XML DB foldering module.

See Also:

Chapter 13, "Oracle XML DB Foldering".

The contents of Oracle XML DB Repository are referred to as resources. These can be either containers (or directories / folders) or files. All resources are identified by a path name and have a (extensible) set of (metadata) properties such as Owner, CreationDate, and so on, in addition to the actual contents defined by the user.

Supported XML Access APIs

Figure 1-1 lists the following Oracle XML DB supported XML access and manipulation APIs:

Supported XML Services

XML Repository, besides supporting APIs to access and manipulate XML and other data, also supports the following services:

XMLType Storage Architecture

Figure 1-2 describes the XMLType tables and views storage architecture in more detail.

For XMLType tables, tables with XMLType columns, and views, if XML schema-based and the XML schema is registered with Oracle XML DB, XML elements are mapped to database tables. These can be easily viewed and accessed in XML Repository.

Data in XMLType tables and tables containing XMLType columns can be stored in Character Large Objects (CLOBs) or natively in structured XML storage.

Data in XMLType views can be stored in local tables or remote tables that are accessed using DBLinks.

Both XMLType tables and views can be indexed using B*Tree, Oracle Text, function-based, or bitmap indexes.

Options for accessing data in XML Repository include:

Figure 1-2 Oracle XML DB: XMLType Storage and Retrieval Architecture

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

Cached XML Object Management Architecture

Figure 1-3 shows the Oracle XML DB Cached XML Object Management Architecture, relevant for programmatic access to XMLType instances. The Oracle XML DB cache can be deployed at the client (with Oracle JDBC OCI driver) or within the server. This cache provides:

You can thus get dynamic access to XML without having to materialize an entire XML DOM in memory. This is accomplished by calculating offsets to the nodes in the DOM during compilation.

Figure 1-3 Cached XML Object Management Architecture

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

XML Repository Architecture

Figure 1-4 describes the Oracle XML DB Repository (XML Repository) architecture.

A resource is any piece of content managed by Oracle XML DB, for which we desire to maintain or view the file/folder metaphor.

Each resource has a name, an associated access control list that determines who can see the resource, certain static properties, and some extra ones that are extensible by the application. The application using the Repository obtains a logical view of folders in parent-child arrangement. The Repository is available in the database (for example, for SQL access) using the RESOURCE_VIEW.

The RESOURCE_VIEW in Oracle9i database consists of a Resource (itself an XMLType), that contains the queryable name of the resource, its ACLs, and its properties, static or extensible.

Parent-child relationships between folders (necessary to construct the hierarchy) are maintained and traversed efficiently using the hierarchical index. Text indexes are available to search the properties of a resource, and internal B*Tree indexes over Names and ACLs speed up access to these attributes of the Resource XMLType.

In addition to the resource information, the RESOURCE_VIEW also contains a Path column, which holds the paths to each resource.

See Also:

Figure 1-4 Oracle XML DB: Repository Architecture

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

Why Use Oracle XML DB?

The following section describes Oracle XML DB advantages for building XML database applications. The main advantages are:

Unifying Data and Content with Oracle XML DB

Most applications' data and Web content is stored in a relational database or a file system, or a combination of both. XML is used mostly for transport and is generated from a database or a file system. As the volume of XML transported grows, the cost of regenerating these XML documents grows and these storage methods become less effective at accommodating XML content. See Figure 1-5. Oracle XML DB is effective at accommodating XML content. It provides enhanced native support for XML.

Figure 1-5 Unifying Data and Content: Some Common XML Architectures

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

Organizations today typically manage their structured data and unstructured data differently:

With Oracle XML DB you can store and manage both structured, unstructured, and pseudo or semi-structured data, using a standard data model, and standard SQL and XML.

Oracle XML DB provides complete transparency and interchangeability between XML and SQL. You can perform both the following:

This makes the database much more accessible to XML-shaped data content.

Exploiting Database Capabilities

In previous releases, without strong database XML support, you most likely stored your XML data in files or in unstructured storage such as CLOBs. Whether you stored your XML data in files or CLOBs, you did not exploit several key capabilities of Oracle database:

Exploiting XML Capabilities

If the drawbacks of XML file storage force you to break down XML into database tables and columns, there are several XML advantages you have left:

Oracle XML DB Offers Faster Storage and Retrieval of Complex XML Documents

Users today face a performance barrier when storing and retrieving complex, large, or many XML documents. Oracle XML DB provides very high performance and scalability for XML operations. The major performance features are:

Oracle XML DB Helps You Integrate Applications

Oracle XML DB enables data from disparate systems to be accessed through gateways and combined into one common data model. This reduces the complexity of developing applications that must deal with data from different stores.

When Your Data Is Not XML You Can Use XMLType Views

XMLType views provide a way for you wrap existing relational and object-relational data in XML format. This is especially useful if, for example, your legacy data is not in XML but you need to migrate to an XML format. Using XMLType views you do not need to alter your application code.

See Also:

Chapter 11, "XMLType Views".

To use XMLType views you must first register an XML schema with annotations that represent the bi-directional mapping from XML to SQL object types and back to XML. An XMLType view conforming to this schema (mapping) can then be created by providing an underlying query that constructs instances of the appropriate SQL object type. Figure 1-6 summarizes the Oracle XML DB advantages.

Figure 1-6 Oracle XML DB Benefits

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

Searching XML Data Stored in CLOBs Using Oracle Text

Oracle enables special indexing on XML, including Oracle Text indexes for section searching, special operators to process XML, aggregation of XML, and special optimization of queries involving XML.

XML data stored in Character Large Objects (CLOBs) or stored in XMLType columns in structured storage (object-relationally), can be indexed using Oracle Text. HASPATH() and INPATH() operators are designed to optimize XML data searches where you can search within XML text for substring matches.

Oracle9i Release 2 (9.2) also provides:

Building Oracle XML DB XML Messaging Applications with Advanced Queueing

Advanced Queueing now supports the use of:

Managing Oracle XML DB Applications with Oracle Enterprise Manager

You can use Oracle Enterprise Manager (Enterprise Manager) to manage and administer your Oracle XML DB application. Enterprise Manager's graphical user interface facilitates your performing the following tasks:

Requirements for Running Oracle XML DB

Oracle XML DB is available with Oracle9i Release 2 (9.2).


Standards Supported by Oracle XML DB

Oracle XML DB supports all major XML, SQL, Java, and Internet standards:

Oracle XML DB Technical Support

Besides your regular channels of support through your customer representative or consultant, technical support for Oracle XML-enabled technologies is available free through the Discussions option on Oracle Technology Network (OTN):

You do not need to be a registered user of OTN to post or reply to XML-related questions on the OTN technical discussion forum. To use the OTN technical forum follow these steps:

  1. In the left-hand navigation bar of the OTN site, select Support > Discussions.
  2. Click Enter a Technical Forum.
  3. Scroll down to the Technologies section. Select XML.
  4. Post any questions, comments, requests, or bug reports.

Terminology Used in This Manual

Table 1-2 describes terms used in this manual.

See Also:


Table 1-2 Terminology Used in This Manual  
Term Used in Manual Description

XML Schema

XML Schema is a schema definition language (also in XML) that can be used to describe the structure and various other semantics of conforming instance documents. See Appendix B, "XML Schema Primer".

Oracle XML DB uses annotated XML schemas, that is, XML schemas that include additional attributes defined by Oracle XML DB. The Oracle XML DB attributes serve to specify metadata that in turn determines both the XML structuring and its mapping to a database schema. You can register XML schemas and then use the appropriate XML schema URLs while creating XMLType tables and columns and also to define XMLType views. See:


A language for addressing parts of an XML document, for use by XSLT and XPointer. XPath uses the directory traversal syntax to traverse an XML document. It includes syntax for specifying predicate expressions on the nodes traversed. The result of a XPath traversal is an XML fragment. See Appendix C, "XPath and Namespace Primer".


A stylesheet language used for transforming XML documents to HTML, XML or any other formats. See Appendix D, "XSLT Primer".


Document Object Model (DOM) is an application program interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. In the DOM specification, the term "document" is used in the broad sense.

XML is increasingly being used as a way of representing many different kinds of information that may be stored in diverse systems, and much of this would traditionally have been seen as data rather than as documents. Nevertheless, XML presents this data as documents, and DOM can be used to manage this data.

With DOM, you can build documents, navigate their structure, and add, modify, or delete elements and content. Anything in an HTML or XML document can be accessed, changed, deleted, or added using DOM, with a few exceptions. DOM is designed for use with any programming language.

Oracle XML DB provides implementations of DOM APIs to operate on XMLType instances using various client APIs including PL/SQL DOM, Java DOM, and C DOM (for OCI clients). See

Oracle XML DB Repository

See also Chapter 3, "Using Oracle XML DB"


An object identified by a URL. In compliance with HTTP and WebDAV standards, it has a set of system properties, such as displayname, creationdate, and so on. In all cases, it maintains a reference count and destroys any associated data when the last URL binding to it is removed. It maintains an access control list (ACL) and owner. An Oracle XML DB resource is an XMLType mapped to a path name that contains these properties. See Chapter 15, "RESOURCE_VIEW and PATH_VIEW".


Oracle XML DB Repository is the set of all Oracle XML DB resources. The Repository is a hierarchically organized set of XMLType objects, each with a path name to identify them. Think of the Oracle XML DB Repository as a file system of objects rather than files. There is one root to this Repository ("/"), which contains a set of resources, each with a path name. Resources that contain ("contain" with respect to the hierarchical naming system) other resources are called folders (see "Folder" in the following).

Oracle XML DB objects can have many path names (that is, a resource can be in more than one folder). In some sense, the database itself is the Repository, since any database object can be mapped to a path name. However, Oracle XML DB uses "Repository" to refer to the set of database objects, in any schema, that are mapped to path names. See Chapter 13, "Oracle XML DB Foldering".


A non-leaf node object in Oracle XML DB Repository, or one with the potential to be such a node. Oracle XML DB has special storage semantics for collections for optimization reasons. It maintains a special kind of hierarchical index used to navigate the hierarchy of collections, and defines a property, called name that is used to form path names in the hierarchy. There are many names for collections, such as folders and directories. Any XML element type can be a folder by specifying the isFolder attribute in the Oracle XML DB schema. See Chapter 13, "Oracle XML DB Foldering".


A hierarchical name is composed of a root element (the first /), element separators (/), and various sub-elements (or path elements). A path element can be composed of any character in the database character set except the following ('\' `/'). In Oracle XML DB, a forward slash is the default name separator in a path name.

Resource Name

A resource here means any database object stored in Oracle XML DB Repository. Resource name is the name of a resource within its parent folder. Resource names are the path elements, that is, filenames within folders. Resource names must be unique (potentially subject to case-insensitivity) within a folder.


The body of a resource is what you get when you treat the resource like a file and ask for its contents.


An XML element defined by the Oracle XML DB schema that contains binary data. XDBBinary elements are stored in the Repository when completely unstructured binary data is uploaded into Oracle XML DB.

ACL Terminology

See also Chapter 18, "Oracle XML DB Resource Security"

Access Control List (ACL)

Restricts access to an object. Oracle XML DB uses ACLs to restrict access to any Oracle XML DB resource, that is, any XMLType object that is mapped into the Oracle XML DB file system hierarchy.

Protocol Terminology

See also Chapter 19, "Using FTP, HTTP, and WebDAV Protocols" and Chapter 3, "Using Oracle XML DB"


"File Transfer Protocol". Defined as an Internet Standard (STD009) in RFC959. Oracle XML DB implements this standard. FTP is implemented by both dedicated clients at the operating system level, file system explorer clients, and browsers. FTP is commonly used for bulk file upload and download and for scripting of Repository maintenance. FTP can be used in a mode similar to HTTP, with frequent session establishment/destruction, by browsers in "passive" mode.


"HyperText Transfer Protocol". Oracle XML DB implements HTTP 1.1 as defined in RFC2616. Oracle XML DB implements cookies, basic authentication, and HTTP/1.1 (RFC2616, 2109 & 2965) in this release.


Web Distributed Authoring and Versioning (WebDav). Oracle XML DB supports RFC2518 and access control in this release.


Sun developed a widely accepted standard for invoking Java code as the result of protocol requests and passing parameters to that request. Servlets are most commonly implemented with HTTP. The majority of Java services are implemented as servlets, through mechanisms (implemented in Java) such as JSPs (Java Server Pages) or SOAP (Simple Object Access Protocol). Servlets thus form the architectural basis for a large percentage of web application development.

Oracle XML DB provides a method for invoking Java stored procedures over protocols other than Oracle Services (Net Services). Oracle XML DB implements most servlet standards. Chapter 20, "Writing Oracle XML DB Applications in Java".

Oracle XML DB Examples Used in This Manual

This manual contains examples that illustrate the use of Oracle XML DB and XMLType. The examples are based on a number of database schema, sample XML documents, and sample XML schema. The infrastructure for the examples is described, in most cases, with the examples in each chapter.

See Also: