Generating and Storing XML Documents

If the XML document has a well-defined structure and contains data that is updateable or used in other ways, the document is data-centric. Typically, the XML document contains elements or attributes that have complex structures.

Generated XML Examples

Examples of this kind of document include sales orders and invoices, airline flight schedules, and so on.

Oracle8i, with its object-relational extensions has the ability to capture the structure of the data in the database using object types, object references, and collections. There are two options for storing and preserving the structure of the XML data in an object-relational form:

Store the attributes of the elements in a relational table and define object views to capture the structure of the XML elements

Store the structured XML elements in an object table

Once stored in the object-relational form, the data can be easily updated, queried, rearranged, and reformatted as needed using SQL.

XML-SQL Utility (XSU) provides the means to then store an XML document by mapping it to the underlying object-relational storage, and conversely, provides the ability retrieve the object-relational data as an XML document.

When the XML Document Structure Needs Transforming

If an XML document is structured, but the structure of the XML document is not compatible with the structure of the underlying database schema, you must transform the data into the correct format before writing it to the database. You can achieve this in one of the following ways:

Use XSL stylesheets or other programming approaches

Store the data-centric XML document as an intact single object

Define object views corresponding to the various XML document structure and define instead-of triggers to perform the appropriate transformation and update the base data.

Combining XML Documents and Data Using Views

Finally, if you have a combination of structured and unstructured XML data, but still want to view and operate on it as a whole, you can use Oracle8i views.

Views enable you to construct an object on the "fly" by combining XML data stored in a variety of ways. You can do the following:

Store structured data, such as employee data, customer data, and so on, in one location within object -relational tables.

Store related unstructured data, such as descriptions and comments, within a CLOB.

When you need to retrieve the data as a whole, simply construct the structure from the various pieces of data with the use of type constructors in the view's select statement. XML-SQL Utility then enables retrieving the constructed data from the view as a single XML document.

How to Generate a Web Form's Infrastructure

To generate a web form's infrastructure, you can do the following:

Use XML-SQL Utility to generate a DTD based on the schema of the underlying table being queried.

Use the generated DTD as input to the XML Java Class Generator, which will generate a set of classes based on the DTD elements.

Write Java code that use these classes to generate the infrastructure behind a web-based form.

Based on this infrastructure, the web form can capture user data and create an XML document compatible with the database schema.

This data can then be written directly to the corresponding database table or object view without further processing.