This document describes Customer Management Application(CMA)
using Oracle9i XML features. This application is a concise demonstration
ofnew XML features incorporated in Oracle9i. This application
stores customer information as XML documents. Every customer record
has a unique customer id. Each customer record stores customer name
and customer information in XML with column called customer_xml.
The column for storing customer XML is an XMLType column in the
database. Customer can have an associated schema definition as well,
however this is optional. This application allows users to view,
update, modify, validate and delete the customer records.
Note: Further in this document, we refer to this
application as CMA.
Oracle provides a set of XML parsers for Java and PL/SQL. Each of these
parsers is a stand-alone XML component that parses an XML document (XML
Schema) so that it can be processed by an application.
XMLType data type
Oracle9i supports XMLType, a new system defined object type. XMLType
has built-in member functions that offer a powerful mechanism to create,
extract and index XML data. Users can also generate XML documents as
XMLType instances dynamically using the SQL functions.
LAX mode validation of XML documents
This sample also demonstrates Schema LAX validation of XML document
provided. With LAX Mode Validation of XML Content, you can validate
only some parts of the XML content without validating the whole document.
The Schema can be defined for the part of XML which has to be validated
and the flag SCHEMA_LAX_VALIDATION to be set in the Schema Processor
to enable the LAX mode validation.
For more information about Oracle XML features please visit /tech/xml/index.html
We have written a PL/SQL package called as CUSTOMER. This package
has two methods which validate the XML Schema and document. IsValidDocSchema
andIsValidDocSchemaURL methods in this package
act as java stored procedures. These methods delegate their work to SchemaUtil
class, which is deployed in the database.
When we upload
any XML document using this application, we must specify a valid schema as well.
This schema is used to validate the given XML document. If the document confirms
to the given schema then it is insterted into the database along with corresponding
schema document. We support two validation modes, Schema Validation and Schema
LAX validation.
Please go through the Install.html
and make sure that you set up the application properly.
Visit the application home page Welcome.jsp
and move your mouse over the menu to get pop-up
menu.
Select 'Add new customer Information menu'.
This will give you one more choice select 'New
record using File Upload'.
In the resultant screen, type Customer Name. Note: All .xml and .xsd example files referred below can be found
under the CustomerManagement\xml directory which was extracted
as part of installation instructions in the Install.html file.
Select customer1.xml and click open
Similarly select customer.xsd and
click open.
Select the Schema Validation radio button.
Click on save button.
This saves the data in the database.
Similarly upload customer2
and customer3.xml with customer.xsd.
Upload customerlax.xml with the customerlax.xsd
schema and select the Schema LAX Validation radio button. This example
demonstrates use of LAX validation.
We can add customer documents
by 2 more ways. We can cut and paste XML document and schemain
the text area provided. If you want to use this method please select
the 'New record using Form' menu option
from the Welcome page.
We can also provide url of
XML document and XML schema document and use the third way of uploading
documents. To do this select 'New record using URLs' menu from the Welcome
page. If your document is on some other server where we have not granted
connection privilege to the user an exception will be generated. This
can be corrected by granting permission to the USER
to open socket to that machine. Please refer installation instructions
for more details. For example URL, refer to the ones provided on the
'New record using URLs' page.
Select 'Edit existing customer information'. This
will bring up a selection box where you can select the record you want
to edit and press the 'Edit Record' button.
You can View/Modify this document now and update
the changes. You can press View Schemabutton
to view the schema document associated with this XML document.
Similar functionality is offered by menu 'View
List of existing customers'. However we have an option of deleting the
customer record here in addition.
Select 'Query Customer Information'. This will
bring up a page where we can enter query criteria.
Search attribute name is mandatory here. Search
attribute value is optional. If we specify both records are returned
only if search attribute contains specified value inside it. If second
parameter is not supplied all records having that attribute in the XML
document are returned. This demonstrates use of Xpath and use ofXMLType variable in both PL/SQL and java.