The EMF SDOToXML Function Component converts Service Data Objects to XML. This component uses an XML Schema definition to build an Ecore model.
The SDOToXML Function Component is deprecated in the IBM TDI 7.1 release and will be removed in a future version.
The Function Component receives an Entry whose Attributes represent an XML document. The types of the Entry Attribute values are either Java classes representing primitive types or Service Data Objects (org.eclipse.emf.ecore.sdo.EDataObject) representing complex XML elements.
The Entry Attribute names describe the XML hierarchy in exactly the same manner as the EMF XMLToSDO Function Component constructs Attribute names. All Attribute names start with "DocRoot" which represents the XML root. Subsequent elements down the XML hierarchy are separated with the "@" character. If the TDI Entry Attribute represents an XML attribute the "#' character is used to separate the name of the XML attribute from the name of the XML element containing this attribute.
It is possible that the TDI Entry passed contains only Entry Attributes corresponding to the real data. For example, the Entry may contain an Attribute "DocRoot@database@person" without containing an Attribute "DocRoot@database" - the EMF SDOToXML Function Component will automatically create the "database" XML element in the XML document it builds. The EMF SDOToXML Function Component uses the XML Schema to track and create all XML elements that are ancestors of the specified XML element or attribute.
It might happen that the Entry contains Attributes specifying XML elements that are contained in other XML elements specified by Entry Attributes, for example the Entry contains both "DocRoot@database@person" and "DocRoot@database" Attributes. In this case the Attributes are processed starting from the one that is closest to the root, continuing with the one closest to it and so on - the last one will be the most specific XML element that is contained in all the other. This order of processing provides the option to change specific details in a bigger XML context.
For example, if we want to change just the "DocRoot@database@person" element but we want to leave the other parts of the "DocRoot@database" element untouched, you might read the XML document with the EMF XMLToSDO Function Component, map the "DocRoot@database" attribute and provide it to the EMF SDOToXML Function Component as is. Then we will also provide the "DocRoot@database@person" Attribute that contains the specific updates we want to make on the "person" XML element(s). The EMF SDOToXML Function Component will first process the "DocRoot@database" applying all the content to the resulting XML and it will then override the "person" child of the "database" element with whatever is provided in the "DocRoot@database@person" Entry Attribute.
In case a multi-valued Attribute is provided together with an Attribute specifying a child or other successor of that element, the function Component will signal an error (throw exception) because it cannot be determined to which of the sibling XML elements, this successor applies. For example, if "DocRoot@database@person" is provided and contains two values (thus specifying two XML "person" elements at the same level) and also "DocRoot@database@person@name" is provided, the Function Component would not know to which "person" element of the two existing this "name" element applies to. The names of the elements in the Entry Attribute can be XML namespace prefixed.
The names of the elements are prefixed with the namespace URI or with the prefixes defined in the "namespaceMap" parameter.
For example, in order to construct the following XML document:
<?xml version="1.0"?> <database xmlns="www.ibm.com" xmlns:tmp="www.tmp.com" name="employees"> <person> <name>Ivan</name> <tmp:age>21</tmp:age> </person> </database>
the following TDI Entry can be passed to the EMF SDOToXML Function Component:
The namespace prefixes used assume that the "namespaceMap" parameter contains the "ibm" prefix set to "www.ibm.com" and no namespace prefix is defined for "www.tmp.com" (that is why it is used directly in the Attribute name).
The EMF XMLToSDO and SDOToXML Function Components are not compatible with the TDI 6.0 Castor Function Components. That is why any solution which uses the Castor Function Components needs to be re-implemented in order to work with the EMF XMLToSDO and EMF SDOToXML Function Components. The Castor XML To Java Function Component used to support a mapping file. This mapping file could be used to specify how a complex custom XML is to be parsed and converted to a complex custom Java object. This feature is not supported by the EMF XMLToSDO Function Component. However by following the next broad guidelines such a TDI 6.0 configuration can be re-implemented to work with the EMF XMLToSDO Function Component:
The Castor XML To Java Function Component used to support a mechanism which allowed a specific portion of the XML to be mapped to Entry Attributes. The EMF XMLToSDO Function Component does not support this feature. The EMF XMLToSDO Function Component always parses and maps the entire XML to Entry Attribute. By using the Input Attribute Map of the EMF XMLToSDO Function Component, however, only the desired Attributes can be mapped thus emulating the behavior of the Castor XML To Java Function Component.
The Castor Java To XML Function Component used to support a mapping file, which could be used to specify how to serialize a complex Java object into XML (element/attribute names, etc.). The EMF SDOToXML Function Component serializes into XML based on an XML Schema file, that is, the names of elements/attributes, etc. are specified in the XML Schema file specified as a Function Component parameter.