Friday, May 25, 2007

oracle xml db

ORACLE XML DB

This white paper provides an overview of ORACLE XML DB. It will provide information on why and where to use oracle xml db. Features of using oracle XML DB and functional architectural model of oracle XML DB. This will provide all the usage of DML and DDL statements used in oracle XML DB.
It will club all the necessary information required to start using oracle xml db. It also has information like how to register schema’s for xml type table and how to insert, update, alter and select node value from XML file.
This also provides information on retrieving xml attribute value from xml node and how to retrieve entire xml file in to an object. It will also provide information on JNDI Lookup and Java beans generation in Oracle XML DB and all pros and corns of xml storage option in Oracle XML DB.

1. Why Oracle XML DB?

Oracle XML DB is the name for a set of Oracle Database technologies related to high-performance XML storage and retrieval. It provides native XML support by encompassing both SQL and XML data models in an interoperable manner.

1.1 Features of Oracle XML DB:
Oracle XML DB includes the following features:
· Support for the World Wide Web Consortium (W3C) XML and XML Schema data models and standard access methods for navigating and querying XML. The data models are incorporated into Oracle Database.
· Ways to store, query, update, and transform XML data while accessing it using SQL.
· Ways to perform XML operations on SQL data.
· A simple, lightweight XML repository where you can organize and manage database content, including XML, using a file/folder/URL metaphor.
· A storage-independent, content-independent and programming language-independent infrastructure for storing and managing XML data. This provides new ways of navigating and querying XML content stored in the database. For example, Oracle XML DB Repository facilitates this by managing XML document hierarchies.
· Industry-standard ways to access and update XML. The standards include the W3C XPath recommendation and the ISO-ANSI SQL/XML standard. FTP, HTTP(S), and WebDAV can be used to move XML content into and out of Oracle Database. Industry-standard APIs provide programmatic access and manipulation of XML content using Java, C, and PL/SQL.
· XML-specific memory management and optimizations.
· Enterprise-level Oracle Database features for XML content: reliability, availability, scalability, and security.
Oracle XML DB can be used in conjunction with Oracle XML Developer's Kit (XDK) to build applications that run in the middle tier in either Oracle Application Server or Oracle Database.
2. Oracle XML DB Architecture:
Figure 1-1 shows the Oracle XML DB architecture. The two main features in Oracle XML DB architecture are:
The XMLType tables and views storage, which includes storage of XMLType tables and views
The Oracle XML DB Repository, also referred to in this manual as "XML Repository" or "Repository"

3. XMLType Tables and Views Storage:
"XMLType table s 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.

3.1 Supported XML Access APIs:
PL/SQL and Java APIs for XMLType. Use these APIs to:
Create XMLType tables, columns, and views
Query and retrieve XML data
SQL functions, such as XMLElement()and XMLForest(). Applications can query XML data in the database using standard SQL and SQL member functions that comply with the SQLX standard.

3.2 Supported XML Services:
In Oracle XML DB, besides accessing or generating XML data, you can also perform various operations on the data:
PL/SQL and Java APIs for XMLType. These enable you to manipulate XMLType data, such as update, delete, and insert XML data.
Indexing. This speeds up data searches where XPath features are not critical. It is most suited for XML data stored in LOBs.
Transforming XML data to other XML, HTML, and so on, using XMLType's XMLTransform() function, XDK's XSLT Processors, or XSQL Servlet Pages Publishing Framework..
Validating XML data. Validates XML data against XML schema when the XML data is stored in the database.

3.3 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.
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.

3.4 Supported XML Access APIs:
Oracle XML DB Resource APIs. Use these APIs to access the foldered XMLType and other data, that is, data accessed using the Oracle XML DB hierarchically indexed Repository. The APIs are available in the following languages:
SQL (through the RESOURCE_VIEW and PATH_VIEW APIs)
PL/SQL (DBMS_XDB) API
JNDI (Java/JNI) API o
Oracle XML DB Protocol Server. Oracle XML DB supports FTP, HTTP, and WebDav protocols, as well as JDBC, for fast access of XML data stored in the database in XMLType tables and columns.

3.5 Supported XML Services:
XML Repository, besides supporting APIs to access and manipulate XML and other data, also supports the following services:
Versioning. Oracle XML DB provides support for versioning resources. The 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.
ACL Security. Security of accessing Oracle XML DB resources is based on the ACL (Access Control Lists) mechanism. Every resource in Oracle XML DB has an associated ACL that lists its privileges. Whenever resources are accessed or manipulated, these ACLs determine if the operation is legal.

Foldering. XML Repository's foldering module manages a persistent hierarchy of containers, also known as folders or directories, and resources. Other Oracle XML DB modules, such as protocol servers, the schema manager, and the Oracle XML DB RESOURCE_VIEW API, use the foldering module to map path names to resources.

4. XMLType Storage Architecture:
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:
HTTP, through the HTTP protocol handler.
WebDav and FTP, through the WebDav and FTP protocol server.
SQL, through Oracle Net Services including JDBC. Oracle XML DB also supports XML data messaging using Advanced Queueing (AQ) and SOAP.
5. Cached XML Object Management Architecture:
The Oracle XML DB cache can be deployed at the client (with Oracle JDBC OCI driver) or within the server. This cache provides:
A lazily materialized virtual DOM from the stored XMLType, whose nodes are fetched on demand
A cache for XML schemas
You can thus get dynamic access to XML without having to materialize an entire XML DOM in memory. Static (Java Bean) access is also available. This is accomplished by calculating offsets to the nodes in the DOM during compilation.
5.1 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:
Native XMLType.
The lazily evaluated virtual DOM support.
Database-integrated ad-hoc XPath and XSLT support. This support is described in several chapters, including
XML Schema-caching support.
CTXPATH Text indexing.
The hierarchical index over the Repository.
5.2 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.

6. 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.
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.

No comments: