N·CYCLES

software solutions

 

XML White Paper

Where XML Fits in Enterprise Applications

 

 

 

 

 

 

 

May 2001

 

 


Table of Contents

Table of Contents. 1

Introduction. 2

Understanding XML. 2

Benefits of XML. 3

Using Oracle with XML, Xerces, and Apache. 3

Implementation Successes. 5

Conclusion. 6

 


 

Introduction (back to top | back to Whitepapers)

Is it the savior of E-Commerce?   It is a step in the right direction.  Actually, XML is a retrenchment back to simplicity. EDI (Electronic Data Interface) and its X12 book of standards work well in most cases, but it takes coordination of multiple parties.  EDI is expensive with VAN Charges, Translators, and EDI Coordinators. EDI is not flexible, if the standard does not suit your application, or does not have all your required fields such as a field for an electronic signature, there is no way to transmit the needed data. The standard becomes less effective for a tailored solution. The other major drawback with EDI, is all vendors interpret the standard in different ways. The same EDI Document from FedEx, and UPS will require two separate data maps. The data path to legacy systems will be different because of vendor specific implementations, removing the effectiveness of the standard. Because of Sun, Microsoft, IBM, and the open source movement behind it, XML is becoming the next generation of usable business technology.

Understanding XML (back to top | back to Whitepapers)

The Development of XML started in 1996, it was built on the successes and failures of Standard Generalized Markup Language (SGML).  SGML has been an ISO standard since 1986. All the Internet markup languages such as HTML, CSS, and others have their roots in SGML.

 XML, the Extensible Markup Language, is a language of creating your own markup language.  XML allows a developer to create information modules for different types of data such as rendering, configuration, or an interface standard. By tagging these information elements according to their meanings, development of external data access methods is simplified. For example, if a Microsoft Word Document was saved in XML Format, all Platforms and programs could view and manipulate the data: not just Microsoft Applications, or Windows Applications! 

Sample XML Document for saving product data:

<?XML VERSION=”1.0” ENCODING=”UTF-8”?>
<!DOCTYPE products SYSTEM “products.dtd”>
     <TRANSACTION>
           <PRODUCTS> 
               <ROW>
                      <ID>1</ID>
                      <NAME>TOSHIBA LAPTOP </NAME>
                      <COST>1.95</COST>
                </ROW>
            </PRODUCTS>
    </TRANSACTION> 

 

Benefits of XML (back to top | back to Whitepapers)

XML files are text files, allowing a XML document to be human readable.  With simple tools such as Notepad or VI, the message can be read and manipulated. The messages compress well using standard tools such as Zip or GZIP, allowing messages to be transported efficiently using HTTP protocols, raw sockets, or FTP. 

 

The most powerful argument for using XML is its flexibility. For Instance, a developer can create a purchase order and place all the required data elements along with binary data all in the same document.  The binary data could be a signature or a picture of the desired outcome. The document can then be parsed, and processed by the intended receiver using a standard XML parser such as Apache’s XERCES, IBM’S XML4J, etc. Possible uses of XML include: disparate databases, interfaces, or configuration files.

 

Using Oracle with XML, Xerces, and Apache (back to top | back to Whitepapers)

XML is complementary technology to a relational database.  A XML Document is a data holder, similar to how a PL/SQL record works with PL/SQL Tables. In PL/SQL Tables, records are pushed and popped off an ordered stack based on a key.  XML is broken down in two types of processing: DOM, and SAX.  DOM ( Document Object Model )  processing is more memory and processor expensive because its creates a tree view of data. SAX  ( Simple API for XML )   works by creating an element handler or callback. Since SAX does not create a data structure, it’s more efficient in dealing with large data sets.  For instance, creating a processes that would be similar to a SQL*LOADER task.  Apache / JSERV is ideal deployment platform for E-Commerce, Intranet, and Internet.  JSERV can serve web pages that are headless, as well as the typical user interactive website.  A headless web site is a site that does not render HTML to the user, only name / value pairs of data. The XML message becomes a parameter and is passed to the server for processing, and a XML reply message is formed and replied to the calling client application.

 

