|
|
With version 10g, Oracle has fully incorporated XML into its architecture and created an ideal
platform for modern development. XML has emerged over the past few years as the de facto standard
for portable data storage. With its human-readable hierarchical structure, XML provides an attractive
medium for a data repository, but its positive attributes also make XML much harder to manage.
Since version 8i, Oracle has incorporated tools in the database to make working with XML much
easier for developers. Oracle calls its core XML technology XML DB. After reading this chapter,
you will have an understanding of the basic technologies included with XML DB and how and
when to use them.
Overview of the XML DB Repository
Oracle and other databases have traditionally been used to manage relational data stored in a table
structure. While the relational model has been proven to be highly successful at managing strongly
related data, it is less successful at managing hierarchical data that is loosely related. Relational
data lends itself nicely to being stored in table structures with key relationships to connect it to
other data. Hierarchical data like XML tends to be stored best in a hierarchical folder structure like
a file system. Oracle combines both of these storage methods to give you the best of both worlds:
an extremely powerful relational engine and a highly optimized hierarchical storage engine for
XML data.
Examples in this section use the Order Entry sample schema included with Oracle.
The schema name Oracle creates is OE. If you created the sample database when
installing Oracle, you probably have the OE schema installed. If not, you can install
it using the Database Configuration Assistant (dbca). Check the Oracle documentation
for more information about installing the sample schemas.
Oracle XML DB stores XML data in tables optimized for this purpose. Oracle makes use of a highly
optimized foldering module to map relational structures to path-based structures, as well as special
indexes on these tables to speed up path-based access. Oracle can access path-based resources with the
same speed if not faster than the OS file system.
The repository also provides several ways of getting data in and out for use with applications. The Oracle
XML DB repository allows for both SQL-based access and path-based access. SQL-based access is
traditionally what developers think of when dealing with a database. You can query tables and views
using either PL/SQL or Java to get data out of the repository. Path-based access is new, and it provides a
very powerful and easy way to get data in and out of the repository using familiar file system–type
syntax.XML DB is tightly coupled with Oracle’s foldering module, which generates and tracks path information
for resources stored in the database, and Oracle’s protocol servers, which provide access to the repository
using standards-based protocols like WebDAV (Web-based Distributed Authoring and Versioning), HTTP
(Hypertext Transfer Protocol), and FTP (File Transfer Protocol). It is possible to use standard business
applications like Microsoft Office to update XML content in Oracle simply by writing to a virtual file
system over one of these protocols.
Following is a summation of SQL-based access:
? Uses SQL for querying data
? Uses XMLType API for XML manipulation using PL/SQL, Java, or C
Following are characteristics of path-based access:
? Uses standard URIs to access data
? Can use SQL RESOURCE_VIEW and PATH_VIEW to access data
? Can use standard protocols like FTP, HTTP, and WebDAV to access content in the repository
Protocol-Based Access to XML in the Oracle Repository
One of the most powerful and useful new additions to Oracle is the ability to work with XML data
stored in relational tables as if it is located on the file system. Oracle makes this possible by building
popular protocols like FTP, HTTP, and WebDAV right into the database. To external applications like
Web application servers, content management applications, and content creation tools, the Oracle XML
repository can look like any other file system.
If you have XDB installed and configured (the sample database Oracle installs for you is already configured
for XDB), you can access a schema via HTTP over port 8080. The following examples use the OE sample
schema. You may have to log in to Enterprise Manager and enable the schema before you can log in.
To log in to the database, you simply go to http://your_server_address:8080/. Oracle will prompt
you for a login and password. These would be the same as the login you would use to log in to the schema
using SQL Plus. Once logged in, you should see something similar to Figure 22-1 in your Web browser. |
|
|
|
|
|