Using XML-Enabled Objects Instead of Virtual Documents
This page briefly describes how to treat XML documents as standard production messages, as an alternative to using XML virtual documents. With this approach, you generate XML-enabled classes from the corresponding XML schema and then define message classes that inherit from those XML-enabled classes. You can then use the following business services and operations to handle the messages:
Business Services for XML-Enabled Objects
EnsLib.XML.Object.Service.FileServiceOpens in a new tab and EnsLib.XML.Object.Service.FTPServiceOpens in a new tab read a file containing an XML document and convert it to one or more objects. You specify a property that defines the XML element to convert to objects. If the XML root document contains a single element, then the service converts it to one object, but if the XML root document contains a series of these elements, then the service converts them to separate objects.
To use these business services, do the following:
-
Define a class that matches the structure of the input XML documents that you are processing. The class can either match the entire XML document or a repeating element within the root XML document. You can use the XML Schema Wizard to define this class. You can optionally define a NAMESPACE parameter for this class. This parameter specifies the XML namespace.
-
Specify the class name in the business service Class Name field.
-
Optionally, specify the element name in the Element Name field. If you specify this field, the service looks for one or more XML elements with this name within the root XML object. Each occurrence of this element is converted to an instance of the specified class. If you do not specify this field, the service matches the root document to the specified class.
-
Optionally, specify the Format parameter and optionally select Ignore Null. The Format parameter can have a value of "literal", "encoded", or "encoded12". These parameters specify the corresponding parameters for the %XML.AdaptorOpens in a new tab class.
For information on %XML.AdaptorOpens in a new tab, see Projecting Objects to XML.
Business Operations for XML-Enabled Objects
EnsLib.XML.Object.Operation.FileOperationOpens in a new tab and EnsLib.XML.Object.Operation.FTPOperationOpens in a new tab convert an object to an XML document and write the document to a file. In addition to specifying information about the XML class and element, you can specify properties that are used when the operation invokes the %XML.WriterOpens in a new tab class.
Specify the following properties in the operations:
-
Root Element Name—If you specify this property, it is used as the root element name. If you omit this element, the operation uses the input element name.
-
Namespace—Specifies the XML namespace except if the class defines a NAMESPACE property. In that case, the operation always uses the XML namespace defined in the class.
-
Expected Class Name—Class name of the XML-enabled object. If the expected name does not match the actual name, the %XML.WriterOpens in a new tab adds an xsi:type attribute to the XML element.
-
Indentation Type—Specifies the corresponding property for %XML.WriterOpens in a new tab. Indentation Type specifies if indentation of the XML output should take place and what type of indentation.
-
Indentation Depth—Specifies the corresponding property for %XML.WriterOpens in a new tab. Indentation Depth specifies the number of indentation characters to be used for indentation. The default for "tab" is 1. The default for "space" is 4.
-
Charset—Specifies the corresponding property for %XML.WriterOpens in a new tab. Charset is the charset to use for encoding the XML output. The default depends upon the output destination. "UTF-8" is the default for output to files and binary streams. On a Unicode system, "UTF-16 is the default for output to character streams and strings. On an 8-bit system, the default charset for the locale is the default charset for output to character streams and strings
-
No XML Declaration—Specifies the corresponding property for %XML.WriterOpens in a new tab. If No XML Declaration is 1 (true), the %XML.WriterOpens in a new tab does not write the XML declaration. The default is for the %XML.WriterOpens in a new tab to write the XML declaration unless Charset is not specified and the output is directed to a string or character stream in which case it does not write an XML declaration.
-
Runtime Ignore Null—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
Element Qualified—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
Attribute Qualified—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
Default Namespace—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
Suppress xmlns—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
Format—Specifies the corresponding property for %XML.WriterOpens in a new tab.
-
References inline—Specifies the corresponding property for %XML.WriterOpens in a new tab.
For information on %XML.WriterOpens in a new tab, see Writing XML Output from Objects: Basics.