ST 4U 248: Using a SAX Handler in VA Smalltalk
Today's Smalltalk 4 You looks at the standard development process using VA Smalltalk and ENVY. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.
You can also watch it on YouTube:
Today we'll look at a SAX content handler example - to get started, you'll want to load the XML Support and XML Examples. Once you've done that, you can have a look at class AbtXmlBasicExample class, and method #saxExample. You'll also see that there are other examples - you should probably have a look at all of them. Try executing the example code
AbtXmlBasicSamples saxExample
That will drop the XML file that's used first, which you can see below. It then hooks up the component parts (as explained in the last screencast) to parse the file and get a set of objects back:
To see how that all works, take a look at class JrcOrderContentHandler. This class handles the different XML nodes in the file, and creates the appropriate types of objects as they are encountered. If you look at the customized methods (overrides of the placeholders in the superclass), you can see that it's all done via:
- Creating the proper instance of an object based on the node
- Managing the current "filling" of instance variables via a stack
- Catching the end of the current node to close the current object out and pop it off the stack
You'l also need a class for each kind of object (unless you plan on creating a simple Collection/Dictionary setup, which would be easy enough to do in your handler). Here's one of those classes:
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
Technorati Tags: smalltlk, sax, va smalltalk, xml
Enclosures:
[st4u248-iPhone.m4v ( Size: 5422879 )]