Example:  For reading, and parsing a XML Document in Java.

 

   /* ---------------------------------------------------------------*/

   /* function : parse                                               */

   /* Purpose  : Parse the xmlMessages, and inserts the data into    */

   /*          : oracle                                              */

   /* Copyright: Ncycles Software Solutions                          */

   /* ---------------------------------------------------------------*/

 

   private void parse (long id, String xmlMessage ) throws IOException, SQLException, DOMException

   {

 

        ByteArrayInputStream is = new ByteArrayInputStream ( xmlMessage.getBytes () );

        InputSource input = new InputSource(is);

        DOMParser domParser = new DOMParser();

        domParser.parse(input);

 

        Document doc = domParser.getDocument();

 

        Node root = doc.getElementsByTagName("TRANSACTION").item(0);

        NodeList children = root.getChildNodes();

 

        for (int i = 0; i < children.getLength(); i++)

        {

           Node table = (Element) children.item(i);

 

           String tableName = table.getLocalName ();

 

           // Search through the table elements

           NodeList rows = table.getChildNodes();

 

           // Reset the default to one

          ((OracleConnection)connection ).setDefaultExecuteBatch ( rows.getLength() );

 

           for (int j = 0; j < rows.getLength(); j++)

           {

               pw.println ("\n RowItr - > ");

 

               DataHolder holder = new DataHolder ();

               holder.setTableName( tableName.toUpperCase().trim() );

 

              // Rows have no data tags

              Node row = rows.item(j);

              NodeList rowChildren = row.getChildNodes();

 

              Vector columnNames = new Vector ();

              Vector columnData  = new Vector ();

 

              for (int k = 0; k < rowChildren.getLength(); k++)

              {

                  Node dataElement      = rowChildren.item(k);

                  if (dataElement.getNodeType() == Node.ELEMENT_NODE)

                  {

                    String columnField       = dataElement.getLocalName().trim();

                    String columnDataElement = "";

 

                    NodeList textChildren = dataElement.getChildNodes();

                    for (int l = 0; l < textChildren.getLength(); l++)

                    {

                      Node text = textChildren.item(l);

                      if (text.getNodeType() == Node.CDATA_SECTION_NODE ||

                          text.getNodeType() == Node.TEXT_NODE)

                        columnDataElement += text.getNodeValue().trim();

                    }

 

                    columnNames.add ( columnField.toUpperCase() );

                    if (!columnField.equalsIgnoreCase("IMAGE"))  // Do not want to upper base 64 data, it corrupts it.

                      columnData.add  ( columnDataElement.trim().toUpperCase() );

                    else

                      columnData.add  ( columnDataElement );

                  }

              }

 

              // Inserts Records

 

              holder.setColumnNames ( columnNames);

              holder.setColumnData( columnData  );

 

              displayHolder ( holder );

 

              int chkValue = insert ( id, holder );

 

              if ( chkValue == 0) insertIsGood = false;

 

              pw.flush();

 

           } // rows

 

 

        } // tables

 

 

    } // parse

 
         

Implementation Successes (back to top | back to Whitepapers)

N•Cycles Software Solutions has designed, developed, and implemented XML Solutions for over two years. 

Accuship.com: created shipping applications that are headed and headless utilizing XML, Apache, JDBC, and Oracle.

N•Cycles’s WebDBA Monitor agents utilize headless XML / SSL messaging to ensure remote Oracle Database’s are operational, and performing optimally.

Major Financial Institution: Bi-directional synchronization of data from Oracle to Cloudscape. Note: Included Binary Images as well.

 

Conclusion (back to top | back to Whitepapers)

XML is a very powerful tool in a developer’s tool chest. Like any great tool, if used properly it yields powerful results. For instance: a hammer is for driving, and extracting. It does not work well tightening a bolt. XML is not a save all, or the Rosetta Stone for business data. It is a language for defining information about data.