Reviews
PHP Oracle Training TutorialsUsing Oracle XML DB Repository
Using Oracle XML DB Repository
Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository, which is an essential component of Oracle XML DB.
NOTE: Oracle XML DB repository, also known as XML repository, is a hierarchically organized repository seamlessly integrated with Oracle Database, containing resources that can be manipulated using a file/ folder/URL metaphor.
The most significant thing about XML repository is that it makes it possible to access and manipulate XML data in a number of different ways, including SQL, PL/SQL, and standard internet protocols, such as HTTP, FTP, and WebDAV. Graphically, it looks as shown in the following figure.

You may find it convenient to think of Oracle XML DB repository as a file system whose metadata and data are stored in the database. Like a conventional file system, Oracle XML DB repository contains resources: files and folders. However, in the case of XML repository, each resource also can be accessed through SQL.
NOTE: Although XML repository is optimized for working with XML data, you can use it to store non-XML data as well. For example, you might store a collection of pictures there.
Manipulating Repository Resources with PL/SQL
Oracle XML DB provides PL/SQL package DBMS_XDB to access Oracle XML DB repository programmatically from within PL/SQL code.
For example, to create a repository folder and then a resource in that folder, you might use the DBMS_XDB.createFolder and DBMS_XDB.createResource function respectively, as follows:
- CONN xmlusr/xmlusr;
- DECLARE
- rslt BOOLEAN;
- xmldoc VARCHAR2(250) :=
- '<EMPLOYEE
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" target="_blank" rel="nofollow"
- xsi:noNamespaceSchemaLocation="employee.xsd"
- id="303">
- <ENAME>Locke</ENAME>
- <SALARY>7000</SALARY>
- </EMPLOYEE>';
- BEGIN
- IF (NOT DBMS_XDB.existsResource('/public/xmlusr')) THEN
- rslt:=DBMS_XDB.createFolder('/public/xmlusr');
- END IF;
- IF (NOT DBMS_XDB.existsResource('/public/xmlusr/emps')) THEN
- rslt:=DBMS_XDB.createFolder('/public/xmlusr/emps');
- END IF;
- rslt := DBMS_XDB.createResource('/public/xmlusr/emps/emp303.xml',
- xmldoc);
- COMMIT;
- END;
- /
As you can see, when creating a resource, regardless of whether it is a file or folder, you must specify an absolute path to that resource. This is required because, as in a conventional file system, each resource in the XML repository is identified by a path and name.
PHP Oracle Training Tutorials
- PHP Oracle Web Development
- XML Processing in PHP and Oracle Applications
- Creating XML with the DOM PHP Extension
- Querying a DOM Document with XPath
- Transforming and Processing XML with XSLT
- Performing XML Processing inside the Database
- Moving All the XML Processing into the Database
- Performing XSLT Transformations inside the Database
- Using Oracle Database for Storing, Modifying, and Retrieving XML Data
- Using XMLType for Handling XML Data in the Database
- Using XML Schemas
- Retrieving XML Data
- Using XMLType Views
- Performing DML Operations on XML Schema Based XMLType Views
- Using Oracle XML DB Repository
- Accessing Repository Resources with SQL
- Taking Advantage of Standard Internet Protocols
- Querying Data with Oracle XQuery
- Breaking up XML into Relational Data







