Creating a Relational View on XML Data

Next, let’s look at matters from the other way around. If you have a set of XML documents, how do you access the data via relational SQL queries? Some Oracle database applications, such as APEX applications, are created mainly to work on relational database schemas. How can you enable these applications to access XML content? In Oracle XML DB 11g, the best approach is to create relational views using XMLTable().

The XMLTable() function can set up the mapping between the XML data and relational data using the XQuery and XPath expressions. The following is an example (create_email_template_ img_vw.sql):

Listing 9-8 Creating XML View in XML DB Repository Using XMLTable()

CREATE OR REPLACE VIEW email_template_img_vw ...

Get Oracle Database 11g Building Oracle XML DB Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.