The output serialization API generates XML from Smalltalk objects. The basic method of XML generation is the abtXmlPrintString method. The amount of information provided to the output serialization API affects the default behaviour of the abtXmlPrintString method as follows:
If no information is provided to the output serialization API, the instance variables are mapped to subelements. The class name and each instance variable are generated as an XML start and end tag with the value of the variable printed between the two tags. For example, execution of the following code, (Point x:5 y:10) abtXmlPrintString results in the following XML:
<Point> <x>5</x> <y>10</y> </Point>
The more information you provide, the closer the generated XML is to validated XML.
The XML output serialization determines if the mapping specification and DTD are available by sending methods to the class of the object that is being printed. To enable your object to use a mapping specification and DTD, you must implement the abtXmlMappingSpecification and abtXmlDtd methods on your class. Most applications would then look up the mapping specification or DTD in the XML object cache using the following Smalltalk code:
^AbtXmlObjectCache current mappingSpecNamed: 'MySpecName'.
The following methods, which customers can override, are provided in the Object class:
The DOM classes contain implementations of the
abtXmlPrintOn: method. This allows you to print out
the XML that is parsed. For example, you can parse XML, change the DOM,
and print the modified DOM as XML. If the original XML was validated
XML, it is still validated XML.
You can generate XML from a DOM without the need to use the mapping
support. The mapping support supplied with VisualAge is only necessary
when mapping parsed DOM objects into custom business objects.
For example, you can parse an XML stream containing the representation of a
'Customer' and derive an instance of a Smalltalk
'Customer' object. If the DOM is manipulated directly, there
is no need for mapping. You can send the message
abtXmlPrintString to a DOM document instance to derive the XML
string that represents that DOM.Generating XML from the DOM