Converting XML documents to business objects

This section provides the following information on how the XML data handler converts XML documents to business objects:

XML document requirements

The XML data handler makes the following assumptions about an XML document:

Serialized-data processing

When converting an XML document into a business object, the XML data handler assumes that the business object follows the structure of the XML document and conforms to the business object definition requirements described in Requirements for business object definitions. If there is no attribute in the business object for a given element name, the XML data handler returns an error.

To convert an XML document to a business object, the XML data handler does the following:

  1. If the calling connector passes in a business object to the conversion method, the data handler uses this business object and continues. If the caller does not pass in a business object, the data handler determines the business object name and creates a business object to contain the data in the XML document.

    To determine the business object name, the data handler invokes the name handler. The default name handler forms the top-level business object name by combining the BOPrefix meta-object attribute, an underscore, and the value of the root element. For example, if the XML document contains <!DOCTYPE Customer > and the BOPrefix attribute is MyApp, the resulting name is MyApp_Customer. You can provide a custom name handler to configure different behavior.

  2. The data handler retrieves the value of the Parser meta-object attribute to determine which SAX parser to use to parse the XML document. For information on which SAX parser the XML data handler uses, see SAX parser. When the data handler determines the name of the parser, it instantiates the parser.
  3. The data handler registers the event handler (for a DTD-based XML document, it also registers the entity resolver) with the parser. The event handler is a callback method that processes each XML element and attribute.
    Note:
    The entity resolver handles external entity references in DTD documents. If the data handler does not find an EntityResolver option with a valid class name, it uses com.crossworlds.DataHandlers.xml.DefaultEntityResolver. This entity resolver ignores all external references.
  4. The data handler invokes the parser to parse the XML document.
  5. When the business object is complete, the data handler returns it to the caller.

Note:
For every element and attribute found in an XML document, the data handler expects to find an attribute in the business object. If there is no attribute in the business object definition for a given element or attribute name, the data handler returns an error. The exception to this rule is for attributes of type FIXED, which are not required in a business object definition. If FIXED attributes are not present in the business object definition, execution does not stop if a FIXED attribute is found in the XML document.

Copyright IBM Corp. 1997, 2003