Producing and Transforming XML Query Results

In this section, we’ll briefly cover the following mechanisms available to PL/SQL in Oracle8i for producing XML from SQL queries and for transforming XML using XSLT transformations:

  • The XML SQL Utility provides capabilities to automatically deliver the results of any valid SELECT statement as an XML document.

  • The Oracle XSLT processor implements a transformation engine for XML documents that is compliant with the W3C XSLT 1.0 Recommendation (see http://www.w3.org/TR/1999/REC-xslt-19991116), and that allows you to transform XML in one format into XML, HTML, or plain text of another format.

These topics are covered in detail in Chapter 7, and Chapter 9, so here we will focus mostly on the basic PL/SQL syntax of working with the XML SQL Utility and the Oracle XSLT processor. First, we’ll cover the steps required to verify that these facilities are properly installed in your database, then we’ll cover simple examples of their use.

Installing the XML SQL Utility and XSLT Processor

First, check to see if the Oracle XML SQL Utility is already installed in your Oracle8i database by doing the following:

  1. Connect to your Oracle8i database with SQL*Plus:

    sqlplus xmlbook/xmlbook
  2. Check the status of the oracle.xml.sql.query.OracleXMLQuery class by running the following SQL statement:

    SELECT SUBSTR(dbms_java.longname(object_name),1,35) AS class, status FROM all_objects WHERE object_type = 'JAVA CLASS' AND object_name = dbms_java.shortname('oracle/xml/sql/query/OracleXMLQuery') ...

Get Building Oracle XML 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.