Oracle9i XML Product Order Application

Table of Contents

Overview of the Sample

Back To Top

The application will accept user inputs for Product and Customer details for creating a Product Order XML document. The document created adhers to the given schema ProductOrder.xsd. The application also allows the XML document to be saved into the database.

The Sample demonstrates the use of Oracle9i Xml Class Generator to create XML documents for a given XML schema. Along with this, the sample also demonstrates few features of XSQL pages. XSQL pages use custom action handlers to save the record into the database and also use XSL for transforming the XML output.

Oracle9i XML Features being demonstrated

Back To Top
  • XMLType Datatype

    Oracle9i supports XMLType, a new system defined object type. The application has Orders table with a XmlType column to store the Product Order as an instance of XML document.

  • XML Class Generator

    Oracle9i XML Class Generator for Java creates Java source files from an XML DTD or XML Schema Definition.The sample uses the XML schema for generating the Product Order XML document. The class generator creates the classes for the given XML schema which can be used to programmatically construct XML documents. The application uses the java bean OrderXmlBean to create the XML instance document.
    • Oracg Command Line Utility

      The oracg command line utility is used to invoke the Schema Class Generator for Java, depending on the input arguments. The classes are generated using this oracg utility. For example, the classes corresponding to the application XML Schema ProductOrder.xsd.can be generated from the command line:
      java oracle.xml.classgen.oracg -c -s ProductOrder.xsd -p oracle.otnsamples.ProductOrder

  • Namespace feature in XML Schema

    XSQL pages refer to database connections by using a "nickname" for the connection defined in the XSQL configuration file.
    Connection names are defined in the <connectiondefs> section of XSQLConfig.xml file like below.

    <connectiondefs>
    <connection name="otn9i">
    <username>scott</username>
    <password>tiger</password>
    <dburl>jdbc:oracle:thin:@localhost:1521:testDB</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    <autocommit>true</autocommit>
    </connection>
    </connectiondefs>
    The details concerning the username, password, database, and JDBC driver that will be used for the "otn9i" connection are centralized into the configuration file. Replace the above localhost, port and sid in the file.

    Note: XSQLConfig.xml is copied from %XDK_HOME%/xdk/admin directory to %OC4J_HOME%/lib directory. %XDK_HOME% is where you have extracted Oracle XDK, and %OC4J_HOME% is where you have installed OC4J server.

  • XSQL Page Custom Action Handlers

    XSQL Pages framework allows custom actions to be invoked as part of page processing. For example, to perform DML operations we can write our own action handler instead of using the built-in action handlers. The application uses PoInsertHanlder for saving the XML instance document into the database.To create a custom Action Handler, a class should implement the oracle.xml.xsql.XSQLActionHandler interface.

The custom action handlers should extend oracle.xml.xsql.XSQLActionHandlerImpl. Some of the methods of the
XSQLActionHandlerImpl class used in the application are :

  • getActionElement which returns the current action element being handled
  • getAttributeAllowingParam to retrieve the attribute value from an element, resolving any XSQL lexical parameter references that in the attribute's value.
  • variableValue which returns the value of a lexical parameter, taking into account all scoping rules which might determine its default value.
  • addResultElement which Simplifies appending a single element with text content to the root of the action handler result content.
  • getPageRequest.getJDBCConnection() which gets the JDBC connection in use by this page
For more information about Oracle XML features please visit /tech/xml/index.html

Running the Sample Application

Back To Top
  • Please go through the Install.html and set up the application.
  • Visit the application home page ProductsMain.jsp
  • This will display a HTML form to enter Customer and Order details.
  • On entering all the details, press the button 'Generate Order XML'.
  • On pressing the button, GetXmlDoc.jsp is invoked with the XML document in a text area. There is button 'Save Order XML'.Press this button to save it to the database.
  • On pressing the save button, Results.jsp is invoked with the success message. There is a button 'Back to Main Page' when pressed will invoke the ProductMain.jsp.  

Description of Sample Files

Back To Top

Directory File Name Description
ProductOrder\jsps Welcome.jsp This page is the Home page of the Product Orders Application. It displays documentation links to all the Oracle9i XML technology stack used in the application. This page calls the ProductsMain.jsp to get into the application.
ProductsMain.jsp This is the main JSP that will invoke the application. It presents the user with a form to be filled for Customer and Order details. Products table in the database is queried to get the list of products for which order can be placed. It is displayed in a drop down list. There is a 'Generate Order XML' button which when pressed will call the GetXmlDoc.jsp The customer and Order information is passed to GetXmlDoc.jsp
GetXmlDoc.jsp This JSP is called from ProductsMain.jsp. This page will display the Product Order as an XML document. There is a 'Save Product Order XML' button which when pressed will save the XML document into the Orders table in the database. The save button will call Results.jsp
Results.jsp This page will call the XSQL page : InsertPo.xsql to save the XML document into the database.
ErrorHandler.jsp This is the JSP error page to which is used by the application to throw all the jsp errors.
ProductOrder\sql CreateTables.sql This SQL batch file is used for creation of the objects required for running of the sample.
ProductOrder\etc *.xml The files in this folder are used in EAR deployment.
ProductOrder\docs *.html The files in this folder include the Readme and Install files for this sample application.
ProductOrder\images *.gifs The files in this folder include the gif files that are used by the JSPs.
ProductOrder\java Customer.java This file is generated by the 'oracg' command for the XML schema: ProductOrder.xsd. This holds all the information to construct the customer information tag in the XML document. Please note that this file is not shipped with the sample jar, but has to be created using ORACG. For details read install.html
Products.java This file is generated by the 'ORACG' command for the XML schema: ProductOrder.xsd. This holds all the information to construct the Product information tag in the XML document. Please note that this file is not shipped with the sample jar, but has to be created using ORACG. For details read install.html
ProductsOrder.java This file is generated by the 'ORACG' command for the XML schema: ProductOrder.xsd. This holds all the information to construct the whole Product Order tag comprising of Customer and Products in the XML document. Please note that this file is not shipped with the sample jar, but has to be created using ORACG. For details read install.html
OrderXmlBean.java This Java bean uses the above source files created by'ORACG' and creates the XML instance for the Product Order and returns it as a string to the GetXmlDoc.jsp
PoInsertHandler.java
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy