XML Features of Oracle 8i and 9i (1/7) - exploring XML
XML Features of Oracle 8i and 9i
Today, guest writer and database specialist Simon Hume chips in with an introduction to the XML features of the most recent Oracle database versions:
Overview: XML compared with RDBMs
XML and relational databases are both technologies for structuring, cataloguing and processing data. If data has a regular and atomic structure, it is more appropriate and efficient to use a database than XML. In this case, why would you wish to go to the trouble of converting such data from a database into XML and vice versa? Reasons include:
- XML is easy to convert further into different formats as required: e.g HTML, PDF, and plain text. This gives a flexibility to web applications where data can be searched for and accessed from the database, and then formatted for output in different formats using e.g XSL.
- XML is already a standard for data interchange, so you may need to pass your data on to others as XML or take XML as input. There are advantages over competing technologies such as EDI. A feature of XML allows XML from different sources to be processed together to give a combined result.
- In Web applications, XML can theoretically be used to reduce server hits and load on the server for sorts etc, because some processing can be done by the client browser. However, in practice many browsers in use have no or limited XML capability.
- XML is a non-proprietary standard and is unlikely to become obsolete.
On the other hand text documents, which are usually irregularly structured, cannot be effectively stored in a relational database. In this case, you can only store them in the database as BLOBs, which cannot be searched or processed in the normal way. However, there are cases where this is still desirable: very large repositories of pre-existing XML/SGML documents. The database can be used for cataloguing and searching, and documents once extracted can be processed further using XSL/XSLT.
So there are two possibilities: perform backwards and forwards conversion of data between the database and XML, or store complete XML documents inside the database. Oracle terminology calls the former "generated XML", and the latter "authored XML".
And there are essentially two reasons for using XML and databases together: The first Oracle calls "content and document management" where the requirement is for data to be presented differently as required, the second "B2B messaging" where XML is used to communicate between different applications/sites/companies (cf EDI).
The XML tools provided with Oracle are mainly to simplify conversion between the database and XML, and a standard XML parser for the usual XSL/XSL-T/DOM/SAX operations.
The main tools are:
- XSU (XML Unit. Also known as XML-SQL): utility to insert and extract XML into and out of the database. This can be used directly via the command line, but in practice would normally be used via an API, available for Java or PL/SQL.
- XDKs "XML development kit"s for different languages Java, C, C++, PL/SQL. The Java XDK consists of:
- XSQL servlet: ability to create, read, update and delete data with corresponding XML output/input.
- XML parser
- XML class generator
- XML transviewer Java Beans: provides basic ability to view XML and apply XSL transformations.
- A further tool, "interMedia text", allows for text searches of XML documents stored as BLOBs.
On to real-world examples and code...
Produced by Michael Claßen
Created: May 10, 2003
Revised: May 10, 2003