Working with XML in Oracle
Introduction to XML
Extensive markup language is the language which presents data in a human readable form of text. The data can be anything from a purchase order or a stock quote or weather radar or a flight schedule it can be represented using XML. XML is very similar to HTML in its functionalities because even XML uses the open tag and the close tag.
But the difference between the both is that the HTML has a set of fixed tags and you have to use something from the specified list and in XML you can use your own tags. These tags can be something which is related to the industry you are in or you can also come up with your own tags and define them. The data that is presented in XML is called an XML document which can be quantified as one unit of data. For example each purchase quote can be called one XML document.
When these XML documents are transformed form one place to another or one system to another system in the packets it is called a datagram. XML documents are usually well structured and well formed documents because they follow the syntax rules correctly and follow the standards exactly the way they are set such as the rule that the start tag and the end tag should always match with each other. This way the XML tags allow you to create a clean and structured form of data.
Tools for XML in Oracle applications
Oracle offers something called the MXL developer’s kit or the XDK which provides all the functionalities of XML in the Oracle 8i environment and even in the Oracle 9i environment. The intermediate text which has started in the Oracle 8i has been built around XML and has an increased awareness for being compatible with XML.
In addition to all of these the developer also includes a lot of functions which were built to work along with XML in coalition. But people who work on Oracle versions which were released before the oracle 8i came into picture cannot directly use the XML but for these people a version of XML called the PLSXML which is a utility based on ML is available and gives the users the same advantages XML gives to oracle 8i users in terms of functionality for the Sequel Applications.
The XML Developer Kit
Ever since Oracle 8i was released, the XML developer’s kit has come along for Oracle developers. The XML Developer’s kit has basically integrated itself into the database ad automatically installs itself along with the database whenever it is installed. PL/SQL can also be used to access the XML developers kit. Even programming languages like Java, C and C++ are used to access the XML developer’s kit.
Sequel Applications have a limitation that they have to run inside the database only for example programs like the packages or stored procedures if you have to access the XML developer’s kit. Where as the java applications may be inside the database or outside the database it doesn’t matter to the XML developer’s kit. C and C++ by default are located outside the database and there is no other possibility that exists in their case.
If you have to access the XML developer Kit from a Pl or Sequel or even Java applications for that matter you will have to install the Java virtual machine or JVM and also known as the Jserver. It is quite contradictory that you have to install a jserver or Oracle Java virtual machine installed in order to be able to use the java virtual machine because the XML developers kit was written in Java, this fact has given birth to the need for JVM. Oracle puts wrappers from PL/SQL on the java code so that it is accessible from the PL/SQL.
The XML developers Kit includes an XML parser along with an XSLT processor and also an XPath engine which comes with XSQL page processor and a servlet and additional XML SQL utility. The XDK and the XML parser and the XSLT processor were implemented by Oracle to make itself more adaptable to XML so that it can work cohesively with XML but the XSQL page processor and the XML SQL utility are Oracles own feature which were introduced long with the borrowed features. These elements function together in coordination.
However the XSQL page can be accessed only through the Java applications or the Java virtual machine. In the previous versions of the XDK the XML SQL utility was a tool by itself separate from the XDK and also had to be installed separately, but now it has been built into the XDK and can be installed while the XDK is being installed.
XML Parser, XSLT Processor, and XPath Engine
The main function of an XML parser is to parse and also validate the XML document and builds an info set data structure in the memory, the functions also include manipulating the info set and then write the same data back into the XML document. The PL/SQL applications can gain access to the XML parser by using the functions called xmlparser and xmldom. Java applications provide default access to java classes. The XML documents enable the transformation into various XML document types or other formats of file using the XSLT. The PL/SQL will let you access the XSLT only when there is XSLT processor package.
You can also use something called oraxsl program to transform directly form the command line. All you have to do is give the name from the command line and give the name of the XML document that has to be transformed and a description about the style sheet which will transform and a file name for the output file. The same file can be used to transform many more documents in batches from the script.
The XDK also uses the Xpath engine because the XML parser and the XSLT processor which are an integral part of the XXDK use the Xpath engine. Functions like calling the XMLDOM in a PL/SQL package for example is the job of the Xpath engine and typically the users do not have to interact with the XML developer’s kit Xpath engine.
The XSQL Pages
For XML data to be published the X sequel provides a wide platform and an extensible framework. This facility is only available in the Java programs and not in Oracle. The XSQL page facility is inbuilt with the XSQL page processor and an XSQL servlet and also includes a program that will run directly from the command line. The servlet can also run with Apache, the Oracle 9i database. The command line program and the java servlet both call for the XQL page.
Publishing data has become very easy since the XSQL pages have been introduced. XML documents can be easily created using the XSQL document type data. The document also has the capability to encapsulate the data and SQL queries; it also can efficiently identify all the parameters that are passed through as a URL or even command line arguments. When the command line is used in the program the servlet is called and the query also is executed. Then the results of the query are then converted into XML.
The XML SQL Utility
The XML SQL utility is used to further simplify the loading and the retrieving activity of XML documents when the tables, rows and columns are used from the table, which are in turn used to represent the various segments of the XML document. An XML document is well structured can be passed to the XML SQL utility and the function of this utility is to insert the rows inside the database table.
Queries can also be submitted into the XML document which will be formatted into the document using this function. The XSLT can also be used after the querying is over or before the querying starts that the inputs can be made and the outputs turn out to be more flexible. This utility also includes the facility to update and delete the data in the database so that the XML SQL utility can be used.
Java API and the PL/SQL API are used to call the XML SQL utility from the command line. In the PL/SQL environment the XML SQL will appear like packages which are also called the DBMS or the data base management service Xml query or the data base management Service XML slave. This command can be invoked using the Java and Oracle XML. On the whole the concept which underlies the XML and its functions when associated with various programming languages and environments are all very simple.
The simple tools associated with the XML can make complex programs and complex networks run effortlessly. After Microsoft even Oracle has realized the true capabilities of XML and has jumped into the bandwagon along with Microsoft that it can harness all the goodness that XML has to offer. Every variation of Oracle and all the latest versions have unspoken bias to XML and are automatically inbuilt with the XML enabled components.