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 Moreover.com news story datagram fetched directly over the
Web into our newsstoryview.
Example 12.34 does the following to accomplish this feat:
Parses the live XML news feed from Moreover.com by calling the
parse()method of aDOMParserobject, passing it a string URL to the live news feed:// Create a DOM Parser to Parse the News Document DOMParser ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access