Inserting Datagrams Using Java

In this section, we’ll study how the previous techniques can be applied from within your own Java programs.

Inserting Arbitrary XML Using Java

We’ve learned so far that the Oracle XML SQL Utility can be used to insert XML datagrams into database tables and views. We used the command-line oraxsl utility to transform the XML datagram into canonical <ROWSET>/<ROW> format before feeding it to the OracleXML utility for insertion into the database. Later, we saw how a simple <xsql:insert-request> action element could be used in an XSQL page to accomplish the same thing. The XSQL Servlet is able to automate these steps since both the Oracle XSLT Processor (oraxsl) and the Oracle XML SQL Utility (OracleXML) can be used programmatically by any Java program.

The API for the Oracle XSLT Processor comprises two simple-to-use objects, XSLStylesheet and XSLProcessor , and the API for the Oracle XML SQL Utility is even simpler. The OracleXMLSave object takes care of inserting XML into the database for us. Here we’ll look at an example of using these three objects in a simple Java program to insert the contents of a live news story datagram fetched directly over the Web into our newsstoryview.

Example 12.34 does the following to accomplish this feat:

  1. Parses the live XML news feed from by calling the parse() method of a DOMParser object, passing it a string URL to the live news feed:

    // Create a DOM Parser to Parse the News Document DOMParser ...

Get Building Oracle XML Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.