Producing and Transforming XML Query Results

In this section, we’ll briefly cover the mechanisms available in Java 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 an XML transformation engine compliant with the W3C XSLT 1.0 Recommendation (see http://www.w3.org/TR/1999/REC-xslt-19991116) that allows you to transform XML in one format into XML, HTML, or text of another format.

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

Installing 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')

You should see the result:

CLASS STATUS ...

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.