The input serialization API uses the following steps to create a VisualAge Smalltalk object or objects from the contents of an XML input stream, a DTD, and a mapping specification defined in XML.
If you are using the object cache, you can retrieve the mapping specification from the cache instead of performing steps 2 and 3.
The following method is provided in the AbtDOMElement class:
The following methods are provided in the AbtDOMDocument class:
Mapping exceptions are described using instances of the AbtXmlMappingError class. By default, mapping exceptions are NOT signalled. To enable signalling of mapping exceptions, execute the following code:
AbtXmlMappingError enableExceptionSignal: true
Enabling mapping exceptions is especially useful during initial construction of the mapping specification because it allows mapping errors to be more easily detected and debugged. An SgmlException will be signalled and will contain the AbtXmlMappingError that describes the problem. In order to simplify debugging, the domElement and mapping are saved with the AbtXmlMappingError class
The following Smalltalk code creates a VisualAge Smalltalk object from the contents of an XML input stream, a DTD, and an interface mapping specification:
| domSource domMap mapSpec orderObject| "Parse the input XML" domSource := (AbtXmlDOMParser newValidatingParser) parseURI: 'E:\xmlJim\Order.xml'. "Parse the mapping XML" domMap := (AbtXmlDOMParser newValidatingParser) parseURI: 'E:\xmlJim\mapping.xml'. "Optional, example of using cache" domSource dtd addToXmlObjectCache. "Create mapping spec object (with optional caching shown)" (mapSpec := AbtXmlMappingSpec fromMappingDOM: domMap) addToXmlObjectCache. "Create objects from input DOM and mapping spec" orderObject := domSource mapUsing: mapSpec.