Oracle9i XML Database Developer's Guide - Oracle XML DB Release 2 (9.2) Part Number A96620-02 |
|
|
View PDF |
This chapter introduces you to Oracle XML DB by describing the Oracle XML DB benefits, features, and architecture. This chapter contains the following sections:
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.
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 |
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:
Table 1-1 describes Oracle XML DB features. This list includes XML features available since Oracle9i Release 1 (9.0.1).
Oracle XML DB Features | Description |
---|---|
XMLType |
The native datatype 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
You can build regular SQL indexes or Oracle Text indexes on |
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". |
|
For applications that need to store XML while maintaining complete fidelity to the original, including whitespace characters, the CLOB storage option is available. |
|
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". |
|
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 |
|
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". |
|
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". |
|
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". |
|
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". |
|
New SQL member functions tracking the emerging ANSI SQLX standard, such as, |
|
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". |
|
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". |
|
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". |
|
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". |
|
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". |
|
SQL operators such as |
|
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".
|
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". |
|
You can access any foldered |
|
Oracle XML DB provides versioning and version-management capabilities over resources managed by the XML Repository. See Chapter 14, "Oracle XML DB Versioning". |
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.
Figure 1-1 shows the Oracle XML DB architecture. The two main features in Oracle XML DB architecture are:
XMLType
tables and viewsThe section following Figure 1-1 describes the architecture in more detail.
"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".
XMLType
. Use these APIs to:
XMLElement()
and XMLForest()
. Applications can query XML data in the database using standard SQL and SQL member functions that comply with the SQLX standard.
See Also:
Part IV. Viewing Existing Data as XML. |
In Oracle XML DB, besides accessing or generating XML data, you can also perform various operations on the data:
XMLType
data, such as update, delete, and insert XML data.XMLType's
XMLTransform()
function, XDK's XSLT Processors, or XSQL Servlet Pages Publishing Framework. See Chapter 6, "Transforming and Validating XMLType Data" and Chapter 10, "Generating XML Data from the Database".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.
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.
Figure 1-1 lists the following Oracle XML DB supported XML access and manipulation APIs:
XMLType
and other data, that is, data accessed using the Oracle XML DB hierarchically indexed Repository. The APIs are available in the following languages:
DBMS_XDB
) APISee Also:
Part V. Oracle XML DB Repository: Foldering, Security, and Protocols |
XMLType
tables and columns. See Chapter 19, "Using FTP, HTTP, and WebDAV Protocols".XML Repository, besides supporting APIs to access and manipulate XML and other data, also supports the following services:
DBMS_XDB_VERSION
PL/SQL package implements functions to make a resource version-controlled. Any subsequent updates to the resource results in new versions being created while the data corresponding to the previous versions is retained.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-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:
XMLType
, whose nodes are fetched on demandYou 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-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.
XMLType
table or view), the RESOURCE_VIEW points to that XMLType
row that stores the content.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.
The following section describes Oracle XML DB advantages for building XML database applications. The main advantages are:
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.
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.
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:
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:
XMLType
enables you to write applications without that knowledge and allows DBAs to map structured data to physical table and column storage. See Chapter 5, "Structured Mapping of XMLType" and Chapter 13, "Oracle XML DB Foldering".XMLType
examples.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:
XMLType
. See Chapter 4, "Using XMLType".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.
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.
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.
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:
CONTAINS()
function that can be used with existsNode()
for XPath based searches. This is for use as the ora:contains
function in an XPath query, as part of existsNode()
.UriType
and XDBUriType
columns.CTXXPATH
, that allows higher performance XPath searching in Oracle XML DB under existsNode()
.
Advanced Queueing now supports the use of:
XMLType
as a message/payload type, including XML schema-based XMLType
XMLType
messages
See Also:
|
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:
Oracle XML DB is available with Oracle9i Release 2 (9.2).
See:
|
Oracle XML DB supports all major XML, SQL, Java, and Internet standards:
web.xml
is not supported in its entirety, and only one ServletContext
and one web-app
are currently supported, and stateful servlets are not supported). See Chapter 20, "Writing Oracle XML DB Applications in Java".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:
Table 1-2 describes terms used in this manual.
Term Used in Manual | Description |
---|---|
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 |
|
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 |
|
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 |
|
Oracle XML DB Repository is the set of all Oracle XML DB resources. The Repository is a hierarchically organized set of 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 |
|
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. |
|
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 |
|
Restricts access to an object. Oracle XML DB uses ACLs to restrict access to any Oracle XML DB resource, that is, any |
|
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". |
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:
|